bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: declare a="$b" if $a previously set as array


From: Stephane Chazelas
Subject: Re: declare a="$b" if $a previously set as array
Date: Sun, 14 Dec 2014 21:19:00 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

2014-12-14 14:39:29 -0500, Chet Ramey:
[...]
> > ~$ bash --version
> > GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
> > Copyright (C) 2013 Free Software Foundation, Inc.
> > License GPLv3+: GNU GPL version 3 or later 
> > <http://gnu.org/licenses/gpl.html>
> > 
> > This is free software; you are free to change and redistribute it.
> > There is NO WARRANTY, to the extent permitted by law.
> > ~$ b='($(uname))' bash --norc -c 'declare -a a; declare a="$b"; printf 
> > "<%s>\n" "$a" "${a[0]}"'
> > <>
> > <Linux>
> > 
> > (on Linux Mint amd64).
> 
> $ ./bash --version
> GNU bash, version 4.3.30(15)-release (x86_64-apple-darwin13.1.0)
> Copyright (C) 2013 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> 
> This is free software; you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> $ b='($(uname))' ./bash --norc -c 'declare -a a; declare a="$b"; printf
> "<%s>\n" "$a" "${a[0]}"'
> <Darwin>
> <Darwin>
[...]

Yes I don't know what Mint (Ubuntu?) did, but it's a bit broken
see also:

$ bash -c 'f() { declare a[1]=foo; declare -p a; }; a[0]=x; f; declare -p a' 
bash: line 0: declare: a: not found
declare -a a='([0]="x")'

(sorry about the confusion there).

-- 
Stephane



reply via email to

[Prev in Thread] Current Thread [Next in Thread]