On Fri, Feb 18, 2000 at 03:39:59PM +0100, Akim Demaille wrote:
> 
> Could you change tests/tools.m4 from
> 
> # 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
> ]])

You need to use the || exit 1 stuff, otherwise you return with the
exit status of kill which is the complement of the one we're
interested in.

| With buggy shell, syntax.sh return expected value 0 and 1 otherwise.
| This part works fine.
| 
| > | 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)
| > |   AT_CHECK([/bin/sh -n ../autoreconf], 0)
| > |   AT_CHECK([/bin/sh -n ../ifnames],    0)
| > | fi
| 
| The problem is that a `0' return value is equivalent to `true' and `1'
| if interpreted as `false'.
| 
| njoly@medusa [~/Softs]> true
| njoly@medusa [~/Softs]> echo $?
| 0
| njoly@medusa [~/Softs]> false
| njoly@medusa [~/Softs]> echo $?
| 1
| 
| We need to reverse this test or syntax.sh return values to have correct
| behaviour.

We did that.  You said that included with || exit 1 it was wrong.  You
said

if /bin/sh ./syntax.sh; then

was failing, while

/bin/sh ./syntax.sh
if test $? = 0; then

was giving the expected behavior.  I don't understand the difference,
to me the two constructs are equivalent.

I must confess I am not an expert with background jobs in shell
scripts.  In fact, I don't think I need to store $!, I was afraid that
some shell might reset it after the sleep.  Actually, syntax.sh should
just be

AT_DATA(syntax.sh,
[[(/bin/sh -n endless.sh) &
sleep 2
kill $! >/dev/null 2>&1 || exit 1
]]

it should $? = 0 if sh -n works, 1 otherwise.

        Akim

Reply via email to