dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Perkin <jperkin@joyent.com>
To: dash@vger.kernel.org
Subject: [PATCH] trap: Implement POSIX.1-2008 trap reset behaviour
Date: Mon, 7 Dec 2015 13:18:33 +0000	[thread overview]
Message-ID: <20151207131833.GC735@joyent.com> (raw)

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;
 	else
 		action = *ap++;
-- 
2.4.9 (Apple Git-60)

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

                 reply	other threads:[~2015-12-07 13:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151207131833.GC735@joyent.com \
    --to=jperkin@joyent.com \
    --cc=dash@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).