Mercurial Hosting > bricolage
changeset 2:078a17d15fa5
Support calling a spied command with arguments.
`b.sh` was not compatible with calling a spied command with arguments.
Example:
my_test() {
spy diff
diff --brief test/a test/b
ok "$(cat $T/spy.diff.exit)" = 0
}
bricolage my_test
This was not work. `diff` was complaining about 'illegal option'.
This commit fix this.
author | Jakukyo Friel <weakish@gmail.com> |
---|---|
date | Sun, 29 Mar 2015 08:56:42 +0800 |
parents | bce8021ad094 |
children | 0798045f37b5 |
files | b.sh |
diffstat | 1 files changed, 2 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/b.sh Fri Dec 19 00:01:19 2014 +0200 +++ b/b.sh Sun Mar 29 08:56:42 2015 +0800 @@ -29,7 +29,7 @@ eval "$(cat << EOF $1() { echo \$* >> "$T/spy.$1.args" - ([ -f "$T/spy.$1" ] && cat "$T/spy.$1" || $SHELL -c $1 \$@) >> "$T/spy.$1.stdout" + ([ -f "$T/spy.$1" ] && cat "$T/spy.$1" || echo "$1 \$@" | $SHELL -s) >> "$T/spy.$1.stdout" echo \$? >> "$T/spy.$1.exit" } __spies="$1 \$__spies" @@ -55,7 +55,7 @@ )" $@ # eval is needed, because unset breaks in zsh due to a trailing space - [ ! -z $__spies ] && eval "unset -f $__spies" + [ ! -z "$__spies" ] && eval "unset -f $__spies" unset -f ok }