mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated Sc2086 (markdown)
@@ -22,10 +22,15 @@ Sometimes you want to split on spaces, like when building a command line.
|
||||
options="-j 5 -B"
|
||||
make $options file
|
||||
|
||||
Just quoting this doesn't work. Instead, you should have used an array:
|
||||
Just quoting this doesn't work. Instead, you should have used an array (bash):
|
||||
|
||||
options=(-j 5 -B)
|
||||
make "${options[@]}" file
|
||||
|
||||
To split on spaces but not perform glob expansion, Bash has a `set -f` to disable globbing. You can disable word splitting by setting IFS="".
|
||||
or a function (POSIX):
|
||||
|
||||
make_with_flags() { make -j 5 -B "$@"; }
|
||||
make_with_flags file
|
||||
|
||||
To split on spaces but not perform glob expansion, Posix has a `set -f` to disable globbing. You can disable word splitting by setting IFS="".
|
||||
|
||||
|
Reference in New Issue
Block a user