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


Groups > gnu.bash.bug > #16562

Re: Return from function depending on number of parameters

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups gnu.bash.bug
Subject Re: Return from function depending on number of parameters
Date Fri, 10 Jul 2020 11:40:18 -0400
Lines 30
Approved bug-bash@gnu.org
Message-ID <mailman.58.1594395650.2306.bug-bash@gnu.org> (permalink)
References <b1c19d38-64c0-f1ae-d08a-1ada435a0022@gmail.com> <506AA493-0D79-4A9A-A53E-279FDA72CED5@larryv.me> <0b8f32e5-0644-526e-59a4-1bad5a474262@passchier.net> <ACF6AB75-5321-42EC-805E-D84048F539C9@larryv.me> <d4a5db68-0594-e540-c931-593469e73ce2@case.edu> <re9bi1$6q3$1@ciao.gmane.io> <20200710154018.GF22833@eeg.ccf.org>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace usenet.stanford.edu 1594395651 13541 209.51.188.17 (10 Jul 2020 15:40:51 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
Mail-Followup-To bug-bash@gnu.org
Content-Disposition inline
In-Reply-To <re9bi1$6q3$1@ciao.gmane.io>
User-Agent Mutt/1.10.1 (2018-07-13)
Received-SPF none client-ip=139.137.100.1; envelope-from=wooledg@eeg.ccf.org; helo=mail.eeg.ccf.org
X-detected-operating-system by eggs.gnu.org: First seen = 2020/07/10 11:40:18
X-ACL-Warn Detected OS = Linux 2.2.x-3.x [generic] [fuzzy]
X-Spam_score_int -8
X-Spam_score -0.9
X-Spam_bar /
X-Spam_report (-0.9 / 5.0 requ) BAYES_00=-1.9, KHOP_HELO_FCRDNS=1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no
X-Spam_action no action
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 <20200710154018.GF22833@eeg.ccf.org>
X-Mailman-Original-References <b1c19d38-64c0-f1ae-d08a-1ada435a0022@gmail.com> <506AA493-0D79-4A9A-A53E-279FDA72CED5@larryv.me> <0b8f32e5-0644-526e-59a4-1bad5a474262@passchier.net> <ACF6AB75-5321-42EC-805E-D84048F539C9@larryv.me> <d4a5db68-0594-e540-c931-593469e73ce2@case.edu> <re9bi1$6q3$1@ciao.gmane.io>
Xref csiph.com gnu.bash.bug:16562

Show key headers only | View raw


On Fri, Jul 10, 2020 at 10:14:38AM +0100, Chris Elvidge wrote:
> export PS1='\[${fcol[d]}${ecol[!!$?]}\][$?] \[${ucol[!!$(id
> -u)]}\]\h\[${fcol[b]}\]!\[${ucol[!!$(id -u)]}\]\u\[${fcol[w]}\]:(`tty|cut
> -d/ -f3-`):\D{%a %d %b %Y %I:%M %P %Z}:`pwd`\n\$\[${fcol[n]}\] '
> 
> I somehow thought that [...] forced 'arithmetic context', so I tried it.

No, not in general.

> Are the two uses (array subscript and arithmetic context) of [...]
> connected/related? Or am I (stupidly) seeing a connection where none really
> exists?

An arithmetic context is created in (at least!) the following
situations (copied from
<https://mywiki.wooledge.org/BashProgramming/05#Arithmetic_Expansion>):

 * The $(( )) arithmetic substitution.
 * The let or (( )) command.
 * The index inside [ ] in an indexed array variable expansion.
 * The start and length parameters in ${parameter:start:length} substitution.
 * The [[ command with -gt or other numeric operators. 

The deprecated $[ ] substitution falls into the same category as the
currently supported $(( )) syntax.

The [ character has several different meanings depending on where
and how it's used.  It doesn't always indicate a math context.  It's
also used for character classes in globs and regular expressions.

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


Thread

Re: Return from function depending on number of parameters Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-10 11:40 -0400

csiph-web