[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Return from function depending on number of parameters
From: |
Lawrence Velázquez |
Subject: |
Re: Return from function depending on number of parameters |
Date: |
Fri, 3 Jul 2020 17:39:52 -0400 |
> 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
- Return from function depending on number of parameters, Chris Elvidge, 2020/07/03
- Re: Return from function depending on number of parameters,
Lawrence Velázquez <=
- Re: Return from function depending on number of parameters, Chris Elvidge, 2020/07/04
- Re: Return from function depending on number of parameters, pepa65, 2020/07/04
- Re: Return from function depending on number of parameters, Oğuz, 2020/07/04
- Re: Return from function depending on number of parameters, Lawrence Velázquez, 2020/07/04
- Re: Return from function depending on number of parameters, Chet Ramey, 2020/07/05
- Re: Return from function depending on number of parameters, Chris Elvidge, 2020/07/10
- Re: Return from function depending on number of parameters, Chet Ramey, 2020/07/10
- Re: Return from function depending on number of parameters, Greg Wooledge, 2020/07/10
Re: Return from function depending on number of parameters, Chris Elvidge, 2020/07/04
Re: Return from function depending on number of parameters, Eli Schwartz, 2020/07/03