2020-02-20 21:36 GMT+01:00, Chet Ramey :
> On 2/19/20 4:03 PM, Arfrever Frehtes Taifersar Arahesis wrote:
>> ${!variable@operator} does not work for variables without values.
>> See empty values for all occurrences of ${!var@...} below.
>>
>> ${variable@A} does no
Chet Ramey 2020-02-20 21:22 UTC:
> On 2/19/20 7:46 PM, Arfrever Frehtes Taifersar Arahesis wrote:
>> But I am not interested in any ${!varname[@]}, but instead in applying
>> @operator transformations.
>
> OK, let's see how these work.
>
> Given the following
&
Chet Ramey 2020-02-20 20:41 UTC:
> On 2/19/20 5:22 PM, Arfrever Frehtes Taifersar Arahesis wrote:
>>> ${variable@A} does not work for scalar variables without values, but
>>> interestingly ${variable[@]@A} works for them.
>>
>> More precisely, ${variable[@]
ot;あ" [1]="い" [2]="う" [3]="え" [4]="お")
$ eval "echo \"\${${REF}[@]@a}\""
a a a a a
$ echo "${ARRAY[@]@A}"
declare -a ARRAY=([0]="あ" [1]="い" [2]="う" [3]="え" [4]="お")
$ echo "${ARRAY[@]@a}"
a a a a a
$
Majority (3 of 4) of bugs reported by me in this thread are unaffected
by above discussion about ${!...} and are certainly still valid.
--
Arfrever Frehtes Taifersar Arahesis
VAR6[@]@P}: 'zzz'
var=VAR1
${!var@A}:''
${!var[@]@A}: ''
${VAR1@A}:''
${VAR1[@]@A}: 'declare -rl VAR1='''
var=VAR2
${!var@A}:'declare -rl VAR2='zzz''
${!var[@]@A}: 'declare -rl VAR2='zzz''
${VAR2@A}:'declare -rl VAR2='zzz''
${VAR2[@]@A}: 'declare -rl VAR2='zzz''
var=VAR3
${!var@A}:''
${!var[@]@A}: ''
${VAR3@A}:''
${VAR3[@]@A}: ''
var=VAR4
${!var@A}:'declare -arl VAR4='zzz''
${!var[@]@A}: 'declare -arl VAR4='zzz''
${VAR4@A}:'declare -arl VAR4='zzz''
${VAR4[@]@A}: 'declare -arl VAR4=([0]="zzz")'
var=VAR5
${!var@A}:''
${!var[@]@A}: ''
${VAR5@A}:''
${VAR5[@]@A}: ''
var=VAR6
${!var@A}:'declare -Arl VAR6='zzz''
${!var[@]@A}: 'declare -Arl VAR6='zzz''
${VAR6@A}:'declare -Arl VAR6='zzz''
${VAR6[@]@A}: 'declare -Arl VAR6=([0]="zzz" )'
var=VAR1
${!var@a}:''
${!var[@]@a}: ''
${VAR1@a}:'rl'
${VAR1[@]@a}: 'rl'
var=VAR2
${!var@a}:'rl'
${!var[@]@a}: 'rl'
${VAR2@a}:'rl'
${VAR2[@]@a}: 'rl'
var=VAR3
${!var@a}:''
${!var[@]@a}: ''
${VAR3@a}:'arl'
${VAR3[@]@a}: ''
var=VAR4
${!var@a}:'arl'
${!var[@]@a}: 'arl'
${VAR4@a}:'arl'
${VAR4[@]@a}: 'arl'
var=VAR5
${!var@a}:''
${!var[@]@a}: ''
${VAR5@a}:'Arl'
${VAR5[@]@a}: ''
var=VAR6
${!var@a}:'Arl'
${!var[@]@a}: 'Arl'
${VAR6@a}:'Arl'
${VAR6[@]@a}: 'Arl'
$
--
Arfrever Frehtes Taifersar Arahesis
1=''"
But should be:
declare -rl VAR1
As in output of 'declare -p VAR1'.
--
Arfrever Frehtes Taifersar Arahesis
quot;
declare -a VAR3=([0]="a" [1]="b")
$ echo "${VAR4[@]@A}"
declare -A VAR4=()
$ echo "${VAR5[@]@A}"
declare -A VAR5=([0]="a" )
$ echo "${VAR6[@]@A}"
declare -A VAR6=([1]="b" [0]="a" )
$
(BASH 5.0.16)
--
Arfrever Frehtes Taifersar Arahesis
;'
var=VAR2
${!var@A}:''
${!var[@]@A}: ''
${VAR2@A}: 'declare -rl VAR2='zzz''
${VAR2[@]@A}: 'declare -rl VAR2='zzz''
var=VAR3
${!var@A}:''
${!var[@]@A}: ''
${VAR3@A}:''
${VAR3[@]@A}: ''
var=VAR4
${!var@A}:''
${!var[@]@A}: ''
${VAR4@A}:'declare -arl VAR4='zzz''
${VAR4[@]@A}: 'declare -arl VAR4=([0]="zzz")'
var=VAR5
${!var@A}:''
${!var[@]@A}: ''
${VAR5@A}:''
${VAR5[@]@A}: ''
var=VAR6
${!var@A}:''
${!var[@]@A}: ''
${VAR6@A}:'declare -Arl VAR6='zzz''
${VAR6[@]@A}: 'declare -Arl VAR6=([0]="zzz" )'
var=VAR1
${!var@a}:''
${!var[@]@a}: ''
${VAR1@a}:'rl'
${VAR1[@]@a}: 'rl'
var=VAR2
${!var@a}:''
${!var[@]@a}: ''
${VAR2@a}:'rl'
${VAR2[@]@a}: 'rl'
var=VAR3
${!var@a}:''
${!var[@]@a}: ''
${VAR3@a}:'arl'
${VAR3[@]@a}: ''
var=VAR4
${!var@a}:''
${!var[@]@a}: ''
${VAR4@a}:'arl'
${VAR4[@]@a}: 'arl'
var=VAR5
${!var@a}:''
${!var[@]@a}: ''
${VAR5@a}:'Arl'
${VAR5[@]@a}: ''
var=VAR6
${!var@a}:''
${!var[@]@a}: ''
${VAR6@a}:'Arl'
${VAR6[@]@a}: 'Arl'
$
--
Arfrever Frehtes Taifersar Arahesis
: VAR2: readonly variable
$ f() { VAR3= ; echo AAA ; } ; f
bash: VAR3: readonly variable
$
--
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}"
decl
quot;B" [1]="A" [2]="A" [3]="A")'
$ A
A
declare -a FUNCNAME='([0]="A" [1]="A" [2]="A" [3]="A")'
$ B
B
declare -a FUNCNAME='([0]="B" [1]="A" [2]="A" [3]="A" [4]="A")'
$
Also is it intentional that code after attempt of assignment to FUNCNAME is not
run?
The sentence in manual could be interpreted as simply setting $? to non-zero
value and still running subsequent code.
$ A() { echo A; local FUNCNAME=(); echo AAA; }
$ A
A
bash: FUNCNAME: variable may not be assigned value
$
--
Arfrever Frehtes Taifersar Arahesis
signature.asc
Description: This is a digitally signed message part.
2014-09-27 23:12 Eric Blake napisał(a):
> On 09/27/2014 02:57 PM, Arfrever Frehtes Taifersar Arahesis wrote:
> > 2014-09-27 22:29 Eric Blake napisał(a):
> >> Thankfully, bash already forbids trying to name a function 'a=b'
> >
> > It works in bash 4.
2014-09-27 22:29 Eric Blake napisał(a):
> Thankfully, bash already forbids trying to name a function 'a=b'
It works in bash 4.3.26:
$ function a=b() { echo A; }
$ "a=b"
A
$ a\=b
A
--
Arfrever Frehtes Taifersar Arahesis
signature.asc
Description: This is a digitally signed message part.
lare: VAR1: not found
bash: declare: VAR2: not found
bash: declare: VAR3: not found
bash: declare: VAR4: not found
### Non-subshell subprocess:
declare -x VAR1="aaa"
declare -x VAR2="aaa"
declare -x VAR3="aaa"
declare -x VAR4="aaa"
$ bash -c 'declare -p VAR{1,2,3,4}'
declare -x VAR1="aaa"
declare -x VAR2="aaa"
declare -x VAR3="aaa"
declare -x VAR4="aaa"
'declare +x' (or 'local +x') fails to unexport a variable when called in a
function (both bash 4.2 and 4.3):
$ export VAR=abc
$ f() { declare +x VAR; bash -c 'declare -p VAR'; }
$ f
declare -x VAR="abc"
$ declare +x VAR
$ bash -c 'declare -p VAR'
bash: line 0: declare: VAR: not found
--
Arfrever Frehtes Taifersar Arahesis
signature.asc
Description: This is a digitally signed message part.
2014-05-05 17:18 Chet Ramey napisał(a):
> On 5/3/14, 7:22 PM, Arfrever Frehtes Taifersar Arahesis wrote:
> > 'local -x VARIABLE' (without assignment of value) does not clear variable
> > for subprocesses.
> > It is regression in bash 4.3.
>
> It's not ac
clare -x VAR1="abc"
declare -x VAR2="abc"
--
Arfrever Frehtes Taifersar Arahesis
signature.asc
Description: This is a digitally signed message part.
Y: not found
$ ARRAY=(x y z)
$ f
declare -a ARRAY='([0]="a" [1]="b" [2]="c")'
bash: declare: ARRAY: cannot destroy array variables in this way
declare -a ARRAY='([0]="a" [1]="b" [2]="c")'
--
Arfrever Frehtes Taifersar Arahesis
signature.asc
Description: This is a digitally signed message part.
.` incorrectly restore function with here
string with pattern substitution.
Repeat-By:
The following function is incorrectly restored:
here_string_test() {
: <<< "${var// /$'\n'}"
}
Run the attached bash_test.sh script u
18 matches
Mail list logo