[SOLVED] bash arithmetic evaluation null variable strange behavior
by doru from LinuxQuestions.org on (#4XRHD)
a is unset. Why would this happen?
Code:$ echo $(($a+1))
1
$ echo $((1+$a))
bash: 1+: syntax error: operand expected (error token is "+")
$ bash --version
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>


Code:$ echo $(($a+1))
1
$ echo $((1+$a))
bash: 1+: syntax error: operand expected (error token is "+")
$ bash --version
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>