Quizzer
view release on metacpan or search on metacpan
exercises/compile-tcsh/tcsh-6.10.00/tcsh.man view on Meta::CPAN
The character `&' in the \fIr\fR is replaced by \fIl\fR; `\\' also quotes `&'.
If \fIl\fR is empty (``''), the \fIl\fR from a previous substitution or the
\fIs\fR from a previous `?\fIs\fR?' event specification is used.
The trailing delimiter may be omitted if it is immediately followed by a newline.
.TP 8
&
Repeat the previous substitution.
.TP 8
g
Apply the following modifier once to each word.
.TP 8
a (+)
Apply the following modifier as many times as possible to a single word.
`a' and `g' can be used together to apply a modifier globally.
In the current implementation, using the `a' and `s' modifiers together can
lead to an infinite loop. For example, `:as/f/ff/' will never terminate.
This behavior might change in the future.
.TP 8
p
Print the new command line but do not execute it.
.TP 8
q
Quote the substituted words, preventing further substitutions.
.TP 8
x
Like q, but break into words at blanks, tabs and newlines.
.PD
.RE
.PP
Modifiers are applied to only the first modifiable word (unless `g' is used).
It is an error for no word to be modifiable.
.PP
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 \fBSpelling correction\fR for a
different approach).
.PP
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 `!'.
.PP
(+) In \fIcsh\fR as such, only one modifier may be applied to each history
or variable expansion. In \fItcsh\fR, more than one may be used, for example
.IP "" 4
% mv wumpus.man /usr/man/man1/wumpus.1
.br
% man !$:t:r
.br
man wumpus
.PP
In \fIcsh\fR, the result would be `wumpus.1:r'. A substitution followed by a
colon may need to be insulated from it with braces:
.IP "" 4
> mv a.out /usr/games/wumpus
.br
> setenv PATH !$:h:$PATH
.br
Bad ! modifier: $.
.br
> setenv PATH !{\-2$:h}:$PATH
.br
setenv PATH /usr/games:/bin:/usr/bin:.
.PP
The first attempt would succeed in \fIcsh\fR but fails in \fItcsh\fR,
because \fItcsh\fR expects another modifier after the second colon
rather than `$'.
.PP
Finally, history can be accessed through the editor as well as through
the substitutions just described.
The \fIup-\fR and \fIdown-history\fR, \fIhistory-search-backward\fR and
\fI-forward\fR, \fIi-search-back\fR and \fI-fwd\fR,
\fIvi-search-back\fR and \fI-fwd\fR, \fIcopy-prev-word\fR
and \fIinsert-last-word\fR editor commands search for
events in the history list and copy them into the input buffer.
The \fItoggle-literal-history\fR editor command switches between the
expanded and literal forms of history lines in the input buffer.
\fIexpand-history\fR and \fIexpand-line\fR expand history substitutions
in the current word and in the entire input buffer respectively.
.SS "Alias substitution"
The shell maintains a list of aliases which can be set, unset and printed by
the \fIalias\fR and \fIunalias\fR commands. After a command line is parsed
into simple commands (see \fBCommands\fR) 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
\fBHistory substitution\fR (q.v.) 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.
.PP
Thus if the alias for `ls' were `ls \-l' the command `ls /usr' would 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 \e!* | lpr'' defines a ``command'' (`print') which
\fIpr\fR(1)s its arguments to the line printer.
.PP
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.
.PP
Some aliases are referred to by the shell; see \fBSpecial aliases\fR.
.SS "Variable substitution"
The shell maintains a list of variables, each of which has as value a list of
zero or more words.
The values of shell variables can be displayed and changed with the
\fIset\fR and \fIunset\fR commands.
The system maintains its own list of ``environment'' variables.
These can be displayed and changed with \fIprintenv\fR, \fIsetenv\fR and
\fIunsetenv\fR.
.PP
(+) Variables may be made read-only with `set \-r' (q.v.)
Read-only variables may not 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.
.PP
Some variables are set by the shell or referred to by it.
For instance, the \fBargv\fR 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 shell are toggles;
the shell does not care what their value is, only whether they are set or not.
For instance, the \fBverbose\fR variable is a toggle which causes command
input to be echoed. The \fB\-v\fR command line option sets this variable.
\fBSpecial shell variables\fR lists all variables which are referred to by the shell.
.PP
Other operations treat variables numerically. The `@' 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 multi-word values are ignored.
.PP
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 `\e' except within `"'s
where it \fIalways\fR occurs, and within `''s where it \fInever\fR occurs.
Strings quoted by ``' are interpreted later (see \fBCommand substitution\fR
below) 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.
.PP
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.
.PP
Unless enclosed in `"' or given the `:q' modifier the results of variable
substitution may eventually be command and filename 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 filename substitution.
.PP
The following metasequences are provided for introducing variable values into
the shell input. Except as noted, it is an error to reference a variable which
is not set.
.PP
.PD 0
$\fIname\fR
.TP 8
${\fIname\fR}
Substitutes the words of the value of variable \fIname\fR, each separated
by a blank. Braces insulate \fIname\fR from following characters which would
otherwise be part of it. Shell variables have names consisting of up to 20
letters and digits starting with a letter. The underscore character is
considered a letter. If \fIname\fR is not a shell variable, but is set in the
environment, then that value is returned (but `:' modifiers and the other forms
exercises/compile-tcsh/tcsh-6.10.00/tcsh.man view on Meta::CPAN
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.
.PP
Command substitutions inside double
quotes (`"') 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.
.SS "Filename substitution"
If a word contains any of the characters `*', `?', `[' or `{' or begins with
the character `~' it is a candidate for filename 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.
.PP
In matching filenames, the character `.' at the beginning of a filename or
immediately following a `/', 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.
.PP
(+) Some glob-patterns can be negated:
The sequence `[^...]' matches any single character \fInot\fR specified by the
characters and/or ranges of characters in the braces.
.PP
An entire glob-pattern can also be negated with `^':
.IP "" 4
> echo *
.br
bang crash crunch ouch
.br
> echo ^cr*
.br
bang ouch
.PP
Glob-patterns which do not use `?', `*', or `[]' or which use `{}' or `~'
(below) are not negated correctly.
.PP
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:
`../{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 may be nested.
As a special case the words `{', `}' and `{}' are passed undisturbed.
.PP
The character `~' at the beginning of a filename refers to home directories.
Standing alone, i.e., `~', it expands to the invoker's home directory as
reflected in the value of the \fBhome\fR shell variable. When followed by a
name consisting of letters, digits and `\-' 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.
.PP
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, e.g., `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 \fBnonomatch\fR shell variable is set a pattern (or list
of patterns) which matches nothing is left unchanged rather than causing
an error.
.PP
The \fBnoglob\fR shell variable can be set to prevent filename substitution,
and the \fIexpand-glob\fR editor command, normally bound to `^X-*', can be
used to interactively expand individual filename substitutions.
.SS "Directory stack substitution (+)"
The directory stack is a list of directories, numbered from zero, used by the
\fIpushd\fR, \fIpopd\fR and \fIdirs\fR builtin commands (q.v.).
\fIdirs\fR can print, store in a file, restore and clear the directory stack
at any time, and the \fBsavedirs\fR and \fBdirsfile\fR shell variables can be set to
store the directory stack automatically on logout and restore it on login.
The \fBdirstack\fR shell variable can be examined to see the directory stack and
set to put arbitrary directories into the directory stack.
.PP
The character `=' followed by one or more digits expands to an entry in
the directory stack. The special case `=\-' expands to the last directory in
the stack. For example,
.IP "" 4
> dirs \-v
.br
0 /usr/bin
.br
1 /usr/spool/uucp
.br
2 /usr/accts/sys
.br
> echo =1
.br
/usr/spool/uucp
.br
> echo =0/calendar
.br
/usr/bin/calendar
.br
> echo =\-
.br
/usr/accts/sys
.PP
The \fBnoglob\fR and \fBnonomatch\fR shell variables and the \fIexpand-glob\fR
editor command apply to directory stack as well as filename substitutions.
.SS "Other substitutions (+)"
There are several more transformations involving filenames, not strictly
related to the above but mentioned here for completeness.
\fIAny\fR filename may be expanded to a full path when the
\fBsymlinks\fR variable (q.v.) is set to `expand'.
Quoting prevents this expansion, and
the \fInormalize-path\fR editor command does it on demand.
The \fInormalize-command\fR editor command expands commands in PATH into
full paths on demand.
Finally, \fIcd\fR and \fIpushd\fR interpret `\-' as the old working directory
(equivalent to the shell variable \fBowd\fR).
This is not a substitution at all, but an abbreviation recognized by only
exercises/compile-tcsh/tcsh-6.10.00/tcsh.man view on Meta::CPAN
prompt is printed after the time when the command is scheduled.
It is possible to miss the exact time when the command is to be run, but
an overdue command will execute at the next prompt.
A command which comes due while the shell
is waiting for user input is executed immediately.
However, normal operation of an already-running command will not
be interrupted so that a scheduled-event list element may be run.
.PP
This mechanism is similar to, but not the same as, the \fIat\fR(1)
command on some Unix systems.
Its major disadvantage is that it may not run a command at exactly the
specified time.
Its major advantage is that because \fIsched\fR runs directly from
the shell, it has access to shell variables and other structures.
This provides a mechanism for changing one's working environment
based on the time of day.
.RE
.PP
.B set
.br
.B set \fIname\fR ...
.br
.B set \fIname\fR\fB=\fIword\fR ...
.br
.B set [\-r] [\-f|\-l] \fIname\fR\fB=(\fIwordlist\fB)\fR ... (+)
.br
.B set \fIname[index]\fR\fB=\fIword\fR ...
.br
.B set \-r \fR(+)
.br
.B set \-r \fIname\fR ... (+)
.PD 0
.TP 8
.B set \-r \fIname\fR\fB=\fIword\fR ... (+)
The first form of the command prints the value of all shell variables.
Variables which contain more than a single word print as a
parenthesized word list.
The second form sets \fIname\fR to the null string.
The third form sets \fIname\fR to the single \fIword\fR.
The fourth form sets \fIname\fR to the list of words in
\fIwordlist\fR. 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.
The fifth form sets the \fIindex\fR'th component of name to \fIword\fR;
this component must already exist.
The sixth form lists only the names of all shell variables that are read-only.
The seventh form makes \fIname\fR read-only, whether or not it has a value.
The second form sets \fIname\fR to the null string.
The eighth form is the same as the third form, but
make \fIname\fR read-only at the same time.
.PD
.IP "" 8
These arguments can be repeated to set and/or make read-only multiple variables
in a single set command. Note, however, that variable expansion
happens for all arguments before any setting occurs. Note also that `=' can
be adjacent to both \fIname\fR and \fIword\fR or separated from both by
whitespace, but cannot be adjacent to only one or the other.
See also the \fIunset\fR builtin command.
.TP 8
.B setenv \fR[\fIname \fR[\fIvalue\fR]]
Without arguments, prints the names and values of all environment variables.
Given \fIname\fR, sets the environment variable \fIname\fR to \fIvalue\fR
or, without \fIvalue\fR, to the null string.
.TP 8
.B setpath \fIpath \fR(+)
Equivalent to \fIsetpath\fR(1). (Mach only)
.TP 8
.B setspath\fR LOCAL|\fIsite\fR|\fIcpu\fR ... (+)
Sets the system execution path. (TCF only)
.TP 8
.B settc \fIcap value \fR(+)
Tells the shell to believe that the terminal capability \fIcap\fR
(as defined in \fItermcap\fR(5)) has the value \fIvalue\fR.
No sanity checking is done.
Concept terminal users may have to `settc xn no' to get proper
wrapping at the rightmost column.
.TP 8
.B setty \fR[\fB\-d\fR|\fB\-q\fR|\fB\-x\fR] [\fB\-a\fR] [[\fB+\fR|\fB\-\fR]\fImode\fR] (+)
Controls which tty modes (see \fBTerminal management\fR)
the shell does not allow to change.
\fB\-d\fR, \fB\-q\fR or \fB\-x\fR tells \fIsetty\fR to act
on the `edit', `quote' or `execute' set of tty modes respectively; without
\fB\-d\fR, \fB\-q\fR or \fB\-x\fR, `execute' is used.
.IP "" 8
Without other arguments, \fIsetty\fR lists the modes in the chosen set
which are fixed on (`+mode') or off (`\-mode').
The available modes, and thus the display, vary from system to system.
With \fB\-a\fR, lists all tty modes in the chosen set
whether or not they are fixed.
With \fB+\fImode\fR, \fB\-\fImode\fR or \fImode\fR, fixes \fImode\fR on or off
or removes control from \fImode\fR 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.
.TP 8
.B setxvers\fR [\fIstring\fR] (+)
Set the experimental version prefix to \fIstring\fR, or removes it
if \fIstring\fR is omitted. (TCF only)
.TP 8
.B shift \fR[\fIvariable\fR]
Without arguments, discards \fBargv\fR[1] and shifts the members of
\fBargv\fR to the left. It is an error for \fBargv\fR not to be set or to have
less than one word as value. With \fIvariable\fR, performs the
same function on \fIvariable\fR.
.TP 8
.B source \fR[\fB\-h\fR] \fIname\fR [\fIargs\fR ...]
The shell reads and executes commands from \fIname\fR.
The commands are not placed on the history list.
If any \fIargs\fR are given, they are placed in \fBargv\fR. (+)
\fIsource\fR commands may be nested;
if they are nested too deeply the shell may run out of file descriptors.
An error in a \fIsource\fR at any level terminates all nested
\fIsource\fR commands.
With \fB\-h\fR, commands are placed on the history list instead of being
executed, much like `history \-L'.
.TP 8
.B stop \fB%\fIjob\fR|\fIpid\fR ...
Stops the specified jobs or processes which are executing in the background.
\fIjob\fR may be a number, a string, `', `%', `+' or `\-' as described
under \fBJobs\fR.
There is no default \fIjob\fR; saying just `stop' does not stop
exercises/compile-tcsh/tcsh-6.10.00/tcsh.man view on Meta::CPAN
The file metacharacters `*', `?' and `[...]' may be used
in the case labels, which are variable expanded. If none
of the labels match before a `default' label is found, then
the execution begins after the default label. Each case
label and the default label must appear at the beginning of
a line. The command \fIbreaksw\fR causes execution to continue
after the \fIendsw\fR. Otherwise control may fall through case
labels and default labels as in C. If no label matches and
there is no default, execution continues after the \fIendsw\fR.
.PD
.TP 8
.B telltc \fR(+)
Lists the values of all terminal capabilities (see \fItermcap\fR(5)).
.TP 8
.B time \fR[\fIcommand\fR]
Executes \fIcommand\fR (which must be a simple command, not an alias,
a pipeline, a command list or a parenthesized command list)
and prints a time summary as described under the \fBtime\fR variable.
If necessary, an extra shell is created to print the time statistic when
the command completes.
Without \fIcommand\fR, prints a time summary for the current shell and its
children.
.TP 8
.B umask \fR[\fIvalue\fR]
Sets the file creation mask to \fIvalue\fR, which is given in octal.
Common values for the mask are
002, giving all access to the group and read and execute access to others, and
022, giving read and execute access to the group and others.
Without \fIvalue\fR, prints the current file creation mask.
.TP 8
.B unalias \fIpattern
.br
Removes all aliases whose names match \fIpattern\fR.
`unalias *' thus removes all aliases.
It is not an error for nothing to be \fIunalias\fRed.
.TP 8
.B uncomplete \fIpattern\fR (+)
Removes all completions whose names match \fIpattern\fR.
`uncomplete *' thus removes all completions.
It is not an error for nothing to be \fIuncomplete\fRd.
.TP 8
.B unhash
Disables use of the internal hash table to speed location of
executed programs.
.TP 8
.B universe \fIuniverse\fR (+)
Sets the universe to \fIuniverse\fR. (Masscomp/RTU only)
.TP 8
.B unlimit \fR[\fB\-h\fR] [\fIresource\fR]
Removes the limitation on \fIresource\fR or, if no \fIresource\fR is
specified, all \fIresource\fR limitations.
With \fB\-h\fR, the corresponding hard limits are removed.
Only the super-user may do this.
.TP 8
.B unset \fIpattern
Removes all variables whose names match \fIpattern\fR, unless they are read-only.
`unset *' thus removes all variables unless they are read-only;
this is a bad idea.
It is not an error for nothing to be \fIunset\fR.
.TP 8
.B unsetenv \fIpattern
Removes all environment variables whose names match \fIpattern\fR.
`unsetenv *' thus removes all environment variables;
this is a bad idea.
It is not an error for nothing to be \fIunsetenv\fRed.
.TP 8
.B ver \fR[\fIsystype\fR [\fIcommand\fR]] (+)
Without arguments, prints \fBSYSTYPE\fR. With \fIsystype\fR, sets \fBSYSTYPE\fR
to \fIsystype\fR. With \fIsystype\fR and \fIcommand\fR, executes \fIcommand\fR
under \fIsystype\fR. \fIsystype\fR may be `bsd4.3' or `sys5.3'.
(Domain/OS only)
.TP 8
.B wait
The shell waits for all background jobs. If the shell is interactive, an
interrupt will disrupt the wait and cause the shell to print the names and job
numbers of all outstanding jobs.
.TP 8
.B warp \fIuniverse\fR (+)
Sets the universe to \fIuniverse\fR. (Convex/OS only)
.TP 8
.B watchlog \fR(+)
An alternate name for the \fIlog\fR builtin command (q.v.).
Available only if the shell was so compiled;
see the \fBversion\fR shell variable.
.TP 8
.B where \fIcommand\fR (+)
Reports all known instances of \fIcommand\fR, including aliases, builtins and
executables in \fBpath\fR.
.TP 8
.B which\fR \fIcommand\fR (+)
Displays the command that will be executed by the shell after substitutions,
\fBpath\fR searching, etc.
The builtin command is just like \fIwhich\fR(1), but it correctly reports
\fItcsh\fR aliases and builtins and is 10 to 100 times faster.
See also the \fIwhich-command\fR editor command.
.PP
.B while (\fIexpr\fB)\fR
.br
\&...
.PD 0
.TP 8
.B end
Executes the commands between the \fIwhile\fR and the matching \fIend\fR
while \fIexpr\fR (an expression, as described under \fBExpressions\fR)
evaluates non-zero.
\fIwhile\fR and \fIend\fR must appear alone on their input lines.
\fIbreak\fR and \fIcontinue\fR 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 \fIforeach\fR.
.PD
.SS "Special aliases (+)"
If set, each of these aliases executes automatically at the indicated time.
They are all initially undefined.
.TP 8
.B beepcmd
Runs when the shell wants to ring the terminal bell.
.TP 8
.B cwdcmd
Runs after every change of working directory. For example, if the user is
working on an X window system using \fIxterm\fR(1) and a re-parenting window
manager that supports title bars such as \fItwm\fR(1) and does
.RS +8
.IP "" 4
> alias cwdcmd 'echo \-n "^[]2;${HOST}:$cwd ^G"'
( run in 0.721 second using v1.01-cache-2.11-cpan-364913b4093 )