diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2020-01-21 06:53:43 +0100 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2020-01-21 07:01:34 +0100 |
commit | 1587a5ea9b9a0e3b23c234ab090ad01bc149c20a (patch) | |
tree | c7d0c493d831f5c5719278abc360f49e8fdd92c0 | |
parent | 4ab2cf7450686f5409f09ed2d3d08dbb86d04815 (diff) | |
download | bison-1587a5ea9b9a0e3b23c234ab090ad01bc149c20a.tar.gz |
examples: be more robust to spaces in paths
Reported by Nikki Valen.
https://lists.gnu.org/r/bug-bison/2020-01/msg00032.html
* examples/test ($prog): Remove, replaced by...
(prog): This new function, which pays attention to quoting shell
variables.
-rw-r--r-- | THANKS | 1 | ||||
-rwxr-xr-x | examples/test | 28 |
2 files changed, 15 insertions, 14 deletions
@@ -130,6 +130,7 @@ Nick Bowler nbowler@elliptictech.com Nicolas Bedon nicolas.bedon@univ-rouen.fr Nicolas Burrus nicolas.burrus@epita.fr Nicolas Tisserand nicolas.tisserand@epita.fr +Nikki Valen nicolettavalencia.nv@gmail.com Noah Friedman friedman@gnu.org Odd Arild Olsen oao@fibula.no Oleg Smolsky oleg.smolsky@pacific-simulators.co.nz diff --git a/examples/test b/examples/test index 79b8c994..75f4c58d 100755 --- a/examples/test +++ b/examples/test @@ -31,18 +31,18 @@ exit=true cwd=$(pwd) # The exercised program. -for p in "$cwd/examples/$medir/$me" -do - if test -x "$p"; then - prog=$p - break - elif test -f "$p.class"; then - pwd - prog="$SHELL $cwd/javaexec.sh -cp $(dirname $p) $(basename $p)" - break - fi -done -if test x"$prog" = x; then +abs_medir=$cwd/examples/$medir +if test -x "$abs_medir/$me"; then + prog () + { + "$abs_medir/$me" "$@" + } +elif test -f "$abs_medir/$me.class"; then + prog () + { + "$SHELL" "$cwd/javaexec.sh" -cp "$abs_medir" "$me" "$@" + } +else echo "$me: ERROR: cannot find program to exercise in:" echo "$me: ERROR: $cwd/examples/$medir/$me" exit 1 @@ -55,7 +55,7 @@ cleanup () { status=$? if test -z "$DEBUG"; then - cd $cwd + cd "$cwd" rm -rf $$.dir fi exit $status @@ -82,7 +82,7 @@ run () shift # Effective exit status. sta_eff=0 - $prog "$@" - <input >out_eff 2>err_eff || sta_eff=$? + prog "$@" - <input >out_eff 2>err_eff || sta_eff=$? # Combine effective output and error streams. out_eff=$(cat out_eff && $noerr || sed -e 's/^/err: /g' err_eff) if test $sta_eff -eq $sta_exp; then |