xref: /illumos-gate/usr/src/cmd/sh/defs.c (revision d48be21240dfd051b689384ce2b23479d757f2d8)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
27 /*	  All Rights Reserved	*/
28 
29 /*
30  *	UNIX shell
31  */
32 
33 #include 		<setjmp.h>
34 #include		"mode.h"
35 #include		"name.h"
36 #include		<sys/param.h>
37 #ifndef NOFILE
38 #define	NOFILE 20
39 #endif
40 /* temp files and io */
41 
42 int				output = 2;
43 int				ioset;
44 struct ionod	*iotemp;	/* files to be deleted sometime */
45 struct ionod	*fiotemp;	/* function files to be deleted sometime */
46 struct ionod	*iopend;	/* documents waiting to be read at NL */
47 struct fdsave	fdmap[NOFILE];
48 
49 /* substitution */
50 int				dolc;
51 unsigned char			**dolv;
52 struct dolnod	*argfor;
53 struct argnod	*gchain;
54 
55 
56 /* name tree and words */
57 int				wdval;
58 int				wdnum;
59 int				fndef;
60 int				nohash;
61 struct argnod	*wdarg;
62 int				wdset;
63 BOOL			reserv;
64 
65 /* special names */
66 unsigned char			*pcsadr;
67 unsigned char			*pidadr;
68 unsigned char			*cmdadr;
69 
70 /* transput */
71 int 			tmpout_offset;
72 unsigned int 		serial;
73 unsigned 		peekc;
74 unsigned		peekn;
75 unsigned char 			*comdiv;
76 long			flags;
77 int				rwait;	/* flags read waiting */
78 
79 /* error exits from various parts of shell */
80 jmp_buf			subshell;
81 jmp_buf			errshell;
82 
83 /* fault handling */
84 BOOL			trapnote;
85 
86 /* execflgs */
87 int				exitval;
88 int				retval;
89 BOOL			execbrk;
90 int				loopcnt;
91 int				breakcnt;
92 int 			funcnt;
93 int				eflag;
94 /*
95  * The following flag is set if you try to exit with stopped jobs.
96  * On the second try the exit will succeed.
97  */
98 int			tried_to_exit;
99 /*
100  * The following flag is set to true if /usr/ucb is found in the path
101  * before /usr/bin. This value is checked when executing the echo and test
102  * built-in commands. If true, the command behaves as in BSD systems.
103  */
104 int				ucb_builtins;
105 
106 /* The following stuff is from stak.h	*/
107 
108 unsigned char 			*stakbas;
109 unsigned char			*staktop;
110 unsigned char			*stakbot = 0;
111 struct blk			*stakbsy;
112 unsigned char 			*brkend;
113