bug-bash
[Top][All Lists]
Advanced

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

Parameter indirection


From: konsolebox
Subject: Parameter indirection
Date: Mon, 16 Jul 2018 02:19:30 +0800

Hi Chet,

As noted in the manual a "variable is a parameter denoted by a name",
and a parameter "is an entity that stores values; it can be a name, a
number, or one of the special characters."

But as observed, variable indirection doesn't only expand "variables".
It also expands other forms of parameters including array elements,
array[@], and special parameters like @.

This not-so-explicitly-documented behavior is actually useful if one
would want indirect parameter expansion of arrays to older versions of
bash since namerefs were not available there yet.  It also useful in
some other use cases.  I've been using it for a while now.

It would be nice to have the behavior actually documented.  Currently
there is "Bash uses the value of the variable formed from the rest of
parameter as the name of the variable; ...", but it pretty much just
refers to expanding a variable.

An official note in this mailing list that it won't change if intended
may also help.

Cheers,
konsolebox



reply via email to

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