tcsh [–bcdeFfimnqstvVxX]
The tcsh shell is an enhanced but completely compatible version of the Berkeley UNIX C shell, tcsh. It is a command language interpreter usable both as an interactive login shell and a shell script command processor. It includes a command-line editor, programmable word completion, spelling correction, a history mechanism, job control, and a C-like syntax.
You can invoke the shell by typing an explicit tcsh command. A login shell can also be specified by invoking the shell with the –l option as the only argument.
A login shell begins by executing commands from the system files /etc/csh.cshrc and /etc/csh.login. It then executes commands from files in the user's home directory: first ~/.tcshrc, then ~/.history (or the value of the histfile shell variable), then ~/.login, and finally ~/.cshdirs (or the value of the dirsfile shell variable). The shell reads /etc/csh.login after /etc/csh.cshrc.
Non-login shells read only /etc/csh.cshrc and ~/.tcshrc or ~/.cshrc on invocation.
Commands like stty, which need be run only once per login, typically go in the user's ~/.login file.
In the normal case, the shell begins reading commands from the terminal, prompting with >. The shell repeatedly reads a line of command input, breaks it into words, places it on the command history list, and then parses and executes each command in the line. See Command execution.
If the first argument (argument 0) to the tcsh shell is - (hyphen), then it is a login shell. You can also specify the login shell by invoking the tcsh shell with the –l as the only argument.
After processing of option arguments, if arguments remain but none of the –c, –i, –s, or –t were given, the first argument is taken as the name of a file of commands, or script , to be executed. The shell opens this file and saves its name for possible resubstitution by $0. Since many systems use shells whose shell scripts are not compatible with this shell, the tcsh shell uses such a standard shell to execute a script whose character is not a #, that is, which does not start with a comment.
Remaining arguments are placed in the argv shell variable.
In this topic, we first describe the Command-Line Editor. We then discuss Completion and Listing and Spelling Correction which describe two sets of functionality that are implemented as editor commands but which deserve their own treatment. Finally, the Editor Commands topic lists and describes the editor commands specific to the tcsh shell and their default bindings.
Command-line input can be edited using key sequences much like those used in GNU Emacs or vi. The editor is active only when the edit shell variable is set, which it is by default in interactive shells. The bindkey built-in command can display and change key bindings. Emacs-style key bindings are used by default, but bindkey can change the key bindings to vi-style bindings.
The tcsh shell is often able to complete words when given a unique abbreviation. Type part of a word (for example ls /usr/lost) and press the tab key to run the complete-word editor command. The shell completes the file name /usr/lost to /usr/lost+found/, replacing the incomplete word with the complete word in the input buffer. (Note the terminal / (forward slash); completion adds a / to the end of completed directories and a space to the end of other completed words, to speed typing and provide a visual indicator of successful completion. The addsuffix shell variable can be unset to prevent this.) If no match is found (for example, /usr/lost+found doesn't exist), the terminal bell rings. If the word is already complete (for example, there is a /usr/lost on your system, or you were thinking too far ahead and typed the whole thing), a / or space is added to the end if it isn't already there.
Completion works anywhere in the line, not just at the end; completed text pushes the rest of the line to the right. Completion in the middle of a word often results in leftover characters to the right of the cursor which need to be deleted.
Commands and variables can be completed in much the same way. For example, typing em [tab] would complete 'em' to 'emacs' if emacs were the only command on your system beginning with 'em'. Completion can find a command in any directory in the path or if given a full path name. Typing echo $ar[tab] would complete '$ar' to '$argv' if no other variable began with 'ar'.
The shell parses the input buffer to determine whether the word you want to complete should be completed as a file name, command or variable. The first word in the buffer and the first word following ';', '|', '|&', '&&' or '||' is considered to be a command. A word beginning with '$' is considered to be a variable. Anything else is a file name. An empty line is completed as a file name.
> ls /usr/l['^D]
lbin/ lib/ local/ lost+found/
> ls /usr/l
> set autolist
> nm /usr/lib/libt[tab]
libtermcap.a@ libtermlib.a@
> nm /usr/lib/libterm
If autolist is set to ambiguous, choices are listed only if multiple matches are possible, and if the completion adds no new characters to the name to be matched.
> ls ~k[^D]
kahn kas kellogg
> ls ~ke[tab]
> ls ~kellogg/
or
> set local = /usr/local
> ls $lo[tab]
> ls $local/[^D]
bin/ etc/ lib/ man/ src/
> ls $local/
Variables can also be expanded explicitly with the expand-variables editor
command.delete-char-or-list-or-eof only lists at the end of the line; in the middle of a line it deletes the character under the cursor and on an empty line it logs one out or, if ignoreeof is set, does nothing. M-^D, bound to the editor command list-choices, lists completion possibilities anywhere on a line, and list-choices (or any one of the related editor commands which do or don't delete, list and log out, listed under delete-char-or-list-or-eof) can be bound to ^D with the bindkey built-in command if so desired.
The complete-word-fwd and complete-word-back editor commands (not bound to any keys by default) can be used to cycle up and down through the list of possible completions, replacing the current word with the next or previous word in the list.
> ls
Makefile condiments.h~ main.o side.c
README main.c meal side.o
condiments.h main.c~
> set fignore = (.o \~)
> emacs ma[^D]
main.c main.c~ main.o
> emacs ma[tab]
> emacs main.c
'main.c~' and 'main.o' are ignored
by completion (but not listing), because they end in suffixes in fignore.
\ is needed in front of ~ to prevent it from being expanded to home as
described under File name substitution. fignore is
ignored if only one completion is possible.If the complete shell variable is set to enhance, completion: 1.) ignores case and 2.) considers periods, hyphens and underscores ('.', '-' and '_') to be word separators and hyphens and underscores to be equivalent.
comp.lang.c comp.lang.perl comp.std.c++
comp.lang.c++ comp.std.c
and typed mail -f c.l.c[tab],
it would be completed to mail -f comp.lang.c,
and ^D would list comp.lang.c and comp.lang.c++. mail
-f c..c++[^D] would list comp.lang.c++
and comp.std.c++. Typing rm a--file[^D] in
the following directory A_silly_file a-hyphenated-file another_silly_file
would
list all three files, because case is ignored and hyphens and underscores
are equivalent. Periods, however, are not equivalent to hyphens or
underscores.> ls
fodder foo food foonly
> set recexact
> rm fo[tab]
just beeps, because 'fo' could expand to 'fod'
or 'foo', but if we type another 'o', > rm foo[tab]
> rm foo
the completion completes on 'foo', even though
'food' and 'foonly' also match. autoexpand can be set to run
the expand-history editor command before each completion attempt,
and correct can be set to complete commands automatically after
one hits 'return'. matchbeep can be set to make completion
beep or not beep in a variety of situations, and nobeep can
be set to never beep at all. nostat can be set to a list of
directories and patterns which match directories to prevent the completion
mechanism from stat(2)ing those directories. >set listflags=x>
ls-F /u/pluto
Dir1/exe1*
>set nostat=(/u/pluto/)
>ls-F /u/pluto
Dir1exe1
>
Although, you must be careful when setting nostat to
keep the trailing / (forward slash).Finally, the complete built-in command can be used to tell the shell how to complete words other than file names, commands and variables. Completion and listing do not work on glob-patterns (see File name substitution), but the list-glob and expand-glob editor commands perform equivalent functions for glob-patterns.
The tcsh shell can sometimes correct the spelling of file names, commands and variable names as well as completing and listing them.
Individual words can be corrected for spelling with the spell-word editor command (typically bound to M-s and M-S where M = Meta Key or escape (ESC) key) and the entire input buffer with spell-line (typically bound to M-$). The correct shell variable can be set to 'cmd' to correct the command name or 'all' to correct the entire line each time return is typed.
> set correct = cmd
> lz /usr/bin
CORRECT>ls /usr/bin (y|n|e|a)?
where one can answer 'y'
or space to execute the corrected line, 'e' to leave the uncorrected
command in the input buffer, 'a' to abort the command as if ^C had
been pressed, and anything else to execute the original line unchanged.Spelling correction recognizes user-defined completions (see the complete built-in command). If an input word in a position for which a completion is defined resembles a word in the completion list, spelling correction registers a misspelling and suggests the latter word as a correction. However, if the input word does not match any of the possible completions for that position, spelling correction does not register a misspelling.
Like completion, spelling correction works anywhere in the line, pushing the rest of the line to the right and possibly leaving extra characters to the right of the cursor.
Spelling correction is not guaranteed to work the way one intends, and is provided mostly as an experimental feature.
bindkey lists key bindings and bindkey -l lists and briefly describes editor commands. Only new or especially interesting editor commands are described here. See emacs and vi for descriptions of each editor's key bindings.
The character or characters to which each command is bound by default is given in parentheses. ^character means a control character and M-character a meta character, typed as escape-character on terminals without a meta key. Case counts, but commands which are bound to letters by default are bound to both lower- and uppercase letters for convenience.
>ls test*[^X-*]
would expand to >ls test1.c test2.c
if
those were the only two files in your directory that begin with 'test'.
See File name substitution.The tcsh shell splits input lines into words at blanks and tabs. The special characters '&', '|', ';', '<', '>', '(', and ')' and the doubled characters '&&', '||', '<<' and '>>' are always separate words, whether or not they are surrounded by white space.
When the tcsh shell's input is not a terminal, the character '#' is taken to begin a comment. Each # and the rest of the input line on which it appears is discarded before further parsing.
A special character (including a blank or tab) can be prevented from having its special meaning, and possibly made part of another word, by preceding it with a backslash (\) or enclosing it in single ( ' ), double ( " ) or backward (' ` ') quotation marks. When not otherwise quoted a newline preceded by a \ is equivalent to a blank, but inside quotes this sequence results in a newline.
Furthermore, all substitutions (see Substitutions) except history substitution can be prevented by enclosing the strings (or parts of strings) in which they appear with single quotation marks or by quoting the crucial characters (for example, '$' or ' `' for variable substitution or command substitution respectively) with \. (alias substitution is no exception: quoting in any way any character of a word for which an alias has been defined prevents substitution of the alias. The usual way of quoting an alias is to precede it with a backslash.) History substitution is prevented by backslashes but not by single quotation marks. Strings quoted with double or backward quotation marks undergo Variable substitution and Command substitution, but other substitutions are prevented.
Text inside single or double quotation marks becomes a single word (or part of one). Metacharacters in these strings, including blanks and tabs, do not form separate words. Only in one special case (see Command substitution) can a double-quoted string yield parts of more than one word; single-quoted strings never do. Backward quotes are special: they signal command substitution, which might result in more than one word.
Quoting complex strings, particularly strings which themselves contain quoting characters, can be confusing. Remember that quotes need not be used as they are in human writing. It might be easier to quote not an entire string, but only those parts of the string which need quoting, using different types of quoting to do so if appropriate.
The backslash_quote shell variable can be set to make backslashes always quote \, ', and ". This might make complex quoting tasks easier, but it can cause syntax errors in csh (or tcsh) scripts.
This topic describes the various transformations the tcsh shell performs on input in the order in which they occur. The topic will cover data structures involved and the commands and variables which affect them. Remember that substitutions can be prevented by quoting as described in Command syntax.
Each command, or event, input from the terminal is saved in the history list. The previous command is always saved, and the history shell variable can be set to a number to save that many commands. The histdup shell variable can be set to not save duplicate events or consecutive duplicate events.
Saved commands are numbered sequentially from 1 and stamped with the time. It is not typically necessary to use event numbers, but the current event number can be made part of the prompt by placing an exclamation point (!) in the prompt shell variable.
The shell actually saves history in expanded and literal (unexpanded) forms. If the histlit shell variable is set, commands that display and store history use the literal form.
The history built-in command can print, store in a file, restore and clear the history list at any time, and the savehist and histfile shell variables can be set to store the history list automatically on logout and restore it on login.
History substitutions introduce words from the history list into the input stream, making it easy to repeat commands, repeat arguments of a previous command in the current command, or fix spelling mistakes in the previous command with little typing and a high degree of confidence.
History substitutions begin with the character !. They can begin anywhere in the input stream, but they do not nest. The ! can be preceded by a \ to prevent its special meaning; for convenience, a ! is passed unchanged when it is followed by a blank, tab, newline, = or (. History substitutions also occur when an input line begins with ^. The characters used to signal history substitution (! and ^ (caret)) can be changed by setting the histchars shell variable. Any input line which contains a history substitution is printed before it is executed.
A history substitution can have an event specification, which indicates the event from which words are to be taken, a word designator, which selects particular words from the chosen event, and a modifier, which manipulates the selected words.
9 8:30 nroff -man wumpus.man
10 8:31 cp wumpus.man wumpus.man old
11 8:36 vi wumpus.man
12 8:37 diff wumpus.man.old wumpus.man
The commands are
shown with their event numbers and time stamps. The current event,
which we have not typed in yet, is event 13. !11 and !-2 refer to
event 11. !! refers to the previous event, 12. !! can be abbreviated
! if it is followed by a : (colon). !n refers to event 9, which begins
with n. !?old? also refers to event 12, which contains old.
Without word designators or modifiers history references simply expand
to the entire event, so we might type !cp to redo the copy command
or !!|more if the diff output scrolled off
the top of the screen.History references can be insulated from the surrounding text with braces if necessary. For example, !vdoc would look for a command beginning with vdoc, and, in this example, not find one, but !{v}doc would expand unambiguously to vi wumpus.mandoc. Even in braces, history substitutions do not nest.
While csh expands, for example, !3d to event 3 with the letter d appended to it, tcsh expands it to the last event beginning with 3d; only completely numeric arguments are treated as event numbers. This makes it possible to recall events beginning with numbers. To expand !3d as in csh say !\3d.
The : separating the event specification from the word designator can be omitted if the argument selector begins with a '^', '$', '*', '%' or '-'. For example, our diff command might have been diff !!^.old !!^ or, equivalently, diff !!$.old !!$. However, if !! is abbreviated !, an argument selector beginning with - (hyphen) will be interpreted as an event specification.
A history reference can have a word designator but no event specification. It then references the previous command. Continuing our diff example, we could have said simply diff !^.old !^or, to get the arguments in the opposite order, just diff !*.
For example, the diff command might have been written as diff wumpus.man.old !#^:r, using :r to remove .old from the first argument on the same line (!#^). We could say echo hello out there, then echo !*:u to capitalize 'hello', echo !*:au to say it out loud, or echo !*:agu to really shout. We might follow mail -s "I forgot my password" rot with !:s/rot/root to correct the spelling of 'root' (but see Spelling correction for a different approach).
There is a special abbreviation for substitutions. ^, when it is the first character on an input line, is equivalent to !:s^. Thus, we might have said ^rot^root to make the spelling correction in the previous example. This is the only history substitution which does not explicitly begin with !.
% mv wumpus.man /usr/man/man1/wumpus.1
% man !$:t:r
man wumpus
In csh, the result would be wumpus.1:r.
A substitution followed by a colon might need to be insulated from
it with braces: > mv a.out /usr/games/wumpus
> setenv PATH !$:h:$PATH
Bad ! modifier: $.
> setenv PATH !{-2$:h}:$PATH
setenv PATH /usr/games:/bin:/usr/bin:.
The first attempt
would succeed in csh but fails in tcsh, because tcsh expects another
modifier after the second colon instead of $.The shell maintains a list of aliases which can be set, unset, and printed by the alias and unalias commands. After a command line is parsed into simple commands (see Command execution) the first word of each command, left-to-right, is checked to see if it has an alias. If so, the first word is replaced by the alias. If the alias contains a history reference, it undergoes history substitution as though the original command were the previous input line. If the alias does not contain a history reference, the argument list is left untouched.
Thus if the alias for ls were ls -l the command ls /usrwould become ls -l /usr, the argument list here being undisturbed. If the alias for lookup were grep !^ /etc/passwd then lookup bill would become grep bill /etc/passwd. Aliases can be used to introduce parser metasyntax. For example, alias print 'pr \!* | lpr' defines a command (print) which prints its arguments to the line printer.
Alias substitution is repeated until the first word of the command has no alias. If an alias substitution does not change the first word (as in the previous example) it is flagged to prevent a loop. Other loops are detected and cause an error.
Some aliases are referred to by the shell; see tcsh built-in commands.
The tcsh shell maintains a list of variables, each of which has as value a list of zero or more words. The values of tcsh shell variables can be displayed and changed with the set and unset commands. The system maintains its own list of "environment" variables. These can be displayed and changed with printenv, setenv and unsetenv.
Variables can be made read-only with set -r. Read-only variables cannot be modified or unset; attempting to do so will cause an error. Once made read-only, a variable cannot be made writable, so set -r should be used with caution. Environment variables cannot be made read-only.
Some variables are set by the tcsh shell or referred to by it. For instance, the argv variable is an image of the shell's argument list, and words of this variable's value are referred to in special ways. Some of the variables referred to by the tcsh shell are toggles; the shell does not care what their value is, only whether they are set or not. For instance, the verbose variable is a toggle which causes command input to be echoed. The -v command line option sets this variable. Special shell variables lists all variables which are referred to by the shell.
Other operations treat variables numerically. The @ (at) command permits numeric calculations to be performed and the result assigned to a variable. Variable values are, however, always represented as (zero or more) strings. For the purposes of numeric operations, the null string is considered to be zero, and the second and subsequent words of multiword values are ignored.
After the input line is aliased and parsed, and before each command is executed, variable substitution is performed keyed by $ characters. This expansion can be prevented by preceding the $ with a \ except within double quotation marks (") where it always occurs, and within single quotation marks ( ' ) where it never occurs. Strings quoted by backward quotation marks or accents (`) are interpreted later (see Command substitution) so $ substitution does not occur there until later, if at all. A $ is passed unchanged if followed by a blank, tab, or end-of-line.
Input/output redirections are recognized before variable expansion, and are variable expanded separately. Otherwise, the command name and entire argument list are expanded together. It is thus possible for the first (command) word (to this point) to generate more than one word, the first of which becomes the command name, and the rest of which become arguments.
Unless enclosed in double quotation marks (") or given the :q modifier the results of variable substitution can eventually be command and file name substituted. Within ", a variable whose value consists of multiple words expands to a (portion of a) single word, with the words of the variable's value separated by blanks. When the :q modifier is applied to a substitution the variable will expand to multiple words with each word separated by a blank and quoted to prevent later command or file name substitution.
The remaining substitutions are applied selectively to the arguments of tcsh built-in commands. This means that portions of expressions which are not evaluated are not subjected to these expansions. For commands which are not internal to the tcsh shell, the command name is substituted separately from the argument list. This occurs very late, after input-output redirection is performed, and in a child of the main shell.
Command substitution is indicated by a command enclosed in ' ' '. The output from such a command is broken into separate words at blanks, tabs and newlines, and null words are discarded. The output is variable and command substituted and put in place of the original string.
Command substitutions inside double quotation marks ( " ) retain blanks and tabs; only newlines force new words. The single final newline does not force a new word in any case. It is thus possible for a command substitution to yield only part of a word, even if the command outputs a complete line.
If a word contains any of the characters '*', '?', '[' or '{' or begins with the character '~' it is a candidate for file name substitution, also known as globbing. This word is then regarded as a pattern (glob-pattern), and replaced with an alphabetically sorted list of file names which match the pattern.
In matching file names, the character . (period) at the beginning of a file name or immediately following a / (forward slash), as well as the character / must be matched explicitly. The character * matches any string of characters, including the null string. The character ? matches any single character. The sequence […] matches any one of the characters enclosed. Within […], a pair of characters separated by - matches any character lexically between the two.
Some glob-patterns can be negated: The sequence [^…] matches any single character not specified by the characters and ranges of characters in the braces.
> echo *
bang crash crunch ouch
> echo ^cr*
bang ouch
Glob-patterns which do not use '?', '*', or'[]'
or which use '{}' or '^' are not negated correctly.The metanotation a{b,c,d}e is a shorthand for abe ace ade. Left-to-right order is preserved: /usr/source/s1/{oldls,ls}.c expands to /usr/source/s1/oldls.c /usr/source/s1/ls.c. The results of matches are sorted separately at a low level to preserve this order, such as, like the following example, where ../{memo,*box} might expand to ../memo ../box ../mbox. (Note that 'memo' was not sorted with the results of matching '*box'.) It is not an error when this construct expands to files which do not exist, but it is possible to get an error from a command to which the expanded list is passed. This construct can be nested. As a special case the words {, } and {} are passed undisturbed. The character ~ at the beginning of a file name refers to home directories. Standing alone, for example, ~, it expands to the invoker's home directory as reflected in the value of the home shell variable. When followed by a name consisting of letters, digits and - (hyphen) characters the shell searches for a user with that name and substitutes their home directory; thus ~ken might expand to /usr/ken and ~ken/chmach to /usr/ken/chmach. If the character ~ is followed by a character other than a letter or / or appears elsewhere than at the beginning of a word, it is left undisturbed. A command like setenv MANPATH /usr/man:/usr/local/man:~/lib/man does not, therefore, do home directory substitution as one might hope. It is an error for a glob-pattern containing '*', '?', '[' or '~', with or without '^', not to match any files. However, only one pattern in a list of glob-patterns must match a file (so that, for example, rm *.a *.c *.o would fail only if there were no files in the current directory ending in '.a', '.c', or '.o'), and if the nonomatch shell variable is set a pattern (or list of patterns) which matches nothing is left unchanged instead of causing an error.
The noglob shell variable can be set to prevent file name substitution, and the expand-glob editor command, normally bound to ^X-*, can be used to interactively expand individual file name substitutions.
The directory stack is a list of directories, numbered from zero, used by the pushd, popd and dirs built-in commands for tcsh. dirs can print, store in a file, restore, and clear the directory stack at any time, and the savedirs and dirsfile shell variables can be set to store the directory stack automatically on logout and restore it on login. The dirstack shell variable can be examined to see the directory stack and set to put arbitrary directories into the directory stack.
> dirs -v
0 /usr/bin
1 /usr/spool/uucp
2 /usr/accts/sys
> echo =1
/usr/spool/uucp
> echo =0/calendar
/usr/bin/calendar
> echo =-
/usr/accts/sys
The noglob and nonomatch shell
variables and the expand-glob editor command apply to directory
stack as well as file name substitutions.There are several more transformations involving file names, not strictly related to the Directory stack substitution, but mentioned here for completeness. Any file name can be expanded to a full path when the symlinks variable is set to expand. Quoting prevents this expansion, and the normalize-path editor command does it on demand. The normalize-command editor command expands commands in PATH into full paths on demand. Finally, cd and pushd interpret - (hyphen) as the old working directory (equivalent to the tcsh shell variable owd). This is not a substitution at all, but an abbreviation recognized only by those commands. Nonetheless, it too can be prevented by quoting.
The next three topics describe how the shell executes commands and deals with their input and output.
Built-in commands for tcsh are executed within the shell. If any component of a pipeline except the last is a built-in command, the pipeline is executed in a subshell.
(cd; pwd); pwd
which
prints the home directory, leaving you where you were (printing this
after the home directory), while cd; pwd
leaves
you in the home directory. Parenthesized commands are most often used
to prevent cd from affecting the current
shell.When a command to be executed is found not to be a built-in command the tcsh shell attempts to execute the command via execve. Each word in the variable path names a directory in which the tcsh shell will look for the command. If it is given neither a -c nor a -t option, the shell hashes the names in these directories into an internal table so that it will only try an execve in a directory if there is a possibility that the command resides there. This greatly speeds command location when a large number of directories are present in the search path. If this mechanism has been turned off (via unhash), if the shell was given a -c or -t argument or in any case for each directory component of path which does not begin with a /, the shell concatenates the current working directory with the given command name to form a path name of a file which it then attempts to execute.
If the file has execute permissions but is not an executable to the system (that is, it is neither an executable binary nor a script which specifies its interpreter), then it is assumed to be a file containing shell commands and a new shell is spawned to read it. The shell special alias can be set to specify an interpreter other than the shell itself.
The standard input and standard output of a command can be redirected with the following syntax listed in Table 1.
Syntax | Description |
---|---|
< name | Open file name (which is first variable, command and file name expanded) as the standard input. |
<< word | Read the shell input up to a line which is identical to word. word is not subjected to variable, file name or command substitution, and each input line is compared to word before any substitutions are done on this input line. Unless a quoting \, " , ' ' or ' ' ' appears in word variable and command substitution is performed on the intervening lines, allowing \ to quote $, \ and ' (single quotation mark). Commands which are substituted have all blanks, tabs, and newlines preserved, except for the final newline which is dropped. The resultant text is placed in an anonymous temporary file which is given to the command as standard input. |
> name |
The file name is
used as standard output. If the file does not exist then it is created;
if the file exists, its is overwritten and, therefore, the previous
contents are lost. If the shell variable noclobber is set, then the file must not exist or be a character special file (for example, a terminal or /dev/null) or an error results. This helps prevent accidental destruction of files. In this case the ! forms can be used to suppress this check. The forms involving & (ampersand) route the diagnostic output into the specified file as well as the standard output. name is expanded in the same way as < input file names are. |
>> name |
Like >, but appends output to the end of name. If the shell variable noclobber is set, then it is an error for the file not to exist, unless one of the ! forms is given. |
A command receives the environment in which the shell was invoked as modified by the input-output parameters and the presence of the command in a pipeline. Thus, unlike some previous shells, commands run from a file of shell commands have no access to the text of the commands by default; instead they receive the original standard input of the shell. The << mechanism should be used to present inline data. This permits shell command scripts to function as components of pipelines and allows the shell to block read its input. The default standard input for a command run detached is not the empty file /dev/null, but the original standard input of the shell. If this is a terminal and if the process attempts to read from the terminal, then the process will block and the user is notified (see Jobs).
Diagnostic output can be directed through a pipe with the standard output. Simply use the form |& instead of just |.
The shell cannot presently redirect diagnostic output without also redirecting standard output, but (command > output-file) >& error-file is often an acceptable workaround. Either output-file or error-file can be /dev/tty to send output to the terminal.
Having described how the shell accepts, parses and executes command lines, we now turn to a variety of its useful features.
The tcsh shell contains a number of commands which can be used to regulate the flow of control in command files (shell scripts) and (in limited by useful ways) from terminal output. These commands all operate by forcing the shell to reread or skip in its input and, due to the implementation, restrict the placement of some of the commands.
The foreach, switch, and while statements, as well as the if-then-else form of the if statement, require that the major keywords appear in a single simple command on an input line.
If the shell's input is not seekable, the shell buffers up input whenever a loop is being read and performs seeks in this internal buffer to accomplish the rereading implied by the loop . (To the extent that this allows, backward gotos will succeed on non-seekable inputs.)
The if, while, and exit built-in commands use expressions with a common syntax. The expressions can include any of the operators described in the next three topics. Note that the @ built-in command has its own separate syntax.
|| && | ^ & == != =~ !~ <= >=
< > << >> + - * / % ! ~ ( )
Here the precedence
increases to the right, '==' '!=' '=~' and '!~', '<=' '>=' '<'
and '>', '<<' and '>>', '+' and '-', '*' / and '%' being in
groups, at the same level. The '==' '!=' '=~' and '!~' operators compare
their arguments as strings; all others operate on numbers. The operators
'=~' and '!~' are like '!=' and '==' except that the right hand side
is a glob-pattern (see File name substitution)
against which the left hand operand is matched. This reduces the need
for use of the switch built-in command in
shell scripts when all that is really needed is pattern matching.Strings that begin with 0 are considered octal numbers. Null or missing arguments are considered 0. The results of all expressions are strings, which represent decimal numbers. It is important to note that no two components of an expression can appear in the same word; except when adjacent to components of expressions which are syntactically significant to the parser ('$' '|' '<' '>' '(' ')') they should be surrounded by spaces.
Commands can be executed in expressions and their exit status returned by enclosing them in braces ({}). The braces must be separated from the words of the command by spaces. Command executions succeed, returning true, that is, 1, if the command exits with status 0, otherwise they fail, returning false (0). If more detailed status information is required, then the command should be executed outside of an expression and the status shell variable examined.
These operators can be combined for conciseness: –xy file is equivalent to –x file && –y file. For example, –fx is true (returns 1) for plain executable files, but not for directories.
L can be used in a multiple-operator test to apply subsequent operators to a symbolic link instead of to the file to which the link points. For example, -lLo is true for links owned by the invoking user. Lr, Lw, and Lx are always ture for links and false for non-links. L has a different meaning when it is the last operator in a multiple-operator test.
It is possible but not useful, and sometimes misleading, to combine operators which expect file to be a file with operators which do not (for example, X and t). Following L with a non-file operator can lead to particularly strange results.
File inquiry operators can also be evaluated with the filetest built-in command.
if ( -T file == IBM-1047 ) #True if tagged as IBM-1047 text
if ( -B file ) #True if tagged as binary
[1] 1234
indicating
that the job which was started asynchronously was job number 1 and
had one (top-level) process, whose process id was 1234.If you are running a job and want to do something else you can press the suspend key (typically ^Z), which sends a STOP signal to the current job. The shell will then normally indicate that the job has been 'Suspended' and print another prompt. If the listjobs shell variable is set, all jobs is listed like the jobs built-in command; if it is set to 'long' the listing is in long format, like jobs -l. You can then manipulate the state of the suspended job. You can put it in the background with the bg command or run some other commands and eventually bring the job back into the foreground with fg. (See also the run-fg-editor editor command.) A ^Z takes effect immediately and is like an interrupt in that pending output and unread input are discarded when it is typed. The wait built-in command causes the shell to wait for all background jobs to complete.
The ^] key sends a delayed suspend signal, which does not generate a STOP signal until a program attempts to read it, to the current job. This can be typed ahead when you have prepared some commands for a job that you want to stop after it has read them. The ^Y key performs this function in csh; in tcsh , ^Y is an editing command.
A job being run in the background stops if it tries to read from the terminal. Background jobs are typically allowed to produce output, but this can be disabled by giving the command stty tostop. If you set the stty option, then background jobs will stop when they try to produce output like they do when they try to read input.
There are several ways to refer to jobs in the shell. The character % introduces a job name. If you want to refer to job number 1, you can name it as %1. Just naming a job brings it to the foreground; thus %' is a synonym for fg %1, bringing job 1 back into the foreground. Similarly, saying %1 & resumes job 1 in the background, just like bg %1. A job can also be named by an unambiguous prefix of the string typed in to start it: %ex would normally restart a suspended ex job, if there were only one suspended job whose name began with the string 'ex'. It is also possible to say %? string to specify a job whose text contains string , if there is only one such job.
The shell maintains a notion of the current and previous jobs. In output pertaining to jobs, the current job is marked with a + (plus) and the previous job with a - (hyphen). The abbreviations %+, %, and (by analogy with the syntax of the history mechanism) %% all refer to the current job, and %- refers to the previous job.
The job control mechanism requires that the stty option new be set on some systems. It is an artifact from a new implementation of the tty driver which allows generation of interrupt characters from the keyboard to tell jobs to stop. See stty and the setty tcsh built-in command for details on setting options in the new tty driver.
The tcsh shell learns immediately whenever a process changes state. It normally informs you whenever a job becomes blocked so that no further progress is possible, but only just before it prints a prompt. This is done so that it does not otherwise disturb your work. If, however, you set the shell variable notify, the shell will notify you immediately of changes of status in background jobs. There is also a shell command notify which marks a single process so that its status changes are immediately reported. By default notify marks the current process; simply say 'notify' after starting a background job to mark it.
When you try to leave the shell while jobs are stopped, you are warned that 'You have stopped jobs.' You can use the jobs command to see what they are. If you do this or immediately try to exit again, the shell will not warn you a second time and the suspended jobs are terminated.
There are various ways to run commands and take other actions automatically at various times in the life cycle of the shell.
When using the system's multicultural support, the setlocale function is called to determine appropriate character classification and sorting. This function typically examines the LANG and LC_CTYPE environment variables; refer to the system documentation for further details.
Unknown characters (those that are neither printable nor control characters) are printed in the format \nnn.
The version shell variable indicates what options were chosen when the shell was compiled. Note also the newgrp built-in and echo_style shell variable and the locations of the shell's input files (see tcsh files).
Restriction: The tcsh shell currently does not support three locales. They are IBM-1388 (Chinese), IBM-933 (Korean) and IBM-937 (Traditional Chinese).
Login shells ignore interrupts when reading the file ~/.logout.The shell ignores quit signals unless started with -q. Login shells catch the terminate signal, but non-login shells inherit the terminate behavior from their parents. Other signals have the values which the shell inherited from its parent.
In shell scripts, the shell's handling of interrupt and terminate signals can be controlled with onintr, and its handling of hangups can be controlled with hup and nohup.
The shell exits on a hangup (see also the logout shell variable). By default, the shell's children do too, but the shell does not send them a hangup when it exits. hup arranges for the shell to send a hangup to a child when it exits, and nohup sets a child to ignore hangups.
The shell uses three different sets of terminal (tty) modes: edit, used when editing, quote, used when quoting literal characters, and execute, used when executing commands. The shell holds some settings in each mode constant, so commands which leave the tty in a confused state do not interfere with the shell. The shell also matches changes in the speed and padding of the tty. The list of tty modes that are kept constant can be examined and modified with the setty built-in. Although the editor uses CBREAK mode (or its equivalent), it takes typed-ahead characters anyway.
The echotc, settc and telltc commands can be used to manipulate and debug terminal capabilities from the command line.
The tcsh shell adapts to window resizing automatically and adjusts the environment variables LINES and COLUMNS if set.
The following table lists the tcsh built-in commands, which are not /bin/sh built-ins.
@ (at) | filetest | notify | source |
% | glob | onintr | telltc |
alloc | hashstat | popd | uncomplete |
bindkey | hup | pushd | unhash |
builtins | limit | rehash | unlimit |
bye | log | repeat | unsetenv |
chdir | login | sched | watchlog |
complete | logout | setenv | where |
dirs | ls-F | settc | which |
echotc | notify | setty |
Other tcsh built-in commands are also found in the z/OS shell. In some cases, they might differ in function; see the specific command description for a discussion of the tcsh version of the command.
: (colon) | continue | fg | nice | stop | unset |
alias | echo | history | nohup | suspend | wait |
bg | eval | jobs | printenv | time | writedown |
break | exec | kill | set | umask | |
cd | exit | newgrp | shift | unalias |
> alias cwdcmd 'echo -n "^[]2;${HOST}:$cwd ^G"'
then
the shell will change the title of the running xterm to be the name
of the host, a colon, and the full current working directory. A fancier
way to do that is > alias cwdcmd 'echo -n "^[]2;${HOST}:$cwd^G^[]1;${HOST}^G"'
This
will put the hostname and working directory on the title bar but only
the hostname in the icon manager menu. Putting a cd, pushd or popd in cwdcmd might
cause an infinite loop. > set tperiod = 30
> alias periodic checknews
then the checknews program
runs every 30 minutes. If periodic is set
but tperiod is unset or set to 0, periodic behaves
like precmd.> alias precmd date
then date runs
just before the shell prompts for each command. There are no limits
on what precmd can be set to do, but discretion
should be used.The variables described in this topic have special meaning to the tcsh shell. The tcsh shell sets addsuffix, argv, autologout, command, echo_style, edit, gid, group, home, loginsh, path, prompt, prompt2, prompt3, shell, shlvl, tcsh, term, tty, uid, user, and version at startup. They do not change thereafter, unless changed by the user. The tcsh shell updates cwd, dirstack, owd, and status when necessary, and sets logout on logout.
The shell synchronizes group, home, path, shlvl, term, and user with the environment variables of the same names: whenever the environment variable changes the shell changes the corresponding shell variable to match (unless the shell variable is read-only) and vice versa. Although cwd and PWD have identical meanings, they are not synchronized in this manner.
The shell automatically interconverts the different formats of path and PATH.
Variable | Purpose |
---|---|
addsuffix | If set, file name completion adds / to the end of directories and a space to the end of normal files. |
ampm | This variable gives a user the ability to alter the time format in their tcsh prompt. Specifically, ampm will override the %T and %P formatting sequences in a user's prompt. If set, all times are shown in 12hour AM/PM format. |
argv | The arguments to the shell. Positional parameters are taken from argv. For example, $1 is replaced by $argv. Set by default, but typically empty in interactive shells. |
autocorrect | If set, the spell-word editor command is invoked automatically before each completion. (This variable is not implemented.) |
autoexpand | If set, the expand-history editor command is invoked automatically before each completion attempt. |
autolist | If set, possibilities are listed after an ambiguous completion. If set to ambiguous, possibilities are listed only when no new characters are added by completion. |
autologout | Set to the number of minutes of inactivity before automatic logout. Automatic locking is an unsupported feature on the z/OS platform. If you specify a second parameter on the autologout statement (intending it to be for autolock), this parameter will be assigned to autologout. When the shell automatically logs out, it prints 'autologout', sets the variable logout to automatic and exits. Set to 60 (automatic logout after 60 minutes) by default in login and superuser shells, but not if the shell thinks it is running under a window system (the DISPLAY environment variable is set), or the tty is a pseudo-tty (pty). See also the logout shell variable. |
backslash_ quote | If set, backslashes (\) always quote \, ' (single quotation mark) and " (double quotation mark). This might make complex quoting tasks easier, but it can cause syntax errors in csh scripts. |
cdpath | A list of directories in which cd should search for subdirectories if they aren't found in the current directory. |
command | If set, the command which was passed to the shell with the -c flag. |
complete | If set to enhance, completion first ignores case and then considers periods, hyphens and underscores ('.', '-' and '_') to be word separators and hyphens and underscores to be equivalent. |
correct | If set to cmd, commands are automatically spelling-corrected. If set to complete, commands are automatically completed. If set to all, the entire command line is corrected. |
cwd | The full path name of the current directory. See also the dirstack and owd shell variables. |
dextract | If set, pushd +n extracts the nth directory from the directory stack instead of rotating it to the top. |
dirsfile | The default location in which dirs
-S and dirs -L look for a
history file. If unset, ~/.cshdirs is used.
Because only ~/.tcshrc is normally sourced
before ~/.cshdirs, dirsfile should be set
in ~/.tcshrc instead of ~/.login. For
example:
|
dirstack | An array of all the directories on the directory stack. $dirstack[1] is the current working directory, $dirstack[2] the first directory on the stack, etc. Note that the current working directory is $dirstack[1] but =0 in directory stack substitutions, etc. One can change the stack arbitrarily by setting dirstack, but the first element (the current working directory) is always correct. See also the cwd and owd shell variables. |
dunique | If set, pushd removes any instances of name from the stack before pushing it onto the stack. |
echo | If set, each command with its arguments is echoed just before it is executed. For non-built-in commands all expansions occur before echoing. Built-in commands are echoed before command and file name substitution, since these substitutions are then done selectively. Set by the -x command line option. |
echo_style | The style of the echo built-in.
Can be set to:
The
following is an example of this variable's use:
|
edit | If set, the command-line editor is used. Set by default in interactive shells. |
ellipsis | If set, the %c'/'%. and %C prompt sequences (see the prompt shell variable) indicate skipped directories with an ellipsis (…) instead of /. |
fignore | Lists file name suffixes to be ignored by completion. |
filec | In the tcsh shell, completion is always used and this variable is ignored. |
gid | The user's real group ID. |
group | The user's group name. |
histchars | A string value determining the characters used in history substitution. The first character of its value is used as the history substitution character, replacing the default character ! (exclamation point). The second character of its value replaces the character ^ (caret) in quick substitutions. |
histdup | Controls handling of duplicate entries in the history list. If set to all only unique history events are entered in the history list. If set to prev and the last history event is the same as the current command, then the current command is not entered in the history. If set to erase and the same event is found in the history list, that old event gets erased and the current one gets inserted. The prev and all options renumber history events so there are no gaps. |
histfile | The default location in which history
-S and history -L look for
a history file. If unset, ~/.history is
used. histfile is useful when sharing the same home directory
between different machines, or when saving separate histories on different
terminals. Because only ~/.tcshrc is normally
sourced before ~/.history, histfile should
be set in ~/.tcshrc instead of ~/.login. An
example:
|
histlit | If set, built-in and editor commands and the savehist mechanism use the literal (unexpanded) form of lines in the history list. See also the toggle-literal-history editor command. |
history | The first word indicates the number of history events to save. The optional second word indicates the format in which history is printed; if not given, %h\t%T\t%R\n is used. The format sequences are described under prompt. (Note that %R has a variable meaning). Set to 100 by default. |
home | Initialized to the home directory of the invoker. The file name expansion of ~ refers to this variable. |
ignoreeof | If set to the empty string or 0 and the input device is a terminal, the end-of-file command (typically generated by the user by typing ^D on an empty line) causes the shell to print 'Use "logout" to leave tcsh.' instead of exiting. This prevents the shell from accidentally being killed. If set to a number n, the shell ignores n - 1 consecutive end-of-files and exits on the nth. If unset, 1 is used. That is, the shell exits on a single ^D. |
implicitcd | If set, the shell treats a directory name typed as a command as though it were a request to change to that directory. If set to verbose, the change of directory is echoed to the standard output. This behavior is inhibited in non-interactive shell scripts, or for command strings with more than one word. Changing directory takes precedence over executing a like-named command, but it is done after alias substitutions. Tilde and variable expansions work as expected. |
inputmode | If set to insert or overwrite, puts the editor into that input mode at the beginning of each line. |
listflags | If set to x, a or A, or any combination thereof (for example, xA), they are used as flags to ls-F, making it act like ls -xF, ls -Fa, ls -FA or a combination (for example, ls -FxA): a shows all files (even if they start with a '.'), A shows all files but '.' and '..', and x sorts across instead of down. If the second word of listflags is set, it is used as the path to ls(1). |
listjobs | If set, all jobs are listed when a job is suspended. If set to long, the listing is in long format. |
listlinks | If set, the ls-F built-in command shows the type of file to which each symbolic link points. For an example of its use, see ls-F built-in command for tcsh: List files. |
listmax | The maximum number of items which the list-choices editor ocmmand will list without asking first. |
listmaxrows | The maximum number of rows of items which the list-choices editor command will list without asking first. |
loginsh | Set by the shell if is a login shell. Setting or unsetting it within a shell has no effect. See also shlvl. |
logout | Set by the shell to normal before a normal logout, automatic before an automatic logout, and hangup if the shell was killed by a hangup signal. See also the autologout shell variable. |
The names of the files or directories
to check for incoming mail, separated by white space, and optionally
preceeded by a numeric word. Before each prompt, if 10 minutes have
passed since the last check, the shell checks each file and says
'You have new mail.' (or, if mail contains multiple files, 'You have
new mail in name.') if the filesize is greater than zero in size and
has a modification time greater than its access time. If you are in a login shell, then no mail file is reported unless it has been modified after the time the shell has started up, in order to prevent redundant notifications. Most login programs will tell you whether or not you have mail when you log in. If a file specified in mail is a directory, the shell will count each file within that directory as a separate message, and will report 'You have n mails.' or 'You have n mails in name.' as appropriate. This functionality is provided primarily for those systems which store mail in this manner, such as the Andrew Mail System. If the first word of mail is numeric it is taken as a different mail checking interval, in seconds. Under very rare circumstances, the shell might report 'You have mail.' instead of 'You have new mail.' |
|
matchbeep | If set to never, completion never beeps. If set to nomatch, it beeps only when there is no match. If set to ambiguous, it beeps when there are multiple matches. If set to notunique, it beeps when there is one exact and other longer matches. If unset, ambiguous is used. |
nobeep | If set, beeping is completely disabled. |
noclobber | If set, restrictions are placed on output redirection to insure that files are not accidentally destroyed and that >> redirections refer to existing files, as described in Input or output. |
noglob | If set, file name substitution and directory stack substitution are inhibited. This is most useful in shell scripts which do not deal with file names, or after a list of file names has been obtained and further expansions are not desirable. |
nokanji | If set and the shell supports Kanji (see the version shell variable), it is disabled so that the meta key can be used. |
nonomatch | If set, a file name substitution or directory stack substitution which does not match any existing files is left untouched instead of causing an error. It is still an error for the substitution to be malformed, that is, echo [ still gives an error. |
nostat | A list of directories (or glob-patterns which match directories; see File name substitution) that should not be stat(2)ed during a completion operation. This is typically used to exclude directories which take too much time to stat(2), for example /afs. |
notify | If set, the shell announces job completions asynchronously. The default is to present job completions just before printing a prompt. |
owd | The old working directory, equivalent to the - (hyphen) used by cd and pushd. See also the cwd and dirstack shell variables. |
path | A list of directories in which to look for executable commands. A null word specifies the current directory. If there is no path variable then only full path names will be executed. path is set by the shell at startup from the PATH environment variable or, if PATH does not exist, to a system-dependent default something like (/usr/local/bin /usr/bsd /bin /usr/bin .). The shell might put '.' first or last in path or omit it entirely depending on how it was compiled; see the version shell variable. A shell which is given neither the -c nor the -t option hashes the contents of the directories in path after reading ~/.tcshrc and each time path is reset. If you add a new command to a directory in path while the shell is active, you might need to do a rehash for the shell to find it. |
printexit- value | If set and an interactive program exits with a nonzero status, the shell prints 'Exit status'. |
prompt2 | The string with which to prompt in while and foreach loops and after lines ending in \ (backslash). The same format sequences can be used as in prompt (note the variable meaning of %R). Set by default to %R? in interactive shells. |
prompt3 | The string with which to prompt when confirming automatic spelling correction. The same format sequences can be used as in prompt (note the variable meaning of %R). Set by default to CORRECT>%R (y|n|e|a)? in interactive shells. |
promptchars | If set to a two-character string, the %# formatting sequence in the prompt shell variable is replaced with the first character for normal users and the second character for the superuser. |
pushdtohome | If set, pushd without arguments does pushd ^, like cd. |
pushdsilent | If set, pushd and popd do not print the directory stack. |
recexact | If set, completion completes on an exact match even if a longer match is possible. |
recognize_ only_ executables | If set, command listing displays only files in the path that are executable. |
rmstar | If set, the user is prompted before rm * is executed. |
rprompt | The string to print on the right-hand side of the screen (after the command input) when the prompt is being displayed on the left. It recognises the same formatting characters as prompt. It will automatically disappear and reappear as necessary, to ensure that command input isn't obscured, and will only appear if the prompt, command input, and itself will fit together on the first line. If edit isn't set, then rprompt will be printed after the prompt and before the command input. |
savedirs | If set, the shell does dirs -S before exiting. |
savehist | If set, the shell does history
-S before exiting. If the first word is set to a number,
at most that many lines are saved. (The number must be less than or
equal to history.) If the second word is set to merge, the
history list is merged with the existing history file instead of replacing
it (if there is one) and sorted by time stamp and the most recent
events are retained. An example:
|
sched | The format in which the sched built-in command prints scheduled events. If not given, %h\t%T\t%R\n is used. The format sequences are described under prompt; note the variable meaning of %R. |
shell | The file in which the shell resides. This is used in forking shells to interpret files which have execute bits set, but which are not executable by the system (see Built-in and non-built-in command execution. Initialized to the (system-dependent) home of the shell. |
shlvl | The number of nested shells. Reset to 1 in login shells. See also loginsh. |
status | The status returned by the last command. If it terminated abnormally, then 0200 is added to the status. tcsh built-in commands which fail return exit status 1, all other built-in commands return status 0. |
tcsh | The version number of the shell in the format R.VV.PP, where R is the major release number, VV the current version and PP the patch level. |
term | The terminal type. Typically set in ~/.login. |
tperiod | The period, in minutes, between executions of the periodic special alias. |
tty | The name of the tty, or empty if not attached to one. |
uid | The user's login name. |
user | The user's login name. |
verbose | If set, causes the words of each command to be printed, after history substitution (if any). Set by the –v command line option. |
version | The version ID stamp. It contains
the shell's version number (see tcsh), origin, release date, vendor,
operating system and machine (see VENDOR, OSTYPE, and MACHTYPE environment
variables) and a comma-separated list of options which were set at
compile time. Options which are set by default in the distribution
are noted.
|
visiblebell | If set, a screen flash is used instead of the audible bell. See nobeep. (Currently not implemented.) |
watch | A list of user/terminal pairs to
watch for logins and logouts. If either the user is any all
terminals are watched for the given user and vice versa. Setting watch
to (any any) watches all users and terminals. For example,
reports
activity of the user george on ttyd1, any user on the console, and
oneself (or a trespasser) on any terminal. Logins and logouts are
checked every 10 minutes by default, but the first word of watch can
be set to a number to check every so many minutes. For example,
reports
any login/logout once every minute. For the impatient, the log built-in
command triggers a watch report at any time. All current logins are
reported (as with the log built-in) when
watch is first set.The who shell variable controls the format of watch reports. |
who | The format string for watch messages.
The following sequences are replaced by the given information:
|
wordchars | A list of non-alphanumeric characters to be considered part of a word by the forward-word, backward word, etc. editor commands. If unset, *?_-.[] ~= is used. |
tcsh shell variables not described in the Table 2 are described as follows:
>set prompt = "%m [%h] %B[%@%b [%/] you rang?"
tut [37] [2:54] [/usr/accts/sys] you rang? _
Set
by default to %# in interactive shells. > cd /tmp
> mkdir from from/src to
> ln -s from/src to/dist
Here's the behavior
with symlinks unset, > cd /tmp/to/dist; echo $cwd
/tmp/to/dist
> cd ..; echo $cwd
/tmp/from
here's the behavior with symlinks set
to chase, > cd /tmp/to/dst; echo $cwd
/tmp/from/src
> cd ..; echo $cwd
/tmp/from
here's the behavior with symlinks set
to ignore, > cd /tmp/to/dist; echo $cwd
/tmp/to/dst
> cd ..; echo $cwd
/tmp/to
and here's the behavior with symlinks set
to expand. > cd /tmp/to/dist; echo $cwd
/tmp/to/dst
> cd ..; echo $cwd
/tmp/to
> cd /tmp/to/dist; echo $cwd
/tmp/to/dst
> cd ".."; echo $cwd
/tmp/from
> /bin/echo ..
/tmp/to
> /bin/echo ".."
..
expand expansion: Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww
for
systems that support resource usage reporting.The following table contains a list of tcsh environment variables.
Environment variable | Purpose |
---|---|
COLUMNS | A list of directories in which cd should search for subdirectories if they aren't found in the current directory. |
DISPLAY | Used by X Window System. If set, the shell does not set AUTOLOGOUT. |
EDITOR | The path name to a default editor. See also the VISUAL environment variable and the run-fg-editor editor command. |
GROUP | Equivalent to the group shell variable. |
HOME | Equivalent to the HOME shell variable. |
HOST | Initialized to the name of the machine of the machine on which the shell is running, as determined by the gethostname system call. |
HOSTTYPE | Initialized to the type of the machine on which the shell is running, as determined at compile time. This variable is obsolete and will be removed in a future version. |
HPATH | A colon-separated list of directories in which the run-help editor command looks for a command documentation. |
LANG | Gives the preferred character environment. See National language system report. |
LC_CTYPE | If set, only CTYPE character handling is changed. See National language system report. |
LINES | The number of lines in the terminal. See Managing terminals. |
MACHTYPE | The machine type (microprocessor class or machine model), as determined at compile time. |
NOREBIND | If set, printable characters are not rebound to SELF-INSERT-COMMAND. After a user sets NOREBIND, a new shell must be started. See National language system report. |
OSTYPE | The operating system, as determined at compile time. |
PATH | A colon-separated list of directories in which to look for executables. Equivalent to the path shell variable, but in a different format. |
PWD | Equivalent to the cwd shell variable, but not synchronized to it; updated only after an actual directory change. |
REMOTE- HOST | The host from which the user has logged in remotely, if this is the case and the shell is able to determine it. (The z/OS tcsh shell is not currently compiled with REMOTEHOST defined; see the version shell variable.) |
SHLVL | Equivalent to the shlvl shell variable. |
TERM | Equivalent to the term shell varialbe. |
USER | Equivalent to the user shell variable. |
VENDOR | The vendor, as determined at compile time. |
VISUAL | The path name to a default full-screen editor. See the editor environment variable and the run-fg-editor editor command. |
TXTFLAG = ON, CCSID = existing file tag CCSID
This has no effect if CCSID = 0.
TXTFLAG = OFF, CCSID = existing file tag CCSID
This effectively disables automatic conversion.
TXTFLAG = ON, CCSID = program CCSID at the time of the first write (if not already tagged)
TXTFLAG = OFF, CCSID = program CCSID at the time of the first write (if not already tagged)
TXTFLAG = ON, CCSID = program CCSID at the time of the first write (if not already tagged)
TXTFLAG = OFF, CCSID = program CCSID at the time of the first write (if not already tagged)
(set _TAG_REDIR_OUT=TXT; command >file)
You can also use these shell variables for commands in a pipeline. For example, they can be used to tag the standard output of each command that is writing to a pipeline or to tag the standard input of each command that is reading from a pipeline.
When a suspended command is restarted, the tcsh shell prints the directory it started in if this is different from the current directory. This can be misleading (that is, wrong) as the job might have changed directories internally.
Shell built-in functions are not stoppable/restartable. Command sequences of the form 'a ; b ; c' are also not handled gracefully when stopping is attempted. If you suspend 'b', the tcsh shell will then immediately execute 'c'. This is especially noticeable if this expansion results from an alias. It suffices to place the sequence of commands in ()'s to force it to a subshell, for example, ( a ; b ; c ).
Control over tty output after processes are started is primitive. In a virtual terminal interface much more interesting things could be done with output control.
Alias substitution is most often used to clumsily simulate shell procedures; shell procedures should be provided instead of aliases.
Commands within loops are not placed in the history list. Control structures should be parsed instead of being recognized as built-in commands. This would allow control commands to be placed anywhere, to be combined with |, and to be used with & and ; (semicolon) metasyntax.
foreach does not ignore here-documents when looking for its end.
It should be possible to use the : (colon) modifiers on the output of command substitutions.
The screen update for lines longer than the screen width is very poor if the terminal cannot move the cursor up (terminal type 'dumb').
It is not necessary for HPATH and NOREBIND to be environment variables.
Glob-patterns which do not use '?', '*' or '[]' or which use '{}' or '~' are not negated correctly.
The single-command form of if does output redirection even if the expression is false and the command is not executed.
ls-F includes file identification characters when sorting file names and does not handle control characters in file names well. It cannot be interrupted.
The visiblebell shell variable is currently not implemented.
In file name and programmed completion, the 'C' completion rule word list type does not correctly select completion from the given directory.
There are three locales (code pages) which the tcsh shell will not correctly support: IBM-1388 (Chinese), IBM-933 (Korean) and IBM-937 (Traditional Chinese).
If you want to help maintain and test tcsh, send mail to listserv@mx.gw.com with the text 'subscribe tcsh '.
: (colon), @ (at), alias, bg, break, cd, continue, echo, eval, exec, exit, fg, history, jobs, kill, newgrp, nice, nohup, printenv, set, shift, stop, suspend, time, umask, unalias, unset, wait