find len of array w/name in another var...(bash 4.4.12)

2020-10-20 Thread L A Walsh
There's got to be an easier way to do this, but not remembering or finding it: First tried the obvious: declare -a ar1=([0]="1" [1]="2" [2]="3" [3]="44") an=ar1 echo ${#!an[@]} -bash: ${#!an[@]}: bad substitution This works but feels kludgy an=ar1 eval echo \${#$an[@]} 4 I thought the !na

Re: find len of array w/name in another var...(bash 4.4.12)

2020-10-20 Thread Martin Schulte
Hello! Am Tue, 20 Oct 2020 00:58:36 -0700 schrieb L A Walsh : > There's got to be an easier way to do this, but not remembering or finding > it: > > First tried the obvious: > declare -a ar1=([0]="1" [1]="2" [2]="3" [3]="44") > an=ar1 > echo ${#!an[@]} > -bash: ${#!an[@]}: bad substitution > > T

Re: find len of array w/name in another var...(bash 4.4.12)

2020-10-20 Thread Andreas Kusalananda Kähäri
On Tue, Oct 20, 2020 at 12:58:36AM -0700, L A Walsh wrote: > There's got to be an easier way to do this, but not remembering or finding > it: > > First tried the obvious: > declare -a ar1=([0]="1" [1]="2" [2]="3" [3]="44") > an=ar1 > echo ${#!an[@]} > -bash: ${#!an[@]}: bad substitution > > This

Re: find len of array w/name in another var...(bash 4.4.12)

2020-10-20 Thread Martin Schulte
Hello! Am Tue, 20 Oct 2020 00:58:36 -0700 schrieb L A Walsh : > There's got to be an easier way to do this, but not remembering or finding > it: > > First tried the obvious: > declare -a ar1=([0]="1" [1]="2" [2]="3" [3]="44") > an=ar1 > echo ${#!an[@]} > -bash: ${#!an[@]}: bad substitution > > T

Re: Bash-5.1-rc1 available

2020-10-20 Thread Bob Proulx
Chet Ramey wrote: > This release fixes several outstanding bugs in bash-5.0 and introduces > several new features. An unlisted change (I couldn't locate it in the changes) is that 'reverse-search-history (C-r)' now highlights the search pattern. Is that because it is the search pattern or because

Re: Bash-5.1-rc1 available

2020-10-20 Thread dancol
On 2020-10-20 13:44, Bob Proulx wrote: Chet Ramey wrote: This release fixes several outstanding bugs in bash-5.0 and introduces several new features. An unlisted change (I couldn't locate it in the changes) is that 'reverse-search-history (C-r)' now highlights the search pattern. Is that beca

Re: find len of array w/name in another var...(bash 4.4.12)

2020-10-20 Thread L A Walsh
On 2020/10/20 01:29, Andreas Kusalananda Kähäri wrote: In bash 4.3+, I would manke your "ar" variable a name reference variable instead: $ ar1=(1 2 3 44) $ declare -n ar=ar1 $ echo "${#ar[@]}" 4 Ya, I was trying to use the 'byname' feature for older/wider support...sigh