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 * @(#)exec.h 8.3 (Berkeley) 6/8/95 3350471Speter * $FreeBSD: releng/11.0/bin/sh/exec.h 238468 2012-07-15 10:19:43Z jilles $ 341556Srgrimes */ 351556Srgrimes 361556Srgrimes/* values of cmdtype */ 371556Srgrimes#define CMDUNKNOWN -1 /* no entry in table for command */ 381556Srgrimes#define CMDNORMAL 0 /* command is an executable program */ 391556Srgrimes#define CMDBUILTIN 1 /* command is a shell builtin */ 401556Srgrimes#define CMDFUNCTION 2 /* command is a shell function */ 411556Srgrimes 42151810Sstefanf/* values for typecmd_impl's third parameter */ 43151810Sstefanfenum { 44151810Sstefanf TYPECMD_SMALLV, /* command -v */ 45151810Sstefanf TYPECMD_BIGV, /* command -V */ 46151810Sstefanf TYPECMD_TYPE /* type */ 47151810Sstefanf}; 481556Srgrimes 49196483Sjillesunion node; 501556Srgrimesstruct cmdentry { 511556Srgrimes int cmdtype; 521556Srgrimes union param { 531556Srgrimes int index; 54196483Sjilles struct funcdef *func; 551556Srgrimes } u; 56157601Sstefanf int special; 571556Srgrimes}; 581556Srgrimes 591556Srgrimes 60204800Sjilles/* action to find_command() */ 61204800Sjilles#define DO_ERR 0x01 /* prints errors */ 62204800Sjilles#define DO_NOFUNC 0x02 /* don't return shell functions, for command */ 63204800Sjilles 64200956Sjillesextern const char *pathopt; /* set by padvance */ 6520425Ssteveextern int exerrno; /* last exec error */ 661556Srgrimes 67200967Sjillesvoid shellexec(char **, char **, const char *, int) __dead2; 68200956Sjilleschar *padvance(const char **, const char *); 69200956Sjillesvoid find_command(const char *, struct cmdentry *, int, const char *); 70200956Sjillesint find_builtin(const char *, int *); 7190111Simpvoid hashcd(void); 7290111Simpvoid changepath(const char *); 73200956Sjillesvoid defun(const char *, union node *); 74200956Sjillesint unsetfunc(const char *); 75238468Sjillesint isfunc(const char *); 76201343Sjillesint typecmd_impl(int, char **, int, const char *); 77218324Sjillesvoid clearcmdentry(void); 78