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





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 because it is the search pattern or because it now sets the 
region?


'reverse-search-history (C-r)'
 Search backward starting at the current line and moving 'up'
 through the history as necessary.  This is an incremental search.
	 This command sets the region to the matched text and activates 
the

 mark.

f. New active mark and face feature: when enabled, it will highlight 
the text
   inserted by a bracketed paste (the `active region') and the text 
found by

   incremental and non-incremental history searches.


I find the reverse video highlight to be very difficult to read.  For
me it is extreme eye strain.  Is there a way to disable the reverse
video?  For both the paste text and the search text?

This is so bad for me that for the moment I had to revert to the
previous version of bash to avoid it.  (Note that disabling bracketed
paste mode avoids it for the paste but doesn't address the reverse
video of search.)


 The problem right now is that the "face" mechanism is very primitive 
compared to Emacs'. In Emacs, you can define the attributes of a face to 
be whatever you want: if you want to make readline highlight things in 
underlined red, more power to you. Bash's highlight face is hardcoded to 
use the terminal "standout" mode, which can mean whatever the terminal 
wants it to mean. Normally that's fine, but it seems like your terminal 
defines standout to be something ugly. It seems reasonable to add a knob 
to make bash's FACE_STANDOUT mean the same as FACE_NORMAL, but I think a 
better solution is to add an Emacs-like ability to define at runtime 
what each face actually means.




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 it now sets the region?

'reverse-search-history (C-r)'
 Search backward starting at the current line and moving 'up'
 through the history as necessary.  This is an incremental search.
 This command sets the region to the matched text and activates the
 mark.

> f. New active mark and face feature: when enabled, it will highlight the text
>inserted by a bracketed paste (the `active region') and the text found by
>incremental and non-incremental history searches.

I find the reverse video highlight to be very difficult to read.  For
me it is extreme eye strain.  Is there a way to disable the reverse
video?  For both the paste text and the search text?

This is so bad for me that for the moment I had to revert to the
previous version of bash to avoid it.  (Note that disabling bracketed
paste mode avoids it for the paste but doesn't address the reverse
video of search.)

Bob




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
> 
> This works but feels kludgy
> 
> an=ar1
> eval echo \${#$an[@]}
> 4

I'm not quite sure what exactly you intend, but if you use

  declare -n an=ar1

instead of an=ar1, then

  echo ${#an} ${an[3]}

will work as I expect.

Best regards

Martin



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 works but feels kludgy
> 
> an=ar1
> eval echo \${#$an[@]}
> 4
> 
> 
> I thought the !name was supposed to take the place
> of using $an, but haven't seen a case where !an works where
> an points to an array name.
> 
> Is there a place in the bash manpage that gives an example of using !name
> where name points to an array?
> 
> Thanks...
> -l
> 
> 


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


-- 
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden

.



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
> 
> This works but feels kludgy
> 
> an=ar1
> eval echo \${#$an[@]}
> 4

I'm not quite sure what exactly you intend, but if you use

  declare -n an=ar1

instead of an=ar1, then

  echo ${#an} ${an[3]}

will work as I expect.

Best regards

Martin



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 !name was supposed to take the place
of using $an, but haven't seen a case where !an works where
an points to an array name.

Is there a place in the bash manpage that gives an example of using !name
where name points to an array?

Thanks...
-l