Reputation: 3235
I just did the following experiment in TCL 8.6:
% expr \"\{" ne \"x\"
1
% expr \"\[" ne \"x\"
extra characters after close-quote
in expression ""[" ne "x""
The first command makes sense to me:
The error in the 2nd command does not make sense. The only difference is replacing bracket with brace, why does it fail?
I know bracing the arguments is expected for expression, this question is mostly to understand TCL parsing.
Upvotes: 1
Views: 188
Reputation: 137567
The problem with the second command is that the expr
command processes [
…]
sequences inside double quotes as command substitutions. This is independent of whether Tcl does and is part of why it is a really good idea to always brace your overall expressions. Had you instead used:
expr \{\[\} ne \"x\"
then it would have worked; just as with the base Tcl language, expr
does not expand command substitutions in brace-quoted terms.
Upvotes: 2