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.
This commit is contained in:
Akim Demaille
2020-01-21 06:53:43 +01:00
parent 78e43ce8ff
commit 3197d0fac9
2 changed files with 15 additions and 14 deletions

1
THANKS
View File

@@ -130,6 +130,7 @@ Nick Bowler nbowler@elliptictech.com
Nicolas Bedon nicolas.bedon@univ-rouen.fr Nicolas Bedon nicolas.bedon@univ-rouen.fr
Nicolas Burrus nicolas.burrus@epita.fr Nicolas Burrus nicolas.burrus@epita.fr
Nicolas Tisserand nicolas.tisserand@epita.fr Nicolas Tisserand nicolas.tisserand@epita.fr
Nikki Valen nicolettavalencia.nv@gmail.com
Noah Friedman friedman@gnu.org Noah Friedman friedman@gnu.org
Odd Arild Olsen oao@fibula.no Odd Arild Olsen oao@fibula.no
Oleg Smolsky oleg.smolsky@pacific-simulators.co.nz Oleg Smolsky oleg.smolsky@pacific-simulators.co.nz

View File

@@ -31,18 +31,18 @@ exit=true
cwd=$(pwd) cwd=$(pwd)
# The exercised program. # The exercised program.
for p in "$cwd/examples/$medir/$me" abs_medir=$cwd/examples/$medir
do if test -x "$abs_medir/$me"; then
if test -x "$p"; then prog ()
prog=$p {
break "$abs_medir/$me" "$@"
elif test -f "$p.class"; then }
pwd elif test -f "$abs_medir/$me.class"; then
prog="$SHELL $cwd/javaexec.sh -cp $(dirname $p) $(basename $p)" prog ()
break {
fi "$SHELL" "$cwd/javaexec.sh" -cp "$abs_medir" "$me" "$@"
done }
if test x"$prog" = x; then else
echo "$me: ERROR: cannot find program to exercise in:" echo "$me: ERROR: cannot find program to exercise in:"
echo "$me: ERROR: $cwd/examples/$medir/$me" echo "$me: ERROR: $cwd/examples/$medir/$me"
exit 1 exit 1
@@ -55,7 +55,7 @@ cleanup ()
{ {
status=$? status=$?
if test -z "$DEBUG"; then if test -z "$DEBUG"; then
cd $cwd cd "$cwd"
rm -rf $$.dir rm -rf $$.dir
fi fi
exit $status exit $status
@@ -82,7 +82,7 @@ run ()
shift shift
# Effective exit status. # Effective exit status.
sta_eff=0 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. # Combine effective output and error streams.
out_eff=$(cat out_eff && $noerr || sed -e 's/^/err: /g' err_eff) out_eff=$(cat out_eff && $noerr || sed -e 's/^/err: /g' err_eff)
if test $sta_eff -eq $sta_exp; then if test $sta_eff -eq $sta_exp; then