Re: select syntax violates the POLA

2021-04-01 Thread Robert Elz
Date:Thu, 01 Apr 2021 21:33:31 -0400 From:wor...@alum.mit.edu (Dale R. Worley) Message-ID: <874kgpqxlg@hobgoblin.ariadne.com> | I was going to ask why "else {" works, Wrong question. That one is easy. What follows 'else' is a list and the simplest form of a li

Re: select syntax violates the POLA

2021-04-01 Thread Greywolf
On 4/1/2021 16:03, Robert Elz wrote: Partly because if you didn't use the braces, the issue wouldn't have arisen. (And because to most of us it just looks weird, kind of like people who write functions like f() {( commands to run in a subshell )} where the braces do nothing useful at all. and sho

Re: select syntax violates the POLA

2021-04-01 Thread Dale R. Worley
Chet Ramey writes: > Yes, you need a list terminator so that `done' is recognized as a reserved > word here. `;' is sufficient. Select doesn't allow the `done' unless it's > in a command position. Some of the other compound commands have special > cases, mostly inherited from the Bourne shell, to

Re: select syntax violates the POLA

2021-04-01 Thread Dale R. Worley
Greg Wooledge writes: > It's amazing how many people manage to post their code with NO comments > or explanations of what it's supposed to do, what assumptions are being > made about the inputs, etc. This leaves us to guess. It seems to be a modern style. When I was learning to program, poorly

Re: select syntax violates the POLA

2021-04-01 Thread Robert Elz
Date:Thu, 1 Apr 2021 14:40:13 -0700 From:Greywolf Message-ID: <354ec4df-c24e-d82a-32ad-788a352a5...@starwolf.com> | Or do you mean my coding style It was that, | (which has been valid for over 25 years)? | (why's everyone bagging on my style and ignoring my or

Re: select syntax violates the POLA

2021-04-01 Thread Greg Wooledge
On Thu, Apr 01, 2021 at 02:54:55PM -0700, Greywolf wrote: > the requirement > to have ${var[ix]} instead of honouring $var[ix] with regard to arrays > is another one). Before the introduction of arrays, $var[ix] already had a meaning: the value of the "var" parameter, followed by the 4-character s

Re: select syntax violates the POLA

2021-04-01 Thread Greywolf
Hi, Chet! I've read a lot of your posts long ago, as well! On 4/1/2021 8:57, Chet Ramey wrote: It's more like `select' doesn't inherit some of the shell's special cases.     select dir in ${d[@]}; do {     break;     } done; >> ...but select breaks on the "} done;" syntax

Re: select syntax violates the POLA

2021-04-01 Thread Greywolf
On 4/1/2021 9:58, Robert Elz wrote: Date:Thu, 1 Apr 2021 11:36:14 -0400 From:Greg Wooledge Message-ID: | On Thu, Apr 01, 2021 at 01:36:59AM -0700, greyw...@starwolf.com wrote: | > The following is valid shell code: | > | > d=($(ls /usr/sr

Re: select syntax violates the POLA

2021-04-01 Thread Greywolf
On 4/1/2021 9:16, konsolebox wrote: On Thu, Apr 1, 2021 at 11:25 PM wrote: if ((n > 1)); then { echo "Ambiguous dir specification"; exit 1; } else { dir=${d[0]}; } fi; The grouping is unnecessary or should be separate

Re: Changing the way bash expands associative array subscripts

2021-04-01 Thread konsolebox
On Fri, Apr 2, 2021 at 3:02 AM konsolebox wrote: > > On Fri, Apr 2, 2021 at 2:56 AM Chet Ramey wrote: > > > > On 4/1/21 2:55 PM, konsolebox wrote: > > > > > So to keep compatibility, would this be the right way? > > > > > > if [[ BASH_VERSINFO -ge 6 || BASH_VERSINFO -eq 5 && BASH_VERSINFO -ge 2

Re: Changing the way bash expands associative array subscripts

2021-04-01 Thread konsolebox
On Fri, Apr 2, 2021 at 2:56 AM Chet Ramey wrote: > > On 4/1/21 2:55 PM, konsolebox wrote: > > > So to keep compatibility, would this be the right way? > > > > if [[ BASH_VERSINFO -ge 6 || BASH_VERSINFO -eq 5 && BASH_VERSINFO -ge 2 ]]; > > then > > unset() { > > set -- "${@//\[/\\[}"

Re: select syntax violates the POLA

2021-04-01 Thread Robert Elz
Date:Thu, 1 Apr 2021 13:18:07 -0400 From:Greg Wooledge Message-ID: | It's amazing how many people manage to post their code with NO comments | or explanations of what it's supposed to do, what assumptions are being | made about the inputs, etc. This leaves us

Re: select syntax violates the POLA

2021-04-01 Thread Eli Schwartz
On 4/1/21 1:18 PM, Greg Wooledge wrote: > On Thu, Apr 01, 2021 at 11:58:13PM +0700, Robert Elz wrote: >> >> | If $1 is not a directory, then you want: >> >> It is a directory, or I'd guess, quite likely a pattern chosen > > It's amazing how many people manage to post their code with NO comments

Re: select syntax violates the POLA

2021-04-01 Thread Greg Wooledge
On Thu, Apr 01, 2021 at 11:58:13PM +0700, Robert Elz wrote: > > | If $1 is not a directory, then you want: > > It is a directory, or I'd guess, quite likely a pattern chosen It's amazing how many people manage to post their code with NO comments or explanations of what it's supposed to do, wha

Re: select syntax violates the POLA

2021-04-01 Thread Robert Elz
Date:Thu, 1 Apr 2021 11:36:14 -0400 From:Greg Wooledge Message-ID: | On Thu, Apr 01, 2021 at 01:36:59AM -0700, greyw...@starwolf.com wrote: | > The following is valid shell code: | > | > d=($(ls /usr/src/pkg/*/$1)); | | Syntactically valid, but seman

Re: select syntax violates the POLA

2021-04-01 Thread konsolebox
On Thu, Apr 1, 2021 at 11:25 PM wrote: > > if ((n > 1)); then { > echo "Ambiguous dir specification"; > exit 1; > } > else { > dir=${d[0]}; > } fi; The grouping is unnecessary or should be separate from the first class syntax. B

Re: select syntax violates the POLA

2021-04-01 Thread Chet Ramey
On 4/1/21 4:36 AM, greyw...@starwolf.com wrote: Bash Version: 5.1 Patch Level: 4 Release Status: release Description: The 'select' directive's syntax does not correspond to the rest of the shell's syntax. I am not sure if this is by design; if it is, let me know and I'll go aw

Re: select syntax violates the POLA

2021-04-01 Thread Greg Wooledge
On Thu, Apr 01, 2021 at 01:36:59AM -0700, greyw...@starwolf.com wrote: > The following is valid shell code: > > d=($(ls /usr/src/pkg/*/$1)); Syntactically valid, but semantically wrong. If $1 is not a directory, then you want: d=(/usr/src/pkg/*/"$1") If $1 is supposed to be a direc

select syntax violates the POLA

2021-04-01 Thread greywolf
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: netbsd Compiler: gcc Compilation CFLAGS: -O2 -I/usr/local/include -D_FORTIFY_SOURCE=2 -I/usr/include uname output: NetBSD eddie.starwolf.com 9.99.81 NetBSD 9.99.81 (EDDIE) #9: Tue Mar 23 19:13:25 PDT 2021 gre