Instead of checking if "$Var" was equal or not equal, I wanted to use
pattern matching.
Normally, for = or !=, I'd write:
if [[ "$Var" = "4" ]]; then ...
But when I used regex pattern matching in the if, the spaces around the operator
caused a failure in matching. I.e.:
if [[ "$Var"=~"+([:digit:])" ]] ; then ...
worked.
But:
if [[ "$Var" =~ "+([:digit:])" ]] ; then ...
evaluates to 'FALSE', trace(-x) shows the eval as:
+ [[ 4 =~ \+\(\[:digit:]\) ]]
and inserting a space on only-one side of the operator yielded the error
message:
"conditional binary operator expected"
at the line of the expression.
Obviously, I can workaround my mis-comprehension and just proceed,
but I wanted to ask why, what I thought was "normal" syntax,
(i.e. args separated by spaces), didn't work.
bash --version:
GNU bash, version 3.2.39(1)-release (x86_64-suse-linux-gnu)
TIA,
-linda