From 2533d0df20e871da156d80078b79d93c8c02f0ad Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Fri, 2 Apr 2010 13:59:42 +0800 Subject: [BUILTIN] Make trap signal name/number errors non-fatal. On Wed, Feb 24, 2010 at 10:23:34AM +0000, Peter Kjellerstedt wrote: > > there seems to be a problem with the trap implementation in dash > (tested with 0.5.4 and 0.5.5.1). If I specify a signal which is not > supported, the shell unconditionally aborts. E.g., I had expected > the following to print foo (like bash and zsh do): > > # dash -c 'trap "echo trap executed" UNKNOWNSIGNAL || echo "foo"' > trap: 1: UNKNOWNSIGNAL: bad trap > > This means I cannot write a construct like the following to take > advantage of the ERR signal which is present in some shells: > > trap "echo ERR trap executed" ERR 2>/dev/null || : > > I also checked the POSIX documentation, and quoting from > http://www.opengroup.org/onlinepubs/009695399/utilities/trap.html > (exit status): "For both interactive and non-interactive shells, > invalid signal names [XSI] [Option Start] or numbers [Option End] > shall not be considered a syntax error and do not cause the shell > to abort." This patch replaces sh_error with a outfmt + return 1 in trapcmd so that these errors are no longer fatal. Signed-off-by: Herbert Xu --- src/trap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/trap.c b/src/trap.c index 16703b3..3f93c46 100644 --- a/src/trap.c +++ b/src/trap.c @@ -117,8 +117,10 @@ trapcmd(int argc, char **argv) else action = *ap++; while (*ap) { - if ((signo = decode_signal(*ap, 0)) < 0) - sh_error("%s: bad trap", *ap); + if ((signo = decode_signal(*ap, 0)) < 0) { + outfmt(out2, "trap: %s: bad trap\n", *ap); + return 1; + } INTOFF; if (action) { if (action[0] == '-' && action[1] == '\0') -- cgit 1.4.1 ='q' value=''/>
Commit message (Collapse)Author
2019-09-23Add Trail of LightningJune McEnroe
2019-09-22Revert "Enable cookies in title"June McEnroe
This reverts commit 3231fe21d3b389448c9a5ca7b4c91fdd25c9e677.
2019-09-20Enable cookies in titleJune McEnroe
Perhaps this will make it less suspicious to Google. Who knows.
2019-09-16Use sensitivity aliases in TF2June McEnroe
2019-09-16Add The Just CityJune McEnroe
2019-09-12Only GET the final redirect locationJune McEnroe
2019-09-12Consume entire bodyJune McEnroe
Aborting the request and leaving data around may be causing intermittent errors. Just discard the rest of the data.
2019-09-10Add title -v flagJune McEnroe
2019-09-10Use curl error bufferJune McEnroe
2019-09-10Set Accept-Encoding in titleJune McEnroe
Because apparently it's fine for servers to respond with Content-Encoding you didn't ask for, and curl won't decode it if you didn't ask for it.
2019-09-08Set title User-AgentJune McEnroe
Some things don't like you if you don't send one.
2019-09-07Add -x flag to titleJune McEnroe
2019-09-07Ignore SIGPIPE in relayJune McEnroe
Allows restarting consumers safely.
2019-09-07Add A Memory Called EmpireJune McEnroe
2019-09-05Handle lack of Content-TypeJune McEnroe
2019-09-05Use CURLINFO_CONTENT_TYPEJune McEnroe
Oops, didn't see this.
2019-09-05Decode entities in titlesJune McEnroe
2019-09-05Print title as soon as it's availableJune McEnroe
2019-09-05Use CURL_PREFIX to set flagsJune McEnroe
2019-09-05Add titleJune McEnroe
2019-09-04Add Avorter n'est pas tuerJune McEnroe
2019-08-29Unset executable on shell scriptsJune McEnroe
2019-08-29Add long-missing setopt to bin.7June McEnroe
2019-08-29Add editJune McEnroe