8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / sh / error.c
blobe6567549618187eb8517593caed59170de93b245
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 #pragma ident "%Z%%M% %I% %E% SMI"
33 * UNIX shell
36 #include "defs.h"
39 /* ======== error handling ======== */
41 void
42 error(const char *s)
44 prp();
45 prs(_gettext(s));
46 newline();
47 exitsh(ERROR);
50 static void
51 failed_body(unsigned char *s1, const char *s2, unsigned char *s3, int gflag)
53 prp();
54 if (gflag)
55 prs(_gettext((const char *)s1));
56 else
57 prs_cntl(s1);
58 prs(colon);
59 prs(_gettext(s2));
60 if (s3)
61 prs(s3);
62 newline();
65 void
66 failed_real(unsigned char *s1, const char *s2, unsigned char *s3)
68 failed_body(s1, s2, s3, 0);
69 exitsh(ERROR);
72 void
73 failure_real(unsigned char *s1, const char *s2, int gflag)
75 failed_body(s1, s2, NULL, gflag);
77 if (flags & errflg)
78 exitsh(ERROR);
80 flags |= eflag;
81 exitval = ERROR;
82 exitset();
85 void
86 exitsh(int xno)
89 * Arrive here from `FATAL' errors
90 * a) exit command,
91 * b) default trap,
92 * c) fault with no trap set.
94 * Action is to return to command level or exit.
96 exitval = xno;
97 flags |= eflag;
98 if ((flags & (forcexit | forked | errflg | ttyflg)) != ttyflg)
99 done(0);
100 else
102 clearup();
103 restore(0);
104 (void) setb(1);
105 execbrk = breakcnt = funcnt = 0;
106 longjmp(errshell, 1);
110 void
111 rmtemp(struct ionod *base)
113 while (iotemp > base) {
114 unlink(iotemp->ioname);
115 free(iotemp->iolink);
116 iotemp = iotemp->iolst;
120 void
121 rmfunctmp(void)
123 while (fiotemp) {
124 unlink(fiotemp->ioname);
125 fiotemp = fiotemp->iolst;