On Mon, Feb 21, 2000 at 11:38:30AM +0100, Akim Demaille wrote:
>
> 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.
If kill works, its return value is 0 and we need to add `&& exit 1' to
have the complement as `|| exit 1' is only executed if kill returns >0.
It will become:
# A script in charge of testing `/bin/sh -n'.
AT_DATA(syntax.sh,
[[(/bin/sh -n endless.sh) &
sleep 2
kill $! >/dev/null 2>&1 && exit 1
exit 0
]]
> 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
it was:
if test $? -ne 0; then
Not Equal, and produce a reversed test.
> 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.
Right
--
Nicolas Joly
Informatique Scientifique
Institut Pasteur, Paris.