[Top][All Lists]

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

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

From: Paul Eggert
Subject: Re: gnulib/gnulib-tool shell quoting problem for Solaris /bin/sh
Date: Wed, 25 Jan 2006 14:44:25 -0800
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Bruno Haible <address@hidden> writes:

> POSIX says that "trap ''" makes the shell "ignore each specified condition
> if it arises". That means, if the user presses Ctrl-C, the shell will
> continue to run. That's not what I want here. I just wish the Ctrl-C
> to trigger no additional commands, and "trap :" looks right for doing this.

But POSIX says that "trap : 2" is normally equivalent to "trap '' 2",
as far as the shell itself is concerned.  The main difference is that
with "trap : 2", subcommands can be interrupted by signal 2, whereas
with "trap '' 2", subcommands ignore signal 2.

Therefore, this change to gnulib-tool:

> -  trap - 0 1 2 3 15
> +  trap : 0 1 2 3 15

has a real effect on how gnulib-tool behaves: it causes the shell to
continue after a subcommand was interrupted, rather than exiting. I
doubt whether this change was intended.

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 -".

How about if you replace this:

  trap : 0 1 2 3 15

with this?

  trap '' 0
  trap '(exit $?); exit $?' 1 2 13 15

reply via email to

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