|
From: | Chris Elvidge |
Subject: | Return / exit values |
Date: | Thu, 10 Sep 2020 00:10:00 -0000 |
User-agent: | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 |
Tested in a bash script 'exit $((!$#)) / $[!$#]' - both work.'echo $((!$#)) / $[!$#]' - both echo 1 when no params, 0 when any number of params.
I'm told ( https://wiki.bash-hackers.org/scripting/obsolete ) that $[...] is obsolete and that $((...)) should be used instead. OK so far.
However 'N=0; echo $((!$N))' gives an error at the bash prompt. 'echo $[!$N]' echo's 1 as expected.
My question - is $[...] actually obsolete? If so, what should I use at the bash prompt to get the same effect?
Cheers
[Prev in Thread] | Current Thread | [Next in Thread] |