3 ms·
Indeed, and actual Bash scripting (as opposed to plain POSIX sh) is much more pleasant. Used properly, arrays make it easy to build commands with arguments and
by useragent86 7y ago
Indeed, and actual Bash scripting (as opposed to plain POSIX sh) is much more pleasant. Used properly, arrays make it easy to build commands with arguments and finally run them, e.g.
#!/bin/bash
command_args=(
--foo bar
--baz "buzz buzz"
)
[[ $frob_option ]] && command_args+=(--frob frab)
echo command_name "${command_args[@]}" "other" "arg"
# Echoes:
# command_name --foo bar --baz "buzz buzz" --frob frab other arg