You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Derek Lewis edited this page Nov 17, 2022
·
1 revision
Double quote array expansions to avoid re-splitting elements SH-2068
Description:
Double quotes around $@ (and similarly, ${array[@]}) prevents
globbing and word splitting of individual elements, while still
expanding to multiple separate arguments.
Let's say you have four arguments: baz, foo bar, * and /*/*/*/*.
"$@" will expand into exactly that: baz, foo bar, * and
/*/*/*/*.
$@ will expand into multiple other arguments: baz, foo, bar,
file.txt, otherfile.jpg, and (eventually) a list of most files on
the system.
Since the latter is rarely expected or desired, this issue warns you
about it.