[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Error message garbage when parameter expansion used inside (()) and
From: |
Chet Ramey |
Subject: |
Re: Error message garbage when parameter expansion used inside (()) and variable unset |
Date: |
Tue, 3 Apr 2018 09:49:43 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
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 chet@case.edu http://tiswww.cwru.edu/~chet/
- Error message garbage when parameter expansion used inside (()) and variable unset, PRussell, 2018/04/02
- Re: Error message garbage when parameter expansion used inside (()) and variable unset, Greg Wooledge, 2018/04/03
- Re: Error message garbage when parameter expansion used inside (()) and variable unset, Daniel Mills, 2018/04/03
- Re: Error message garbage when parameter expansion used inside (()) and variable unset,
Chet Ramey <=
- Re: Error message garbage when parameter expansion used inside (()) and variable unset, PRussell, 2018/04/03
- Re: Error message garbage when parameter expansion used inside (()) and variable unset, Greg Wooledge, 2018/04/03
- Re: Error message garbage when parameter expansion used inside (()) and variable unset, Chet Ramey, 2018/04/03
- Re: Error message garbage when parameter expansion used inside (()) and variable unset, PRussell, 2018/04/03
- Re: Error message garbage when parameter expansion used inside (()) and variable unset, Chet Ramey, 2018/04/04
- Re: Error message garbage when parameter expansion used inside (()) and variable unset, Chet Ramey, 2018/04/04