On 2/5/15 8:06 AM, isabella parakiss wrote: > On 2/4/15, konsolebox <konsole...@gmail.com> wrote: >> Logically that should only unset the elements of an array and not the >> array variable >> itself since '*' or '@' is more of a wildcard that represents the >> indices. However, bash >> does otherwise: >> >> #define ALL_ELEMENT_SUB(c) ((c) == '@' || (c) == '*') >> >> ... >> >> if (ALL_ELEMENT_SUB (sub[0]) && sub[1] == 0) // If substring is >> just '@' or '*' >> { >> unbind_variable (var->name); // It just removes it. >> return (0); >> } >> >> Bash version is 4.3.33. >> > > So, this is completely intended. > May I ask what's the rationale behind this design choice?
It's a decision that's over twenty years old. It was probably one way or the other: I didn't want to make it an error, like ksh93, so do you want array[@] to refer to the array itself or `expand' to all the members. I chose the former. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/