diff --git a/Fixes b/Fixes index 85b0b9f3c0c0..db401f23fad0 100644 --- a/Fixes +++ b/Fixes @@ -1,3 +1,11 @@ + 5. PR/113: Sobomax: avoid infinite loops for -c commands when stdout is + not a tty. + 4. Avoid infinite loops during history loads when merging, print a better + error for errors during history load. + 3. PR/88: Preserve empty arguments in :q + 2. PR/94: Small apple issues (SAVESIGVEC, HOSTTYPE) + 1. PR/81: Fix range matching issue where we were comparing with the + range character instead of the start of range. [l-z]* would match foo 12. V6.21.00 - 20190508 11. Abort history loading on words and lines too long https://bugzilla.redhat.com/show_bug.cgi?id=1598502 diff --git a/README.md b/README.md index 5c0787d7d4f9..58a30738daa6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Tcsh +# TCSH *C shell with file name completion and command line editing* @@ -14,10 +14,10 @@ PLEASE file any bug reports, fixes, and code for new features at: > https://bugs.astron.com/ Comments, questions, etc. (even flames) are welcome via email to -the Tcsh Bugs mailing list: +the tcsh mailing list: -> tcsh-bugs@astron.com -> https://mailman.astron.com/ +> tcsh@astron.com +> https://mailman.astron.com/mailman/listinfo/tcsh [![Build Status][status]][travis] diff --git a/glob.c b/glob.c index c2bc95f85a6b..dbdfa1e75dcd 100644 --- a/glob.c +++ b/glob.c @@ -100,7 +100,7 @@ static int Lstat (const char *, struct stat *); static int Stat (const char *, struct stat *sb); static Char *Strchr (Char *, int); #ifdef DEBUG -static void qprintf (const Char *); +static void qprintf (const char *, const Char *); #endif #define DOLLAR '$' @@ -254,19 +254,20 @@ Strchr(Char *str, int ch) #ifdef DEBUG static void -qprintf(const Char *s) +qprintf(const char *pre, const Char *s) { const Char *p; - + + xprintf("%s", pre); for (p = s; *p; p++) - printf("%c", *p & 0xff); - printf("\n"); + xprintf("%c", *p & 0xff); + xprintf("\n%s", pre); for (p = s; *p; p++) - printf("%c", *p & M_PROTECT ? '"' : ' '); - printf("\n"); + xprintf("%c", *p & M_PROTECT ? '"' : ' '); + xprintf("\n%s", pre); for (p = s; *p; p++) - printf("%c", *p & M_META ? '_' : ' '); - printf("\n"); + xprintf("%c", *p & M_META ? '_' : ' '); + xprintf("\n"); } #endif /* DEBUG */ @@ -410,7 +411,7 @@ glob(const char *pattern, int flags, int (*errfunc) (const char *, int), } *bufnext = EOS; #ifdef DEBUG - qprintf(patbuf); + qprintf("patbuf=", patbuf); #endif if ((err = glob1(patbuf, pglob, no_match)) != 0) { @@ -707,7 +708,7 @@ match(const char *name, const Char *pat, const Char *patend, int m_not) while (pat < patend || *name) { size_t lwk, pwk; - __Char wc, wk; + __Char wc, wk, wc1; c = *pat; /* Only for M_MASK bits */ if (*name == EOS) @@ -742,18 +743,20 @@ match(const char *name, const Char *pat, const Char *patend, int m_not) pat += pwk; pwk = One_Char_mbtowc(&wc, pat, MB_LEN_MAX); } + wc1 = wc; while ((*pat & M_MASK) != M_END) { if ((*pat & M_MASK) == M_RNG) { __Char wc2; pat += pwk; pwk = One_Char_mbtowc(&wc2, pat, MB_LEN_MAX); - if (globcharcoll(wc, wk, 0) <= 0 && + if (globcharcoll(wc1, wk, 0) <= 0 && globcharcoll(wk, wc2, 0) <= 0) ok = 1; } else if (wc == wk) ok = 1; pat += pwk; + wc1 = wc; pwk = One_Char_mbtowc(&wc, pat, MB_LEN_MAX); } pat += pwk; diff --git a/host.defs b/host.defs index 5d4af1c13ccc..40572cc24271 100644 --- a/host.defs +++ b/host.defs @@ -854,9 +854,9 @@ enddef : newdef : defined(APPLE) && defined(MACH) comment : OS X vendor : : "apple" -hosttype: defined(i386) : "intel-pc" +hosttype: defined(i386) : "intel-mac" hosttype: defined(ppc) : "powermac" -hosttype: defined(M_amd64) : "amd" +hosttype: defined(M_amd64) : "intel-mac" ostype : : "darwin" machtype: defined(i386) : "i386" machtype: defined(M_amd64) : "x86_64" diff --git a/sh.c b/sh.c index 4b5c62453aef..dd871727d2aa 100644 --- a/sh.c +++ b/sh.c @@ -237,6 +237,7 @@ main(int argc, char **argv) int nofile = 0; volatile int nverbose = 0; volatile int rdirs = 0; + volatile int exitcode = 0; int quitit = 0; Char *cp; #ifdef AUTOLOGOUT @@ -1390,6 +1391,12 @@ main(int argc, char **argv) if (targinp) { + /* If this -c command caused an error before, skip processing */ + if (reenter && arginp) { + exitcode = 1; + goto done; + } + arginp = SAVE(targinp); /* * we put the command into a variable @@ -1422,6 +1429,7 @@ main(int argc, char **argv) */ process(setintr); +done: /* * Mop-up. */ @@ -1443,7 +1451,7 @@ main(int argc, char **argv) } record(); exitstat(); - return (0); + return exitcode; } void diff --git a/sh.err.c b/sh.err.c index c676f5e35327..010b23c7d99b 100644 --- a/sh.err.c +++ b/sh.err.c @@ -43,6 +43,7 @@ #endif char *seterr = NULL; /* Holds last error if there was one */ +extern int enterhist; #define ERR_FLAGS 0xf0000000 #define ERR_NAME 0x10000000 @@ -630,6 +631,8 @@ stderror(unsigned int id, ...) */ flush();/*FIXRESET*/ haderr = 1; /* Now to diagnostic output */ + if (enterhist) + xprintf("Can't load history: ");/*FIXRESET*/ if (flags & ERR_NAME) xprintf("%s: ", bname);/*FIXRESET*/ if ((flags & ERR_OLD)) { diff --git a/sh.h b/sh.h index d2cefa9ac8f8..0bada305756b 100644 --- a/sh.h +++ b/sh.h @@ -682,13 +682,27 @@ EXTERN int OLDSTD IZERO; /* Old standard input (def for cmds) */ */ #ifdef SIGSETJMP - typedef struct { sigjmp_buf j; } jmp_buf_t; -# define setexit() sigsetjmp(reslab.j, 1) -# define _reset() siglongjmp(reslab.j, 1) + typedef struct { const char *f; size_t l; sigjmp_buf j; } jmp_buf_t; +# define tcsh_setjmp() sigsetjmp(reslab.j, 1) +# define tcsh_longjmp() siglongjmp(reslab.j, 1) +# define setexit() (reslab.f = __func__, \ + reslab.l = __LINE__, \ + sigsetjmp(reslab.j, 1)) +# define _reset() siglongjmp(reslab.j, 1) #else - typedef struct { jmp_buf j; } jmp_buf_t; -# define setexit() setjmp(reslab.j) -# define _reset() longjmp(reslab.j, 1) + typedef struct { const char *f; size_t l; jmp_buf j; } jmp_buf_t; +# define tcsh_setjmp() setjmp(reslab.j) +# define tcsh_longjmp() longjmp(reslab.j, 1) +#endif + +#define setexit() (reslab.f = __func__, \ + reslab.l = __LINE__, \ + tcsh_setjmp()) +#ifdef SETJMP_DEBUG +# define _reset() xprintf("reset %s %zu\n", reslab.f, reslab.l), \ + flush(), tcsh_longjmp() +#else +# define _reset() tcsh_longjmp() #endif #define getexit(a) (void) ((a) = reslab) diff --git a/sh.hist.c b/sh.hist.c index bce3702b4e40..5be5c4fbde53 100644 --- a/sh.hist.c +++ b/sh.hist.c @@ -1281,6 +1281,7 @@ rechist(Char *fname, int ref) } if (merge) { + jmp_buf_t osetexit; if (lock) { #ifndef WINNT_NATIVE char *lockpath = strsave(short2str(fname)); @@ -1290,7 +1291,10 @@ rechist(Char *fname, int ref) cleanup_push(lockpath, dotlock_cleanup); #endif } - loadhist(fname, 1); + getexit(osetexit); + if (setexit()) + loadhist(fname, 1); + resexit(osetexit); } } rs = randsuf(); diff --git a/sh.lex.c b/sh.lex.c index b879a1daf6af..2893768e9584 100644 --- a/sh.lex.c +++ b/sh.lex.c @@ -1020,8 +1020,10 @@ domod(Char *cp, Char type) switch (type) { - case 'x': case 'q': + case 'x': + if (*cp == '\0') + return Strsave(STRQNULL); wp = Strsave(cp); for (xp = wp; (c = *xp) != 0; xp++) if ((c != ' ' && c != '\t') || type == 'q') diff --git a/tc.const.c b/tc.const.c index 6acda7e46940..b19d012d5a1d 100644 --- a/tc.const.c +++ b/tc.const.c @@ -253,10 +253,10 @@ Char STRnormal[] = { 'n', 'o', 'r', 'm', 'a', 'l', '\0' }; Char STRsldtlogout[] = { '/', '.', 'l', 'o', 'g', 'o', 'u', 't', '\0' }; Char STRjobs[] = { 'j', 'o', 'b', 's', '\0' }; Char STRdefprompt[] = { '%', '#', ' ', '\0' }; -Char STRmquestion[] = { '%', 'R', '?' | QUOTE, ' ', '\0' }; +Char STRmquestion[] = { '%', 'R', (Char)('?' | QUOTE), ' ', '\0' }; Char STRKCORRECT[] = { 'C', 'O', 'R', 'R', 'E', 'C', 'T', '>', '%', 'R', ' ', '(', 'y', '|', 'n', '|', 'e', '|', 'a', ')', - '?' | QUOTE, ' ', '\0' }; + (Char)('?' | QUOTE), ' ', '\0' }; Char STRunalias[] = { 'u', 'n', 'a', 'l', 'i', 'a', 's', '\0' }; Char STRalias[] = { 'a', 'l', 'i', 'a', 's', '\0' }; Char STRprecmd[] = { 'p', 'r', 'e', 'c', 'm', 'd', '\0' }; @@ -380,7 +380,7 @@ Char STRlistmaxrows[] = { 'l', 'i', 's', 't', 'm', 'a', 'x', 'r', 'o', 'w', Char STRlistmax[] = { 'l', 'i', 's', 't', 'm', 'a', 'x', '\0' }; Char STRlistlinks[] = { 'l', 'i', 's', 't', 'l', 'i', 'n', 'k', 's', '\0' }; Char STRDING[] = { 'D', 'I', 'N', 'G', '!', '\0' }; -Char STRQNULL[] = { '\0' | QUOTE, '\0' }; +Char STRQNULL[] = { (Char)('\0' | QUOTE), '\0' }; Char STRcorrect[] = { 'c', 'o', 'r', 'r', 'e', 'c', 't', '\0' }; Char STRcmd[] = { 'c', 'm', 'd', '\0' }; Char STRall[] = { 'a', 'l', 'l', '\0' }; diff --git a/tc.sig.h b/tc.sig.h index 067e6f9fc46b..f7271b6cd397 100644 --- a/tc.sig.h +++ b/tc.sig.h @@ -42,7 +42,7 @@ # include #endif /* SYSVREL > 0 */ -#if defined(__APPLE__) || defined(SUNOS4) || defined(DGUX) || defined(hp800) || (SYSVREL > 3 && defined(VFORK)) +#if defined(SUNOS4) || defined(DGUX) || defined(hp800) || (SYSVREL > 3 && defined(VFORK)) # define SAVESIGVEC #endif /* SUNOS4 || DGUX || hp800 || SVR4 & VFORK */ diff --git a/tcsh.man.new b/tcsh.man.new index fc7fbd726d66..cb82955db317 100644 --- a/tcsh.man.new +++ b/tcsh.man.new @@ -391,7 +391,7 @@ variants; see .Sx FILES . .Ss Editing We first describe -.Sx The command-line editor" +.Sx The command-line editor The .Sx Completion and listing and @@ -402,7 +402,7 @@ Finally, .Sx Editor commands lists and describes the editor commands specific to the shell and their default bindings. -.It Sx The command-line editor (+) +.Ss The command-line editor (+) Command-line input can be edited using key sequences much like those used in .Xr emacs 1 or @@ -684,9 +684,8 @@ If the .Va complete shell variable is set to .Sq enhance , -completion -1) ignores case and 2) considers periods, hyphens and underscores -.Sq ( . , +completion 1) ignores case and 2) considers periods, hyphens and underscores +.Sq ( \&. , .Sq \&- and .Sq _ ) @@ -727,7 +726,7 @@ hyphens or underscores. If the .Va complete shell variable is set to -.Sq enhance , +.Sq Enhance , completion ignores case and differences between a hyphen and an underscore word separator only when the user types a lowercase character or a hyphen. @@ -1093,17 +1092,20 @@ must be bound to a single character for this to work) or one of the following special characters may be typed: .Pp -.Sq ^W +.Bl -tag -width indent -compact +.It ^W Appends the rest of the word under the cursor to the search pattern. -delete (or any character bound to +.It delete +(or any character bound to .Ic backward-delete-char ) Undoes the effect of the last character typed and deletes a character from the search pattern if appropriate. -.Sq ^G +.It ^G If the previous search was successful, aborts the entire search. If not, goes back to the last successful search. -escape +.It escape Ends the search, leaving the current line in the input buffer. +.El .Pp Any other character not bound to .Ic self-insert-command @@ -1664,6 +1666,7 @@ The words of an input line are numbered from 0, the first (usually command) word being 0, the second word (first argument) being 1, etc. The basic word designators are: +.Pp .Bl -tag -width XXXX -offset indent -compact .It Ar 0 The first (command) word @@ -2021,7 +2024,7 @@ cause an error. .Pp Some aliases are referred to by the shell; see .Va Special aliases -.Sx Variable substitution +.Ss Variable substitution The shell maintains a list of variables, each of which has as value a list of zero or more words. The values of shell variables can be displayed and changed with the @@ -2219,7 +2222,7 @@ The following substitutions can not be modified with .Sq \&: modifiers. .Pp -.Bl -tag -width XXXXXXXX -offset indent -compact +.Bl -tag -width XXXXXXXXXX -offset indent -compact .It Ar $?name .It Ar ${?name} Substitutes the string @@ -2238,27 +2241,21 @@ if it is not. Always .Sq 0 in interactive shells. -.It Ar -$#name -${#name} +.It Ar $#name +.It Ar ${#name} Substitutes the number of words in .Va name -.It Ar -$# +.It Ar $# Equivalent to .Sq $#argv (+) -.It Ar -$% -.Va name +.It Ar $%name .It Ar ${%name} Substitutes the number of characters in .Va name (+) .Pp -$% -.Va number -.TP 8 +.It Ar $%number .It Ar ${%number} Substitutes the number of characters in .Va $argv[number] . @@ -2749,7 +2746,7 @@ file to it on standard input. The standard input and standard output of a command may be redirected with the following syntax: .Pp -.Bl -tag -width XXXXXX -offset indent -compact +.Bl -tag -width XXXXXXXXX -offset indent -compact .It Ar < name Open file .Va name @@ -3143,63 +3140,47 @@ They have the same format as before; .Va op may be one of .Pp -.PD 0 -.RS +4 -.TP 8 -.B A +.Bl -tag -width XXX -offset indent -compact +.It Ar A Last file access time, as the number of seconds since the epoch -.TP 8 -.B A: +.It Ar A: Like -.Va A +.Va Ar A , but in timestamp format, e.g., .Sq Fri May 14 16:36:10 1993 -.TP 8 -.B M +.It Ar M Last file modification time -.TP 8 -.B M: +.It Ar M: Like .Va M , but in timestamp format -.TP 8 -.B C +.It Ar C Last inode modification time -.TP 8 -.B C: +.It Ar C: Like .Va C , but in timestamp format -.TP 8 -.B D +.It Ar D Device number -.TP 8 -.B I +.It Ar I Inode number -.TP 8 -.B F +.It Ar F Composite .Va f ile identifier, in the form -.Va device -: +.Va device : .Va inode -.TP 8 -.B L +.It Ar L The name of the file pointed to by a symbolic link -.TP 8 -.B N +.It Ar N Number of (hard) links -.TP 8 -.B P +.It Ar P Permissions, in octal, without leading zero -.TP 8 -.B P: +.It Ar P: Like .Va P , with leading zero -.TP 8 -.B P\fImode +.It Ar P Equivalent to .Sq \-P .Va file @@ -3217,28 +3198,22 @@ if by group only, and .Sq 0 if by neither -.TP 8 -.B P\fImode\fB: -Like \fBP +.It Ar P: +Like +.Ar BP .Va mode , with leading zero -.TP 8 -.B U +.It Ar U Numeric userid -.TP 8 -.B U: +.It Ar U: Username, or the numeric userid if the username is unknown -.TP 8 -.B G +.It Ar G Numeric groupid -.TP 8 -.B G: +.It Ar G: Groupname, or the numeric groupid if the groupname is unknown -.TP 8 -.B Z +.It Ar Z Size, in bytes -.RE -.PD +.El .Pp Only one of these operators may appear in a multiple-operator test, and it must be the last. @@ -3791,45 +3766,24 @@ The next sections of this manual describe all of the available and .Va Special shell variables .Ss "Builtin commands" -.TP 8 -.B %\fIjob +.Bl -tag -width XXXXXXX -offset indent +.It Ar %job A synonym for the .Va fg builtin command. -.TP 8 -.B %\fIjob \fB& +.It Ar %job \&& A synonym for the .Va bg builtin command. -.TP 8 -.B : +.It Ar \&: Does nothing, successfully. .Pp -.B @ -.br -.B @ \fIname\fB = \fIexpr -.br -.B @ -.Va name -[ -.Va index -]\fB = \fIexpr -.br -.B @ \fIname -.Va ++ -|\fB-- -.PD 0 -.TP 8 -.B @ -.Va name -[ -.Va index -] -.Va ++ -|\fB-- +.It Ar @ +.It Ar @ name = expr +.It Ar @ name[index] = expr +.It Ar @ name++|-- +.It Ar @name[index]++|-- The first form prints the values of all shell variables. -.PD -.RS +8 .Pp The second form assigns the value of .Va expr @@ -3875,7 +3829,10 @@ has nothing to do with that described under .Va Expressions .Pp -The fourth and fifth forms increment (`++') or decrement (`\-\-') +The fourth and fifth forms increment ( +.Sq ++ ) +or decrement +.Sq ( -- ) .Va name or its .Va index @@ -3898,14 +3855,7 @@ are optional. Components of .Va expr must be separated by spaces. -.RE -.PD -.TP 8 -.B alias \fR[ -.Va name -[ -.Va wordlist -]] +.It Ar alias[name[wordlist]] Without arguments, prints all aliases. With .Va name @@ -3928,8 +3878,7 @@ or See also the .Va unalias builtin command. -.TP 8 -.B alloc +.It Ar alloc Shows the amount of dynamic memory acquired, broken down into used and free memory. With an argument shows the number of free and used blocks in each size @@ -3939,9 +3888,7 @@ This command's output may vary across system types, because systems other than the VAX may use a different memory allocator. .TP 8 -.B bg \fR[\fB% -.Va job -...] +.It Ar bg[%job...] Puts the specified jobs (or, without arguments, the current job) into the background, continuing each if it is stopped. .Va job @@ -3957,35 +3904,10 @@ as described under .Va Jobs .Pp -.B bindkey \fR[ -.Fl l\fR| -.Fl d\fR| -.Fl e\fR| -.Fl v\fR| -.Fl u\fR] (+) -.br -.Va bindkey -[ -.Fl a\fR] [ -.Fl b\fR] [ -.Fl k\fR] [ -.Fl r\fR] [ -.Fl \-\fR] -.Va key -(+) -.PD 0 -.TP 8 -.Va bindkey -[ -.Fl a\fR] [ -.Fl b\fR] [ -.Fl k\fR] [ -.Fl c\fR| -.Fl s\fR] [ -.Fl \-\fR] -.Va key command -(+) -.\" .B macro can't take too many words, so I used \fB in the previous tags +.It Ar bindkey Oo Fl l Ns | Ns Fl d Ns | Ns Fl e Ns | Ns Fl v Ns | Ns Fl u Oc (+) +.It Ar bindkey Oo Fl a Oc Oo Fl b Oc Oo Fl k Oc Oo Fl r Oc Oo Fl Fl Oc Ar key (+) +.It Ar bindkey Oo Fl a Oc Oo Fl b Oc Oo Fl k Oc Oo Fl c Ns | Ns Fl s Oc Oo Fl Fl Oc Ar key command (+) +.\" .It Ar macro can't take too many words, so I used \fB in the previous tags Without options, the first form lists all bound keys and the editor command to which each is bound, the second form lists the editor command to which .Va key @@ -3995,43 +3917,35 @@ the third form binds the editor command to .Va key Options include: -.PD .Pp -.PD 0 -.RS +8 -.TP 4 -.Fl l +.Bl -tag -width XXX -compact +.It Fl l Lists all editor commands and a short description of each. -.TP 4 -.Fl d +.It Fl d Binds all keys to the standard bindings for the default editor, as per .Va -e and .Va -v below. -.TP 4 -.Fl e +.It Fl e Binds all keys to .Va emacs (1)\-style bindings. Unsets .Va vimode -.TP 4 -.Fl v +.It Fl v Binds all keys to .Va vi (1)\-style bindings. Sets .Va vimode -.TP 4 -.Fl a +.It Fl a Lists or changes key-bindings in the alternative key map. This is the key map used in .Va vimode command mode. -.TP 4 -.Fl b +.It Fl b .Va key is interpreted as a control character written ^ @@ -4059,8 +3973,7 @@ or an extended prefix key written X- (e.g., .Sq X-A ). -.TP 4 -.Fl k +.It Fl k .Va key is interpreted as a symbolic arrow key name, which may be one of `down', @@ -4069,8 +3982,7 @@ is interpreted as a symbolic arrow key name, which may be one of .Sq left or .Sq right -.TP 4 -.Fl r +.It Fl r Removes .Va key 's binding. @@ -4085,13 +3997,11 @@ to (q.v.), it unbinds .Va key completely. -.TP 4 -.Fl c +.It Fl c .Va command is interpreted as a builtin or external command instead of an editor command. -.TP 4 -.Fl s +.It Fl s .Va command is taken as a literal string and treated as terminal input when @@ -4101,15 +4011,14 @@ Bound keys in .Va command are themselves reinterpreted, and this continues for ten levels of interpretation. -.TP 4 -.Fl \- +.It Fl \&- Forces a break from option processing, so the next word is taken as .Va key -even if it begins with '\-'. -.TP 4 -.Fl u \fR(or any invalid option) +even if it begins with '\&-'. +.It Fl u +(or any invalid option) Prints a usage message. -.PD +.El .Pp .Va key may be a single character or a string. @@ -4137,48 +4046,35 @@ can contain backslashed escape sequences (in the style of System V .Va echo (1)) as follows: -.RS +4 -.TP 8 -.PD 0 -.B \ea +.Pp +.Bl -tag -width XXXX -compact -offset indent +.It \ea Bell -.TP 8 -.B \eb +.It \eb Backspace -.TP 8 -.B \ee +.It \ee Escape -.TP 8 -.B \ef +.It \ef Form feed -.TP 8 -.B \en +.It \en Newline -.TP 8 -.B \er +.It \er Carriage return -.TP 8 -.B \et +.It \et Horizontal tab -.TP 8 -.B \ev +.It \ev Vertical tab -.TP 8 -.B \e\fInnn +.It \e\fInnn The ASCII character corresponding to the octal number .Va nnn -.PD -.RE +.El .Pp `\e' nullifies the special meaning of the following character, if it has any, notably .Sq \e and .Sq ^ -.RE -.TP 8 -.B bs2cmd -.Va bs2000-command +.It bs2cmd Va bs2000-command (+) Passes .Va bs2000-command @@ -4186,8 +4082,7 @@ to the BS2000 command interpreter for execution. Only non-interactive commands can be executed, and it is not possible to execute any command that would overlay the image of the current process, like /EXECUTE or /CALL-PROCEDURE. (BS2000 only) -.TP 8 -.B break +.It break Causes execution to resume after the .Va end of the nearest @@ -4199,17 +4094,16 @@ The remaining commands on the current line are executed. Multi-level breaks are thus possible by writing them all on one line. -.TP 8 -.B breaksw +.It breaksw Causes a break from a .Va switch , resuming after the .Va endsw -.TP 8 -.B builtins \fR(+) + +.It builtins \fR(+) Prints the names of all builtin commands. -.TP 8 -.B bye \fR(+) + +.It bye \fR(+) A synonym for the .Va logout builtin command. @@ -4217,13 +4111,13 @@ Available only if the shell was so compiled; see the .Va version shell variable. -.TP 8 -.B case \fIlabel\fB: + +.It case \fIlabel\fB: A label in a .Va switch statement as discussed below. -.TP 8 -.B cd \fR[ + +.It cd \fR[ .Fl p\fR] [ .Fl l\fR] [ .Fl n\fR| @@ -4300,13 +4194,13 @@ and .Va cdtohome shell variables. .RE -.TP 8 -.B chdir + +.It chdir A synonym for the .Va cd builtin command. -.TP 8 -.B complete \fR[ + +.It complete \fR[ .Va command [\fIword\fB/\fIpattern\fB/ .Va list @@ -4350,7 +4244,7 @@ is to be completed, and may be one of the following: .PD 0 .RS +4 .TP 4 -.B c +.It c Current-word completion. .Va pattern is a glob-pattern which must match the beginning of the current word on @@ -4358,25 +4252,25 @@ the command line. .Va pattern is ignored when completing the current word. .TP 4 -.B C +.It C Like .Va c , but includes .Va pattern when completing the current word. .TP 4 -.B n +.It n Next-word completion. .Va pattern is a glob-pattern which must match the beginning of the previous word on the command line. .TP 4 -.B N +.It N Like .Va n , but must match the beginning of the word two before the current word. .TP 4 -.B p +.It p Position-dependent completion. .Va pattern is a numeric range, with the same syntax used to index shell @@ -4387,71 +4281,50 @@ variables, which must include the current word. .Va list , the list of possible completions, may be one of the following: .Pp -.PD 0 -.RS +4 -.TP 8 -.B a +.Bl -tag +.It a Aliases -.TP 8 -.B b +.It b Bindings (editor commands) -.TP 8 -.B c +.It c Commands (builtin or external commands) -.TP 8 -.B C +.It C External commands which begin with the supplied path prefix -.TP 8 -.B d +.It d Directories -.TP 8 -.B D +.It D Directories which begin with the supplied path prefix -.TP 8 -.B e +.It e Environment variables -.TP 8 -.B f +.It f Filenames -.TP 8 -.B F +.It F Filenames which begin with the supplied path prefix -.TP 8 -.B g +.It g Groupnames -.TP 8 -.B j +.It j Jobs -.TP 8 -.B l +.It l Limits -.TP 8 -.B n +.It n Nothing -.TP 8 -.B s +.It s Shell variables -.TP 8 -.B S +.It S Signals -.TP 8 -.B t +.It t Plain ( .Dq text ) files -.TP 8 -.B T +.It T Plain ( .Dq text ) files which begin with the supplied path prefix -.TP 8 -.B v +.It v Any variables -.TP 8 -.B u +.It u Usernames -.TP 8 -.B x +.It x Like .Va n , but prints @@ -4459,22 +4332,17 @@ but prints when .Va list-choices is used. -.TP 8 -.B X +.It X Completions -.TP 8 $ .Va var Words from the variable .Va var -.TP 8 (...) Words from the given list -.TP 8 \`...\` Words from the output of command -.PD -.RE +.El .Pp .Va select is an optional glob-pattern. diff --git a/tests/lexical.at b/tests/lexical.at index 3dc602437bdc..d3ad14905830 100644 --- a/tests/lexical.at +++ b/tests/lexical.at @@ -572,7 +572,7 @@ echo -n "$SERVICE_NAME_LOG" > ./output1 cat batchsystem.properties | grep '^jdbc_url' | sed -ne 's/^[^=]*=[^@]*@[[:blank:]]*\([^$]*\)$/\1/p' | perl -pe 's/\s//g' | perl -pe 's/\)/\\\)/g' | perl -pe 's/\(/\\\(/g' > ./output2 -diff -uprN ./output1 ./output2 >& /dev/null +diff -ur ./output1 ./output2 >& /dev/null if ( $? != 0 ) then echo -n 'FAIL: tcsh does not have uniform output when `...` is used!' @@ -591,7 +591,7 @@ set SERVICE_NAME_LOG = `echo "$string" | grep '^jdbc_url' | sed -ne 's/^[^=]*=[ echo "$SERVICE_NAME_LOG" > ./actual_result -diff -uprN ./expected_result ./actual_result >& /dev/null +diff -ur ./expected_result ./actual_result >& /dev/null if ( $? != 0 ) then echo -n 'FAIL: tcsh has unexpected result when `...` is used!' diff --git a/tests/subst.at b/tests/subst.at index 71feb978e6a6..48d9f2892a8f 100644 --- a/tests/subst.at +++ b/tests/subst.at @@ -50,11 +50,11 @@ nothing* foo* ab{c,d} ^fo* ]) -AT_CHECK([echo 'echo ~; echo "$HOME"' | tcsh -f | uniq | wc -l | tr -d ' \t'], +AT_CHECK([export HOME=$(getent passwd $(id -un) | awk -F: '{ print $(NF - 1) }'); echo 'echo ~; echo "$HOME"' | tcsh -f | uniq | wc -l | tr -d ' \t'], , [1 ]) -AT_CHECK([echo "echo ~$(id -un)/foo; echo \"$HOME/foo\"" | tcsh -f | uniq dnl +AT_CHECK([export HOME=$(getent passwd $(id -un) | awk -F: '{ print $(NF - 1) }'); echo "echo ~$(id -un)/foo; echo \"\$HOME/foo\"" | tcsh -f | uniq dnl | wc -l | tr -d ' \t'], , [1 ]) diff --git a/tests/syntax.at b/tests/syntax.at index 35134d1bd11e..eeaacc66c618 100644 --- a/tests/syntax.at +++ b/tests/syntax.at @@ -2,6 +2,10 @@ AT_SETUP([Command combinations]) +# False on OpenSolaris returns 255 +echo 'exit 1' > myfalse +chmod +x myfalse + AT_CHECK([tcsh -f -c 'echo ok|tr ok OK'], , [OK ]) @@ -21,7 +25,7 @@ AT_CHECK([tcsh -f -c 'true && echo OK'], , [OK ]) -AT_CHECK([tcsh -f -c 'false && echo fail'], 1) +AT_CHECK([tcsh -f -c './myfalse && echo fail'], 1) AT_CHECK([[tcsh -f -c '(sleep 1; echo async) & echo sync; wait' \ | sed 's/ [0123456789]*$/ /']], , diff --git a/tests/variables.at b/tests/variables.at index ffa0da299cc6..a1f098d42305 100644 --- a/tests/variables.at +++ b/tests/variables.at @@ -41,13 +41,16 @@ VAR_UNSET([ampm]) AT_SETUP([$ anyerror]) +echo 'exit 1' > myfalse +chmod +x myfalse + AT_DATA([exit_status.csh], [[echo $?anyerror $anyerror -false | true ; echo $? +./myfalse | true ; echo $? unset anyerror ; echo $?anyerror -false | true ; echo $? +./myfalse | true ; echo $? set anyerror -false | true ; echo $? +./myfalse | true ; echo $? ]]) AT_CHECK([tcsh -f exit_status.csh],, @@ -588,7 +591,7 @@ printenv HOME setenv HOME /bar echo $home ]]) -AT_CHECK([tcsh -f home.csh], , +AT_CHECK([export HOME=$(getent passwd $(id -nu) | awk -F: '{ print $(NF - 1) }'); tcsh -f home.csh], , [1 1 /foo @@ -705,7 +708,7 @@ AT_CLEANUP AT_SETUP([$ cdtohome]) -AT_CHECK([tcsh -f -c 'cd'], 0) +AT_CHECK([export HOME=$(getent passwd $(id -nu) | awk -F: '{ print $(NF - 1) }'); tcsh -f -c 'cd'], 0) AT_CLEANUP AT_SETUP([$ noimplicithome]) AT_CHECK([tcsh -f -c 'unset cdtohome; cd'], 1, , [cd: Too few arguments. @@ -781,10 +784,13 @@ AT_CLEANUP AT_SETUP([$ printexitvalue]) +echo 'exit 1' > myfalse +chmod +x myfalse + AT_DATA([printexitvalue.csh], [[echo $?printexitvalue set printexitvalue -false +./myfalse (exit 3 >/dev/null) : ]])