From dff42f5125307b9efa453abf707332c537ef336b Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Thu, 18 Apr 2019 10:34:34 +0100 Subject: [PATCH] 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. --- build/build.plugin.zsh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/build/build.plugin.zsh b/build/build.plugin.zsh index 688d0b6..21b0bb0 100644 --- a/build/build.plugin.zsh +++ b/build/build.plugin.zsh @@ -165,11 +165,18 @@ EOF # Build then run a target residing in `~build/bin`. build-run() { 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-debug() { 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 }