svn commit: r199641 - in head: bin/sh tools/regression/bin/sh/builtins

Jilles Tjoelker jilles at FreeBSD.org
Sat Nov 21 20:44:35 UTC 2009


Author: jilles
Date: Sat Nov 21 20:44:34 2009
New Revision: 199641
URL: http://svn.freebsd.org/changeset/base/199641

Log:
  trap: do not consider a bad signal name a fatal error.
  POSIX explicitly prescribes this.
  Continue processing any other signals and return status 1.

Added:
  head/tools/regression/bin/sh/builtins/trap3.0   (contents, props changed)
Modified:
  head/bin/sh/trap.c

Modified: head/bin/sh/trap.c
==============================================================================
--- head/bin/sh/trap.c	Sat Nov 21 17:11:51 2009	(r199640)
+++ head/bin/sh/trap.c	Sat Nov 21 20:44:34 2009	(r199641)
@@ -149,6 +149,7 @@ trapcmd(int argc, char **argv)
 {
 	char *action;
 	int signo;
+	int errors = 0;
 
 	if (argc <= 1) {
 		for (signo = 0 ; signo < sys_nsig ; signo++) {
@@ -183,8 +184,10 @@ trapcmd(int argc, char **argv)
 		}
 	}
 	while (*argv) {
-		if ((signo = sigstring_to_signum(*argv)) == -1)
-			error("bad signal %s", *argv);
+		if ((signo = sigstring_to_signum(*argv)) == -1) {
+			out2fmt_flush("trap: bad signal %s\n", *argv);
+			errors = 1;
+		}
 		INTOFF;
 		if (action)
 			action = savestr(action);
@@ -196,7 +199,7 @@ trapcmd(int argc, char **argv)
 		INTON;
 		argv++;
 	}
-	return 0;
+	return errors;
 }
 
 

Added: head/tools/regression/bin/sh/builtins/trap3.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/builtins/trap3.0	Sat Nov 21 20:44:34 2009	(r199641)
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+{
+	trap '' garbage && exit 3
+	trap - garbage && exit 3
+	trap true garbage && exit 3
+	trap '' 99999 && exit 3
+	trap - 99999 && exit 3
+	trap true 99999 && exit 3
+} 2>/dev/null
+test -n "$(trap true garbage TERM 2>/dev/null || trap)" || exit 3
+exit 0


More information about the svn-src-all mailing list