diff --git a/Sc2086.md b/Sc2086.md index 844516e..466945d 100644 --- a/Sc2086.md +++ b/Sc2086.md @@ -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="".