Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16562
| From | Greg Wooledge <wooledg@eeg.ccf.org> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: Return from function depending on number of parameters |
| Date | 2020-07-10 11:40 -0400 |
| Message-ID | <mailman.58.1594395650.2306.bug-bash@gnu.org> (permalink) |
| References | (2 earlier) <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> |
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
Re: Return from function depending on number of parameters Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-10 11:40 -0400
csiph-web