bug-bash
[Top][All Lists]
Advanced

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

Re: setvalue builtin command


From: Greg Wooledge
Subject: Re: setvalue builtin command
Date: Mon, 8 Apr 2013 10:54:26 -0400
User-agent: Mutt/1.4.2.3i

On Mon, Apr 08, 2013 at 10:32:40AM -0400, Chet Ramey wrote:
> One clarification: a variable is unset unless it has had a value assigned.
> There might be some placeholder there with some type information, but the
> variable is unset.  There might be some inconsistencies in how bash treats
> such variables, and I can fix those, but the above is how it's supposed
> to be.

Well, this was in the context of a function receiving a variable name in
an argument, using "declare -n", and then attempting to learn what kind
of variable the argument refers to.

If the argument is the name of an empty associative array (declare -A foo),
then associative array operations (such as x=${ref["."]}) work; if the
argument is the name of an empty indexed array (declare -a foo), then
those operations do not work.  And because the arrays are empty, you
can't just see what's inside them.

(If the arrays are non-empty, you can just look at them with
"declare -p ref" and the second word of the output will be "-a" or "-A",
and voila.)

Whether that's important in an actual script/function, I don't know.
Personally I'd be inclined to let the function fail and then the user
(caller) would be responsible for fixing his code.  But I can't speak for
"konsolebox".



reply via email to

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