10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 23*527Schin * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*527Schin * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 270Sstevel@tonic-gate /* All Rights Reserved */ 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate /* 310Sstevel@tonic-gate * UNIX shell 320Sstevel@tonic-gate */ 330Sstevel@tonic-gate 340Sstevel@tonic-gate #include <setjmp.h> 350Sstevel@tonic-gate #include "mode.h" 360Sstevel@tonic-gate #include "name.h" 370Sstevel@tonic-gate #include <sys/param.h> 380Sstevel@tonic-gate #ifndef NOFILE 390Sstevel@tonic-gate #define NOFILE 20 400Sstevel@tonic-gate #endif 410Sstevel@tonic-gate /* temp files and io */ 420Sstevel@tonic-gate 430Sstevel@tonic-gate int output = 2; 440Sstevel@tonic-gate int ioset; 450Sstevel@tonic-gate struct ionod *iotemp; /* files to be deleted sometime */ 460Sstevel@tonic-gate struct ionod *fiotemp; /* function files to be deleted sometime */ 470Sstevel@tonic-gate struct ionod *iopend; /* documents waiting to be read at NL */ 480Sstevel@tonic-gate struct fdsave fdmap[NOFILE]; 490Sstevel@tonic-gate 500Sstevel@tonic-gate /* substitution */ 510Sstevel@tonic-gate int dolc; 520Sstevel@tonic-gate unsigned char **dolv; 530Sstevel@tonic-gate struct dolnod *argfor; 540Sstevel@tonic-gate struct argnod *gchain; 550Sstevel@tonic-gate 560Sstevel@tonic-gate 570Sstevel@tonic-gate /* name tree and words */ 580Sstevel@tonic-gate int wdval; 590Sstevel@tonic-gate int wdnum; 600Sstevel@tonic-gate int fndef; 610Sstevel@tonic-gate int nohash; 620Sstevel@tonic-gate struct argnod *wdarg; 630Sstevel@tonic-gate int wdset; 640Sstevel@tonic-gate BOOL reserv; 650Sstevel@tonic-gate 660Sstevel@tonic-gate /* special names */ 670Sstevel@tonic-gate unsigned char *pcsadr; 680Sstevel@tonic-gate unsigned char *pidadr; 690Sstevel@tonic-gate unsigned char *cmdadr; 700Sstevel@tonic-gate 710Sstevel@tonic-gate /* transput */ 72*527Schin int tmpout_offset; 73*527Schin unsigned int serial; 740Sstevel@tonic-gate unsigned peekc; 750Sstevel@tonic-gate unsigned peekn; 760Sstevel@tonic-gate unsigned char *comdiv; 770Sstevel@tonic-gate long flags; 780Sstevel@tonic-gate int rwait; /* flags read waiting */ 790Sstevel@tonic-gate 800Sstevel@tonic-gate /* error exits from various parts of shell */ 810Sstevel@tonic-gate jmp_buf subshell; 820Sstevel@tonic-gate jmp_buf errshell; 830Sstevel@tonic-gate 840Sstevel@tonic-gate /* fault handling */ 850Sstevel@tonic-gate BOOL trapnote; 860Sstevel@tonic-gate 870Sstevel@tonic-gate /* execflgs */ 880Sstevel@tonic-gate int exitval; 890Sstevel@tonic-gate int retval; 900Sstevel@tonic-gate BOOL execbrk; 910Sstevel@tonic-gate int loopcnt; 920Sstevel@tonic-gate int breakcnt; 930Sstevel@tonic-gate int funcnt; 940Sstevel@tonic-gate int eflag; 950Sstevel@tonic-gate /* 960Sstevel@tonic-gate * The following flag is set if you try to exit with stopped jobs. 970Sstevel@tonic-gate * On the second try the exit will succeed. 980Sstevel@tonic-gate */ 990Sstevel@tonic-gate int tried_to_exit; 1000Sstevel@tonic-gate /* 1010Sstevel@tonic-gate * The following flag is set to true if /usr/ucb is found in the path 1020Sstevel@tonic-gate * before /usr/bin. This value is checked when executing the echo and test 1030Sstevel@tonic-gate * built-in commands. If true, the command behaves as in BSD systems. 1040Sstevel@tonic-gate */ 1050Sstevel@tonic-gate int ucb_builtins; 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate /* The following stuff is from stak.h */ 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate unsigned char *stakbas; 1100Sstevel@tonic-gate unsigned char *staktop; 1110Sstevel@tonic-gate unsigned char *stakbot = 0; 1120Sstevel@tonic-gate struct blk *stakbsy; 1130Sstevel@tonic-gate unsigned char *brkend; 114