/*-1* Copyright (c) 1991, 19932* The Regents of the University of California. All rights reserved.3*4* This code is derived from software contributed to Berkeley by5* Kenneth Almquist.6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15* 3. Neither the name of the University nor the names of its contributors16* may be used to endorse or promote products derived from this software17* without specific prior written permission.18*19* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND20* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE21* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE22* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE23* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL24* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS25* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)26* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT27* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY28* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF29* SUCH DAMAGE.30*/3132/* values of cmdtype */33#define CMDUNKNOWN -1 /* no entry in table for command */34#define CMDNORMAL 0 /* command is an executable program */35#define CMDBUILTIN 1 /* command is a shell builtin */36#define CMDFUNCTION 2 /* command is a shell function */3738/* values for typecmd_impl's third parameter */39enum {40TYPECMD_SMALLV, /* command -v */41TYPECMD_BIGV, /* command -V */42TYPECMD_TYPE /* type */43};4445union node;46struct cmdentry {47int cmdtype;48union param {49int index;50struct funcdef *func;51} u;52int special;53const char *cmdname;54};555657/* action to find_command() */58#define DO_ERR 0x01 /* prints errors */59#define DO_NOFUNC 0x02 /* don't return shell functions, for command */6061void shellexec(char **, char **, const char *, int) __dead2;62char *padvance(const char **, const char **, const char *);63void find_command(const char *, struct cmdentry *, int, const char *);64int find_builtin(const char *, int *);65void hashcd(void);66void changepath(const char *);67void defun(const char *, union node *);68int unsetfunc(const char *);69int isfunc(const char *);70int typecmd_impl(int, char **, int, const char *);71void clearcmdentry(void);72const void *itercmd(const void *, struct cmdentry *);737475