-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC2048
Vidar Holen edited this page Apr 24, 2021
·
5 revisions
Or: Use "${array[@]}" (with quotes) to prevent whitespace problems.
cp $* ~/dir
cp ${array[*]} ~/dir
cp "$@" ~/dir
cp "${array[@]}" ~/dir
$*
and ${array[*]}
, unquoted, is subject to word splitting and globbing.
Let's say you have three arguments or array elements: baz
, foo bar
and *
"$@"
and "${array[@]}"
will expand into exactly that: baz
, foo bar
and *
$*
and ${array[*]}
will expand into multiple other arguments: baz
, foo
, bar
, file.txt
and otherfile.jpg
Since the latter is rarely expected or desired, ShellCheck warns about it.
None.