SUSv4 says trap foo UNKNOWN is not a syntax error, merely exit ≠0.

Inspired by 673dab8698b0399c967216c02262eaf95361a75c.
This commit is contained in:
tg 2011-01-30 01:36:00 +00:00
parent bdfcdc56c8
commit 30d8e3934d
3 changed files with 34 additions and 14 deletions

24
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.402 2011/01/30 01:35:32 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.403 2011/01/30 01:35:56 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -25,7 +25,7 @@
# http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout:
@(#)MIRBSD KSH R39 2011/01/22
@(#)MIRBSD KSH R39 2011/01/29
description:
Check version of shell.
stdin:
@ -3385,6 +3385,26 @@ expected-stdout:
line <6>
expected-exit: 1
---
name: unknown-trap
description:
Ensure unknown traps are not a syntax error
stdin:
(
trap "echo trap 1 executed" UNKNOWNSIGNAL || echo "foo"
echo =1
trap "echo trap 2 executed" UNKNOWNSIGNAL EXIT 999999 FNORD
echo = $?
) 2>&1 | sed "s^${__progname}: <stdin>\[[0-9]*]PROG"
expected-stdout:
PROG: trap: bad signal 'UNKNOWNSIGNAL'
foo
=1
PROG: trap: bad signal 'UNKNOWNSIGNAL'
PROG: trap: bad signal '999999'
PROG: trap: bad signal 'FNORD'
= 3
trap 2 executed
---
name: read-IFS-1
description:
Simple test, default IFS

20
funcs.c
View File

@ -26,7 +26,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.167 2011/01/22 20:33:13 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.168 2011/01/30 01:35:58 tg Exp $");
#if HAVE_KILLPG
/*
@ -2336,15 +2336,15 @@ c_trap(const char **wp)
s = NULL;
/* set/clear traps */
while (*wp != NULL) {
p = gettrap(*wp++, true);
if (p == NULL) {
bi_errorf("bad signal '%s'", wp[-1]);
return (1);
}
settrap(p, s);
}
return (0);
i = 0;
while (*wp != NULL)
if ((p = gettrap(*wp++, true)) == NULL) {
warningf(true, "%s: %s '%s'", builtin_argv0,
"bad signal", wp[-1]);
++i;
} else
settrap(p, s);
return (i);
}
int

4
sh.h
View File

@ -154,9 +154,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.425 2011/01/30 01:35:35 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.426 2011/01/30 01:36:00 tg Exp $");
#endif
#define MKSH_VERSION "R39 2011/01/22"
#define MKSH_VERSION "R39 2011/01/29"
#ifndef MKSH_INCLUDES_ONLY