From 0cf60eb2d29078a3bd27c7fa772731efb8399336 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 18 Feb 2000 09:25:46 +0000 Subject: [PATCH] * tests/tools.m4 (Syntax of the scripts): Be robust to shells that never return on some `/bin/sh -n foo.sh'. Reported by Nicolas Joly. --- ChangeLog | 6 ++++++ THANKS | 1 + tests/tools.m4 | 41 ++++++++++++++++++++++++++++++++++++----- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 59f16a6d..56d613e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2000-02-18 Akim Demaille + + * tests/tools.m4 (Syntax of the scripts): Be robust to shells that + never return on some `/bin/sh -n foo.sh'. + Reported by Nicolas Joly. + 2000-02-17 Akim Demaille Move the documentation into doc/. diff --git a/THANKS b/THANKS index 906f12b9..40264175 100644 --- a/THANKS +++ b/THANKS @@ -43,6 +43,7 @@ Markku Savela msa@msa.tte.vtt.fi Matthew D. Langston langston@SLAC.Stanford.EDU Mike Stump mrs@wrs.com Miles Bader miles@gnu.ai.mit.edu +Nicolas Joly njoly@pasteur.fr Noah Friedman friedman@gnu.ai.mit.edu Paul Eggert eggert@twinsun.com Pavel Roskin pavel_roskin@geocities.com diff --git a/tests/tools.m4 b/tests/tools.m4 index a96a29f9..c19c890f 100644 --- a/tests/tools.m4 +++ b/tests/tools.m4 @@ -11,16 +11,47 @@ EOF ## Check that the shell scripts are syntactically correct. ## ## -------------------------------------------------------- ## +# We use `/bin/sh -n script' to check that there are no syntax errors +# in the scripts. Although incredible, there are /bin/sh that go into +# endless loops with `-n', e.g., SunOS's: +# +# $ uname -a +# SunOS ondine 4.1.3 2 sun4m unknown +# $ cat endless.sh +# while false +# do +# : +# done +# exit 0 +# $ time sh endless.sh +# sh endless.sh 0,02s user 0,03s system 78% cpu 0,064 total +# $ time sh -nx endless.sh +# ^Csh -nx endless.sh 3,67s user 0,03s system 63% cpu 5,868 total +# +# So before using `/bin/sh -n' to check our scripts, we first check +# that `/bin/sh -n' is not broken to death. + AT_SETUP(Syntax of the scripts) -AT_DATA(true, -[[#! /bin/sh -exit 0 +# A script that never returns. We don't care that it never returns, +# broken /bin/sh loop equally with `false', but it makes it easier to +# test the robusteness in a good environment: just remove the `-n'. +AT_DATA(endless.sh, +[[while true +do + : +done ]]) -chmod +x true +# A script in charge of testing `/bin/sh -n'. +AT_DATA(syntax.sh, +[[set -e +(/bin/sh -n endless.sh) & +cpid=$! +sleep 2 && kill $cpid >/dev/null 2>&1 +]]) -if (/bin/sh -n ./true) >/dev/null 2>&1; then +if /bin/sh ./syntax.sh; then AT_CHECK([/bin/sh -n ../autoconf], 0) AT_CHECK([/bin/sh -n ../autoreconf], 0) AT_CHECK([/bin/sh -n ../autoupdate], 0)