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