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#pragma ident	"%Z%%M%	%I%	%E% SMI"
30/*
31 *	UNIX shell
32 */
33
34#include 		<setjmp.h>
35#include		"mode.h"
36#include		"name.h"
37#include		<sys/param.h>
38#ifndef NOFILE
39#define	NOFILE 20
40#endif
41/* temp files and io */
42
43int				output = 2;
44int				ioset;
45struct ionod	*iotemp;	/* files to be deleted sometime */
46struct ionod	*fiotemp;	/* function files to be deleted sometime */
47struct ionod	*iopend;	/* documents waiting to be read at NL */
48struct fdsave	fdmap[NOFILE];
49
50/* substitution */
51int				dolc;
52unsigned char			**dolv;
53struct dolnod	*argfor;
54struct argnod	*gchain;
55
56
57/* name tree and words */
58int				wdval;
59int				wdnum;
60int				fndef;
61int				nohash;
62struct argnod	*wdarg;
63int				wdset;
64BOOL			reserv;
65
66/* special names */
67unsigned char			*pcsadr;
68unsigned char			*pidadr;
69unsigned char			*cmdadr;
70
71/* transput */
72int 			tmpout_offset;
73unsigned int 		serial;
74unsigned 		peekc;
75unsigned		peekn;
76unsigned char 			*comdiv;
77long			flags;
78int				rwait;	/* flags read waiting */
79
80/* error exits from various parts of shell */
81jmp_buf			subshell;
82jmp_buf			errshell;
83
84/* fault handling */
85BOOL			trapnote;
86
87/* execflgs */
88int				exitval;
89int				retval;
90BOOL			execbrk;
91int				loopcnt;
92int				breakcnt;
93int 			funcnt;
94int				eflag;
95/*
96 * The following flag is set if you try to exit with stopped jobs.
97 * On the second try the exit will succeed.
98 */
99int			tried_to_exit;
100/*
101 * The following flag is set to true if /usr/ucb is found in the path
102 * before /usr/bin. This value is checked when executing the echo and test
103 * built-in commands. If true, the command behaves as in BSD systems.
104 */
105int				ucb_builtins;
106
107/* The following stuff is from stak.h	*/
108
109unsigned char 			*stakbas;
110unsigned char			*staktop;
111unsigned char			*stakbot = 0;
112struct blk			*stakbsy;
113unsigned char 			*brkend;
114