eval.h revision 253650
11556Srgrimes/*- 21556Srgrimes * Copyright (c) 1991, 1993 31556Srgrimes * The Regents of the University of California. All rights reserved. 41556Srgrimes * 51556Srgrimes * This code is derived from software contributed to Berkeley by 61556Srgrimes * Kenneth Almquist. 71556Srgrimes * 81556Srgrimes * Redistribution and use in source and binary forms, with or without 91556Srgrimes * modification, are permitted provided that the following conditions 101556Srgrimes * are met: 111556Srgrimes * 1. Redistributions of source code must retain the above copyright 121556Srgrimes * notice, this list of conditions and the following disclaimer. 131556Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 141556Srgrimes * notice, this list of conditions and the following disclaimer in the 151556Srgrimes * documentation and/or other materials provided with the distribution. 161556Srgrimes * 4. Neither the name of the University nor the names of its contributors 171556Srgrimes * may be used to endorse or promote products derived from this software 181556Srgrimes * without specific prior written permission. 191556Srgrimes * 201556Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 211556Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 221556Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 231556Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 241556Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 251556Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 261556Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 271556Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 281556Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 291556Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 301556Srgrimes * SUCH DAMAGE. 311556Srgrimes * 3217987Speter * @(#)eval.h 8.2 (Berkeley) 5/4/95 3350471Speter * $FreeBSD: head/bin/sh/eval.h 253650 2013-07-25 15:08:41Z jilles $ 341556Srgrimes */ 351556Srgrimes 361556Srgrimesextern char *commandname; /* currently executing command */ 371556Srgrimesextern int exitstatus; /* exit status of last command */ 38201053Sjillesextern int oexitstatus; /* saved exit status */ 391556Srgrimesextern struct strlist *cmdenviron; /* environment for builtin command */ 401556Srgrimes 411556Srgrimes 421556Srgrimesstruct backcmd { /* result of evalbackcmd */ 431556Srgrimes int fd; /* file descriptor to read from */ 441556Srgrimes char *buf; /* buffer */ 451556Srgrimes int nleft; /* number of chars in buffer */ 461556Srgrimes struct job *jp; /* job structure for command */ 471556Srgrimes}; 481556Srgrimes 49253650Sjillesvoid reseteval(void); 50253650Sjilles 51194128Sjilles/* flags in argument to evaltree/evalstring */ 52194128Sjilles#define EV_EXIT 01 /* exit after evaluating tree */ 53194128Sjilles#define EV_TESTED 02 /* exit status is checked; ignore -e flag */ 54194128Sjilles#define EV_BACKCMD 04 /* command executing within back quotes */ 55194128Sjilles 56193169Sstefanfvoid evalstring(char *, int); 571556Srgrimesunion node; /* BLETCH for ansi C */ 5890111Simpvoid evaltree(union node *, int); 5990111Simpvoid evalbackcmd(union node *, struct backcmd *); 601556Srgrimes 611556Srgrimes/* in_function returns nonzero if we are currently evaluating a function */ 621556Srgrimes#define in_function() funcnest 631556Srgrimesextern int funcnest; 6420425Ssteveextern int evalskip; 65230212Sdumbbellextern int skipcount; 6620425Ssteve 6720425Ssteve/* reasons for skipping commands (see comment on breakcmd routine) */ 6820425Ssteve#define SKIPBREAK 1 6920425Ssteve#define SKIPCONT 2 7020425Ssteve#define SKIPFUNC 3 7120425Ssteve#define SKIPFILE 4 72