|
| From: | Dan Douglas |
| Subject: | Re: Indirect parameter access combined with Assign Default Values |
| Date: | Wed, 07 May 2014 05:45:54 -0500 |
| User-agent: | KMail/4.13 (Linux/3.14.0-pf1+; KDE/4.13.0; x86_64; ; ) |
This might have the same fix. I guess Bash only checks for valid
variable names during expansion or initial assignment.
$ bash -xc 'typeset -n x; x=@ x=(ha ha); typeset -p @'
+ typeset -n x
+ x=@
+ x=(ha ha)
+ typeset -p @
declare -a @='([0]="ha" [1]="ha")'
Bash eventually catches it if you try using the variable so the harm is
minimal. I suppose you could wreck things for somebody evaluating the
output.
$ typeset -n x; x="_; y" x=foo; typeset -p "${!x}"; eval "$(typeset -p
"${!x}")"; echo "$y"
+ typeset -n x
+ x='_; y'
+ x=foo
+ typeset -p '_; y'
declare -- _; y="foo"
++ typeset -p '_; y'
+ eval 'declare -- _; y="foo"'
++ declare -- _
++ y=foo
+ echo foo
foo
--
Dan Douglas
| [Prev in Thread] | Current Thread | [Next in Thread] |