exec.h revision 204800
12311Sjkh/*- 22311Sjkh * Copyright (c) 1991, 1993 32311Sjkh * The Regents of the University of California. All rights reserved. 42311Sjkh * 52311Sjkh * This code is derived from software contributed to Berkeley by 62311Sjkh * Kenneth Almquist. 72311Sjkh * 82311Sjkh * Redistribution and use in source and binary forms, with or without 92311Sjkh * modification, are permitted provided that the following conditions 102311Sjkh * are met: 112311Sjkh * 1. Redistributions of source code must retain the above copyright 122311Sjkh * notice, this list of conditions and the following disclaimer. 132311Sjkh * 2. Redistributions in binary form must reproduce the above copyright 142311Sjkh * notice, this list of conditions and the following disclaimer in the 152311Sjkh * documentation and/or other materials provided with the distribution. 165176Sache * 4. Neither the name of the University nor the names of its contributors 172311Sjkh * may be used to endorse or promote products derived from this software 182311Sjkh * without specific prior written permission. 192311Sjkh * 2029452Scharnier * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2150479Speter * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 222311Sjkh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 232311Sjkh * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 242311Sjkh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 252311Sjkh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 262311Sjkh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 272311Sjkh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 282311Sjkh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 292311Sjkh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 302311Sjkh * SUCH DAMAGE. 312311Sjkh * 322311Sjkh * @(#)exec.h 8.3 (Berkeley) 6/8/95 332311Sjkh * $FreeBSD: head/bin/sh/exec.h 204800 2010-03-06 16:57:53Z jilles $ 34135242Sdds */ 3569793Sobrien 362311Sjkh/* values of cmdtype */ 372311Sjkh#define CMDUNKNOWN -1 /* no entry in table for command */ 382311Sjkh#define CMDNORMAL 0 /* command is an executable program */ 392311Sjkh#define CMDBUILTIN 1 /* command is a shell builtin */ 402311Sjkh#define CMDFUNCTION 2 /* command is a shell function */ 412311Sjkh 422311Sjkh/* values for typecmd_impl's third parameter */ 432311Sjkhenum { 442311Sjkh TYPECMD_SMALLV, /* command -v */ 452311Sjkh TYPECMD_BIGV, /* command -V */ 462311Sjkh TYPECMD_TYPE /* type */ 472311Sjkh}; 48135242Sdds 492311Sjkhunion node; 502311Sjkhstruct cmdentry { 512311Sjkh int cmdtype; 522311Sjkh union param { 532311Sjkh int index; 542311Sjkh struct funcdef *func; 552311Sjkh } u; 562311Sjkh int special; 572311Sjkh}; 582311Sjkh 592311Sjkh 602311Sjkh/* action to find_command() */ 612311Sjkh#define DO_ERR 0x01 /* prints errors */ 622311Sjkh#define DO_NOFUNC 0x02 /* don't return shell functions, for command */ 632311Sjkh 642311Sjkhextern const char *pathopt; /* set by padvance */ 652311Sjkhextern int exerrno; /* last exec error */ 66173412Skevlo 67173412Skevlovoid shellexec(char **, char **, const char *, int) __dead2; 68173412Skevlochar *padvance(const char **, const char *); 69173412Skevloint hashcmd(int, char **); 70173412Skevlovoid find_command(const char *, struct cmdentry *, int, const char *); 71173412Skevloint find_builtin(const char *, int *); 72173412Skevlovoid hashcd(void); 732311Sjkhvoid changepath(const char *); 742311Sjkhvoid deletefuncs(void); 752311Sjkhvoid addcmdentry(const char *, struct cmdentry *); 762311Sjkhvoid defun(const char *, union node *); 772311Sjkhint unsetfunc(const char *); 782311Sjkhint typecmd_impl(int, char **, int, const char *); 7929452Scharnierint typecmd(int, char **); 8029452Scharniervoid clearcmdentry(int); 8129452Scharnier