dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] trap: Implement POSIX.1-2008 trap reset behaviour
@ 2015-12-07 13:18 Jonathan Perkin
  0 siblings, 0 replies; only message in thread
From: Jonathan Perkin @ 2015-12-07 13:18 UTC (permalink / raw)
  To: dash

POSIX.1-2008 for trap adds the following behaviour:

    If the first operand is an unsigned decimal integer, the shell shall
    treat all operands as conditions, and shall reset each condition to
    the default value.

Whilst the standard specifies an "unsigned decimal integer", we take the
pragmatic approach of enabling this behaviour iff the first operand is a
valid signal, otherwise it is interpreted as an action.  This matches
the behaviour of most other shells in this regard.
 src/trap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/trap.c b/src/trap.c
index 82d4263..2d20c3f 100644
--- a/src/trap.c
+++ b/src/trap.c
@@ -112,7 +112,7 @@ trapcmd(int argc, char **argv)
 		return 0;
-	if (!ap[1])
+	if ((!ap[1]) || (decode_signal(*ap, 0) >= 0))
 		action = NULL;
 		action = *ap++;
2.4.9 (Apple Git-60)

Jonathan Perkin  -  Joyent, Inc.  -  www.joyent.com

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-12-07 13:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-07 13:18 [PATCH] trap: Implement POSIX.1-2008 trap reset behaviour Jonathan Perkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).