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.