Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16532 > unrolled thread
| Started by | Chris Elvidge <celvidge001@gmail.com> |
|---|---|
| First post | 2020-07-04 12:01 +0100 |
| Last post | 2020-07-04 12:01 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to gnu.bash.bug
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Return from function depending on number of parameters Chris Elvidge <celvidge001@gmail.com> - 2020-07-04 12:01 +0100
| From | Chris Elvidge <celvidge001@gmail.com> |
|---|---|
| Date | 2020-07-04 12:01 +0100 |
| Subject | Re: Return from function depending on number of parameters |
| Message-ID | <mailman.929.1593860511.2574.bug-bash@gnu.org> |
On 03/07/2020 10:39 pm, Lawrence Velázquez wrote: >> On Jul 3, 2020, at 2:00 PM, Chris Elvidge <celvidge001@gmail.com> wrote: >> >> However 'N=0; echo $((!$N))' gives an error at the bash prompt. >> 'echo $[!$N]' echo's 1 as expected. >> >> My question - is $[...] actually obsolete? > > It might tell you something that $[...] is not even mentioned in > the man page for bash 3.2.57, which is decidedly not the current > version. > >> If so, what should I use at the bash prompt to get the same effect? > > > I expect that the error you encountered was caused by !$ expanding > to the last word of the previous command and making the contents > of $((...)) an invalid arithmetic expression. This didn't affect > your scripts because history expansion is not enabled in non-interactive > shells by default. > > Try inserting a space. > > $ N=0; printf %s\\n "$((! $N))" > 1 > > You can even drop the $. > > $ N=0; printf %s\\n "$((! N))" > 1 > > vq > Thanks for the info. It also explains why I couldn't find a reference to $[...] except in the reference I quoted. -- Chris Elvidge 5 Ebor Park, Appleton Roebuck, York. YO23 7DZ. Tel (Mob): +447443472958 mailto:celvidge@outlook.com Calle Padre Raimundo Codesal 1, Vélez-Málaga, 29700, España
Back to top | Article view | gnu.bash.bug
csiph-web