xref: /freebsd/bin/sh/options.h (revision d2c233176f44944ef3ed941a60010839340c06a7)
14b88c807SRodney W. Grimes /*-
28a16b7a1SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
38a16b7a1SPedro F. Giffuni  *
44b88c807SRodney W. Grimes  * Copyright (c) 1991, 1993
54b88c807SRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
64b88c807SRodney W. Grimes  *
74b88c807SRodney W. Grimes  * This code is derived from software contributed to Berkeley by
84b88c807SRodney W. Grimes  * Kenneth Almquist.
94b88c807SRodney W. Grimes  *
104b88c807SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
114b88c807SRodney W. Grimes  * modification, are permitted provided that the following conditions
124b88c807SRodney W. Grimes  * are met:
134b88c807SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
144b88c807SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
154b88c807SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
164b88c807SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
174b88c807SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
18fbbd9655SWarner Losh  * 3. Neither the name of the University nor the names of its contributors
194b88c807SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
204b88c807SRodney W. Grimes  *    without specific prior written permission.
214b88c807SRodney W. Grimes  *
224b88c807SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
234b88c807SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
244b88c807SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
254b88c807SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
264b88c807SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
274b88c807SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
284b88c807SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
294b88c807SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
304b88c807SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
314b88c807SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
324b88c807SRodney W. Grimes  * SUCH DAMAGE.
334b88c807SRodney W. Grimes  *
34aa9caaf6SPeter Wemm  *	@(#)options.h	8.2 (Berkeley) 5/4/95
352a456239SPeter Wemm  * $FreeBSD$
364b88c807SRodney W. Grimes  */
374b88c807SRodney W. Grimes 
384b88c807SRodney W. Grimes struct shparam {
39ab0a2172SSteve Price 	int nparam;		/* # of positional parameters (without $0) */
40ab0a2172SSteve Price 	unsigned char malloc;	/* if parameter list dynamically allocated */
41ab0a2172SSteve Price 	unsigned char reset;	/* if getopts has been reset */
424b88c807SRodney W. Grimes 	char **p;		/* parameter list */
431bc2fdfaSJilles Tjoelker 	char **optp;		/* parameter list for getopts */
444b88c807SRodney W. Grimes 	char **optnext;		/* next parameter to be processed by getopts */
454b88c807SRodney W. Grimes 	char *optptr;		/* used by getopts */
464b88c807SRodney W. Grimes };
474b88c807SRodney W. Grimes 
484b88c807SRodney W. Grimes 
494b88c807SRodney W. Grimes 
503da40d4aSJilles Tjoelker #define eflag optval[0]
513da40d4aSJilles Tjoelker #define fflag optval[1]
523da40d4aSJilles Tjoelker #define Iflag optval[2]
533da40d4aSJilles Tjoelker #define iflag optval[3]
543da40d4aSJilles Tjoelker #define mflag optval[4]
553da40d4aSJilles Tjoelker #define nflag optval[5]
563da40d4aSJilles Tjoelker #define sflag optval[6]
573da40d4aSJilles Tjoelker #define xflag optval[7]
583da40d4aSJilles Tjoelker #define vflag optval[8]
593da40d4aSJilles Tjoelker #define Vflag optval[9]
603da40d4aSJilles Tjoelker #define	Eflag optval[10]
613da40d4aSJilles Tjoelker #define	Cflag optval[11]
623da40d4aSJilles Tjoelker #define	aflag optval[12]
633da40d4aSJilles Tjoelker #define	bflag optval[13]
643da40d4aSJilles Tjoelker #define	uflag optval[14]
653da40d4aSJilles Tjoelker #define	privileged optval[15]
663da40d4aSJilles Tjoelker #define	Tflag optval[16]
673da40d4aSJilles Tjoelker #define	Pflag optval[17]
683da40d4aSJilles Tjoelker #define	hflag optval[18]
693da40d4aSJilles Tjoelker #define	nologflag optval[19]
70484160a9SJilles Tjoelker #define	pipefailflag optval[20]
71*d2c23317SStephane Rochoy #define	verifyflag optval[21]
724b88c807SRodney W. Grimes 
7362c37116SJilles Tjoelker #define NSHORTOPTS	19
74*d2c23317SStephane Rochoy #define NOPTS		22
754b88c807SRodney W. Grimes 
763da40d4aSJilles Tjoelker extern char optval[NOPTS];
773da40d4aSJilles Tjoelker extern const char optletter[NSHORTOPTS];
784b88c807SRodney W. Grimes #ifdef DEFINE_OPTIONS
793da40d4aSJilles Tjoelker char optval[NOPTS];
803da40d4aSJilles Tjoelker const char optletter[NSHORTOPTS] = "efIimnsxvVECabupTPh";
813da40d4aSJilles Tjoelker static const unsigned char optname[] =
823da40d4aSJilles Tjoelker 	"\007errexit"
833da40d4aSJilles Tjoelker 	"\006noglob"
843da40d4aSJilles Tjoelker 	"\011ignoreeof"
853da40d4aSJilles Tjoelker 	"\013interactive"
863da40d4aSJilles Tjoelker 	"\007monitor"
873da40d4aSJilles Tjoelker 	"\006noexec"
883da40d4aSJilles Tjoelker 	"\005stdin"
893da40d4aSJilles Tjoelker 	"\006xtrace"
903da40d4aSJilles Tjoelker 	"\007verbose"
913da40d4aSJilles Tjoelker 	"\002vi"
923da40d4aSJilles Tjoelker 	"\005emacs"
933da40d4aSJilles Tjoelker 	"\011noclobber"
943da40d4aSJilles Tjoelker 	"\011allexport"
953da40d4aSJilles Tjoelker 	"\006notify"
963da40d4aSJilles Tjoelker 	"\007nounset"
973da40d4aSJilles Tjoelker 	"\012privileged"
983da40d4aSJilles Tjoelker 	"\012trapsasync"
993da40d4aSJilles Tjoelker 	"\010physical"
1003da40d4aSJilles Tjoelker 	"\010trackall"
1013da40d4aSJilles Tjoelker 	"\005nolog"
102484160a9SJilles Tjoelker 	"\010pipefail"
103*d2c23317SStephane Rochoy 	"\006verify"
1043da40d4aSJilles Tjoelker ;
1054b88c807SRodney W. Grimes #endif
1064b88c807SRodney W. Grimes 
1074b88c807SRodney W. Grimes 
1084b88c807SRodney W. Grimes extern char *minusc;		/* argument to -c option */
1094b88c807SRodney W. Grimes extern char *arg0;		/* $0 */
1104b88c807SRodney W. Grimes extern struct shparam shellparam;  /* $@ */
1114b88c807SRodney W. Grimes extern char **argptr;		/* argument list for builtin commands */
112f01e3d0cSMartin Cracauer extern char *shoptarg;		/* set by nextopt */
113384aedabSJilles Tjoelker extern char *nextopt_optptr;	/* used by nextopt */
1144b88c807SRodney W. Grimes 
1155134c3f7SWarner Losh void procargs(int, char **);
1165134c3f7SWarner Losh void optschanged(void);
1175134c3f7SWarner Losh void freeparam(struct shparam *);
1182cac6e36SJilles Tjoelker int nextopt(const char *);
1195134c3f7SWarner Losh void getoptsreset(const char *);
120