bug-gnulib
[Top][All Lists]
Advanced

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

Re: gnulib/gnulib-tool shell quoting problem for Solaris /bin/sh


From: Bruno Haible
Subject: Re: gnulib/gnulib-tool shell quoting problem for Solaris /bin/sh
Date: Thu, 26 Jan 2006 13:48:29 +0100
User-agent: KMail/1.5

Paul Eggert wrote:
> The difference can be seen with this script:
>
> trap : 2
> sleep 5
> sleep 10
>
> If you execute this with "bash -x", and interrupt the "sleep 5" with
> Control-C, you'll see that the "sleep 10" is executed with "trap :",
> whereas it would not be executed with "trap -".

Oh, you are right, thanks. I misunderstood how 'trap' works.

> How about if you replace this:
>
>   trap : 0 1 2 3 15
>
> with this?
>
>   trap '' 0
>   trap '(exit $?); exit $?' 1 2 13 15

This works as desired, thanks. The following works as well:

  trap '' 0
  trap 'exit $?' 1 2 13 15

Tested with both bash and zsh. (The confusion about the interpretation
of $? within trap between bash and zsh/Solaris sh applies only to the 0
signal. For signal 2, $? is 130 in all cases.)

I committed the appended patch.

Bruno


*** gnulib-tool 25 Jan 2006 14:20:06 -0000      1.105
--- gnulib-tool 26 Jan 2006 12:51:07 -0000
***************
*** 1176,1182 ****
      func_add_or_update
    done
    rm -rf "$tmp"
!   trap : 0 1 2 3 15
  
    # Command-line invocation printed in a comment in generated gnulib-cache.m4.
    actioncmd="gnulib-tool --import"
--- 1176,1188 ----
      func_add_or_update
    done
    rm -rf "$tmp"
!   # Undo the effect of the previous 'trap' command. Some shellology:
!   # We cannot use "trap - 0 1 2 3 15", because Solaris sh would attempt to
!   # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
!   # exit); for the others we need to call 'exit' explicitly. The value of $? 
is
!   # 128 + signal number and is set before the trap-registered command is run.
!   trap '' 0
!   trap 'exit $?' 1 2 3 15
  
    # Command-line invocation printed in a comment in generated gnulib-cache.m4.
    actioncmd="gnulib-tool --import"





reply via email to

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