On 4/2/18 5:16 PM, PRussell wrote: > Section 6.5 Shell Arithmetic says, > > "Within an expression, shell variables may also be referenced by name without > using the parameter expansion syntax. A shell variable that is null or unset > evaluates to 0 when referenced by name without using the parameter expansion > syntax." - http://www.gnu.org/software/bash/manual/bash.html#Shell-Arithmetic > > The above tells us what happens to an unset variable if not using parameter > expansion. > > But if a shell variable uses parameter expansion and is null or unset, what > does it evaluate to inside (()) syntax?
Since ((...)) is equivalent to let "...", as noted in the description of `((' in the man page and info doc, it expands to the same thing that it would when you perform a double-quoted word expansion. If you expand a shell variable that's null or unset, you get the usual: it disappears. > The problem is what is happening with 3B and 4B. I tested on bash 4.3.11 and > bash 4.4.19 and got a slightly different error message. > > Bash version 4.3.11: > > ./tt: line 18: var1: var1 == : syntax error: operand expected (error token > is "== ") > > Bash version 4.4.19 (???? was garabage): > > ./tt: line 18: ????: var1 == : syntax error: operand expected (error token > is "== ") I don't get this. I get `((' as the command name in the error message for both bash-4.3.46 and bash-4.4.19: ./x18: line 1: ((: var1 == : syntax error: operand expected (error token is "== ") -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/