sh.h revision 1.14 1 /* $NetBSD: sh.h,v 1.14 2017/06/22 23:17:50 kamil Exp $ */
2
3 /*
4 * Public Domain Bourne/Korn shell
5 */
6
7 /* $Id: sh.h,v 1.14 2017/06/22 23:17:50 kamil Exp $ */
8
9 #include "config.h" /* system and option configuration info */
10
11 #ifdef HAVE_PROTOTYPES
12 # define ARGS(args) args /* prototype declaration */
13 #else
14 # define ARGS(args) () /* K&R declaration */
15 #endif
16
17 /* Start of common headers */
18
19 #include <stdio.h>
20 #include <sys/types.h>
21 #include <setjmp.h>
22 #ifdef HAVE_STDDEF_H
23 # include <stddef.h>
24 #endif
25
26 #include <stdlib.h>
27 #include <unistd.h>
28
29 #ifdef HAVE_STRING_H
30 # include <string.h>
31 #else
32 # include <strings.h>
33 # define strchr index
34 # define strrchr rindex
35 #endif /* HAVE_STRING_H */
36 #ifndef HAVE_STRSTR
37 char *strstr ARGS((const char *s, const char *p));
38 #endif /* HAVE_STRSTR */
39 #ifndef HAVE_STRCASECMP
40 int strcasecmp ARGS((const char *s1, const char *s2));
41 int strncasecmp ARGS((const char *s1, const char *s2, int n));
42 #endif /* HAVE_STRCASECMP */
43
44 #ifdef HAVE_MEMORY_H
45 # include <memory.h>
46 #endif
47 #ifndef HAVE_MEMSET
48 # define memcpy(d, s, n) bcopy(s, d, n)
49 # define memcmp(s1, s2, n) bcmp(s1, s2, n)
50 void *memset ARGS((void *d, int c, size_t n));
51 #endif /* HAVE_MEMSET */
52 #ifndef HAVE_MEMMOVE
53 # ifdef HAVE_BCOPY
54 # define memmove(d, s, n) bcopy(s, d, n)
55 # else
56 void *memmove ARGS((void *d, const void *s, size_t n));
57 # endif
58 #endif /* HAVE_MEMMOVE */
59
60 #ifdef HAVE_PROTOTYPES
61 # include <stdarg.h>
62 # define SH_VA_START(va, argn) va_start(va, argn)
63 #else
64 # include <varargs.h>
65 # define SH_VA_START(va, argn) va_start(va)
66 #endif /* HAVE_PROTOTYPES */
67
68 #include <errno.h>
69
70 #ifdef HAVE_FCNTL_H
71 # include <fcntl.h>
72 #else
73 # include <sys/file.h>
74 #endif /* HAVE_FCNTL_H */
75 #ifndef O_ACCMODE
76 # define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
77 #endif /* !O_ACCMODE */
78
79 #ifndef F_OK /* access() arguments */
80 # define F_OK 0
81 # define X_OK 1
82 # define W_OK 2
83 # define R_OK 4
84 #endif /* !F_OK */
85
86 #ifndef SEEK_SET
87 # ifdef L_SET
88 # define SEEK_SET L_SET
89 # define SEEK_CUR L_INCR
90 # define SEEK_END L_XTND
91 # else /* L_SET */
92 # define SEEK_SET 0
93 # define SEEK_CUR 1
94 # define SEEK_END 2
95 # endif /* L_SET */
96 #endif /* !SEEK_SET */
97
98 /* Some machines (eg, FreeBSD 1.1.5) define CLK_TCK in limits.h
99 * (ksh_limval.h assumes limits has been included, if available)
100 */
101 #ifdef HAVE_LIMITS_H
102 # include <limits.h>
103 #endif /* HAVE_LIMITS_H */
104
105 #include <signal.h>
106 #ifdef NSIG
107 # define SIGNALS NSIG
108 #else
109 # ifdef _MINIX
110 # define SIGNALS (_NSIG+1) /* _NSIG is # of signals used, excluding 0. */
111 # else
112 # ifdef _SIGMAX /* QNX */
113 # define SIGNALS _SIGMAX
114 # else /* _SIGMAX */
115 # define SIGNALS 32
116 # endif /* _SIGMAX */
117 # endif /* _MINIX */
118 #endif /* NSIG */
119 #ifndef SIGCHLD
120 # define SIGCHLD SIGCLD
121 #endif
122 /* struct sigaction.sa_flags is set to KSH_SA_FLAGS. Used to ensure
123 * system calls are interrupted
124 */
125 #ifdef SA_INTERRUPT
126 # define KSH_SA_FLAGS SA_INTERRUPT
127 #else /* SA_INTERRUPT */
128 # define KSH_SA_FLAGS 0
129 #endif /* SA_INTERRUPT */
130
131 typedef RETSIGTYPE (*handler_t) ARGS((int)); /* signal handler */
132
133 #ifdef USE_FAKE_SIGACT
134 # include "sigact.h" /* use sjg's fake sigaction() */
135 #endif
136
137 #ifdef HAVE_PATHS_H
138 # include <paths.h>
139 #endif /* HAVE_PATHS_H */
140 #ifdef _PATH_DEFPATH
141 # define DEFAULT__PATH _PATH_DEFPATH
142 #else /* _PATH_DEFPATH */
143 # define DEFAULT__PATH DEFAULT_PATH
144 #endif /* _PATH_DEFPATH */
145
146 #ifndef offsetof
147 # define offsetof(type,id) ((size_t)&((type*)NULL)->id)
148 #endif
149
150 #ifndef HAVE_KILLPG
151 # define killpg(p, s) kill(-(p), (s))
152 #endif /* !HAVE_KILLPG */
153
154 /* Special cases for execve(2) */
155 # if defined(OS_ISC) && defined(_POSIX_SOURCE)
156 /* Kludge for ISC 3.2 (and other versions?) so programs will run correctly. */
157 # define ksh_execve(p, av, ev, flags) \
158 do { \
159 __setostype(0); \
160 execve(p, av, ev); \
161 __setostype(1); \
162 } while (0)
163 # else /* OS_ISC && _POSIX */
164 # define ksh_execve(p, av, ev, flags) execve(p, av, ev)
165 # endif /* OS_ISC && _POSIX */
166
167 /* this is a hang-over from older versions of the os2 port */
168 #define ksh_dupbase(fd, base) fcntl(fd, F_DUPFD, base)
169
170 #ifdef HAVE_SIGSETJMP
171 # define ksh_sigsetjmp(env,sm) sigsetjmp((env), (sm))
172 # define ksh_siglongjmp(env,v) siglongjmp((env), (v))
173 # define ksh_jmp_buf sigjmp_buf
174 #else /* HAVE_SIGSETJMP */
175 # ifdef HAVE__SETJMP
176 # define ksh_sigsetjmp(env,sm) _setjmp(env)
177 # define ksh_siglongjmp(env,v) _longjmp((env), (v))
178 # else /* HAVE__SETJMP */
179 # define ksh_sigsetjmp(env,sm) setjmp(env)
180 # define ksh_siglongjmp(env,v) longjmp((env), (v))
181 # endif /* HAVE__SETJMP */
182 # define ksh_jmp_buf jmp_buf
183 #endif /* HAVE_SIGSETJMP */
184
185 #ifndef HAVE_DUP2
186 extern int dup2 ARGS((int, int));
187 #endif /* !HAVE_DUP2 */
188
189 /* Find a integer type that is at least 32 bits (or die) - SIZEOF_* defined
190 * by autoconf (assumes an 8 bit byte, but I'm not concerned).
191 * NOTE: INT32 may end up being more than 32 bits.
192 */
193 #if SIZEOF_INT >= 4
194 # define INT32 int
195 #else /* SIZEOF_INT */
196 # if SIZEOF_LONG >= 4
197 # define INT32 long
198 # else /* SIZEOF_LONG */
199 #error cannot find 32 bit type...
200 # endif /* SIZEOF_LONG */
201 #endif /* SIZEOF_INT */
202
203 /* end of common headers */
204
205 /* Stop gcc and lint from complaining about possibly uninitialized variables */
206 #if defined(__GNUC__) || defined(lint)
207 # define UNINITIALIZED(var) var = 0
208 #else
209 # define UNINITIALIZED(var) var
210 #endif /* GNUC || lint */
211
212 /* some useful #defines */
213 #ifdef EXTERN
214 # define I__(i) = i
215 #else
216 # define I__(i)
217 # define EXTERN extern
218 # define EXTERN_DEFINED
219 #endif
220
221 #ifndef EXECSHELL
222 /* shell to exec scripts (see also $SHELL initialization in main.c) */
223 # define EXECSHELL "/bin/sh"
224 # define EXECSHELL_STR "EXECSHELL"
225 #endif
226
227 /* ISABSPATH() means path is fully and completely specified,
228 * ISROOTEDPATH() means a .. as the first component is a no-op,
229 * ISRELPATH() means $PWD can be tacked on to get an absolute path.
230 *
231 * OS Path ISABSPATH ISROOTEDPATH ISRELPATH
232 * unix /foo yes yes no
233 * unix foo no no yes
234 * unix ../foo no no yes
235 */
236 # define PATHSEP ':'
237 # define DIRSEP '/'
238 # define DIRSEPSTR "/"
239 # define ISDIRSEP(c) ((c) == '/')
240 # define ISABSPATH(s) ISDIRSEP((s)[0])
241 # define ISRELPATH(s) (!ISABSPATH(s))
242 # define ISROOTEDPATH(s) ISABSPATH(s)
243 # define FILECHCONV(c) c
244 # define FILECMP(s1, s2) strcmp(s1, s2)
245 # define FILENCMP(s1, s2, n) strncmp(s1, s2, n)
246 # define ksh_strchr_dirsep(p) strchr(p, DIRSEP)
247 # define ksh_strrchr_dirsep(p) strrchr(p, DIRSEP)
248
249 typedef int bool_t;
250 #define FALSE 0
251 #define TRUE 1
252
253 #define NELEM(a) (sizeof(a) / sizeof((a)[0]))
254 #define sizeofN(type, n) (sizeof(type) * (n))
255 #define BIT(i) (1<<(i)) /* define bit in flag */
256
257 /* Table flag type - needs > 16 and < 32 bits */
258 typedef INT32 Tflag;
259
260 #define NUFILE 32 /* Number of user-accessible files */
261 #define FDBASE 10 /* First file usable by Shell */
262
263 /* you're not going to run setuid shell scripts, are you? */
264 #define eaccess(path, mode) access(path, mode)
265
266 /* Make MAGIC a char that might be printed to make bugs more obvious, but
267 * not a char that is used often. Also, can't use the high bit as it causes
268 * portability problems (calling strchr(x, 0x80|'x') is error prone).
269 */
270 #define MAGIC (7) /* prefix for *?[!{,} during expand */
271 #define ISMAGIC(c) ((unsigned char)(c) == MAGIC)
272 #define NOT '!' /* might use ^ (ie, [!...] vs [^..]) */
273
274 #define LINE 1024 /* input line size */
275 #define PATH 1024 /* pathname size (todo: PATH_MAX/pathconf()) */
276 #define ARRAYMAX 1023 /* max array index */
277
278 EXTERN const char *kshname; /* $0 */
279 EXTERN pid_t kshpid; /* $$, shell pid */
280 EXTERN pid_t procpid; /* pid of executing process */
281 EXTERN uid_t ksheuid; /* effective uid of shell */
282 EXTERN int exstat; /* exit status */
283 EXTERN int subst_exstat; /* exit status of last $(..)/`..` */
284 EXTERN const char *safe_prompt; /* safe prompt if PS1 substitution fails */
285
286 /*
287 * Area-based allocation built on malloc/free
288 */
289 typedef struct Area {
290 struct link *freelist; /* free list */
291 } Area;
292
293 EXTERN Area aperm; /* permanent object space */
294 #define APERM &aperm
295 #define ATEMP &e->area
296
297 #ifdef MEM_DEBUG
298 # include "chmem.h" /* a debugging front end for malloc et. al. */
299 #endif /* MEM_DEBUG */
300
301 #ifdef KSH_DEBUG
302 # define kshdebug_init() kshdebug_init_()
303 # define kshdebug_printf(a) kshdebug_printf_ a
304 # define kshdebug_dump(a) kshdebug_dump_ a
305 #else /* KSH_DEBUG */
306 # define kshdebug_init()
307 # define kshdebug_printf(a)
308 # define kshdebug_dump(a)
309 #endif /* KSH_DEBUG */
310
311 /*
312 * parsing & execution environment
313 */
314 EXTERN struct env {
315 short type; /* environment type - see below */
316 short flags; /* EF_* */
317 Area area; /* temporary allocation area */
318 struct block *loc; /* local variables and functions */
319 short *savefd; /* original redirected fd's */
320 struct env *oenv; /* link to previous environment */
321 ksh_jmp_buf jbuf; /* long jump back to env creator */
322 struct temp *temps; /* temp files */
323 } *e;
324
325 /* struct env.type values */
326 #define E_NONE 0 /* dummy environment */
327 #define E_PARSE 1 /* parsing command # */
328 #define E_FUNC 2 /* executing function # */
329 #define E_INCL 3 /* including a file via . # */
330 #define E_EXEC 4 /* executing command tree */
331 #define E_LOOP 5 /* executing for/while # */
332 #define E_ERRH 6 /* general error handler # */
333 /* # indicates env has valid jbuf (see unwind()) */
334
335 /* struct env.flag values */
336 #define EF_FUNC_PARSE BIT(0) /* function being parsed */
337 #define EF_BRKCONT_PASS BIT(1) /* set if E_LOOP must pass break/continue on */
338 #define EF_FAKE_SIGDIE BIT(2) /* hack to get info from unwind to quitenv */
339
340 /* Do breaks/continues stop at env type e? */
341 #define STOP_BRKCONT(t) ((t) == E_NONE || (t) == E_PARSE \
342 || (t) == E_FUNC || (t) == E_INCL)
343 /* Do returns stop at env type e? */
344 #define STOP_RETURN(t) ((t) == E_FUNC || (t) == E_INCL)
345
346 /* values for ksh_siglongjmp(e->jbuf, 0) */
347 #define LRETURN 1 /* return statement */
348 #define LEXIT 2 /* exit statement */
349 #define LERROR 3 /* errorf() called */
350 #define LLEAVE 4 /* untrappable exit/error */
351 #define LINTR 5 /* ^C noticed */
352 #define LBREAK 6 /* break statement */
353 #define LCONTIN 7 /* continue statement */
354 #define LSHELL 8 /* return to interactive shell() */
355 #define LAEXPR 9 /* error in arithmetic expression */
356
357 /* option processing */
358 #define OF_CMDLINE 0x01 /* command line */
359 #define OF_SET 0x02 /* set builtin */
360 #define OF_SPECIAL 0x04 /* a special variable changing */
361 #define OF_INTERNAL 0x08 /* set internally by shell */
362 #define OF_ANY (OF_CMDLINE | OF_SET | OF_SPECIAL | OF_INTERNAL)
363
364 struct option {
365 const char *name; /* long name of option */
366 char c; /* character flag (if any) */
367 short flags; /* OF_* */
368 };
369 extern const struct option goptions[];
370
371 /*
372 * flags (the order of these enums MUST match the order in misc.c(options[]))
373 */
374 enum sh_flag {
375 FEXPORT = 0, /* -a: export all */
376 #ifdef BRACE_EXPAND
377 FBRACEEXPAND, /* enable {} globbing */
378 #endif
379 FBGNICE, /* bgnice */
380 FCOMMAND, /* -c: (invocation) execute specified command */
381 #ifdef EMACS
382 FEMACS, /* emacs command editing */
383 FEMACSUSEMETA, /* use 8th bit as meta */
384 #endif
385 FERREXIT, /* -e: quit on error */
386 #ifdef EMACS
387 FGMACS, /* gmacs command editing */
388 #endif
389 FIGNOREEOF, /* eof does not exit */
390 FTALKING, /* -i: interactive */
391 FKEYWORD, /* -k: name=value anywhere */
392 FLOGIN, /* -l: a login shell */
393 FMARKDIRS, /* mark dirs with / in file name completion */
394 FMONITOR, /* -m: job control monitoring */
395 FNOCLOBBER, /* -C: don't overwrite existing files */
396 FNOEXEC, /* -n: don't execute any commands */
397 FNOGLOB, /* -f: don't do file globbing */
398 FNOHUP, /* -H: don't kill running jobs when login shell exits */
399 FNOLOG, /* don't save functions in history (ignored) */
400 #ifdef JOBS
401 FNOTIFY, /* -b: asynchronous job completion notification */
402 #endif
403 FNOUNSET, /* -u: using an unset var is an error */
404 FPHYSICAL, /* -o physical: don't do logical cd's/pwd's */
405 FPOSIX, /* -o posix: be posixly correct */
406 FPRIVILEGED, /* -p: use suid_profile */
407 FRESTRICTED, /* -r: restricted shell */
408 FSTDIN, /* -s: (invocation) parse stdin */
409 FTRACKALL, /* -h: create tracked aliases for all commands */
410 FVERBOSE, /* -v: echo input */
411 #ifdef VI
412 FVI, /* vi command editing */
413 FVIRAW, /* always read in raw mode (ignored) */
414 FVISHOW8, /* display chars with 8th bit set as is (versus M-) */
415 FVITABCOMPLETE, /* enable tab as file name completion char */
416 FVIESCCOMPLETE, /* enable ESC as file name completion in command mode */
417 #endif
418 FXTRACE, /* -x: execution trace */
419 FTALKING_I, /* (internal): initial shell was interactive */
420 FNFLAGS /* (place holder: how many flags are there) */
421 };
422
423 #define Flag(f) (shell_flags[(int) (f)])
424
425 EXTERN char shell_flags [FNFLAGS];
426
427 EXTERN char null [] I__(""); /* null value for variable */
428 EXTERN char space [] I__(" ");
429 EXTERN char newline [] I__("\n");
430 EXTERN char slash [] I__("/");
431
432 enum temp_type {
433 TT_HEREDOC_EXP, /* expanded heredoc */
434 TT_HIST_EDIT /* temp file used for history editing (fc -e) */
435 };
436 typedef enum temp_type Temp_type;
437 /* temp/heredoc files. The file is removed when the struct is freed. */
438 struct temp {
439 struct temp *next;
440 struct shf *shf;
441 int pid; /* pid of process parsed here-doc */
442 Temp_type type;
443 char *name;
444 };
445
446 /*
447 * stdio and our IO routines
448 */
449
450 #define shl_spare (&shf_iob[0]) /* for c_read()/c_print() */
451 #define shl_stdout (&shf_iob[1])
452 #define shl_out (&shf_iob[2])
453 EXTERN int shl_stdout_ok;
454
455 /*
456 * trap handlers
457 */
458 typedef struct trap {
459 int signal; /* signal number */
460 const char *name; /* short name */
461 const char *mess; /* descriptive name */
462 char *trap; /* trap command */
463 int volatile set; /* trap pending */
464 int flags; /* TF_* */
465 handler_t cursig; /* current handler (valid if TF_ORIG_* set) */
466 handler_t shtrap; /* shell signal handler */
467 } Trap;
468
469 /* values for Trap.flags */
470 #define TF_SHELL_USES BIT(0) /* shell uses signal, user can't change */
471 #define TF_USER_SET BIT(1) /* user has (tried to) set trap */
472 #define TF_ORIG_IGN BIT(2) /* original action was SIG_IGN */
473 #define TF_ORIG_DFL BIT(3) /* original action was SIG_DFL */
474 #define TF_EXEC_IGN BIT(4) /* restore SIG_IGN just before exec */
475 #define TF_EXEC_DFL BIT(5) /* restore SIG_DFL just before exec */
476 #define TF_DFL_INTR BIT(6) /* when received, default action is LINTR */
477 #define TF_TTY_INTR BIT(7) /* tty generated signal (see j_waitj) */
478 #define TF_CHANGED BIT(8) /* used by runtrap() to detect trap changes */
479 #define TF_FATAL BIT(9) /* causes termination if not trapped */
480
481 /* values for setsig()/setexecsig() flags argument */
482 #define SS_RESTORE_MASK 0x3 /* how to restore a signal before an exec() */
483 #define SS_RESTORE_CURR 0 /* leave current handler in place */
484 #define SS_RESTORE_ORIG 1 /* restore original handler */
485 #define SS_RESTORE_DFL 2 /* restore to SIG_DFL */
486 #define SS_RESTORE_IGN 3 /* restore to SIG_IGN */
487 #define SS_FORCE BIT(3) /* set signal even if original signal ignored */
488 #define SS_USER BIT(4) /* user is doing the set (ie, trap command) */
489 #define SS_SHTRAP BIT(5) /* trap for internal use (CHLD,ALRM,WINCH) */
490
491 #define SIGEXIT_ 0 /* for trap EXIT */
492 #define SIGERR_ SIGNALS /* for trap ERR */
493
494 EXTERN int volatile trap; /* traps pending? */
495 EXTERN int volatile intrsig; /* pending trap interrupts executing command */
496 EXTERN int volatile fatal_trap;/* received a fatal signal */
497 extern Trap sigtraps[SIGNALS+1];
498
499 #ifdef KSH
500 /*
501 * TMOUT support
502 */
503 /* values for ksh_tmout_state */
504 enum tmout_enum {
505 TMOUT_EXECUTING = 0, /* executing commands */
506 TMOUT_READING, /* waiting for input */
507 TMOUT_LEAVING /* have timed out */
508 };
509 EXTERN unsigned int ksh_tmout;
510 EXTERN enum tmout_enum ksh_tmout_state I__(TMOUT_EXECUTING);
511 #endif /* KSH */
512
513 /* For "You have stopped jobs" message */
514 EXTERN int really_exit;
515
516 /*
517 * fast character classes
518 */
519 #define C_ALPHA BIT(0) /* a-z_A-Z */
520 #define C_DIGIT BIT(1) /* 0-9 */
521 #define C_LEX1 BIT(2) /* \0 \t\n|&;<>() */
522 #define C_VAR1 BIT(3) /* *@#!$-? */
523 #define C_IFSWS BIT(4) /* \t \n (IFS white space) */
524 #define C_SUBOP1 BIT(5) /* "=-+?" */
525 #define C_SUBOP2 BIT(6) /* "#%" */
526 #define C_IFS BIT(7) /* $IFS */
527 #define C_QUOTE BIT(8) /* \n\t"#$&'()*;<>?[\`| (needing quoting) */
528
529 extern short ctypes [];
530
531 #define ctype(c, t) !!(ctypes[(unsigned char)(c)]&(t))
532 #define letter(c) ctype(c, C_ALPHA)
533 #define digit(c) ctype(c, C_DIGIT)
534 #define letnum(c) ctype(c, C_ALPHA|C_DIGIT)
535
536 EXTERN int ifs0 I__(' '); /* for "$*" */
537
538 /* Argument parsing for built-in commands and getopts command */
539
540 /* Values for Getopt.flags */
541 #define GF_ERROR BIT(0) /* call errorf() if there is an error */
542 #define GF_PLUSOPT BIT(1) /* allow +c as an option */
543 #define GF_NONAME BIT(2) /* don't print argv[0] in errors */
544
545 /* Values for Getopt.info */
546 #define GI_MINUS BIT(0) /* an option started with -... */
547 #define GI_PLUS BIT(1) /* an option started with +... */
548 #define GI_MINUSMINUS BIT(2) /* arguments were ended with -- */
549
550 typedef struct {
551 int optind;
552 int uoptind;/* what user sees in $OPTIND */
553 char *optarg;
554 int flags; /* see GF_* */
555 int info; /* see GI_* */
556 unsigned int p; /* 0 or index into argv[optind - 1] */
557 char buf[2]; /* for bad option OPTARG value */
558 } Getopt;
559
560 EXTERN Getopt builtin_opt; /* for shell builtin commands */
561 EXTERN Getopt user_opt; /* parsing state for getopts builtin command */
562
563 #ifdef KSH
564 /* This for co-processes */
565
566 typedef INT32 Coproc_id; /* something that won't (realisticly) wrap */
567 struct coproc {
568 int read; /* pipe from co-process's stdout */
569 int readw; /* other side of read (saved temporarily) */
570 int write; /* pipe to co-process's stdin */
571 Coproc_id id; /* id of current output pipe */
572 int njobs; /* number of live jobs using output pipe */
573 void *job; /* 0 or job of co-process using input pipe */
574 };
575 EXTERN struct coproc coproc;
576 #endif /* KSH */
577
578 /* Used in jobs.c and by coprocess stuff in exec.c */
579 #ifdef JOB_SIGS
580 EXTERN sigset_t sm_default, sm_sigchld;
581 #endif /* JOB_SIGS */
582
583 extern char ksh_version[];
584
585 /* name of called builtin function (used by error functions) */
586 EXTERN char *builtin_argv0;
587 EXTERN Tflag builtin_flag; /* flags of called builtin (SPEC_BI, etc.) */
588
589 /* current working directory, and size of memory allocated for same */
590 EXTERN char *current_wd;
591 EXTERN int current_wd_size;
592
593 #ifdef EDIT
594 /* Minimum required space to work with on a line - if the prompt leaves less
595 * space than this on a line, the prompt is truncated.
596 */
597 # define MIN_EDIT_SPACE 7
598 /* Minimum allowed value for x_cols: 2 for prompt, 3 for " < " at end of line
599 */
600 # define MIN_COLS (2 + MIN_EDIT_SPACE + 3)
601 EXTERN int x_cols I__(80); /* tty columns */
602 #else
603 # define x_cols 80 /* for pr_menu(exec.c) */
604 #endif
605
606 /* These to avoid bracket matching problems */
607 #define OPAREN '('
608 #define CPAREN ')'
609 #define OBRACK '['
610 #define CBRACK ']'
611 #define OBRACE '{'
612 #define CBRACE '}'
613
614 /* Determine the location of the system (common) profile */
615 #ifndef KSH_SYSTEM_PROFILE
616 # ifdef __NeXT
617 # define KSH_SYSTEM_PROFILE "/etc/profile.std"
618 # else /* __NeXT */
619 # define KSH_SYSTEM_PROFILE "/etc/profile"
620 # endif /* __NeXT */
621 #endif /* KSH_SYSTEM_PROFILE */
622
623 /* Used by v_evaluate() and setstr() to control action when error occurs */
624 #define KSH_UNWIND_ERROR 0 /* unwind the stack (longjmp) */
625 #define KSH_RETURN_ERROR 1 /* return 1/0 for success/failure */
626
627 #include "shf.h"
628 #include "table.h"
629 #include "tree.h"
630 #include "expand.h"
631 #include "lex.h"
632 #include "proto.h"
633
634 /* be sure not to interfere with anyone else's idea about EXTERN */
635 #ifdef EXTERN_DEFINED
636 # undef EXTERN_DEFINED
637 # undef EXTERN
638 #endif
639 #undef I__
640