Compare commits

..

1 Commits

Author SHA1 Message Date
dff42f5125 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.
2019-04-18 10:34:34 +01:00

View File

@ -8,16 +8,7 @@ alias build="build-dir --build"
# command line arguments.
if [ `uname` = Linux ]; then
if [[ "`vim --version`" =~ "^VIM - Vi IMproved 8\.1.*$" ]]; then
autoload -U regexp-replace
function vimdebug() {
# For each item in $* replace * and \* and then replace \ with \\
local args=()
for arg in "$@"; do
regexp-replace arg '\*' '\\*'
args+=($arg)
done
vim "+packadd termdebug" "+TermdebugCommand $args"
}
function vimdebug() { vim "+packadd termdebug" "+TermdebugCommand $*" }
alias debug='vimdebug'
elif which cgdb &> /dev/null; then
alias debug='cgdb --args'
@ -180,5 +171,12 @@ build-run() {
# 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
}