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