inet6: require RTF_ANNOUNCE to proxy NS
[dragonfly.git] / contrib / tcsh-6 / sh.h
blobc7b4a69cbbe966ff4f00d47ba4996f443dd75956
1 /*
2 * sh.h: Catch it all globals and includes file!
3 */
4 /*-
5 * Copyright (c) 1980, 1991 The Regents of the University of California.
6 * All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
32 #ifndef _h_sh
33 #define _h_sh
35 #include "config.h"
37 #include <stddef.h>
38 #include <signal.h>
40 #ifdef HAVE_ICONV
41 # include <iconv.h>
42 #endif
44 #ifdef HAVE_STDINT_H
45 # include <stdint.h>
46 #endif
48 #ifdef HAVE_INTTYPES_H
49 # include <inttypes.h>
50 #endif
52 #if !defined(HAVE_STDINT_H) && !defined(HAVE_INTTYPES_H) && !defined(WINNT_NATIVE)
53 typedef unsigned long intptr_t;
54 #endif
56 #ifndef EXTERN
57 # define EXTERN extern
58 #else /* !EXTERN */
59 # ifdef WINNT_NATIVE
60 # define IZERO = 0
61 # define IZERO_STRUCT = {0}
62 # endif /* WINNT_NATIVE */
63 #endif /* EXTERN */
65 #ifndef IZERO
66 # define IZERO
67 #endif /* IZERO */
68 #ifndef IZERO_STRUCT
69 # define IZERO_STRUCT
70 #endif /* IZERO_STRUCT */
72 #ifndef WINNT_NATIVE
73 # define INIT_ZERO
74 # define INIT_ZERO_STRUCT
75 # define force_read xread
76 #endif /*!WINNT_NATIVE */
78 #if defined(KANJI) && defined(WIDE_STRINGS) && defined(HAVE_NL_LANGINFO) && defined(CODESET)
79 #define AUTOSET_KANJI
80 #endif
83 * Sanity
85 #if defined(_POSIX_SOURCE) && !defined(POSIX)
86 # define POSIX
87 #endif
89 #if defined(POSIXJOBS) && !defined(BSDJOBS)
90 # define BSDJOBS
91 #endif
93 #define TMP_TEMPLATE ".XXXXXX"
95 #ifdef SHORT_STRINGS
96 # define TCSH_S "S"
97 # ifdef WIDE_STRINGS
98 #include <wchar.h>
99 # ifdef UTF16_STRINGS
100 typedef wint_t Char;
101 # else
102 typedef wchar_t Char;
103 # endif
104 typedef unsigned long uChar;
105 typedef wint_t eChar; /* Can contain any Char value or CHAR_ERR */
106 #define CHAR_ERR WEOF /* Pretty please, use bit 31... */
107 #define normal_mbtowc(PWC, S, N) rt_mbtowc(PWC, S, N)
108 #define reset_mbtowc() TCSH_IGNORE(mbtowc(NULL, NULL, 0))
109 # else
110 typedef short Char;
111 typedef unsigned short uChar;
112 typedef int eChar;
113 #define CHAR_ERR (-1)
114 #define normal_mbtowc(PWC, S, N) ((void)(N), *(PWC) = (unsigned char)*(S), 1)
115 #define reset_mbtowc() ((void)0)
116 # endif
117 # define SAVE(a) (Strsave(str2short(a)))
118 #else
119 #define TCSH_S "s"
120 typedef char Char;
121 typedef unsigned char uChar;
122 typedef int eChar;
123 #define CHAR_ERR (-1)
124 #define normal_mbtowc(PWC, S, N) ((void)(N), *(PWC) = (unsigned char)*(S), 1)
125 #define reset_mbtowc() ((void)0)
126 # define SAVE(a) (strsave(a))
127 #endif
129 #if !defined(__inline) && !defined(__GNUC__) && !defined(_MSC_VER)
130 #define __inline
131 #endif
132 #ifdef _MSC_VER
133 #define TCSH_PTRDIFF_T_FMT "I"
134 #else
135 #define TCSH_PTRDIFF_T_FMT "t"
136 #endif
137 /* Elide unused argument warnings */
138 #define USE(a) (void) (a)
139 #define TCSH_IGNORE(a) tcsh_ignore((intptr_t)a)
140 static __inline void tcsh_ignore(intptr_t a)
142 USE(a);
146 * Return true if the path is absolute
148 #if defined(WINNT_NATIVE)
149 # define ABSOLUTEP(p) ((p)[0] == '/' || \
150 (Isalpha((p)[0]) && (p)[1] == ':'))
151 #elif defined(__CYGWIN__)
152 # define ABSOLUTEP(p) ((p)[0] == '/' || \
153 (Isalpha((p)[0]) && (p)[1] == ':' && \
154 ((p)[2] == '\0' || (p)[2] == '/')))
155 #else /* !WINNT_NATIVE && !__CYGWIN__ */
156 # define ABSOLUTEP(p) (*(p) == '/')
157 #endif /* WINNT_NATIVE || __CYGWIN__ */
160 * Fundamental definitions which may vary from system to system.
162 * BUFSIZE The i/o buffering size; also limits word size
163 * MAILINTVL How often to mailcheck; more often is more expensive
165 #ifdef BUFSIZE
166 # if BUFSIZE < 4096
167 # undef BUFSIZE
168 # define BUFSIZE 4096 /* buffer size should be no less than this */
169 # endif
170 #else
171 # define BUFSIZE 4096
172 #endif /* BUFSIZE */
174 #define FORKSLEEP 10 /* delay loop on non-interactive fork failure */
175 #define MAILINTVL 600 /* 10 minutes */
177 #ifndef INBUFSIZE
178 # define INBUFSIZE 2*BUFSIZE /* Num input characters on the command line */
179 #endif /* INBUFSIZE */
183 * What our builtin echo looks like
185 #define NONE_ECHO 0
186 #define BSD_ECHO 1
187 #define SYSV_ECHO 2
188 #define BOTH_ECHO (BSD_ECHO|SYSV_ECHO)
190 #ifndef ECHO_STYLE
191 # if SYSVREL > 0
192 # define ECHO_STYLE SYSV_ECHO
193 # else /* SYSVREL == 0 */
194 # define ECHO_STYLE BSD_ECHO
195 # endif /* SYSVREL */
196 #endif /* ECHO_STYLE */
198 /* values for noclobber */
199 #define NOCLOBBER_DEFAULT 1
200 #define NOCLOBBER_NOTEMPTY 2
201 #define NOCLOBBER_ASK 4
204 * The shell moves std in/out/diag and the old std input away from units
205 * 0, 1, and 2 so that it is easy to set up these standards for invoked
206 * commands.
208 #define FSAFE 5 /* We keep the first 5 descriptors untouched */
209 #define FSHTTY 15 /* /dev/tty when manip pgrps */
210 #define FSHIN 16 /* Preferred desc for shell input */
211 #define FSHOUT 17 /* ... shell output */
212 #define FSHDIAG 18 /* ... shell diagnostics */
213 #define FOLDSTD 19 /* ... old std input */
215 #ifdef PROF
216 #define xexit(n) done(n)
217 #endif
219 #ifdef cray
220 # define word word_t /* sys/types.h defines word.. bad move! */
221 #endif
223 #include <sys/types.h>
225 #ifdef cray
226 # undef word
227 #endif
230 * Path separator in environment variables
232 #ifndef PATHSEP
233 # if defined(__EMX__) || defined(WINNT_NATIVE)
234 # define PATHSEP ';'
235 # else /* unix */
236 # define PATHSEP ':'
237 # endif /* __EMX__ || WINNT_NATIVE */
238 #endif /* !PATHSEP */
240 #if defined(__HP_CXD_SPP) && !defined(__hpux)
241 # include <sys/cnx_stat.h>
242 # define stat stat64
243 # define fstat fstat64
244 # define lstat lstat64
245 #endif /* __HP_CXD_SPP && !__hpux */
247 #ifdef HAVE_LONG_LONG
248 typedef long long tcsh_number_t;
249 #else
250 typedef long tcsh_number_t;
251 #endif
253 * This macro compares the st_dev field of struct stat. On aix on ibmESA
254 * st_dev is a structure, so comparison does not work.
256 #ifndef DEV_DEV_COMPARE
257 # define DEV_DEV_COMPARE(x,y) ((x) == (y))
258 #endif /* DEV_DEV_COMPARE */
260 #ifdef _SEQUENT_
261 # include <sys/procstats.h>
262 #endif /* _SEQUENT_ */
263 #if (defined(POSIX) || SYSVREL > 0) && !defined(WINNT_NATIVE)
264 # include <sys/times.h>
265 #endif /* (POSIX || SYSVREL > 0) && !WINNT_NATIVE */
267 #ifdef NLS
268 # include <locale.h>
269 #endif /* NLS */
271 #if !defined(_MINIX) && !defined(_VMS_POSIX) && !defined(WINNT_NATIVE) && !defined(__MVS__)
272 # include <sys/param.h>
273 #endif /* !_MINIX && !_VMS_POSIX && !WINNT_NATIVE && !__MVS__ */
274 #include <sys/stat.h>
276 #if defined(BSDTIMES) || defined(BSDLIMIT)
277 # include <sys/time.h>
278 # if SYSVREL>3 && !defined(SCO) && !defined(sgi) && !defined(SNI) && !defined(sun) && !(defined(__alpha) && defined(__osf__)) && !defined(_SX) && !defined(__MVS__)
279 # include "/usr/ucbinclude/sys/resource.h"
280 # else
281 # ifdef convex
282 # define sysrusage cvxrusage
283 # include <sys/sysinfo.h>
284 # else
285 # define sysrusage rusage
286 # include <sys/resource.h>
287 # endif /* convex */
288 # endif /* SYSVREL>3 */
289 #endif /* BSDTIMES */
291 #ifndef WINNT_NATIVE
292 # ifndef POSIX
293 # ifdef TERMIO
294 # include <termio.h>
295 # else /* SGTTY */
296 # include <sgtty.h>
297 # endif /* TERMIO */
298 # else /* POSIX */
299 # ifndef _UWIN
300 # include <termios.h>
301 # else
302 # include <termio.h>
303 # endif /* _UWIN */
304 # if SYSVREL > 3 || defined(__linux__)
305 # undef TIOCGLTC /* we don't need those, since POSIX has them */
306 # undef TIOCSLTC
307 # undef CSWTCH
308 # define CSWTCH _POSIX_VDISABLE /* So job control works */
309 # endif /* SYSVREL > 3 */
310 # endif /* POSIX */
311 #endif /* WINNT_NATIVE */
313 #ifdef sonyrisc
314 # include <sys/ttold.h>
315 #endif /* sonyrisc */
317 #if defined(POSIX) && !defined(WINNT_NATIVE)
318 # include <unistd.h>
321 * the gcc+protoize version of <stdlib.h>
322 * redefines malloc(), so we define the following
323 * to avoid it.
325 # if defined(SYSMALLOC) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__) || defined(sgi) || defined(_OSD_POSIX) || defined(__OpenBSD__)
326 # define NO_FIX_MALLOC
327 # include <stdlib.h>
328 # else /* glibc */
329 # define _GNU_STDLIB_H
330 # define malloc __malloc
331 # define free __free
332 # define calloc __calloc
333 # define realloc __realloc
334 # include <stdlib.h>
335 # undef malloc
336 # undef free
337 # undef calloc
338 # undef realloc
339 # endif /* glibc || sgi */
340 #endif /* POSIX && !WINNT_NATIVE */
341 #include <limits.h>
343 #if SYSVREL > 0 || defined(_IBMR2) || defined(_MINIX) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)
344 # if !defined(pyr) && !defined(stellar)
345 # include <time.h>
346 # ifdef _MINIX
347 # define HZ CLOCKS_PER_SEC
348 # endif /* _MINIX */
349 # endif /* !pyr && !stellar */
350 #endif /* SYSVREL > 0 || _IBMR2 */
352 /* In the following ifdef the DECOSF1 has been commented so that later
353 * versions of DECOSF1 will get TIOCGWINSZ. This might break older versions...
355 #if !((defined(SUNOS4) || defined(_MINIX) /* || defined(DECOSF1) */) && defined(TERMIO))
356 # if !defined(_VMS_POSIX) && !defined(WINNT_NATIVE)
357 # include <sys/ioctl.h>
358 # if SYSVREL > 3 || defined(__linux__)
359 # undef TIOCGLTC /* we don't need those, since POSIX has them */
360 # undef TIOCSLTC
361 # undef CSWTCH
362 # define CSWTCH _POSIX_VDISABLE /* So job control works */
363 # endif /* SYSVREL > 3 */
364 # endif
365 #endif
367 #if (defined(__DGUX__) && defined(POSIX)) || defined(DGUX)
368 #undef CSWTCH
369 #define CSWTCH _POSIX_VDISABLE
370 #endif
372 #if (!defined(FIOCLEX) && defined(SUNOS4)) || ((SYSVREL == 4) && !defined(_SEQUENT_) && !defined(SCO) && !defined(_SX)) && !defined(__MVS__)
373 # include <sys/filio.h>
374 #endif /* (!FIOCLEX && SUNOS4) || (SYSVREL == 4 && !_SEQUENT_ && !SCO && !_SX ) */
376 #if !defined(_MINIX) && !defined(supermax) && !defined(WINNT_NATIVE) && !defined(IRIS4D)
377 # include <sys/file.h>
378 #endif /* !_MINIX && !supermax && !WINNT_NATIVE && !defined(IRIS4D) */
380 #if !defined(O_RDONLY) || !defined(O_NDELAY)
381 # include <fcntl.h>
382 #endif
384 #include <errno.h>
386 #include <setjmp.h>
388 #include <stdarg.h>
390 #ifdef HAVE_DIRENT_H
391 # include <dirent.h>
392 #else
393 # ifdef HAVE_NDIR_H
394 # include <ndir.h>
395 # else
396 # include <sys/dir.h>
397 # endif
398 # define dirent direct
399 #endif /* HAVE_DIRENT_H */
400 #ifndef HAVE_STRUCT_DIRENT_D_INO
401 # define d_ino d_fileno
402 #endif
403 #if defined(hpux) || defined(sgi) || defined(OREO)
404 # include <stdio.h> /* So the fgetpwent() prototypes work */
405 #endif /* hpux || sgi || OREO */
406 #ifndef WINNT_NATIVE
407 #include <pwd.h>
408 #include <grp.h>
409 #endif /* WINNT_NATIVE */
410 #ifdef HAVE_SHADOW_H
411 # include <shadow.h>
412 #endif /* HAVE_SHADOW_H */
413 #ifdef HAVE_AUTH_H
414 # include <auth.h>
415 #endif /* HAVE_AUTH_H */
416 #if defined(BSD) && !defined(POSIX)
417 # include <strings.h>
418 # define strchr(a, b) index(a, b)
419 # define strrchr(a, b) rindex(a, b)
420 #else
421 # include <string.h>
422 #endif /* BSD */
425 * IRIX-5.0 has <sys/cdefs.h>, but most system include files do not
426 * include it yet, so we include it here
428 #if defined(sgi) && SYSVREL > 3
429 # include <sys/cdefs.h>
430 #endif /* sgi && SYSVREL > 3 */
432 #ifdef REMOTEHOST
433 # ifdef ISC
434 # undef MAXHOSTNAMELEN /* Busted headers? */
435 # endif
437 # include <netinet/in.h>
438 # include <arpa/inet.h>
439 # include <sys/socket.h>
440 # if (defined(_SS_SIZE) || defined(_SS_MAXSIZE)) && defined(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY)
441 # if !defined(__APPLE__) /* Damnit, where is getnameinfo() folks? */
442 # if !defined(sgi)
443 # define INET6
444 # endif /* sgi */
445 # endif /* __APPLE__ */
446 # endif
447 # include <sys/uio.h> /* For struct iovec */
448 #endif /* REMOTEHOST */
450 #ifdef PURIFY
451 /* exit normally, allowing purify to trace leaks */
452 # define _exit exit
453 #endif /* !PURIFY */
456 * ASCII vs. EBCDIC
458 #if 'Z' - 'A' == 25
459 # ifndef IS_ASCII
460 # define IS_ASCII
461 # endif
462 #endif
464 #include "sh.types.h"
466 #if !HAVE_DECL_GETPGRP
467 # ifndef GETPGRP_VOID
468 extern pid_t getpgrp (int);
469 # else
470 extern pid_t getpgrp (void);
471 # endif
472 #endif
474 #ifndef lint
475 typedef ptr_t memalign_t;
476 #else
477 typedef union {
478 char am_char, *am_char_p;
479 short am_short, *am_short_p;
480 int am_int, *am_int_p;
481 long am_long, *am_long_p;
482 float am_float, *am_float_p;
483 double am_double, *am_double_p;
484 } *memalign_t;
486 # define malloc lint_malloc
487 # define free lint_free
488 # define realloc lint_realloc
489 # define calloc lint_calloc
490 #endif
492 #ifdef SYSMALLOC
493 # define xmalloc(i) smalloc(i)
494 # define xrealloc(p, i) srealloc(p, i)
495 # define xcalloc(n, s) scalloc(n, s)
496 # define xfree sfree
497 #else
498 # define xmalloc(i) malloc(i)
499 # define xrealloc(p, i) realloc(p, i)
500 # define xcalloc(n, s) calloc(n, s)
501 # define xfree free
502 #endif /* SYSMALLOC */
503 #include "sh.char.h"
504 #include "sh.err.h"
505 #include "sh.dir.h"
506 #include "sh.proc.h"
508 #include "pathnames.h"
512 * C shell
514 * Bill Joy, UC Berkeley
515 * October, 1978; May 1980
517 * Jim Kulp, IIASA, Laxenburg Austria
518 * April, 1980
521 #ifdef HESIOD
522 # include <hesiod.h>
523 #endif /* HESIOD */
525 #ifdef REMOTEHOST
526 # include <netdb.h>
527 #endif /* REMOTEHOST */
529 #ifndef MAXHOSTNAMELEN
530 # ifdef HOST_NAME_MAX
531 # define MAXHOSTNAMELEN (HOST_NAME_MAX + 1)
532 # elif defined(SCO) && (SYSVREL > 3)
533 # include <sys/socket.h>
534 # else
535 # define MAXHOSTNAMELEN 256
536 # endif
537 #endif /* MAXHOSTNAMELEN */
541 #define eq(a, b) (Strcmp(a, b) == 0)
543 /* globone() flags */
544 #define G_ERROR 0 /* default action: error if multiple words */
545 #define G_IGNORE 1 /* ignore the rest of the words */
546 #define G_APPEND 2 /* make a sentence by cat'ing the words */
549 * Global flags
551 EXTERN int chkstop IZERO; /* Warned of stopped jobs... allow exit */
553 #if (defined(FIOCLEX) && defined(FIONCLEX)) || defined(F_SETFD)
554 # define CLOSE_ON_EXEC
555 #else
556 EXTERN int didcch IZERO; /* Have closed unused fd's for child */
557 #endif /* (FIOCLEX && FIONCLEX) || F_SETFD */
559 EXTERN int didfds IZERO; /* Have setup i/o fd's for child */
560 EXTERN int doneinp IZERO; /* EOF indicator after reset from readc */
561 EXTERN int exiterr IZERO; /* Exit if error or non-zero exit status */
562 EXTERN int child IZERO; /* Child shell ... errors cause exit */
563 EXTERN int haderr IZERO; /* Reset was because of an error */
564 EXTERN int intty IZERO; /* Input is a tty */
565 EXTERN int intact IZERO; /* We are interactive... therefore prompt */
566 EXTERN int justpr IZERO; /* Just print because of :p hist mod */
567 EXTERN int loginsh IZERO; /* We are a loginsh -> .login/.logout */
568 EXTERN int neednote IZERO; /* Need to pnotify() */
569 EXTERN int noexec IZERO; /* Don't execute, just syntax check */
570 EXTERN int pjobs IZERO; /* want to print jobs if interrupted */
571 EXTERN int setintr IZERO; /* Set interrupts on/off -> Wait intr... */
572 EXTERN int handle_interrupt IZERO;/* Are we currently handling an interrupt? */
573 EXTERN int havhash IZERO; /* path hashing is available */
574 EXTERN int editing IZERO; /* doing filename expansion and line editing */
575 EXTERN int noediting IZERO; /* initial $term defaulted to noedit */
576 EXTERN int bslash_quote IZERO;/* PWP: tcsh-style quoting? (in sh.c) */
577 EXTERN int anyerror IZERO; /* propagate errors from pipelines/backq */
578 EXTERN int compat_expr IZERO;/* csh-style expressions? */
579 EXTERN int isoutatty IZERO; /* is SHOUT a tty */
580 EXTERN int isdiagatty IZERO;/* is SHDIAG a tty */
581 EXTERN int is1atty IZERO; /* is file descriptor 1 a tty (didfds mode) */
582 EXTERN int is2atty IZERO; /* is file descriptor 2 a tty (didfds mode) */
583 EXTERN int arun IZERO; /* Currently running multi-line-aliases */
584 EXTERN int implicit_cd IZERO;/* implicit cd enabled?(1=enabled,2=verbose) */
585 EXTERN int cdtohome IZERO; /* cd without args goes home */
586 EXTERN int inheredoc IZERO; /* Currently parsing a heredoc */
587 EXTERN int no_clobber IZERO; /* no clobber enabled? 1=yes 2=notempty, 4=ask*/
588 /* We received a window change event */
589 EXTERN volatile sig_atomic_t windowchg IZERO;
590 #if defined(KANJI) && defined(SHORT_STRINGS) && defined(DSPMBYTE)
591 EXTERN int dspmbyte_ls;
592 #endif
595 * Global i/o info
597 EXTERN Char *arginp IZERO; /* Argument input for sh -c and internal `xx` */
598 EXTERN int onelflg IZERO; /* 2 -> need line for -t, 1 -> exit on read */
599 extern Char *ffile; /* Name of shell file for $0 */
600 extern int dolzero; /* if $?0 should return true... */
602 extern char *seterr; /* Error message from scanner/parser */
603 #ifndef errno
604 extern int errno; /* Error from C library routines */
605 #endif
606 extern int exitset;
607 /* Temp name for << shell files in /tmp, for xfree() */
608 EXTERN Char *shtemp IZERO;
610 #ifdef BSDTIMES
611 EXTERN struct timeval time0; /* Time at which the shell started */
612 EXTERN struct sysrusage ru0;
613 #else
614 # ifdef _SEQUENT_
615 EXTERN timeval_t time0; /* time at which shell started */
616 EXTERN struct process_stats ru0;
617 # else /* _SEQUENT_ */
618 # ifndef POSIX
619 EXTERN time_t time0; /* time at which shell started */
620 # else /* POSIX */
621 EXTERN clock_t time0; /* time at which shell started */
622 EXTERN clock_t clk_tck;
623 # endif /* POSIX */
624 EXTERN struct tms shtimes; /* shell and child times for process timing */
625 # endif /* _SEQUENT_ */
626 EXTERN time_t seconds0;
627 #endif /* BSDTIMES */
629 #ifndef HZ
630 # define HZ 100 /* for division into seconds */
631 #endif
634 * Miscellany
636 EXTERN pid_t mainpid; /* pid of the main shell ($$) */
637 EXTERN Char *doldol; /* Character pid for $$ */
638 EXTERN pid_t backpid; /* pid of the last background job */
642 * Ideally these should be uid_t, gid_t, pid_t. I cannot do that right now
643 * cause pid's could be unsigned and that would break our -1 flag, and
644 * uid_t and gid_t are not defined in all the systems so I would have to
645 * make special cases for them. In the future...
647 EXTERN uid_t uid, euid; /* Invokers real and effective */
648 EXTERN gid_t gid, egid; /* User and group ids */
649 EXTERN pid_t opgrp, /* Initial pgrp and tty pgrp */
650 shpgrp, /* Pgrp of shell */
651 tpgrp; /* Terminal process group */
652 /* If tpgrp is -1, leave tty alone! */
654 EXTERN Char *Prompt; /* The actual printed prompt or NULL */
655 EXTERN Char *RPrompt; /* Right-hand side prompt or NULL */
658 * To be able to redirect i/o for builtins easily, the shell moves the i/o
659 * descriptors it uses away from 0,1,2.
660 * Ideally these should be in units which are closed across exec's
661 * (this saves work) but for version 6, this is not usually possible.
662 * The desired initial values for these descriptors are defined in
663 * sh.local.h.
665 EXTERN int SHIN IZERO; /* Current shell input (script) */
666 EXTERN int SHOUT IZERO; /* Shell output */
667 EXTERN int SHDIAG IZERO; /* Diagnostic output... shell errs go here */
668 EXTERN int OLDSTD IZERO; /* Old standard input (def for cmds) */
671 #if (SYSVREL == 4 && defined(_UTS)) || defined(__linux__)
673 * From: fadden@uts.amdahl.com (Andy McFadden)
674 * we need sigsetjmp for UTS4, but not UTS2.1
676 # define SIGSETJMP
677 #endif
680 * Error control
682 * Errors in scanning and parsing set up an error message to be printed
683 * at the end and complete. Other errors always cause a reset.
684 * Because of source commands and .cshrc we need nested error catches.
687 #ifdef SIGSETJMP
688 typedef struct { const char *f; size_t l; sigjmp_buf j; } jmp_buf_t;
689 # define tcsh_setjmp() sigsetjmp(reslab.j, 1)
690 # define tcsh_longjmp() siglongjmp(reslab.j, 1)
691 #else
692 typedef struct { const char *f; size_t l; jmp_buf j; } jmp_buf_t;
693 # define tcsh_setjmp() setjmp(reslab.j)
694 # define tcsh_longjmp() longjmp(reslab.j, 1)
695 #endif
697 #define setexit() (reslab.f = __func__, \
698 reslab.l = __LINE__, \
699 tcsh_setjmp())
700 #ifdef SETJMP_DEBUG
701 # define _reset() xprintf("reset %s %zu\n", reslab.f, reslab.l), \
702 flush(), tcsh_longjmp()
703 #else
704 # define _reset() tcsh_longjmp()
705 #endif
707 #define getexit(a) (void) ((a) = reslab)
708 #define resexit(a) (void) (reslab = (a))
710 #define cpybin(a, b) (void) ((a) = (b))
712 extern jmp_buf_t reslab;
714 EXTERN Char *gointr; /* Label for an onintr transfer */
716 extern struct sigaction parintr; /* Parents interrupt catch */
717 extern struct sigaction parterm; /* Parents terminate catch */
720 * Lexical definitions.
722 * All lexical space is allocated dynamically.
723 * The eighth/sixteenth bit of characters is used to prevent recognition,
724 * and eventually stripped.
726 #define META 0200
727 #define ASCII 0177
728 #ifdef WIDE_STRINGS /* Implies SHORT_STRINGS */
729 /* 31st char bit used for 'ing (not 32nd, we want all values nonnegative) */
731 * Notice
733 * By fix for handling unicode name file, 32nd bit is used.
734 * We need use '&' instead of '> or <' when comparing with INVALID_BYTE etc..
735 * Cast to uChar is not recommended,
736 * becase Char is 4bytes but uChar is 8bytes on I32LP64. */
737 # define QUOTE 0x80000000
738 # define TRIM 0x7FFFFFFF /* Mask to strip quote bit */
739 # define UNDER 0x08000000 /* Underline flag */
740 # define BOLD 0x04000000 /* Bold flag */
741 # define STANDOUT 0x02000000 /* Standout flag */
742 # define LITERAL 0x01000000 /* Literal character flag */
743 # define ATTRIBUTES 0x0F000000 /* The bits used for attributes */
744 # define INVALID_BYTE 0xF0000000 /* Invalid character on input */
745 # ifdef SOLARIS2
746 # define CHAR 0x30FFFFFF /* Mask to mask out the character */
747 # else
748 # define CHAR 0x00FFFFFF /* Mask to mask out the character */
749 # endif
750 #elif defined (SHORT_STRINGS)
751 # define QUOTE ((Char) 0100000)/* 16nth char bit used for 'ing */
752 # define TRIM 0073777 /* Mask to strip quote/lit bit */
753 # define UNDER 0040000 /* Underline flag */
754 # define BOLD 0020000 /* Bold flag */
755 # define STANDOUT 0010000 /* Standout flag */
756 # define LITERAL 0004000 /* Literal character flag */
757 # define ATTRIBUTES 0074000 /* The bits used for attributes */
758 # define INVALID_BYTE 0
759 # define CHAR 0000377 /* Mask to mask out the character */
760 #else
761 # define QUOTE ((Char) 0200) /* Eighth char bit used for 'ing */
762 # define TRIM 0177 /* Mask to strip quote bit */
763 # define UNDER 0000000 /* No extra bits to do both */
764 # define BOLD 0000000 /* Bold flag */
765 # define STANDOUT META /* Standout flag */
766 # define LITERAL 0000000 /* Literal character flag */
767 # define ATTRIBUTES 0200 /* The bits used for attributes */
768 # define INVALID_BYTE 0
769 # define CHAR 0000177 /* Mask to mask out the character */
770 #endif
771 #define CHAR_DBWIDTH (LITERAL|(LITERAL-1))
773 # define MAX_UTF32 0x7FFFFFFF /* max UTF32 is U+7FFFFFFF */
775 EXTERN int AsciiOnly; /* If set only 7 bits expected in characters */
778 * Each level of input has a buffered input structure.
779 * There are one or more blocks of buffered input for each level,
780 * exactly one if the input is seekable and tell is available.
781 * In other cases, the shell buffers enough blocks to keep all loops
782 * in the buffer.
784 * If (WIDE_STRINGS && cantell), fbobp is always a byte offset, but
785 * (fseekp - fbobp) and (feobp - fbobp) are character offsets (usable for
786 * fbuf indexing).
788 * If (!cantell), all offsets are character offsets; if (!WIDE_STRINGS), there
789 * is no difference between byte and character offsets.
791 EXTERN struct Bin {
792 off_t Bfseekp; /* Seek pointer, generally != lseek() value */
793 off_t Bfbobp; /* Seekp of beginning of buffers */
794 off_t Bfeobp; /* Seekp of end of buffers */
795 int Bfblocks; /* Number of buffer blocks */
796 Char **Bfbuf; /* The array of buffer blocks */
797 #ifdef WIDE_STRINGS
798 /* Number of bytes in each character if (cantell) */
799 unsigned char Bfclens[BUFSIZE + 1];
800 #endif
801 } B;
804 * This structure allows us to seek inside aliases
806 struct Ain {
807 int type;
808 #define TCSH_I_SEEK 0 /* Invalid seek */
809 #define TCSH_A_SEEK 1 /* Alias seek */
810 #define TCSH_F_SEEK 2 /* File seek */
811 #define TCSH_E_SEEK 3 /* Eval seek */
812 union {
813 off_t _f_seek; /* A byte offset if (cantell) */
814 Char* _c_seek;
815 } fc;
816 #define f_seek fc._f_seek
817 #define c_seek fc._c_seek
818 Char **a_seek;
821 extern int aret; /* Type of last char returned */
822 #define SEEKEQ(a, b) ((a)->type == (b)->type && \
823 (a)->f_seek == (b)->f_seek && \
824 (a)->a_seek == (b)->a_seek)
826 #define fseekp B.Bfseekp
827 #define fbobp B.Bfbobp
828 #define feobp B.Bfeobp
829 #define fblocks B.Bfblocks
830 #define fbuf B.Bfbuf
831 #define fclens B.Bfclens
834 * The shell finds commands in loops by reseeking the input
835 * For whiles, in particular, it reseeks to the beginning of the
836 * line the while was on; hence the while placement restrictions.
838 EXTERN struct Ain lineloc;
840 EXTERN int cantell; /* Is current source tellable ? */
843 * Input lines are parsed into doubly linked circular
844 * lists of words of the following form.
846 struct wordent {
847 Char *word;
848 struct wordent *prev;
849 struct wordent *next;
853 * During word building, both in the initial lexical phase and
854 * when expanding $ variable substitutions, expansion by `!' and `$'
855 * must be inhibited when reading ahead in routines which are themselves
856 * processing `!' and `$' expansion or after characters such as `\' or in
857 * quotations. The following flags are passed to the getC routines
858 * telling them which of these substitutions are appropriate for the
859 * next character to be returned.
861 #define DODOL 1
862 #define DOEXCL 2
863 #define DOALL DODOL|DOEXCL
866 * Labuf implements a general buffer for lookahead during lexical operations.
867 * Text which is to be placed in the input stream can be stuck here.
868 * We stick parsed ahead $ constructs during initial input,
869 * process id's from `$$', and modified variable values (from qualifiers
870 * during expansion in sh.dol.c) here.
872 extern struct Strbuf labuf;
873 EXTERN size_t lap; /* N/A if == labuf.len, index into labuf.s otherwise */
876 * Parser structure
878 * Each command is parsed to a tree of command structures and
879 * flags are set bottom up during this process, to be propagated down
880 * as needed during the semantics/exeuction pass (sh.sem.c).
882 struct command {
883 unsigned char t_dtyp; /* Type of node */
884 #define NODE_COMMAND 1 /* t_dcom <t_dlef >t_drit */
885 #define NODE_PAREN 2 /* ( t_dspr ) <t_dlef >t_drit */
886 #define NODE_PIPE 3 /* t_dlef | t_drit */
887 #define NODE_LIST 4 /* t_dlef ; t_drit */
888 #define NODE_OR 5 /* t_dlef || t_drit */
889 #define NODE_AND 6 /* t_dlef && t_drit */
890 unsigned char t_nice; /* Nice value */
891 #ifdef apollo
892 unsigned char t_systype; /* System environment */
893 #endif
894 unsigned long t_dflg; /* Flags, e.g. F_AMPERSAND|... */
895 /* save these when re-doing */
896 #ifndef apollo
897 #define F_SAVE (F_NICE|F_TIME|F_NOHUP|F_HUP)
898 #else
899 #define F_SAVE (F_NICE|F_TIME|F_NOHUP||F_HUP|F_VER)
900 #endif
901 #define F_AMPERSAND (1<<0) /* executes in background */
902 #define F_APPEND (1<<1) /* output is redirected >> */
903 #define F_PIPEIN (1<<2) /* input is a pipe */
904 #define F_PIPEOUT (1<<3) /* output is a pipe */
905 #define F_NOFORK (1<<4) /* don't fork, last ()ized cmd */
906 #define F_NOINTERRUPT (1<<5) /* should be immune from intr's */
907 /* spare */
908 #define F_STDERR (1<<7) /* redirect unit 2 with unit 1 */
909 #define F_OVERWRITE (1<<8) /* output was ! */
910 #define F_READ (1<<9) /* input redirection is << */
911 #define F_REPEAT (1<<10) /* reexec aft if, repeat,... */
912 #define F_NICE (1<<11) /* t_nice is meaningful */
913 #define F_NOHUP (1<<12) /* nohup this command */
914 #define F_TIME (1<<13) /* time this command */
915 #define F_BACKQ (1<<14) /* command is in `` */
916 #define F_HUP (1<<15) /* hup this command */
917 #ifdef apollo
918 #define F_VER (1<<16) /* execute command under SYSTYPE */
919 #endif
920 union {
921 Char *T_dlef; /* Input redirect word */
922 struct command *T_dcar; /* Left part of list/pipe */
923 } L;
924 union {
925 Char *T_drit; /* Output redirect word */
926 struct command *T_dcdr; /* Right part of list/pipe */
927 } R;
928 #define t_dlef L.T_dlef
929 #define t_dcar L.T_dcar
930 #define t_drit R.T_drit
931 #define t_dcdr R.T_dcdr
932 Char **t_dcom; /* Command/argument vector */
933 struct command *t_dspr; /* Pointer to ()'d subtree */
938 * The keywords for the parser
940 #define TC_BREAK 0
941 #define TC_BRKSW 1
942 #define TC_CASE 2
943 #define TC_DEFAULT 3
944 #define TC_ELSE 4
945 #define TC_END 5
946 #define TC_ENDIF 6
947 #define TC_ENDSW 7
948 #define TC_EXIT 8
949 #define TC_FOREACH 9
950 #define TC_GOTO 10
951 #define TC_IF 11
952 #define TC_LABEL 12
953 #define TC_LET 13
954 #define TC_SET 14
955 #define TC_SWITCH 15
956 #define TC_TEST 16
957 #define TC_THEN 17
958 #define TC_WHILE 18
961 * These are declared here because they want to be
962 * initialized in sh.init.c (to allow them to be made readonly)
965 #if defined(hpux) && defined(__STDC__) && !defined(__GNUC__)
966 /* Avoid hpux ansi mode spurious warnings */
967 typedef void (*bfunc_t) ();
968 #else
969 typedef void (*bfunc_t) (Char **, struct command *);
970 #endif /* hpux && __STDC__ && !__GNUC__ */
972 extern const struct biltins {
973 const char *bname;
974 bfunc_t bfunct;
975 int minargs, maxargs;
976 } bfunc[];
977 extern int nbfunc;
978 #ifdef WINNT_NATIVE
979 extern struct biltins nt_bfunc[];
980 extern int nt_nbfunc;
981 #endif /* WINNT_NATIVE*/
982 extern int bequiet;
984 extern struct srch {
985 const char *s_name;
986 int s_value;
987 } srchn[];
988 extern int nsrchn;
991 * Structure defining the existing while/foreach loops at this
992 * source level. Loops are implemented by seeking back in the
993 * input. For foreach (fe), the word list is attached here.
995 EXTERN struct whyle {
996 struct Ain w_start; /* Point to restart loop */
997 struct Ain w_end; /* End of loop (0 if unknown) */
998 Char **w_fe, **w_fe0; /* Current/initial wordlist for fe */
999 Char *w_fename; /* Name for fe */
1000 struct whyle *w_next; /* Next (more outer) loop */
1001 } *whyles;
1004 * Variable structure
1006 * Aliases and variables are stored in AVL balanced binary trees.
1008 EXTERN struct varent {
1009 Char **vec; /* Array of words which is the value */
1010 Char *v_name; /* Name of variable/alias */
1011 int v_flags; /* Flags */
1012 #define VAR_ALL -1
1013 #define VAR_READONLY 1
1014 #define VAR_READWRITE 2
1015 #define VAR_NOGLOB 4
1016 #define VAR_NOERROR 8
1017 #define VAR_FIRST 32
1018 #define VAR_LAST 64
1019 struct varent *v_link[3]; /* The links, see below */
1020 int v_bal; /* Balance factor */
1021 } shvhed IZERO_STRUCT, aliases IZERO_STRUCT;
1023 #define v_left v_link[0]
1024 #define v_right v_link[1]
1025 #define v_parent v_link[2]
1027 #define adrof(v) adrof1(v, &shvhed)
1028 #define varval(v) value1(v, &shvhed)
1031 * The following are for interfacing redo substitution in
1032 * aliases to the lexical routines.
1034 #define HIST_PURGE -500000
1035 EXTERN struct wordent *alhistp IZERO_STRUCT;/* Argument list (first) */
1036 EXTERN struct wordent *alhistt IZERO_STRUCT;/* Node after last in arg list */
1037 EXTERN Char **alvec IZERO_STRUCT,
1038 *alvecp IZERO_STRUCT;/* The (remnants of) alias vector */
1041 * Filename/command name expansion variables
1044 #ifndef MAXPATHLEN
1045 # ifdef PATH_MAX
1046 # define MAXPATHLEN PATH_MAX
1047 # else
1048 # define MAXPATHLEN 2048
1049 # endif
1050 #endif /* MAXPATHLEN */
1052 #ifndef HAVENOLIMIT
1054 * resource limits
1056 extern struct limits {
1057 int limconst;
1058 const char *limname;
1059 int limdiv;
1060 const char *limscale;
1061 } limits[];
1062 #endif /* !HAVENOLIMIT */
1065 * History list
1067 * Each history list entry contains an embedded wordlist
1068 * from the scanner, a number for the event, and a reference count
1069 * to aid in discarding old entries.
1071 * Essentially "invisible" entries are put on the history list
1072 * when history substitution includes modifiers, and thrown away
1073 * at the next discarding since their event numbers are very negative.
1075 EXTERN struct Hist {
1076 struct wordent Hlex;
1077 int Hnum; /* eventno when inserted into history list */
1078 int Href;
1079 time_t Htime;
1080 Char *histline;
1081 struct Hist *Hnext, *Hprev; /* doubly linked list */
1082 unsigned Hhash; /* hash value of command line */
1083 } Histlist IZERO_STRUCT;
1085 extern struct wordent paraml; /* Current lexical word list */
1086 EXTERN int eventno; /* Next events number */
1087 EXTERN int lastev; /* Last event reference (default) */
1089 EXTERN Char HIST; /* history invocation character */
1090 EXTERN Char HISTSUB; /* auto-substitute character */
1091 EXTERN Char PRCH; /* Prompt symbol for regular users */
1092 EXTERN Char PRCHROOT; /* Prompt symbol for root */
1095 * For operating systems with single case filenames (OS/2)
1097 #ifdef CASE_INSENSITIVE
1098 # ifdef WIDE_STRINGS
1099 # define samecase(x) (towlower(x))
1100 # else
1101 # define samecase(x) (isupper((unsigned char)(x)) ? \
1102 tolower((unsigned char)(x)) : (x))
1103 # endif
1104 #else
1105 # define samecase(x) (x)
1106 #endif /* CASE_INSENSITIVE */
1109 * strings.h:
1111 #ifndef SHORT_STRINGS
1112 #define Strchr(a, b) strchr(a, b)
1113 #define Strrchr(a, b) strrchr(a, b)
1114 #define Strcat(a, b) strcat(a, b)
1115 #define Strncat(a, b, c) strncat(a, b, c)
1116 #define Strcpy(a, b) strcpy(a, b)
1117 #define Strncpy(a, b, c) strncpy(a, b, c)
1118 #define Strlen(a) strlen(a)
1119 #define Strcmp(a, b) strcmp(a, b)
1120 #define Strncmp(a, b, c) strncmp(a, b, c)
1121 #define Strcasecmp(a, b) strcasecmp(a, b)
1123 #define Strspl(a, b) strspl(a, b)
1124 #define Strnsave(a, b) strnsave(a, b)
1125 #define Strsave(a) strsave(a)
1126 #define Strend(a) strend(a)
1127 #define Strstr(a, b) strstr(a, b)
1129 #define str2short(a) ((void *)(intptr_t)(a))
1130 #define blk2short(a) saveblk(a)
1131 #define short2blk(a) saveblk(a)
1132 #define short2str(a) caching_strip(a)
1133 #else
1134 #if defined(WIDE_STRINGS) && !defined(UTF16_STRINGS)
1135 #define Strchr(a, b) wcschr(a, b)
1136 #define Strrchr(a, b) wcsrchr(a, b)
1137 #define Strcat(a, b) wcscat(a, b)
1138 #define Strncat(a, b, c) wcsncat(a, b, c)
1139 #define Strcpy(a, b) wcscpy(a, b)
1140 #define Strncpy(a, b, c) wcsncpy(a, b, c)
1141 #define Strlen(a) wcslen(a)
1142 #define Strcmp(a, b) wcscmp(a, b)
1143 #define Strncmp(a, b, c) wcsncmp(a, b, c)
1144 #else
1145 #define Strchr(a, b) s_strchr(a, b)
1146 #define Strrchr(a, b) s_strrchr(a, b)
1147 #define Strcat(a, b) s_strcat(a, b)
1148 #define Strncat(a, b, c) s_strncat(a, b, c)
1149 #define Strcpy(a, b) s_strcpy(a, b)
1150 #define Strncpy(a, b, c) s_strncpy(a, b, c)
1151 #define Strlen(a) s_strlen(a)
1152 #define Strcmp(a, b) s_strcmp(a, b)
1153 #define Strncmp(a, b, c) s_strncmp(a, b, c)
1154 #endif
1155 #define Strcasecmp(a, b) s_strcasecmp(a, b)
1157 #define Strspl(a, b) s_strspl(a, b)
1158 #define Strnsave(a, b) s_strnsave(a, b)
1159 #define Strsave(a) s_strsave(a)
1160 #define Strend(a) s_strend(a)
1161 #define Strstr(a, b) s_strstr(a, b)
1162 #endif
1164 #define TCSH_MODIFIERS "ehlqrstuxQ"
1167 * setname is a macro to save space (see sh.err.c)
1169 EXTERN const char *bname;
1171 #define setname(a) (bname = (a))
1173 #ifdef VFORK
1174 EXTERN Char *Vsav;
1175 EXTERN Char *Vdp;
1176 EXTERN Char *Vexpath;
1177 EXTERN char **Vt;
1178 #endif /* VFORK */
1180 EXTERN Char **evalvec;
1181 EXTERN Char *evalp;
1183 extern struct mesg {
1184 const char *iname; /* name from /usr/include */
1185 const char *pname; /* print name */
1186 } mesg[];
1188 /* word_chars is set by default to WORD_CHARS (or WORD_CHARS_VI) but can
1189 be overridden by the wordchars variable--if unset, reverts to
1190 WORD_CHARS (or WORD_CHARS_VI) */
1192 EXTERN Char *word_chars;
1194 #define WORD_CHARS "*?_-.[]~=" /* default chars besides alnums in words */
1195 #define WORD_CHARS_VI "_" /* default chars besides alnums in words */
1197 EXTERN Char *STR_SHELLPATH;
1199 #ifdef _PATH_BSHELL
1200 EXTERN Char *STR_BSHELL;
1201 #endif
1202 EXTERN Char *STR_WORD_CHARS;
1203 EXTERN Char *STR_WORD_CHARS_VI;
1204 EXTERN Char **STR_environ IZERO;
1206 extern int dont_free; /* Tell free that we are in danger if we free */
1208 extern Char *INVPTR;
1209 extern Char **INVPPTR;
1211 extern char *progname;
1212 extern int tcsh;
1213 extern int xlate_cr;
1214 extern int output_raw;
1215 extern int lbuffed;
1216 extern time_t Htime;
1217 extern int numeof;
1218 extern int insource;
1219 extern char linbuf[];
1220 extern char *linp;
1221 extern int nsig;
1222 #ifdef VFORK
1223 extern int use_fork;
1224 #endif
1225 extern int tellwhat;
1226 extern int NoNLSRebind;
1227 #if !HAVE_DECL_ENVIRON
1228 extern char **environ;
1229 #endif
1231 #include "tc.h"
1233 #ifndef WINNT_NATIVE
1234 # ifdef NLS_CATALOGS
1235 # ifdef HAVE_FEATURES_H
1236 # include <features.h>
1237 # endif
1238 # ifdef HAVE_NL_LANGINFO
1239 # include <langinfo.h>
1240 # endif
1241 # ifdef __uxps__
1242 # define gettxt gettxt_ds
1243 # endif
1244 # include <nl_types.h>
1245 # ifdef __uxps__
1246 # undef gettxt
1247 # endif
1248 EXTERN nl_catd catd;
1249 # if defined(HAVE_ICONV) && defined(HAVE_NL_LANGINFO)
1250 # define CGETS(b, c, d) iconv_catgets(catd, b, c, d)
1251 # else
1252 # define CGETS(b, c, d) xcatgets(catd, b, c, d)
1253 # endif
1254 # define CSAVS(b, c, d) strsave(CGETS(b, c, d))
1255 # else
1256 # define CGETS(b, c, d) d
1257 # define CSAVS(b, c, d) d
1258 # endif
1259 #else /* WINNT_NATIVE */
1260 # define CGETS(b, c, d) nt_cgets( b, c, d)
1261 # define CSAVS(b, c, d) strsave(CGETS(b, c, d))
1262 #endif /* WINNT_NATIVE */
1264 #if defined(FILEC)
1265 extern int filec;
1266 #endif /* FILEC */
1268 #include "sh.decls.h"
1270 * Since on some machines characters are unsigned, and the signed
1271 * keyword is not universally implemented, we treat all characters
1272 * as unsigned and sign extend them where we need.
1274 #define SIGN_EXTEND_CHAR(a) (((a) & 0x80) ? ((a) | ~0x7f) : (a))
1277 * explanation for use by the "--help" option
1279 #define HELP_STRING "\
1280 -b file batch mode, read and execute commands from `file' \n\
1281 -c command run `command' from next argument \n\
1282 -d load directory stack from `~/.cshdirs' \n\
1283 -Dname[=value] define environment variable `name' to `value' (DomainOS only) \n\
1284 -e exit on any error \n\
1285 -f start faster by ignoring the start-up file \n\
1286 -F use fork() instead of vfork() when spawning (ConvexOS only) \n\
1287 -i interactive, even when input is not from a terminal \n\
1288 -l act as a login shell, must be the only option specified \n\
1289 -m load the start-up file, whether or not owned by effective user \n\
1290 -n file no execute mode, just check syntax of the following `file' \n\
1291 -q accept SIGQUIT for running under a debugger \n\
1292 -s read commands from standard input \n\
1293 -t read one line from standard input \n\
1294 -v echo commands after history substitution \n\
1295 -V like -v but including commands read from the start-up file \n\
1296 -x echo commands immediately before execution \n\
1297 -X like -x but including commands read from the start-up file \n\
1298 --help print this message and exit \n\
1299 --version print the version shell variable and exit \n\
1300 \nSee the tcsh(1) manual page for detailed information.\n"
1302 #include "tc.nls.h"
1304 #define TEXP_IGNORE 1 /* in ignore, it means to ignore value, just parse */
1305 #define TEXP_NOGLOB 2 /* in ignore, it means not to globone */
1308 #endif /* _h_sh */