Updated Sc2086 (markdown)

koalaman
2015-04-29 18:19:15 -07:00
parent 647abe3142
commit 5e107b9c05

@@ -22,10 +22,15 @@ Sometimes you want to split on spaces, like when building a command line.
options="-j 5 -B" options="-j 5 -B"
make $options file 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) options=(-j 5 -B)
make "${options[@]}" file 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="".