Deleted Added
full compact
trap.c (217425) trap.c (217461)
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Kenneth Almquist.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 22 unchanged lines hidden (view full) ---

31 */
32
33#ifndef lint
34#if 0
35static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95";
36#endif
37#endif /* not lint */
38#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Kenneth Almquist.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 22 unchanged lines hidden (view full) ---

31 */
32
33#ifndef lint
34#if 0
35static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95";
36#endif
37#endif /* not lint */
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD: head/bin/sh/trap.c 217425 2011-01-14 21:30:27Z jilles $");
39__FBSDID("$FreeBSD: head/bin/sh/trap.c 217461 2011-01-15 21:09:00Z jilles $");
40
41#include <signal.h>
42#include <unistd.h>
43#include <stdlib.h>
44
45#include "shell.h"
46#include "main.h"
47#include "nodes.h" /* for other headers */

--- 100 unchanged lines hidden (view full) ---

148 * The trap builtin.
149 */
150int
151trapcmd(int argc, char **argv)
152{
153 char *action;
154 int signo;
155 int errors = 0;
40
41#include <signal.h>
42#include <unistd.h>
43#include <stdlib.h>
44
45#include "shell.h"
46#include "main.h"
47#include "nodes.h" /* for other headers */

--- 100 unchanged lines hidden (view full) ---

148 * The trap builtin.
149 */
150int
151trapcmd(int argc, char **argv)
152{
153 char *action;
154 int signo;
155 int errors = 0;
156 int i;
156
157
157 if (argc <= 1) {
158 while ((i = nextopt("l")) != '\0') {
159 switch (i) {
160 case 'l':
161 printsignals();
162 return (0);
163 }
164 }
165 argv = argptr;
166
167 if (*argv == NULL) {
158 for (signo = 0 ; signo < sys_nsig ; signo++) {
159 if (signo < NSIG && trap[signo] != NULL) {
160 out1str("trap -- ");
161 out1qstr(trap[signo]);
162 if (signo == 0) {
163 out1str(" exit\n");
164 } else if (sys_signame[signo]) {
165 out1fmt(" %s\n", sys_signame[signo]);
166 } else {
167 out1fmt(" %d\n", signo);
168 }
169 }
170 }
171 return 0;
172 }
173 action = NULL;
168 for (signo = 0 ; signo < sys_nsig ; signo++) {
169 if (signo < NSIG && trap[signo] != NULL) {
170 out1str("trap -- ");
171 out1qstr(trap[signo]);
172 if (signo == 0) {
173 out1str(" exit\n");
174 } else if (sys_signame[signo]) {
175 out1fmt(" %s\n", sys_signame[signo]);
176 } else {
177 out1fmt(" %d\n", signo);
178 }
179 }
180 }
181 return 0;
182 }
183 action = NULL;
174 if (*++argv && strcmp(*argv, "--") == 0)
175 argv++;
176 if (*argv && sigstring_to_signum(*argv) == -1) {
184 if (*argv && sigstring_to_signum(*argv) == -1) {
177 if ((*argv)[0] != '-') {
185 if (strcmp(*argv, "-") == 0)
186 argv++;
187 else {
178 action = *argv;
179 argv++;
188 action = *argv;
189 argv++;
180 } else if ((*argv)[1] == '\0') {
181 argv++;
182 } else if ((*argv)[1] == 'l' && (*argv)[2] == '\0') {
183 printsignals();
184 return 0;
185 } else {
186 error("bad option %s", *argv);
187 }
188 }
189 while (*argv) {
190 if ((signo = sigstring_to_signum(*argv)) == -1) {
191 warning("bad signal %s", *argv);
192 errors = 1;
193 }
194 INTOFF;

--- 322 unchanged lines hidden ---
190 }
191 }
192 while (*argv) {
193 if ((signo = sigstring_to_signum(*argv)) == -1) {
194 warning("bad signal %s", *argv);
195 errors = 1;
196 }
197 INTOFF;

--- 322 unchanged lines hidden ---