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 * @(#)options.h 8.2 (Berkeley) 5/4/95 3350471Speter * $FreeBSD: stable/11/bin/sh/options.h 345561 2019-03-26 22:34:07Z jilles $ 341556Srgrimes */ 351556Srgrimes 361556Srgrimesstruct shparam { 3720425Ssteve int nparam; /* # of positional parameters (without $0) */ 3820425Ssteve unsigned char malloc; /* if parameter list dynamically allocated */ 3920425Ssteve unsigned char reset; /* if getopts has been reset */ 401556Srgrimes char **p; /* parameter list */ 41273700Sjilles char **optp; /* parameter list for getopts */ 4220425Ssteve char **optnext; /* next parameter to be processed by getopts */ 4320425Ssteve char *optptr; /* used by getopts */ 441556Srgrimes}; 451556Srgrimes 461556Srgrimes 471556Srgrimes 48293392Sjilles#define eflag optval[0] 49293392Sjilles#define fflag optval[1] 50293392Sjilles#define Iflag optval[2] 51293392Sjilles#define iflag optval[3] 52293392Sjilles#define mflag optval[4] 53293392Sjilles#define nflag optval[5] 54293392Sjilles#define sflag optval[6] 55293392Sjilles#define xflag optval[7] 56293392Sjilles#define vflag optval[8] 57293392Sjilles#define Vflag optval[9] 58293392Sjilles#define Eflag optval[10] 59293392Sjilles#define Cflag optval[11] 60293392Sjilles#define aflag optval[12] 61293392Sjilles#define bflag optval[13] 62293392Sjilles#define uflag optval[14] 63293392Sjilles#define privileged optval[15] 64293392Sjilles#define Tflag optval[16] 65293392Sjilles#define Pflag optval[17] 66293392Sjilles#define hflag optval[18] 67293392Sjilles#define nologflag optval[19] 68345561Sjilles#define pipefailflag optval[20] 691556Srgrimes 70287296Sjilles#define NSHORTOPTS 19 71345561Sjilles#define NOPTS 21 721556Srgrimes 73293392Sjillesextern char optval[NOPTS]; 74293392Sjillesextern const char optletter[NSHORTOPTS]; 751556Srgrimes#ifdef DEFINE_OPTIONS 76293392Sjilleschar optval[NOPTS]; 77293392Sjillesconst char optletter[NSHORTOPTS] = "efIimnsxvVECabupTPh"; 78293392Sjillesstatic const unsigned char optname[] = 79293392Sjilles "\007errexit" 80293392Sjilles "\006noglob" 81293392Sjilles "\011ignoreeof" 82293392Sjilles "\013interactive" 83293392Sjilles "\007monitor" 84293392Sjilles "\006noexec" 85293392Sjilles "\005stdin" 86293392Sjilles "\006xtrace" 87293392Sjilles "\007verbose" 88293392Sjilles "\002vi" 89293392Sjilles "\005emacs" 90293392Sjilles "\011noclobber" 91293392Sjilles "\011allexport" 92293392Sjilles "\006notify" 93293392Sjilles "\007nounset" 94293392Sjilles "\012privileged" 95293392Sjilles "\012trapsasync" 96293392Sjilles "\010physical" 97293392Sjilles "\010trackall" 98293392Sjilles "\005nolog" 99345561Sjilles "\010pipefail" 100293392Sjilles; 1011556Srgrimes#endif 1021556Srgrimes 1031556Srgrimes 1041556Srgrimesextern char *minusc; /* argument to -c option */ 1051556Srgrimesextern char *arg0; /* $0 */ 1061556Srgrimesextern struct shparam shellparam; /* $@ */ 1071556Srgrimesextern char **argptr; /* argument list for builtin commands */ 10859436Scracauerextern char *shoptarg; /* set by nextopt */ 109201053Sjillesextern char *nextopt_optptr; /* used by nextopt */ 1101556Srgrimes 11190111Simpvoid procargs(int, char **); 11290111Simpvoid optschanged(void); 11390111Simpvoid freeparam(struct shparam *); 114200956Sjillesint nextopt(const char *); 11590111Simpvoid getoptsreset(const char *); 116