-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC2184
koalaman edited this page Sep 24, 2016
·
3 revisions
unset foo[index]
unset 'foo[index]'
Arguments to unset
are subject to regular glob expansion. This is especially relevant when unsetting indices in arrays, where [..]
is considered a glob character group.
In the problematic code, having a file called food
in the current directory will result in unset foo[index]
expanding to unset food
, which will silently succeed without unsetting the element.
Quoting so that the [..]
is passed literally to unset
solves the issue.
None.