[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using unset to destroy array elements doesn't work with 'nullglob' s
Re: Using unset to destroy array elements doesn't work with 'nullglob' set
Fri, 05 Jun 2009 14:29:33 -0400
Thunderbird 18.104.22.168 (Macintosh/20090302)
Francis Moreau wrote:
> My version of bash is "GNU bash, version 3.2.33(1)-release (x86_64-
> redhat-linux-gnu)" running on a fedora 9.
> Here's is a small script to show the bug:
> #shopt -s nullglob
> unset foo
> echo address@hidden
> When shopt line is commented then the element at index 0 is destroyed
> and the echo doesn't output anything. However is a uncomment the shopt
> line the element at index 0 is not destroyed anymore and the echo
> output "0".
This is why the man page says:
The unset builtin is used to destroy arrays. unset name[subscript]
destroys the array element at index subscript. Care must be taken to
avoid unwanted side effects caused by filename generation.
In this case, you should quote the argument if you don't want globbing
to potentially alter it.
``The lyf so short, the craft so long to lerne.'' - Chaucer
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/