Re: info missing in output of declare -a in 4.4.x

2019-02-18 Thread Andreas Schwab
On Feb 17 2019, Dennis Williamson  wrote:

> Oh, interesting! In Bash 4 and 5, I just did declare -p with no args and it
> showed BASH_ALIASES empty. But with declare -p BASH_ALIASES it shows the
> contents (as does the alias command).
>
> Other arrays that show this difference for me:
>
> BASH_CMDS
> DIRSTACK
> GROUPS
>
> Scalars that exhibit this issue:
>
> BASHPID
> BASH_COMMAND
> BASH_SUBSHELL
> COMP_WORDBREAKS
> HISTCMD
> LINENO
> RANDOM
> SECONDS

All these dynamic variables are displayed with values by declare -p
after the variable is accessed once.

Andreas.

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



Re: nested bash 5 interactive sessions without job control

2019-02-18 Thread Grisha Levit
On Sun, Feb 17, 2019 at 8:23 PM Chet Ramey  wrote:
> Thanks for the report. I'll fix it in the next devel branch push.

One more corner case, only shows up when bash is started by `login`:

$ set +m; exec /
-bash: /: Is a directory
-bash: exec: /: cannot execute: Is a directory
$ echo "$(ps -o pid,tpgid -p $$)"
  PID TPGID
57430 57429  # 57429 is the login process
$ set -m; $(:)
-bash: child setpgid (57437 to 57430): Operation not permitted



Re: nested bash 5 interactive sessions without job control

2019-02-18 Thread Chet Ramey
On 2/18/19 12:55 PM, Grisha Levit wrote:
> On Sun, Feb 17, 2019 at 8:23 PM Chet Ramey  wrote:
>> Thanks for the report. I'll fix it in the next devel branch push.
> 
> One more corner case, only shows up when bash is started by `login`:
> 
> $ set +m; exec /
> -bash: /: Is a directory
> -bash: exec: /: cannot execute: Is a directory
> $ echo "$(ps -o pid,tpgid -p $$)"
>   PID TPGID
> 57430 57429  # 57429 is the login process
> $ set -m; $(:)
> -bash: child setpgid (57437 to 57430): Operation not permitted

Before or after today's push?

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/



Re: in bash 4.4.12,want to verify a behavior...

2019-02-18 Thread L A Walsh



On 2/17/2019 6:54 PM, Chet Ramey wrote:
> Not quite. Dynamic variables are only defined to return the correct value
> when they are referenced. The rest of the time, the values are
> indeterminate (and possibly stale). The idea is that you can get an element
> given the right index, or all the elements with the `*' or `@' subscripts.
>
> ...
>
> `declare -p' just lists variables and any existing values. It doesn't cause
> values to be generated. `declare -p BASH_ALIASES' counts as asking for the
> value.
>
>   
Thanks for the more thorough explanation. 

Was wondering if it would be possible (or worth it) on arrays and
hashes, where the current value isn't shown, if the number of entries
stored, might be shown?  That way more people might know that the
declare -p output may only be giving names (and, maybe size) even if
not enumerated.

I would strictly think such a change to be a 'bell/whistle', since
everything seems functional as it is and it may not be worth it to
even makes such a minor change.

Thanks for the explanation!
-l






Re: nested bash 5 interactive sessions without job control

2019-02-18 Thread Grisha Levit
After. Prior to today's push bash just hangs after `exec /`.

Also I tested only on OSX, setting my login shell to the newly built bash
and setting iTerm/Terminal.app to use the login shell.


Re: in bash 4.4.12,want to verify a behavior...

2019-02-18 Thread Chet Ramey
On 2/18/19 1:44 PM, L A Walsh wrote:
> 
> 
> On 2/17/2019 6:54 PM, Chet Ramey wrote:
>> Not quite. Dynamic variables are only defined to return the correct value
>> when they are referenced. The rest of the time, the values are
>> indeterminate (and possibly stale). The idea is that you can get an element
>> given the right index, or all the elements with the `*' or `@' subscripts.
>>
>> ...
>>
>> `declare -p' just lists variables and any existing values. It doesn't cause
>> values to be generated. `declare -p BASH_ALIASES' counts as asking for the
>> value.
>>
>>   
> Thanks for the more thorough explanation. 
> 
> Was wondering if it would be possible (or worth it) on arrays and
> hashes, where the current value isn't shown, if the number of entries
> stored, might be shown?  That way more people might know that the
> declare -p output may only be giving names (and, maybe size) even if
> not enumerated.

If the value shows up as empty, as when the value hasn't yet been
computed, the number of entries is zero.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/