xref: /csrg-svn/bin/csh/csh.h (revision 69126)
147823Sbostic /*-
260765Sbostic  * Copyright (c) 1980, 1991, 1993
360765Sbostic  *	The Regents of the University of California.  All rights reserved.
421946Sdist  *
547823Sbostic  * %sccs.include.redist.c%
647823Sbostic  *
7*69126Schristos  *	@(#)csh.h	8.2 (Berkeley) 04/29/95
821946Sdist  */
947417Sbostic 
1050024Schristos /*
1150024Schristos  * Fundamental definitions which may vary from system to system.
1250024Schristos  *
1350024Schristos  *	BUFSIZ		The i/o buffering size; also limits word size
1450024Schristos  *	MAILINTVL	How often to mailcheck; more often is more expensive
1550024Schristos  */
1650024Schristos #ifndef BUFSIZ
1750024Schristos #define	BUFSIZ	1024		/* default buffer size */
1850024Schristos #endif				/* BUFSIZ */
1950024Schristos 
2050024Schristos #define FORKSLEEP	10	/* delay loop on non-interactive fork failure */
2150024Schristos #define	MAILINTVL	600	/* 10 minutes */
2250024Schristos 
2350024Schristos /*
2450024Schristos  * The shell moves std in/out/diag and the old std input away from units
2550024Schristos  * 0, 1, and 2 so that it is easy to set up these standards for invoked
2650024Schristos  * commands.
2750024Schristos  */
2850024Schristos #define	FSHTTY	15		/* /dev/tty when manip pgrps */
2950024Schristos #define	FSHIN	16		/* Preferred desc for shell input */
3050024Schristos #define	FSHOUT	17		/* ... shell output */
3150439Schristos #define	FSHERR	18		/* ... shell diagnostics */
3250024Schristos #define	FOLDSTD	19		/* ... old std input */
3350024Schristos 
3450024Schristos #ifdef PROF
3550024Schristos #define	xexit(n)	done(n)
3650024Schristos #endif
3750024Schristos 
3850023Sbostic #ifdef SHORT_STRINGS
3950023Sbostic typedef short Char;
4050023Sbostic 
4150023Sbostic #define SAVE(a) (Strsave(str2short(a)))
4250023Sbostic #else
4350023Sbostic typedef char Char;
4450023Sbostic 
4550023Sbostic #define SAVE(a) (strsave(a))
4650023Sbostic #endif
4750023Sbostic 
4860237Schristos /*
4960237Schristos  * Make sure a variable is not stored in a register by taking its address
5060237Schristos  * This is used where variables might be clobbered by longjmp.
5160237Schristos  */
5260237Schristos #define UNREGISTER(a)	(void) &a
5360237Schristos 
5450023Sbostic typedef void *ioctl_t;		/* Third arg of ioctl */
5550023Sbostic 
5649992Sbostic typedef void *ptr_t;
5749992Sbostic 
5850028Sbostic #include "const.h"
5950023Sbostic #include "char.h"
6050023Sbostic #include "err.h"
6150023Sbostic 
6250023Sbostic #define xmalloc(i)	Malloc(i)
6349992Sbostic #define xrealloc(p, i)	Realloc(p, i)
6449992Sbostic #define xcalloc(n, s)	Calloc(n, s)
6550023Sbostic #define xfree(p)	Free(p)
6649992Sbostic 
6750439Schristos #include <stdio.h>
6850439Schristos FILE *cshin, *cshout, *csherr;
6950439Schristos 
7049992Sbostic #define	isdir(d)	((d.st_mode & S_IFMT) == S_IFDIR)
711296Sbill 
7249992Sbostic typedef int bool;
7349992Sbostic 
7449992Sbostic #define	eq(a, b)	(Strcmp(a, b) == 0)
7549992Sbostic 
7649992Sbostic /* globone() flags */
7749992Sbostic #define G_ERROR		0	/* default action: error if multiple words */
7850023Sbostic #define G_IGNORE	1	/* ignore the rest of the words */
7950023Sbostic #define G_APPEND	2	/* make a sentence by cat'ing the words */
8049992Sbostic 
8113008Ssam /*
821296Sbill  * Global flags
831296Sbill  */
8449992Sbostic bool    chkstop;		/* Warned of stopped jobs... allow exit */
8549992Sbostic bool    didfds;			/* Have setup i/o fd's for child */
8649992Sbostic bool    doneinp;		/* EOF indicator after reset from readc */
8749992Sbostic bool    exiterr;		/* Exit if error or non-zero exit status */
8849992Sbostic bool    child;			/* Child shell ... errors cause exit */
8949992Sbostic bool    haderr;			/* Reset was because of an error */
9049992Sbostic bool    intty;			/* Input is a tty */
9149992Sbostic bool    intact;			/* We are interactive... therefore prompt */
9249992Sbostic bool    justpr;			/* Just print because of :p hist mod */
9349992Sbostic bool    loginsh;		/* We are a loginsh -> .login/.logout */
9449992Sbostic bool    neednote;		/* Need to pnotify() */
9549992Sbostic bool    noexec;			/* Don't execute, just syntax check */
9649992Sbostic bool    pjobs;			/* want to print jobs if interrupted */
9749992Sbostic bool    setintr;		/* Set interrupts on/off -> Wait intr... */
9849992Sbostic bool    timflg;			/* Time the next waited for command */
9949992Sbostic bool    havhash;		/* path hashing is available */
10049992Sbostic 
10117518Sedward #ifdef FILEC
10249992Sbostic bool    filec;			/* doing filename expansion */
10317518Sedward #endif
1041296Sbill 
1051296Sbill /*
1061296Sbill  * Global i/o info
1071296Sbill  */
10849992Sbostic Char   *arginp;			/* Argument input for sh -c and internal `xx` */
10949992Sbostic int     onelflg;		/* 2 -> need line for -t, 1 -> exit on read */
11049992Sbostic Char   *ffile;			/* Name of shell file for $0 */
1111296Sbill 
11249992Sbostic char   *seterr;			/* Error message from scanner/parser */
11349992Sbostic Char   *shtemp;			/* Temp name for << shell files in /tmp */
1141296Sbill 
11553725Smckusick #include <sys/types.h>
11650028Sbostic #include <sys/time.h>
11750028Sbostic #include <sys/resource.h>
11850028Sbostic 
11949992Sbostic struct timeval time0;		/* Time at which the shell started */
12049992Sbostic struct rusage ru0;
12149992Sbostic 
1221296Sbill /*
1231296Sbill  * Miscellany
1241296Sbill  */
12549992Sbostic Char   *doldol;			/* Character pid for $$ */
12651530Schristos int	backpid;		/* Pid of the last background process */
12753567Schristos int     uid, euid;		/* Invokers uid */
12853567Schristos int     gid, egid;		/* Invokers gid */
12949992Sbostic time_t  chktim;			/* Time mail last checked */
13049992Sbostic int     shpgrp;			/* Pgrp of shell */
13149992Sbostic int     tpgrp;			/* Terminal process group */
13249992Sbostic 
1331296Sbill /* If tpgrp is -1, leave tty alone! */
13449992Sbostic int     opgrp;			/* Initial pgrp and tty pgrp */
1351296Sbill 
1361296Sbill 
1371296Sbill /*
1381296Sbill  * To be able to redirect i/o for builtins easily, the shell moves the i/o
1391296Sbill  * descriptors it uses away from 0,1,2.
1401296Sbill  * Ideally these should be in units which are closed across exec's
1411296Sbill  * (this saves work) but for version 6, this is not usually possible.
14260243Schristos  * The desired initial values for these descriptors are F{SHIN,...}.
1431296Sbill  */
14450439Schristos int   SHIN;			/* Current shell input (script) */
14550439Schristos int   SHOUT;			/* Shell output */
14650439Schristos int   SHERR;			/* Diagnostic output... shell errs go here */
14750439Schristos int   OLDSTD;			/* Old standard input (def for cmds) */
1481296Sbill 
1491296Sbill /*
1501296Sbill  * Error control
1511296Sbill  *
1521296Sbill  * Errors in scanning and parsing set up an error message to be printed
1531296Sbill  * at the end and complete.  Other errors always cause a reset.
1541296Sbill  * Because of source commands and .cshrc we need nested error catches.
1551296Sbill  */
1561296Sbill 
15750028Sbostic #include <setjmp.h>
15849992Sbostic jmp_buf reslab;
1591296Sbill 
16049992Sbostic #define	setexit()	(setjmp(reslab))
16149992Sbostic #define	reset()		longjmp(reslab, 1)
16249992Sbostic  /* Should use structure assignment here */
163*69126Schristos #define	getexit(a)	memmove((a), reslab, sizeof reslab)
164*69126Schristos #define	resexit(a)	memmove(reslab, (a), sizeof reslab)
1651296Sbill 
16649992Sbostic Char   *gointr;			/* Label for an onintr transfer */
1671296Sbill 
16850028Sbostic #include <signal.h>
16949992Sbostic sig_t parintr;			/* Parents interrupt catch */
17049992Sbostic sig_t parterm;			/* Parents terminate catch */
17149992Sbostic 
1721296Sbill /*
1731296Sbill  * Lexical definitions.
1741296Sbill  *
1751296Sbill  * All lexical space is allocated dynamically.
17650461Schristos  * The eighth/sixteenth bit of characters is used to prevent recognition,
1771296Sbill  * and eventually stripped.
1781296Sbill  */
17949992Sbostic #define	META		0200
18049992Sbostic #define	ASCII		0177
18149992Sbostic #ifdef SHORT_STRINGS
18249992Sbostic #define	CHAR		0377
18349992Sbostic #define	QUOTE 		0100000	/* 16nth char bit used for 'ing */
18449992Sbostic #define	TRIM		0077777	/* Mask to strip quote bit */
18549992Sbostic #else
18649992Sbostic #define	CHAR		0177
18749992Sbostic #define	QUOTE 		0200	/* Eighth char bit used for 'ing */
18849992Sbostic #define	TRIM		0177	/* Mask to strip quote bit */
18949992Sbostic #endif
1901296Sbill 
19149992Sbostic int     AsciiOnly;		/* If set only 7 bits is expected in characters */
19249992Sbostic 
1931296Sbill /*
1941296Sbill  * Each level of input has a buffered input structure.
1951296Sbill  * There are one or more blocks of buffered input for each level,
1961296Sbill  * exactly one if the input is seekable and tell is available.
1971296Sbill  * In other cases, the shell buffers enough blocks to keep all loops
1981296Sbill  * in the buffer.
1991296Sbill  */
20047724Sbostic struct Bin {
20149992Sbostic     off_t   Bfseekp;		/* Seek pointer */
20249992Sbostic     off_t   Bfbobp;		/* Seekp of beginning of buffers */
20349992Sbostic     off_t   Bfeobp;		/* Seekp of end of buffers */
20450439Schristos     int     Bfblocks;		/* Number of buffer blocks */
20549992Sbostic     Char  **Bfbuf;		/* The array of buffer blocks */
20649992Sbostic }       B;
2071296Sbill 
20850944Schristos /*
20950944Schristos  * This structure allows us to seek inside aliases
21050944Schristos  */
21150944Schristos struct Ain {
21250944Schristos     int type;
21350944Schristos #define I_SEEK -1		/* Invalid seek */
21450944Schristos #define A_SEEK	0		/* Alias seek */
21550944Schristos #define F_SEEK	1		/* File seek */
21650944Schristos #define E_SEEK	2		/* Eval seek */
21758876Schristos     union {
21858876Schristos 	off_t _f_seek;
21958876Schristos 	Char* _c_seek;
22058876Schristos     } fc;
22158876Schristos #define f_seek fc._f_seek
22258876Schristos #define c_seek fc._c_seek
22350944Schristos     Char **a_seek;
22450944Schristos } ;
22550944Schristos extern int aret;		/* What was the last character returned */
22650944Schristos #define SEEKEQ(a, b) ((a)->type == (b)->type && \
22750944Schristos 		      (a)->f_seek == (b)->f_seek && \
22850944Schristos 		      (a)->a_seek == (b)->a_seek)
22950944Schristos 
2301296Sbill #define	fseekp	B.Bfseekp
2311296Sbill #define	fbobp	B.Bfbobp
2321296Sbill #define	feobp	B.Bfeobp
2331296Sbill #define	fblocks	B.Bfblocks
2341296Sbill #define	fbuf	B.Bfbuf
2351296Sbill 
2361296Sbill /*
2371296Sbill  * The shell finds commands in loops by reseeking the input
2381296Sbill  * For whiles, in particular, it reseeks to the beginning of the
2391296Sbill  * line the while was on; hence the while placement restrictions.
2401296Sbill  */
24150944Schristos struct Ain lineloc;
2421296Sbill 
24349992Sbostic bool    cantell;		/* Is current source tellable ? */
2441296Sbill 
2451296Sbill /*
2461296Sbill  * Input lines are parsed into doubly linked circular
2471296Sbill  * lists of words of the following form.
2481296Sbill  */
24947724Sbostic struct wordent {
25049992Sbostic     Char   *word;
25149992Sbostic     struct wordent *prev;
25249992Sbostic     struct wordent *next;
2531296Sbill };
2541296Sbill 
2551296Sbill /*
2561296Sbill  * During word building, both in the initial lexical phase and
2571296Sbill  * when expanding $ variable substitutions, expansion by `!' and `$'
2581296Sbill  * must be inhibited when reading ahead in routines which are themselves
2591296Sbill  * processing `!' and `$' expansion or after characters such as `\' or in
2601296Sbill  * quotations.  The following flags are passed to the getC routines
2611296Sbill  * telling them which of these substitutions are appropriate for the
2621296Sbill  * next character to be returned.
2631296Sbill  */
2641296Sbill #define	DODOL	1
2651296Sbill #define	DOEXCL	2
2661296Sbill #define	DOALL	DODOL|DOEXCL
2671296Sbill 
2681296Sbill /*
2691296Sbill  * Labuf implements a general buffer for lookahead during lexical operations.
27049992Sbostic  * Text which is to be placed in the input stream can be stuck here.
27149992Sbostic  * We stick parsed ahead $ constructs during initial input,
27249992Sbostic  * process id's from `$$', and modified variable values (from qualifiers
27349992Sbostic  * during expansion in sh.dol.c) here.
2741296Sbill  */
27549992Sbostic Char   *lap;
2761296Sbill 
2771296Sbill /*
2781296Sbill  * Parser structure
2791296Sbill  *
28049992Sbostic  * Each command is parsed to a tree of command structures and
28149992Sbostic  * flags are set bottom up during this process, to be propagated down
28249992Sbostic  * as needed during the semantics/exeuction pass (sh.sem.c).
2831296Sbill  */
28449992Sbostic struct command {
28549992Sbostic     short   t_dtyp;		/* Type of node 		 */
28649992Sbostic #define	NODE_COMMAND	1	/* t_dcom <t_dlef >t_drit	 */
28749992Sbostic #define	NODE_PAREN	2	/* ( t_dspr ) <t_dlef >t_drit	 */
28849992Sbostic #define	NODE_PIPE	3	/* t_dlef | t_drit		 */
28949992Sbostic #define	NODE_LIST	4	/* t_dlef ; t_drit		 */
29049992Sbostic #define	NODE_OR		5	/* t_dlef || t_drit		 */
29149992Sbostic #define	NODE_AND	6	/* t_dlef && t_drit		 */
29249992Sbostic     short   t_dflg;		/* Flags, e.g. F_AMPERSAND|... 	 */
29349992Sbostic #define	F_SAVE	(F_NICE|F_TIME|F_NOHUP)	/* save these when re-doing 	 */
29447724Sbostic 
29549992Sbostic #define	F_AMPERSAND	(1<<0)	/* executes in background	 */
29649992Sbostic #define	F_APPEND	(1<<1)	/* output is redirected >>	 */
29749992Sbostic #define	F_PIPEIN	(1<<2)	/* input is a pipe		 */
29849992Sbostic #define	F_PIPEOUT	(1<<3)	/* output is a pipe		 */
29949992Sbostic #define	F_NOFORK	(1<<4)	/* don't fork, last ()ized cmd	 */
30049992Sbostic #define	F_NOINTERRUPT	(1<<5)	/* should be immune from intr's */
30149992Sbostic /* spare */
30249992Sbostic #define	F_STDERR	(1<<7)	/* redirect unit 2 with unit 1	 */
30349992Sbostic #define	F_OVERWRITE	(1<<8)	/* output was !			 */
30449992Sbostic #define	F_READ		(1<<9)	/* input redirection is <<	 */
30549992Sbostic #define	F_REPEAT	(1<<10)	/* reexec aft if, repeat,...	 */
30649992Sbostic #define	F_NICE		(1<<11)	/* t_nice is meaningful 	 */
30749992Sbostic #define	F_NOHUP		(1<<12)	/* nohup this command 		 */
30849992Sbostic #define	F_TIME		(1<<13)	/* time this command 		 */
30949992Sbostic     union {
31049992Sbostic 	Char   *T_dlef;		/* Input redirect word 		 */
31149992Sbostic 	struct command *T_dcar;	/* Left part of list/pipe 	 */
31249992Sbostic     }       L;
31349992Sbostic     union {
31449992Sbostic 	Char   *T_drit;		/* Output redirect word 	 */
31549992Sbostic 	struct command *T_dcdr;	/* Right part of list/pipe 	 */
31649992Sbostic     }       R;
3171296Sbill #define	t_dlef	L.T_dlef
3181296Sbill #define	t_dcar	L.T_dcar
3191296Sbill #define	t_drit	R.T_drit
3201296Sbill #define	t_dcdr	R.T_dcdr
32149992Sbostic     Char  **t_dcom;		/* Command/argument vector 	 */
32249992Sbostic     struct command *t_dspr;	/* Pointer to ()'d subtree 	 */
32350439Schristos     int   t_nice;
3241296Sbill };
3251296Sbill 
32649992Sbostic 
32749992Sbostic /*
32850439Schristos  * These are declared here because they want to be
32950439Schristos  * initialized in sh.init.c (to allow them to be made readonly)
33050439Schristos  */
33150439Schristos 
33250439Schristos extern struct biltins {
33350439Schristos     char   *bname;
33450439Schristos     void    (*bfunct) __P((Char **, struct command *));
33550439Schristos     short   minargs, maxargs;
33650439Schristos }       bfunc[];
33750439Schristos extern int nbfunc;
33850439Schristos 
33950439Schristos extern struct srch {
34050439Schristos     char   *s_name;
34150439Schristos     short   s_value;
34250439Schristos }       srchn[];
34350439Schristos extern int nsrchn;
34450439Schristos 
34550439Schristos /*
34649992Sbostic  * The keywords for the parser
34749992Sbostic  */
34847724Sbostic #define	T_BREAK		0
34947724Sbostic #define	T_BRKSW		1
35047724Sbostic #define	T_CASE		2
35147724Sbostic #define	T_DEFAULT 	3
35247724Sbostic #define	T_ELSE		4
35347724Sbostic #define	T_END		5
35447724Sbostic #define	T_ENDIF		6
35547724Sbostic #define	T_ENDSW		7
35647724Sbostic #define	T_EXIT		8
35747724Sbostic #define	T_FOREACH	9
35847724Sbostic #define	T_GOTO		10
35947724Sbostic #define	T_IF		11
36047724Sbostic #define	T_LABEL		12
36147724Sbostic #define	T_LET		13
36247724Sbostic #define	T_SET		14
36347724Sbostic #define	T_SWITCH	15
36447724Sbostic #define	T_TEST		16
36547724Sbostic #define	T_THEN		17
36647724Sbostic #define	T_WHILE		18
3671296Sbill 
3681296Sbill /*
3691296Sbill  * Structure defining the existing while/foreach loops at this
3701296Sbill  * source level.  Loops are implemented by seeking back in the
3711296Sbill  * input.  For foreach (fe), the word list is attached here.
3721296Sbill  */
37349992Sbostic struct whyle {
37450944Schristos     struct Ain   w_start;	/* Point to restart loop */
37550944Schristos     struct Ain   w_end;		/* End of loop (0 if unknown) */
37649992Sbostic     Char  **w_fe, **w_fe0;	/* Current/initial wordlist for fe */
37749992Sbostic     Char   *w_fename;		/* Name for fe */
37849992Sbostic     struct whyle *w_next;	/* Next (more outer) loop */
37949992Sbostic }      *whyles;
3801296Sbill 
3811296Sbill /*
3821296Sbill  * Variable structure
3831296Sbill  *
38417518Sedward  * Aliases and variables are stored in AVL balanced binary trees.
3851296Sbill  */
38649992Sbostic struct varent {
38749992Sbostic     Char  **vec;		/* Array of words which is the value */
38849992Sbostic     Char   *v_name;		/* Name of variable/alias */
38949992Sbostic     struct varent *v_link[3];	/* The links, see below */
39049992Sbostic     int     v_bal;		/* Balance factor */
39149992Sbostic }       shvhed, aliases;
39249992Sbostic 
39317518Sedward #define v_left		v_link[0]
39417518Sedward #define v_right		v_link[1]
39517518Sedward #define v_parent	v_link[2]
3961296Sbill 
39717518Sedward struct varent *adrof1();
39849992Sbostic 
39917518Sedward #define adrof(v)	adrof1(v, &shvhed)
40017518Sedward #define value(v)	value1(v, &shvhed)
40117518Sedward 
4021296Sbill /*
4031296Sbill  * The following are for interfacing redo substitution in
4041296Sbill  * aliases to the lexical routines.
4051296Sbill  */
40649992Sbostic struct wordent *alhistp;	/* Argument list (first) */
40749992Sbostic struct wordent *alhistt;	/* Node after last in arg list */
40851530Schristos Char  **alvec, *alvecp;		/* The (remnants of) alias vector */
4091296Sbill 
4101296Sbill /*
4111296Sbill  * Filename/command name expansion variables
4121296Sbill  */
41350439Schristos int   gflag;			/* After tglob -> is globbing needed? */
4141296Sbill 
41549992Sbostic #define MAXVARLEN 30		/* Maximum number of char in a variable name */
4161296Sbill 
4171296Sbill /*
4181296Sbill  * Variables for filename expansion
4191296Sbill  */
42049992Sbostic extern Char **gargv;		/* Pointer to the (stack) arglist */
42149992Sbostic extern long gargc;		/* Number args in gargv */
4221296Sbill 
4231296Sbill /*
4241296Sbill  * Variables for command expansion.
4251296Sbill  */
42649992Sbostic extern Char **pargv;		/* Pointer to the argv list space */
42749992Sbostic extern long pargc;		/* Count of arguments in pargv */
42849992Sbostic Char   *pargs;			/* Pointer to start current word */
42949992Sbostic long    pnleft;			/* Number of chars left in pargs */
43049992Sbostic Char   *pargcp;			/* Current index into pargs */
4311296Sbill 
4321296Sbill /*
4331296Sbill  * History list
4341296Sbill  *
4351296Sbill  * Each history list entry contains an embedded wordlist
4361296Sbill  * from the scanner, a number for the event, and a reference count
4371296Sbill  * to aid in discarding old entries.
4381296Sbill  *
4391296Sbill  * Essentially "invisible" entries are put on the history list
4401296Sbill  * when history substitution includes modifiers, and thrown away
4411296Sbill  * at the next discarding since their event numbers are very negative.
4421296Sbill  */
44349992Sbostic struct Hist {
44449992Sbostic     struct wordent Hlex;
44549992Sbostic     int     Hnum;
44649992Sbostic     int     Href;
44749992Sbostic     struct Hist *Hnext;
44849992Sbostic }       Histlist;
4491296Sbill 
45049992Sbostic struct wordent paraml;		/* Current lexical word list */
45149992Sbostic int     eventno;		/* Next events number */
45249992Sbostic int     lastev;			/* Last event reference (default) */
4531296Sbill 
45449992Sbostic Char    HIST;			/* history invocation character */
45549992Sbostic Char    HISTSUB;		/* auto-substitute character */
4561296Sbill 
45717518Sedward /*
45849992Sbostic  * strings.h:
45917518Sedward  */
46049992Sbostic #ifndef SHORT_STRINGS
46150023Sbostic #define Strchr(a, b)		strchr(a, b)
46250023Sbostic #define Strrchr(a, b)		strrchr(a, b)
46350023Sbostic #define Strcat(a, b)		strcat(a, b)
46449992Sbostic #define Strncat(a, b, c) 	strncat(a, b, c)
46550023Sbostic #define Strcpy(a, b)		strcpy(a, b)
46649992Sbostic #define Strncpy(a, b, c) 	strncpy(a, b, c)
46749992Sbostic #define Strlen(a)		strlen(a)
46849992Sbostic #define Strcmp(a, b)		strcmp(a, b)
46949992Sbostic #define Strncmp(a, b, c)	strncmp(a, b, c)
47017518Sedward 
47149992Sbostic #define Strspl(a, b)		strspl(a, b)
47249992Sbostic #define Strsave(a)		strsave(a)
47349992Sbostic #define Strend(a)		strend(a)
47449992Sbostic #define Strstr(a, b)		strstr(a, b)
4751296Sbill 
47649992Sbostic #define str2short(a) 		(a)
47749992Sbostic #define blk2short(a) 		saveblk(a)
47849992Sbostic #define short2blk(a) 		saveblk(a)
47950461Schristos #define short2str(a) 		strip(a)
48049992Sbostic #else
48150023Sbostic #define Strchr(a, b)		s_strchr(a, b)
48249992Sbostic #define Strrchr(a, b) 		s_strrchr(a, b)
48350023Sbostic #define Strcat(a, b)		s_strcat(a, b)
48449992Sbostic #define Strncat(a, b, c) 	s_strncat(a, b, c)
48550023Sbostic #define Strcpy(a, b)		s_strcpy(a, b)
48649992Sbostic #define Strncpy(a, b, c)	s_strncpy(a, b, c)
48749992Sbostic #define Strlen(a)		s_strlen(a)
48849992Sbostic #define Strcmp(a, b)		s_strcmp(a, b)
48949992Sbostic #define Strncmp(a, b, c)	s_strncmp(a, b, c)
4901296Sbill 
49149992Sbostic #define Strspl(a, b)		s_strspl(a, b)
49249992Sbostic #define Strsave(a)		s_strsave(a)
49349992Sbostic #define Strend(a)		s_strend(a)
49449992Sbostic #define Strstr(a, b)		s_strstr(a, b)
49549992Sbostic #endif
49649992Sbostic 
4971296Sbill /*
4981296Sbill  * setname is a macro to save space (see sh.err.c)
4991296Sbill  */
50049992Sbostic char   *bname;
50149992Sbostic 
50217518Sedward #define	setname(a)	(bname = (a))
5031296Sbill 
50449992Sbostic Char   *Vsav;
50549992Sbostic Char   *Vdp;
50649992Sbostic Char   *Vexpath;
50749992Sbostic char  **Vt;
50849992Sbostic 
50949992Sbostic Char  **evalvec;
51049992Sbostic Char   *evalp;
51149992Sbostic 
51249992Sbostic /* word_chars is set by default to WORD_CHARS but can be overridden by
51349992Sbostic    the worchars variable--if unset, reverts to WORD_CHARS */
51449992Sbostic 
51549992Sbostic Char   *word_chars;
51649992Sbostic 
51749992Sbostic #define WORD_CHARS "*?_-.[]~="	/* default chars besides alnums in words */
51849992Sbostic 
51949992Sbostic Char   *STR_SHELLPATH;
52049992Sbostic 
52150028Sbostic #include <paths.h>
52249992Sbostic #ifdef _PATH_BSHELL
52349992Sbostic Char   *STR_BSHELL;
5241296Sbill #endif
52549992Sbostic Char   *STR_WORD_CHARS;
52649992Sbostic Char  **STR_environ;
527