Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16536

Re: Return from function depending on number of parameters

Path csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Chris Elvidge <celvidge001@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: Return from function depending on number of parameters
Date Sat, 4 Jul 2020 11:39:51 +0100
Lines 42
Approved bug-bash@gnu.org
Message-ID <mailman.947.1593878416.2574.bug-bash@gnu.org> (permalink)
References <b1c19d38-64c0-f1ae-d08a-1ada435a0022@gmail.com> <506AA493-0D79-4A9A-A53E-279FDA72CED5@larryv.me> <rdpm9o$f3h$1@ciao.gmane.io>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 8bit
X-Trace usenet.stanford.edu 1593878417 20855 209.51.188.17 (4 Jul 2020 16:00:17 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
X-Injected-Via-Gmane http://gmane.org/
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1
In-Reply-To <506AA493-0D79-4A9A-A53E-279FDA72CED5@larryv.me>
Content-Language en-GB
Received-SPF pass client-ip=116.202.254.214; envelope-from=gnu-bug-bash-3@m.gmane-mx.org; helo=ciao.gmane.io
X-detected-operating-system by eggs.gnu.org: First seen = 2020/07/04 12:00:04
X-ACL-Warn Detected OS = Linux 2.2.x-3.x [generic] [fuzzy]
X-Spam_score_int 59
X-Spam_score 5.9
X-Spam_bar +++++
X-Spam_report (5.9 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_03_06=1.592, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FORGED_MUA_MOZILLA=2.309, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN
X-Spam_action reject
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <rdpm9o$f3h$1@ciao.gmane.io>
X-Mailman-Original-References <b1c19d38-64c0-f1ae-d08a-1ada435a0022@gmail.com> <506AA493-0D79-4A9A-A53E-279FDA72CED5@larryv.me>
Xref csiph.com gnu.bash.bug:16536

Show key headers only | View raw


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 suggestion.

-- 
Chris Elvidge
England

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Return from function depending on number of parameters Chris Elvidge <celvidge001@gmail.com> - 2020-07-04 11:39 +0100

csiph-web