Escape * in build-debug before passing to debug

With `setopt nonomatch` unescaped `*` can be used in command arguments
however when passing command arguments to `build-debug` the `*` _should_
be escaped so that the debugger e.g. `gdb` will correctly invoke the
program where `setopt nonomatch` does not apply.
This commit is contained in:
Kenneth Benzie 2019-04-18 10:34:34 +01:00
parent 6bd2b8f0cc
commit dff42f5125

View File

@ -165,11 +165,18 @@ EOF
# Build then run a target residing in `~build/bin`. # Build then run a target residing in `~build/bin`.
build-run() { build-run() {
local target=$1; shift 1 local target=$1; shift 1
eval build $target && ~build/bin/$target $* eval build $target && ~build/bin/$target "$@"
} }
# Build then debug a target residing in `~build/bin`. # Build then debug a target residing in `~build/bin`.
build-debug() { build-debug() {
local target=$1; shift 1 local target=$1; shift 1
eval build $target && debug ~build/bin/$target $* # For each item in $* replace * and \* and then replace \ with \\
autoload -U regexp-replace
local args=()
for arg in "$@"; do
regexp-replace arg '\*' '\\*'
args+=($arg)
done
eval build $target && debug ~build/bin/$target $args
} }