help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shell trap builtin in rules


From: Martin Sebor
Subject: Re: shell trap builtin in rules
Date: Wed, 08 Nov 2006 10:18:06 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.13) Gecko/20060417

Paul D. Smith wrote:
On Monday, 6 November, Martin Sebor (address@hidden) wrote:


I must be missing something but I don't see why the trap special
builtin wouldn't work the same in a make rule as in shell. Could
someone enlighten me? I expect the make output below to be 1 but
I get 0 instead.

$ (trap 'echo $?' EXIT && exit 1)
1
$ echo "foo:; trap 'echo \$\$?' EXIT && exit 1" > mf \
  && gmake -f mf foo
trap 'echo $?' EXIT && exit 1
0
gmake: *** [foo] Error 1


It works for me.  Maybe it's your shell?

Apparently. I originally ran my code on Solaris. I have tried
/usr/xpg4/bin/sh but got the same results. AIX, HP-UX, IRIX,
and Tru64 all behave the same as well. Bash is the only shell
that produces the result I expect.

Martin

Remember that make uses /bin/sh to
run all of its commands.  On my system /bin/sh is really bash but maybe your
/bin/sh is something else.  Also, what version of make are you using?


  $ echo "foo:; trap 'echo \$\$?' EXIT && exit 1" | make -f -
  trap 'echo $?' EXIT && exit 1
  1
  make: *** [foo] Error 1






reply via email to

[Prev in Thread] Current Thread [Next in Thread]