Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/bin/sh Reversed submission of trap.c and sh.1 to wrong ...
details: https://anonhg.NetBSD.org/src/rev/e8938656504d
branches: netbsd-1-5
changeset: 490899:e8938656504d
user: wulf <wulf%NetBSD.org@localhost>
date: Sun Mar 18 03:20:11 2001 +0000
description:
Reversed submission of trap.c and sh.1 to wrong branch
diffstat:
bin/sh/sh.1 | 48 ++++--------------------------
bin/sh/trap.c | 91 +++++-----------------------------------------------------
2 files changed, 15 insertions(+), 124 deletions(-)
diffs (204 lines):
diff -r 2b697b661339 -r e8938656504d bin/sh/sh.1
--- a/bin/sh/sh.1 Sat Mar 17 10:21:33 2001 +0000
+++ b/bin/sh/sh.1 Sun Mar 18 03:20:11 2001 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: sh.1,v 1.33.4.4 2001/03/17 10:21:33 wulf Exp $
+.\" $NetBSD: sh.1,v 1.33.4.5 2001/03/18 03:20:12 wulf Exp $
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -1365,57 +1365,23 @@
.Ic shift
does nothing.
.It Xo trap
-.Op Fl l
-.Xc
-.It Xo trap
.Op Ar action
.Ar signal...
.Xc
Cause the shell to parse and execute action when any of the specified
-signals are received. The signals are specified by signal number or as
-the name of the signal.
-If
+signals are received. The signals are specified by signal number. If
.Ar signal
is
.Li 0 ,
the action is executed when the shell exits.
.Ar action
-may be null, which cause the specified signals to be ignored.
-With
-.Ar action
-omitted or set to `-' the specified signals are set to their default action.
-When the shell forks off a subshell, it resets trapped (but not ignored)
-signals to the default action. The
+may be null or omitted; the former causes the specified signal to be
+ignored and the latter causes the default action to be taken. When the
+shell forks off a subshell, it resets trapped (but not ignored) signals to
+the default action. The
.Ic trap
command has no effect on signals that were
-ignored on entry to the shell.
-Issuing
-.Ic trap
-with option
-.Ar -l
-will print a list of valid signal names.
-.Ic trap
-without any arguments cause it to write a list of signals and their
-associated action to the standard output in a format that is suitable
-as an input to the shell that achieves the same trapping results.
-.Pp
-Examples:
-.Pp
-.Dl trap
-.Pp
-List trapped signals and their corresponding action
-.Pp
-.Dl trap -l
-.Pp
-Print a list of valid signals
-.Pp
-.Dl trap '' SIGINT QUIT tstp 30
-.Pp
-Ignore signals INT QUIT TSTP USR1
-.Pp
-.Dl trap date INT
-.Pp
-Print date upon receiving signal INT
+ignored on entry to the shell.
.It type Op Ar name ...
Interpret each name as a command and print the resolution of the command
search. Possible resolutions are:
diff -r 2b697b661339 -r e8938656504d bin/sh/trap.c
--- a/bin/sh/trap.c Sat Mar 17 10:21:33 2001 +0000
+++ b/bin/sh/trap.c Sun Mar 18 03:20:11 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.24.4.1 2001/03/17 10:21:34 wulf Exp $ */
+/* $NetBSD: trap.c,v 1.24.4.2 2001/03/18 03:20:11 wulf Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95";
#else
-__RCSID("$NetBSD: trap.c,v 1.24.4.1 2001/03/17 10:21:34 wulf Exp $");
+__RCSID("$NetBSD: trap.c,v 1.24.4.2 2001/03/18 03:20:11 wulf Exp $");
#endif
#endif /* not lint */
@@ -85,53 +85,6 @@
int pendingsigs; /* indicates some signal received */
static int getsigaction __P((int, sig_t *));
-static int signame_to_signum __P((const char *));
-void printsignals __P((void));
-
-/*
- * return the signal number described by `p' (as a number or a name)
- * or -1 if it isn't one
- */
-
-static int
-signame_to_signum(p)
- const char *p;
-{
- int i;
-
- if (is_number(p))
- return number(p);
-
- if (strcasecmp(p, "exit") == 0 )
- return 0;
-
- if (strncasecmp(p, "sig", 3) == 0)
- p += 3;
-
- for (i = 0; i < NSIG; ++i)
- if (strcasecmp (p, sys_signame[i]) == 0)
- return i;
- return -1;
-}
-
-/*
- * Print a list of valid signal names
- */
-void
-printsignals(void)
-{
- int n;
-
- out1str("EXIT ");
-
- for (n = 1; n < NSIG; n++) {
- out1fmt("%s", sys_signame[n]);
- if ((n == NSIG/2) || n == (NSIG - 1))
- out1str("\n");
- else
- out1c(' ');
- }
-}
/*
* The trap builtin.
@@ -149,52 +102,24 @@
if (argc <= 1) {
for (signo = 0 ; signo <= NSIG ; signo++) {
if (trap[signo] != NULL)
- out1fmt("trap -- '%s' %s\n", trap[signo],
- (signo) ? sys_signame[signo] : "EXIT");
+ out1fmt("%d: %s\n", signo, trap[signo]);
}
return 0;
}
ap = argv + 1;
-
- action = NULL;
-
- if (strcmp(*ap, "--") == 0)
- if (*++ap == NULL)
- return 0;
-
- if (signame_to_signum(*ap) == -1) {
- if ((*ap)[0] =='-') {
- if ((*ap)[1] == NULL)
- ap++;
- else if ((*ap)[1] == 'l' && (*ap)[2] == NULL) {
- printsignals();
- return 0;
- }
- else
- error("bad option %s\n", *ap);
- }
- else
- action = *ap++;
- }
-
+ if (is_number(*ap))
+ action = NULL;
+ else
+ action = *ap++;
while (*ap) {
- if (is_number(*ap))
- signo = number(*ap);
- else
- signo = signame_to_signum(*ap);
-
- if (signo < 0 || signo > NSIG)
+ if ((signo = number(*ap)) < 0 || signo > NSIG)
error("%s: bad trap", *ap);
-
INTOFF;
if (action)
action = savestr(action);
-
if (trap[signo])
ckfree(trap[signo]);
-
trap[signo] = action;
-
if (signo != 0)
setsignal(signo);
INTON;
Home |
Main Index |
Thread Index |
Old Index