Re: Error message garbage when parameter expansion used inside (()) and variable unset

2018-04-04 Thread Chet Ramey
On 4/3/18 7:07 PM, PRussell wrote: > Hi, > > The error seems to be localized to the expansion of PS4 when "set -x" is > active. > > Please see sample script below. It's not quite that, though the expansion below does demonstrate what I think is the problem. If I am right about the cause, the p

Re: Error message garbage when parameter expansion used inside (()) and variable unset

2018-04-04 Thread Chet Ramey
On 4/3/18 7:07 PM, PRussell wrote: > Hi, > > The error seems to be localized to the expansion of PS4 when "set -x" is > active. > > Please see sample script below. > > I am aware of the unusual parameter expansion for FUNCNAME. There might be a > local historical reason. :-) > > It does not

Re: Error message garbage when parameter expansion used inside (()) and variable unset

2018-04-03 Thread PRussell
Hi, The error seems to be localized to the expansion of PS4 when "set -x" is active. Please see sample script below. I am aware of the unusual parameter expansion for FUNCNAME. There might be a local historical reason. :-) It does not happen outside of the PS4 expansion. It also behaves diffe

Re: Error message garbage when parameter expansion used inside (()) and variable unset

2018-04-03 Thread Chet Ramey
On 4/3/18 1:15 PM, PRussell wrote: > Chet, is the output on opensuse running bash 4.4.19, correct? > > The specific output: > > ./t.sh: line 9: ���#V: var1 ==  : syntax error: operand expected (error > token is "==  ") > > archlinux has the same version of bash and I got the same results as on

Re: Error message garbage when parameter expansion used inside (()) and variable unset

2018-04-03 Thread Greg Wooledge
On Tue, Apr 03, 2018 at 12:15:14PM -0500, PRussell wrote: > ./t.sh: line 9: ���#V: var1 == : syntax error: operand expected (error > token is "== ") > > archlinux has the same version of bash and I got the same results as on > opensuse. I cannot reproduce this on Debian 9 amd64. Not with Debi

Re: Error message garbage when parameter expansion used inside (()) and variable unset

2018-04-03 Thread PRussell
Chet, is the output on opensuse running bash 4.4.19, correct? The specific output: ./t.sh: line 9: ���#V: var1 == : syntax error: operand expected (error token is "== ") archlinux has the same version of bash and I got the same results as on opensuse. Below are the details of running ./

Re: Error message garbage when parameter expansion used inside (()) and variable unset

2018-04-03 Thread Chet Ramey
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 parame

Re: Error message garbage when parameter expansion used inside (()) and variable unset

2018-04-03 Thread Daniel Mills
On Mon, Apr 2, 2018 at 5:16 PM, PRussell wrote: > > echo 4B > ( set -x;var=5;var1=var; (( var1 == $var2 )) && echo yes || echo no ) > > > It appears that 3A and 4A evaluate to 0 because of the arithmetic context. > 3A echo's yes; 4A echo's no. > > The problem is what is happening with 3B and 4B

Re: Error message garbage when parameter expansion used inside (()) and variable unset

2018-04-03 Thread Greg Wooledge
On Mon, Apr 02, 2018 at 04:16:54PM -0500, PRussell wrote: > 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? The parameter expansion

Error message garbage when parameter expansion used inside (()) and variable unset

2018-04-02 Thread PRussell
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/s