[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: declare in a function makes a variable unable to be found with decla
From: |
SN |
Subject: |
Re: declare in a function makes a variable unable to be found with declare -p in some cases |
Date: |
Fri, 20 Feb 2015 20:42:18 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 |
> Yes. The issue is that the assignment doesn't make the variable visible,
> when it clearly should. I've attached a patch that will fix that.
And it does.
> The next version of bash will do things differently, as noted in a
couple of followups to this message. The proposal that prompted the
changes is part of a long thread from December:
http://lists.gnu.org/archive/html/bug-bash/2014-12/msg00115.html
Thanks to you both for the answers. I am glad to see that my original
issue has been fixed.
The thread is indeed long and detailed, so let me just leave a note
about a weird behaviour with 4.4.0 (devel) I have that may or may not be
the intended behaviour.
bash-4.4$ e='(`uname >&2`)'; declare -a a=$e; echo "[$a]"
Linux
[]
bash-4.4$ e='(`uname >&2`)'; declare -a a=$e; echo "[$a]"
[(`uname >&2`)]
As you can see, only in the second case uname is not run. (One can also
type "unset a" to have it execute again.) So there seems to be another
inconsistency.
By the way, I use `cmd` instead of $() because I have this:
$ : $(echo x)
bash: command substitution: line 8: syntax error near unexpected token `)'
bash: command substitution: line 8: `echo x)'
Re: declare in a function makes a variable unable to be found with declare -p in some cases, Chet Ramey, 2015/02/19
- Re: declare in a function makes a variable unable to be found with declare -p in some cases,
SN <=
Re: declare in a function makes a variable unable to be found with declare -p in some cases, Chet Ramey, 2015/02/19