Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Greg Wooledge 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: References: <506AA493-0D79-4A9A-A53E-279FDA72CED5@larryv.me> <0b8f32e5-0644-526e-59a4-1bad5a474262@passchier.net> <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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <20200710154018.GF22833@eeg.ccf.org> X-Mailman-Original-References: <506AA493-0D79-4A9A-A53E-279FDA72CED5@larryv.me> <0b8f32e5-0644-526e-59a4-1bad5a474262@passchier.net> Xref: csiph.com gnu.bash.bug:16562 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 ): * 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.