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:
- Because the argument is not braced, first round parsing is script level parsing, backslash escapes are removed: expr "{" ne "x"
- expr command continues the parsing, "{" and "x" are 2 quoted literals and the execution goes well.
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.