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: Dan Douglas
Subject: Re: declare a="$b" if $a previously set as array
Date: Mon, 15 Dec 2014 23:56:32 -0600
User-agent: KMail/4.14.3 (Linux/3.17.3; KDE/4.14.3; x86_64; ; )

On Sunday, December 14, 2014 09:44:16 PM Stephane Chazelas wrote:
> but:
> 
> x='($(uname>&2))' bash -c 'f() { a[0]=x; declare a=$x; }; f'
> 
> is not, because when in a function, declare ignores variables by
> the same name that have not been declared in that same scope
> (even if they have been *set* in that context)
> 
> So it's more unlikely to be a problem than I thought it would be
> as "declare" is mostly used in functions. 

Indeed I was just about to point this out. It's a rare scenario at least in my 
code to either declare something twice in the same scope or rely upon a global 
being in a particular state.

-- 
Dan Douglas



reply via email to

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