diff --git a/test/ipfs-test-lib.sh b/test/ipfs-test-lib.sh index 94ed5a77ff0..c2e804a2bcd 100644 --- a/test/ipfs-test-lib.sh +++ b/test/ipfs-test-lib.sh @@ -1,10 +1,23 @@ # Generic test functions for go-ipfs +# Quote arguments for sh eval +shellquote() { + _space='' + for _arg + do + # On Mac OS, sed adds a newline character. + # With a printf wrapper the extra newline is removed. + printf "$_space'%s'" "$(printf "%s" "$_arg" | sed -e "s/'/'\\\\''/g;")" + _space=' ' + done + printf '\n' +} + # Echo the args, run the cmd, and then also fail, # making sure a test case fails. test_fsh() { echo "> $@" - eval "$@" + eval $(shellquote "$@") echo "" false } @@ -31,19 +44,6 @@ test_path_cmp() { test_cmp "$1_std" "$2_std" } -# Quote arguments for sh eval -shellquote() { - _space='' - for _arg - do - # On Mac OS, sed adds a newline character. - # With a printf wrapper the extra newline is removed. - printf "$_space'%s'" "$(printf "%s" "$_arg" | sed -e "s/'/'\\\\''/g;")" - _space=' ' - done - printf '\n' -} - # Docker # This takes a Dockerfile, and a build context directory