Rather than residing on disk like UNIX/Linux executable commands, built-in commands are part of the C/TC shell's internal code and are executed from within the shell. If a built-in command occurs as any component of a pipeline except the last, it is executed in a subshell. The tcsh built-in command aptly called builtins lists all the built-in commands.
Table 9.25. tcsh Built-In Commands and Their Meanings
Command | Meaning |
---|
: | Interprets null command, but performs no action. |
alias [name [wordlist]] | A nickname for a command. Without arguments, prints all aliases; with a name, prints the name for the alias; and with a name and wordlist, sets the alias. |
alloc | Displays amount of dynamic memory acquired, broken down into used and free memory. Varies across systems. |
bg [%job]
%job &
| Runs the current or specified jobs in the background.
A synonym for the bg built-in command. |
bindkey [-l|-d|-e|-v|-u] (+)
bindkey [-a] [-b] [-k] [-r] [--] key
bindkey [-a] [-b] [-k] [-c|-s] [--] key command
| 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 key is bound; and the third form binds the editor command command to key. Options include: |
-a | Lists or changes keybindings in the alternative key map. This is the key map used in vi command mode. |
-b | This key is interpreted as a control character written as ^character (e.g., ^A) or C-character (e.g., C-A), a meta- character written M-character (e.g., M-A), a function key written F-string (e.g., F-string), or an extended prefix key written X-character (e.g., X-A). |
-c | This command is interpreted as a built-in or external command, instead of an editor command. |
-d | Binds all keys to the standard bindings for the default editor. |
-e | Binds all keys to the standard GNU emacs-like bindings. |
-k | This key is interpreted as a symbolic arrow key name, which may be one of "down," "up," "left," or "right." |
-l | Lists all editor commands and a short description of each. |
-r | Removes key's binding. Be careful: bindkey-r does not bind key to self-insert command (q.v.), it unbinds key completely. |
-s | This command is taken as a literal string and treated as terminal input when key is typed. Bound keys in commands are themselves reinterpreted, and this continues for 10 levels of interpretation. |
-u | (or any invalid option) Prints a usage message. This key may be a single character or a string. If a command is bound to a string, the first character of the string is bound to sequence-lead-in and the entire string is bound to the command. |
-v | Binds all keys to the standard vi(1)-like bindings. |
-- | Forces a break from option processing, so the next word is taken as a key even if it begins with a hyphen (-). |
Control characters in key can be literal (they can be typed by preceding them with the editor command quoted-insert, normally bound to ^V), or written caret-character style (e.g., ^A). Delete is written ^? (caret-question mark). Key and command can contain backslashed escape sequences (in the style of System V echo(1)) as follows: |
\a Bell
\b Backspace
\e Escape
\f Form feed
\n Newline
\r Carriage return
\t Horizontal tab
\v Vertical tab
\nnn The ASCII character corresponding to the octal number nnn
\ nullifies the special meaning of the following character, if it has any, notably backslash (\) and caret (^). |
break | Breaks out of the innermost foreach or while loop. |
breaksw | Breaks from a switch, resuming after the endsw. |
builtins | Prints the names of all built-in commands. |
bye | A synonym for the logout built-in command. Available only if the shell was so compiled; see the version shell variable. |
case label: | A label in a switch statement. |
cd [ dir ] | Changes the shell's working directory to dir. If no argument is given, changes to the home directory of the user. |
cd [-p] [-l] [-n|-v] [name] | If a directory name is given, changes the shell's working directory to name. If not, changes to home. If name is "-" it is interpreted as the previous working directory. -p prints the final directory stack, just like dirs. -l, -n, and -v flags have the same effect on cd as on dirs, and they imply -p. |
chdir | A synonym for the cd built-in command. |
complete [command [word/pattern/list[:select]/[[suffix]/] ...]] | Without arguments, lists all completions. With command, lists completions for command. With command and word etc., defines completions. (See "Programming Completions" on page 485.) |
continue | Continues execution of the nearest enclosing while or foreach. |
default: | Labels the default case in a switch statement. The default should come after all case labels. |
dirs [-l] [-n|-v]
dirs -S|-L [filename]
dirs -c
| The first form prints the directory stack. The top of the stack is at the left and the first directory in the stack is the current directory. -l, ~, or ~name in the output is expanded explicitly to home or the pathname of the home directory for username.
(+) -n, entries are wrapped before they reach the edge of the screen. (+) -v, entries are printed one per line preceded by their stack postions. -S, the second form saves the directory stack to filename as a series of cd and pushd commands. -L, the shell source's filename, which is presumably a directory stack file saved.
In either case dirsfile is used if filename is not given and ~/.cshdirs is used if dirsfile is unset.
With -c, form clears the directory stack.
|
echo [ -n ] list | Writes the words in list to the shell's standard output, separated by space characters. The output is terminated with a newline unless the -n option is used. |
echo [-n] word ... | Writes each word to the shell's standard output, separated by spaces and terminated with a newline. The echo_style shell variable may be set to emulate (or not) the flags and escape sequences of the BSD and/or System V versions of echo. |
echotc [-sv] arg ... | Exercises the terminal capabilities (see term-cap(5)) in args. For example, echotc home sends the cursor to the home position. If arg is baud, cols, lines, meta, or tabs, prints the value of that capability. With -s, nonexistent capabilities return the empty string rather than causing an error. With -v, messages are verbose. |
else if (expr2) then | See "Conditional Constructs and Flow Control" on page 535. |
else
end
endif
endsw
| See the description of the foreach, if, switch, and while statements below. |
end | Executes the commands between the while and the matching end while expr evaluates nonzero. while and end must appear alone on their input lines. break and continue may be used to terminate or continue the loop prematurely. If the input is a terminal, the user is prompted the first time through the loop as with foreach. |
eval arg ... | Treats the arguments as input to the shell and executes the resulting command(s) in the context of the current shell. This is usually used to execute commands generated as the result of command or variable substitution, as parsing occurs before these substitutions. |
eval command | Runs command as standard input to the shell and executes the resulting commands. This is usually used to execute commands generated as the result of command or variable substitution, as parsing occurs before these substitutions (e.g., eval 'tset -s options'). |
exec command | Executes command in place of the current shell, which terminates. |
exit [ (expr) ] | Exits the shell, either with the value of the status variable or with the value specified by expr. |
fg [% job ]
%job
| Brings the current or specified job into the foreground.
A synonym for the fg built-in command. |
filetest -op file ... | Applies op (which is a file inquiry operator) to each file and returns the results as a space-separated list. |
foreach name (wordlist)
...
end
| See "Looping Control Commands" on page 566. |
foreach var (wordlist) | See "The foreach Loop" on page 561. |
getspath | Prints the system execution path. |
getxvers | Prints the experimental version prefix. |
glob wordlist | Performs filename expansion on wordlist. Like echo, but no escapes (\) are recognized. Words are delimited by null characters in the output. |
goto label | See "The goto" on page 547. |
goto word | word is filename and command-substituted to yield a string of the form "label." The shell rewinds its input as much as possible, searches for a line of the form "label:", possibly preceded by blanks or tabs, and continues execution after that line. |
hashstat | Prints a statistics line indicating how effective the internal hash table has been at locating commands (and avoiding execs). An exec is attempted for each component of the path where the hash function indicates a possible hit, and in each component that does not begin with a backslash. |
history [-hTr] [n]
history -S|-L|-M [filename]
history -c
| The first form prints the history event list. If n is given, only the n most recent events are printed or saved. With -h, the history list is printed without leading numbers. If -T is specified, timestamps are printed also in comment form. (This can be used to produce files suitable for loading with history -L or source -h.) With -r, the order of printing is most recent first rather than oldest first. (See "TC Shell Command-Line History" on page 466.) With -c, clears the history list. |
hup [command] | With command, runs command such that it will exit on a hangup signal and arranges for the shell to send it a hangup signal when the shell exits. Note that commands may set their own response to hangups, overriding hup. Without an argument (allowed only in a shell script), causes the shell to exit on a hangup for the remainder of the script. |
if (expr) command | If expr evaluates true, then command is executed. Variable substitution on command happens early, at the same time it does for the rest of the if command. Command must be a simple command, not an alias, a pipeline, a command list, or a parenthesized command list, but it may have arguments. Input/output redirection occurs even if expr is false and command is thus not executed; this is a bug. |
if (expr) then
...
else if (expr2) then
...
else
...
endif
| If the specified expr is true then the commands to the first else are executed; otherwise if expr2 is true then the commands to the second else are executed, and so on. Any number of else if pairs are possible; only one endif is needed. The else part is likewise optional. (The words else and endif must appear at the beginning of input lines; the if must appear alone on its input line or after an else.) |
inlib shared-library ... | Adds each shared library to the current environment. There is no way to remove a shared library. (Domain/OS only) |
jobs [ -l ] | Lists the active jobs under job control. With -l, lists IDs in addition to the normal information. |
kill [ -sig ] [ pid ] [ %job ] ...
kill -l
| Sends the TERM (terminate) signal, by default or by the signal specified, to the specified ID, the job indicated, or the current job. Signals are given either by number or name. There is no default. Typing kill does not send a signal to the current job. If the signal being sent is TERM (terminate) or HUP (hangup), then the job or process is sent a CONT (continue) signal as well. With -l lists the signal names that can be sent. |
limit [ -h ] [ resource [ max-use ] ] | Limits the consumption by the current process or any process it spawns, each not to exceed max-use on the specified resource. If max-use is omitted, print the current limit; if resource is omitted, display all limits. With -h, uses hard limits instead of the current limits. Hard limits impose a ceiling on the values of the current limits. Only the superuser may raise the hard limits. Resource is one of: cputime, maximum CPU seconds per process; filesize, largest single file allowed; datasize, maximum data size (including stack) for the process; stacksize, maximum stack size for the process; coredump, maximum size of a core dump; and descriptors, maximum value for a file descriptor. |
log | Prints the watch shell variable and reports on each user indicated in watch who is logged in, regardless of when they last logged in. See also watchlog. |
login | Terminates a login shell, replacing it with an instance of /bin/login. |
login [ username|-p ] | Terminates a login shell and invokes login(1). The .logout file is not processed. If username is omitted, login prompts for the name of a user. With -p, preserves the current environment (variables). |
logout | Terminates a login shell. |
ls-F [-switch ...] [file ...] | Lists files like ls -F, but much faster. It identifies each type of special file in the listing with a special character: |
/ | Directory |
* | Executable |
# | Block device |
% | Character device |
| | Named pipe (systems with named pipes only) |
= | Socket (systems with sockets only) |
@ | Symbolic link (systems with symbolic links only) |
+ | Hidden directory (AIX only) or context-dependent (HP-UX only) |
: | Network special (HP-UX only) |
If the listlinks shell variable is set, symbolic links are identified in more detail (only, of course, on systems that have them): |
@ | Symbolic link to a nondirectory |
> | Symbolic link to a directory |
& | Symbolic link to nowhere |
The ls-F built-in can list files using different colors depending on the filetype or extension. |
migrate [-site] pid|%jobid ...
migrate -site
| The first form migrates the process or job to the site specified or the default site determined by the system path. The second form is equivalent to migrate -site $$. It migrates the current process to the specified site. Migrating the shell itself can cause unexpected behavior, because the shell does not like to lose its tty. |
@
@ name = expr
@ name[index] = expr
@ name++|--
@ name[index]++|--
| The first form prints the values of all shell variables. The second form assigns the value of expr to name. The third form assigns the value of expr to the index'th component of name; both name and its index'th component must already exist. The fourth and fifth forms increment (++) or decrement (--) name or its index'th component. |
newgrp [-] group | Equivalent to exec newgrp; see newgrp(1). Available only if the shell was so compiled; see the version shell variable. |
nice [+number] [command] | Sets the scheduling priority for the shell to number, or, without number, to 4. With command, runs command at the appropriate priority. The greater the number, the less CPU the process gets. The superuser may specify negative priority by using nice -number . Command is always executed in a subshell, and the restrictions placed on commands in simple if statements apply. |
nohup [ command ] | Runs command with HUPs (hangups) ignored. With no arguments, ignores HUPs throughout the remainder of a script. |
notify [ %job ] | Notifies the user asynchronously when the status of the current or of a specified job changes. |
onintr [ - | label] | Controls the action of the shell on interrupts. With no arguments, onintr restores the default action of the shell on interrupts. (The shell terminates shell scripts and returns to the terminal command input level.) With the minus sign argument, the shell ignores all interrupts. With a label argument, the shell executes a goto label when an interrupt is received or a child process terminates because it was interrupted. |
popd [+n] | Pops the directory stack and cd to the new top directory. The elements of the directory stack are numbered from zero, starting at the top. With +n, discard the nth entry in the stack. |
printenv [name] | Prints the names and values of all environment variables or, with name, the value of the environment variable name. |
pushd [+n | dir] | Pushes a directory onto the directory stack. With no arguments, exchanges the top two elements. With +n, rotates the nth entry to the top of the stack and cd to it. With dir, pushes the current working directory onto the stack and changes to dir. |
rehash | Recomputes the internal hash table of the contents of directories listed in the path variable to account for new commands added. |
repeat count command | Repeats command count times. |
rootnode //nodename | Changes the rootnode to //nodename, so that / will be interpreted as //nodename. (Domain/OS only) |
sched
sched [+]hh:mm command sched -n
| The first form prints the scheduled-event list. The sched shell variable may be set to define the format in which the scheduled-event list is printed. The second form adds a command to the scheduled-event list. |
set
set name ...
set name=word ...
set [-r] [-f|-l] name=(wordlist) ... (+)
set name[index]=word ...
set -r
set -r name ...
set -r name=word ...
| The first form of the command prints the value of all shell variables. Variables that contain more than a single word print as a parenthesized word list. The second form sets name to the null string. The third form sets name to the single word. The fourth form sets name to the list of words in wordlist. In all cases the value is command and filename expanded. If -r is specified, the value is set read-only. If -f or -l are specified, set only unique words keeping their order. -f prefers the first occurrence of a word, and -l the last occurrence of the word. The fifth form sets the index'th component of name to word; this component must already exist. The sixth form lists the names (only) of all shell variables that are read-only. The seventh form makes name read-only, whether or not it has a value. The eighth form is the same as the third form, but makes name read-only at the same time. |
set [var [ = value ] ] | See "Variables" on page 440. |
setenv [ VAR [ word ] ] | See "Variables" on page 440. The most commonly used environment variables, USER, TERM, and PATH, are automatically imported to and exported from the csh variables, user, term, and path; there is no need to use setenv for these. In addition, the shell sets the PWD environment variable from the csh variable cwd whenever the latter changes. |
setenv [name [value]] | Without arguments, prints the names and values of all environment variables. Given name, sets the environment variable name to value or, without value, to the null string. |
setpath path | Equivalent to setpath(1). (Mach only) |
setspath LOCAL|site|cpu ... | Sets the system execution path. |
settc cap value | Tells the shell to believe that the terminal capability cap (as defined in termcap(5)) has the value value. No sanity checking is done. Concept terminal users may have to settc xn no to get proper wrapping at the rightmost column. |
setty [-d|-q|-x] [-a] [[+|-]mode] | Controls which tty modes the shell does not allow to change. -d, -q, or -x tells setty to act on the edit, quote, or execute set of tty modes, respectively; without -d, -q, or -x, execute is used. Without other arguments, setty lists the modes in the chosen set that are fixed on (+mode) or off (-mode). The available modes, and thus the display, vary from system to system. With -a, lists all tty modes in the chosen set whether or not they are fixed. With +mode, -mode, or mode, fixes mode on or off or removes control from mode in the chosen set. For example, setty +echok echoe fixes echok mode on and allows commands to turn echoe mode on or off, both when the shell is executing commands. |
setxvers [string] | Sets the experimental version prefix to string, or removes it if string is omitted. |
shift [ variable ] | The components of argv, or variable, if supplied, are shifted to the left, discarding the first component. It is an error for variable not to be set, or to have a null value. |
source [ -h ] name | Reads commands from name. Source commands may be nested, but if they are nested too deeply, the shell may run out of file descriptors. An error in a sourced file at any level terminates all nested source commands. Commonly used to re-execute the .login or .cshrc files to ensure variable settings are handled within the current shell, i.e., shell does not create a child shell (fork). With -h, places commands from the filename on the history list without executing them. |
stop [%job] ... | Stops the current or specified background job. |
suspend | Stops the shell in its tracks, much as if it had been sent a stop signal with ^Z. This is most often used to stop shells started by su. |
switch (string) | See "The switch Command" on page 557. |
telltc | Lists the values of all terminal capabilities (see termcap(5)). |
time [ command ] | With no argument, prints a summary of time used by this shell and its children. With an optional command, executes command and prints a summary of the time it uses. |
umask [ value ] | Displays the file creation mask. With value, sets the file creation mask. Value, given in octal, is XORed with the permissions of 666 for files and 777 for directories to arrive at the permissions for new files. Permissions cannot be added via umask. |
unalias pattern | Removes all aliases whose names match pattern. unalias * thus removes all aliases. It is not an error for nothing to be unaliased. |
uncomplete pattern | Removes all completions whose names match pattern.
uncomplete * thus removes all completions. |
unhash | Disables the internal hash table. |
universe universe | Sets the universe to universe. (Masscomp/RTU only) |
unlimit [-h] [resource] | Removes the limitation on resource or, if no resource is specified, all resource limitations. With -h, the corresponding hard limits are removed. Only the superuser may do this. |
unsetenv pattern | Removes all environment variables whose names match pattern. unsetenv * thus removes all environment variables; this is a bad idea. If there is no pattern to be unsetenved, no error will result from this built-in. |
unsetenv variable | Removes variable from the environment. Pattern matching, as with unset, is not performed. |
@ [ var =expr ]
@ [ var[n] =expr ]
| With no arguments, displays the values for all shell variables. With arguments, the variable var, or the nth word in the value of var, is set to the value that expr evaluates to. |
ver [systype [command]] | Without arguments, prints SYSTYPE. With systype, sets SYSTYPE to systype. With systype and command, executes command under systype. systype may be bsd4.3 or sys5.3. (Domain/OS only) |
wait | Waits for background jobs to finish (or for an interrupt) before prompting. |
warp universe | Sets the universe to universe. (Convex/OS only) |
watchlog | An alternate name for the log built-in command (q.v.). Available only if the shell was so compiled; see the version shell variable. |
where command | Reports all known instances of command, including aliases, built-ins, and executables in path. |
which command | Displays the command that will be executed by the shell after substitutions, path searching, etc. The built-in command is just like which(1), but it correctly reports tcsh aliases and built-ins and is 10 to 100 times faster. |
while (expr) | See "Looping Control Commands" on page 566. |
The built-in shell variables have special meaning to the shell and are used to modify and control the way many of the shell commmands behave. They are local variables and therefore most of them are set in the .tcshrc file for the TC shell, and the .cshrc file for the C shell if they are to be passed on to and affect child C/TC shells.
Some of the local variables have a corresponding environment variable of the same name. If one of the environment or local variables is affected by a change in the user's environment, the shell will synchronize the local and environment variables so that their values always match. Examples of cross-matched variables are afuser, group, home, path, shlvl, term, and user. (Although cwd and PWD have the same meaning, they are not cross-matched. Even though the syntax is different for the path and PATH variables, they are automatically cross-matched if either one is changed.)
The TC shell can take a number of command-line switches (also called flag arguments) to control or modify its behavior. The command-line switches are listed in Table 9.27.