Message ID | 20151207175047.GG735@joyent.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Herbert Xu |
Headers | show |
Jonathan Perkin <jperkin@joyent.com> wrote: > Clarifies a couple of issues with the previous patch, and expands on > the rationale in the commit message. Sorry for the noise -- jperkin > > 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. > > The interpretation of this behaviour differs among other shells. In the > case where the first operand is an invalid signo: > > bash-4.3.39(1), zsh-5.1.1: > > $ trap echo 1 2 3 > $ trap 100 1 2 > $ trap > trap -- '100' SIGHUP > trap -- '100' SIGINT > trap -- 'echo' SIGQUIT So dash's behaviour is the same as bash. I'm not changing this. Cheers,
diff --git a/src/trap.c b/src/trap.c index 82d4263..3dc1949 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]) || (is_number(*ap))) action = NULL; else action = *ap++;