I want to group some logic in a test in a bash script.
I.e. I am trying to write something like:-
if [ this -a (that -o theOther) ]
but bash always complains about 'syntax error'. I have reduced the code to the trivial:-
home$ if [ ( true ) ]; then
but still get the syntax error.
According to the man page for test the format is:-
( EXPRESSION ) EXPRESSION is true
I *think* that is trying to tell me that I can use () to group parts of what is inside the []. However, as I said, it refuses to work as I expected. I have tried all combinations of spaces etc. either side of the () but it still just gives a syntax error.
Is this just a case where the () are punctuation in the man page rather than real () to use in the expression? Or am I doing something obvious wrong? (probably!).
I know I *could* rely on precedence in the tests to get the result I want but it's much easier to write and to understand using () for grouping the logic.