Parameter indirection
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
Re: Parameter indirection
On 7/15/18 2:19 PM, konsolebox wrote: > 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 @. True, though I think "variable indirection" is a more approachable way to describe the feature. I think the description in the man page, and especially the contexts where it appears, makes it clear that it works on the `parameter' in ${[!]parameter[op[word]]}. If you think it would read more clearly if I used `parameter' instead of `variable', I can look at doing that. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: ${parameter@A} doesn't work should no value be set
On 7/14/18 3:10 PM, Michal Pesa wrote: > Bash Version: 4.4 > Patch Level: 19 > Release Status: release > > Description: > Hello, I would like to report a bug or rather a feature I think should be > implemented. The new parameter expansions ${parameter@A} and ${parameter@a} > don't work if only attributes are set but value is not. The ${parameter[op[word]]} expansion generally (except where explicitly noted) expand to nothing when `parameter' is unset. I can see making an exception for ${parameter@a}, though, since it displays only the attributes. I'll take a look at that. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: bash history for each folder it was ran in.
On 7/14/18 10:03 AM, Clayton G wrote: > .bash_history for each folder perhaps in one large sql database. and a nice > gui to run it and clear it maybe a weekly option for the cautious. Sounds like an interesting project for someone. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/