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: Paul D. Smith
Subject: Re: shell trap builtin in rules
Date: Wed, 8 Nov 2006 08:24:38 -0500

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?  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

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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