On Wed, Oct 07, 2009 at 08:07:19PM +1030, Lyall Pearce wrote: > Description: > Cannot form expressions which involve left or right brackets.
Parentheses? > Repeat-By: > > basePic="(2008-04)" > if [ "${basePic:0:1}" = '(' -a "${basePic:4:1}" = ')' ] > then > echo "Got brackets" > fi if [ "${basePic:0:1}" = "(" ] && [ "${basePic:(-1):1}" = ")" ]; then echo "Got parentheses" fi When using [ instead of [[, I would strongly recommend never using -a or -o inside it. POSIX has strict rules about exactly how to treat a [ command with a specific number of arguments, and often the most common cases are technically illegal. The workaround is to use multiple [ commands strung together with && and || as needed. Or, the other workaround would be to use [[, since you're already using ${string:start:length} which is non-POSIX syntax. if [[ "${basePic:0:1}" = "(" && "${basePic:(-1):1}" = ")" ]]; then echo "Got parentheses" fi Both of those worked for me in bash 4.0.10.