Re: "wait" loses signals

2020-02-19 Thread Robert Elz
Date:Wed, 19 Feb 2020 23:53:56 + From:Harald van Dijk Message-ID: <9b9d435b-3d2f-99bd-eb3d-4a676ce89...@gigawatt.nl> | POSIX says in the description of the trap command "Otherwise, the | argument action shall be read and executed by the shell when one of

Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a

2020-02-19 Thread Arfrever Frehtes Taifersar Arahesis
Eli Schwartz 2020-02-20 23:49 UTC: > Your examples are all (still) broken. This would affect only 10 examples from 120, so only 8.33 % of examples, far from all examples. > You cannot use ${!ref[@]}, you need the array subscript as part of the > set value of "ref" and then indirectly refer to

Re: "wait" loses signals

2020-02-19 Thread Harald van Dijk
On 19/02/2020 20:30, Chet Ramey wrote: On 2/19/20 5:29 AM, Denys Vlasenko wrote: A bug report from Harald van Dijk: test2.sh: trap 'kill $!; exit' TERM { kill $$; exec sleep 9; } & wait $! The above script ought exit quickly, and not leave a stray "sleep" child: (1) if "kill $$" signal is

Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a

2020-02-19 Thread Eli Schwartz
On 2/19/20 6:18 PM, Arfrever Frehtes Taifersar Arahesis wrote: > While described problems exist, there were typos in original reproduction > steps. > > Corrected output also reveals another bug: > ${!variable[@]@A} for (indexed or associative) arrays does not include > indexes. Your examples

Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a

2020-02-19 Thread Arfrever Frehtes Taifersar Arahesis
While described problems exist, there were typos in original reproduction steps. Corrected output also reveals another bug: ${!variable[@]@A} for (indexed or associative) arrays does not include indexes. Example part of output: var=VAR4 ${!var@A}:'declare -arl VAR4='zzz'' ${!var[@]@A}:

Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a

2020-02-19 Thread Arfrever Frehtes Taifersar Arahesis
> ${variable@A} does not work for scalar variables without values, but > interestingly ${variable[@]@A} works for them. More precisely, ${variable[@]@A} is non-empty, but not exactly correct. > See difference between ${VAR1@A} and ${VAR1[@]@A} below. ${VAR1[@]@A} is: declare -rl VAR1=''" But

Re: ${variable@A} does not work for associative arrays

2020-02-19 Thread Eli Schwartz
On 2/19/20 3:05 PM, Arfrever Frehtes Taifersar Arahesis wrote: > BASH 5.0.16. > > $ VAR1=aaa > $ declare -a VAR2=(aaa) > $ declare -A VAR3=([aaa]=aaa) > $ declare -p VAR{1,2,3} > declare -- VAR1="aaa" > declare -a VAR2=([0]="aaa") > declare -A VAR3=([aaa]="aaa" ) > $ echo "${VAR1@A}" > VAR1='aaa'

Unnecessary space in 'declare -p' and [@]@A for non-empty associative arrays

2020-02-19 Thread Arfrever Frehtes Taifersar Arahesis
Notice unnecessary space before closing parenthesis for non-empty associative arrays (VAR5, VAR6) below: $ declare -a VAR1=() VAR2=(a) VAR3=(a b) $ declare -A VAR4=() VAR5=([0]=a) VAR6=([0]=a [1]=b) $ declare -p VAR{1,2,3,4,5,6} declare -a VAR1=() declare -a VAR2=([0]="a") declare -a

Re: ${variable@A} does not work for associative arrays

2020-02-19 Thread Chet Ramey
On 2/19/20 3:05 PM, Arfrever Frehtes Taifersar Arahesis wrote: > BASH 5.0.16. > > $ VAR1=aaa > $ declare -a VAR2=(aaa) > $ declare -A VAR3=([aaa]=aaa) > $ declare -p VAR{1,2,3} > declare -- VAR1="aaa" > declare -a VAR2=([0]="aaa") > declare -A VAR3=([aaa]="aaa" ) > $ echo "${VAR1@A}" > VAR1='aaa'

${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a

2020-02-19 Thread Arfrever Frehtes Taifersar Arahesis
${!variable@operator} does not work for variables without values. See empty values for all occurrences of ${!var@...} below. ${variable@A} does not work for scalar variables without values, but interestingly ${variable[@]@A} works for them. See difference between ${VAR1@A} and ${VAR1[@]@A} below.

Inconsistent termination of function when 'local' tries to override read-only variable

2020-02-19 Thread Arfrever Frehtes Taifersar Arahesis
When scalar variable is read-only, then calling 'local' for this variable (regardless of presence of value in assignment) is non-fatal and subsequent commands in function are executed. When (indexed or associative) array is read-only, then calling 'local -a' or 'local -A' (without value) for this

${variable@A} does not work for associative arrays

2020-02-19 Thread Arfrever Frehtes Taifersar Arahesis
BASH 5.0.16. $ VAR1=aaa $ declare -a VAR2=(aaa) $ declare -A VAR3=([aaa]=aaa) $ declare -p VAR{1,2,3} declare -- VAR1="aaa" declare -a VAR2=([0]="aaa") declare -A VAR3=([aaa]="aaa" ) $ echo "${VAR1@A}" VAR1='aaa' $ echo "${VAR2@A}" declare -a VAR2='aaa' $ echo "${VAR3@A}" $ -- Arfrever Frehtes

Re: test -v for array does not work as documented

2020-02-19 Thread Grisha Levit
On Wed, Feb 19, 2020 at 11:38 AM Ulrich Mueller wrote: > Especially, to distinguish VARNAME=() (empty > array) from VARNAME being unset? I'm not sure if it's intended to work this way, but ${var@a} will report the attributes if the variable has any set, even if it does not have a value, like:

Re: "wait" loses signals

2020-02-19 Thread Chet Ramey
On 2/19/20 5:29 AM, Denys Vlasenko wrote: > A bug report from Harald van Dijk: > > test2.sh: > trap 'kill $!; exit' TERM > { kill $$; exec sleep 9; } & > wait $! > > The above script ought exit quickly, and not leave a stray > "sleep" child: > (1) if "kill $$" signal is delivered before "wait",

Re: test -v for array does not work as documented

2020-02-19 Thread Stephane Chazelas
2020-02-19 17:18:14 +0100, Ulrich Mueller: [...] > So, is there any syntax that allows to test if a value has been assigned > to the array variable? Especially, to distinguish VARNAME=() (empty > array) from VARNAME being unset? [...] You could do: if typeset -p var 2> /dev/null | grep -q '=';

Re: test -v for array does not work as documented

2020-02-19 Thread Chet Ramey
On 2/19/20 11:18 AM, Ulrich Mueller wrote: >> On Wed, 19 Feb 2020, Chet Ramey wrote: > >> On 2/19/20 7:00 AM, Ulrich Mueller wrote: >>> Bash Version: 5.0 >>> Patch Level: 16 >>> Release Status: release >>> >>> Description: >>> The GNU Bash Reference Manual Version 5.0 says about test -v: >>>

Re: test -v for array does not work as documented

2020-02-19 Thread pepa65
On 19/02/2020 23.18, Ulrich Mueller wrote: > So, is there any syntax that allows to test if a value has been assigned > to the array variable? Especially, to distinguish VARNAME=() (empty > array) from VARNAME being unset? Not `test` as such as we have just learned, but the returncode of `declare

Re: test -v for array does not work as documented

2020-02-19 Thread Ulrich Mueller
> On Wed, 19 Feb 2020, Chet Ramey wrote: > On 2/19/20 7:00 AM, Ulrich Mueller wrote: >> Bash Version: 5.0 >> Patch Level: 16 >> Release Status: release >> >> Description: >> The GNU Bash Reference Manual Version 5.0 says about test -v: >> '-v VARNAME' >> True if the shell variable VARNAME is

Re: test -v for array does not work as documented

2020-02-19 Thread Chet Ramey
On 2/19/20 7:00 AM, Ulrich Mueller wrote: > Bash Version: 5.0 > Patch Level: 16 > Release Status: release > > Description: > The GNU Bash Reference Manual Version 5.0 says about test -v: > '-v VARNAME' >True if the shell variable VARNAME is set (has been >

test -v for array does not work as documented

2020-02-19 Thread Ulrich Mueller
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: x86_64-pc-linux-gnu-gcc Compilation CFLAGS: -march=native -ggdb -O2 -pipe -Wno-parentheses -Wno-format-security uname output: Linux a1i15 4.19.102-gentoo #1 SMP Fri Feb 7 14:32:53 CET 2020

"wait" loses signals

2020-02-19 Thread Denys Vlasenko
A bug report from Harald van Dijk: test2.sh: trap 'kill $!; exit' TERM { kill $$; exec sleep 9; } & wait $! The above script ought exit quickly, and not leave a stray "sleep" child: (1) if "kill $$" signal is delivered before "wait", then TERM trap will kill the child, and exit. (2) if "kill