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