CSH(1) | General Commands Manual | CSH(1) |
csh
—
csh |
[-bcefinstvVxX ] [arg ...] |
csh |
[-l ] |
csh
is a command language interpreter incorporating
a history mechanism (see History
substitutions), job control facilities (see
Jobs), interactive file name and user name
completion (see File Name
Completion), and a C-like syntax. It is used both as an interactive login
shell and a shell script command processor.
-
’, then this
is a login shell. A login shell also can be specified by invoking the shell
with the ‘-l
’
flag as the only argument.
The rest of the flag arguments are interpreted as follows:
-b
-c
-e
-f
-i
-l
-l
is the only flag specified).-m
-n
-s
-t
\
’ may be used to escape the
newline at the end of this line and continue onto another line.-v
-x
-V
-X
-x
as -V
is to
-v
.After processing of flag arguments, if arguments remain but none
of the -c
, -i
,
-s
, or -t
options were
given, the first argument is taken as the name of a file of commands to be
executed. The shell opens this file, and saves its name for possible
resubstitution by `$0'. Since many systems use either the standard version 6
or version 7 shells whose shell scripts are not compatible with this shell,
the shell will execute such a `standard' shell if the first character of a
script is not a `#', i.e., if the script does not start with a comment.
Remaining arguments initialize the variable argv.
An instance of csh
begins by executing
commands from the file /etc/csh.cshrc and, if this
is a login shell, /etc/csh.login. It then executes
commands from .cshrc in the
home directory of the invoker, and, if this is a login
shell, the file .login in the same location. It is
typical for users on crt's to put the command ``stty crt'' in their
.login file, and to also invoke
tset(1) there.
In the normal case, the shell will begin reading commands from the terminal, prompting with `% '. Processing of arguments and the use of the shell to process files containing command scripts will be described later.
The shell repeatedly performs the following actions: a line of command input is read and broken into words. This sequence of words is placed on the command history list and parsed. Finally each command in the current line is executed.
When a login shell terminates it executes commands from the files .logout in the user's home directory and /etc/csh.logout.
Strings enclosed in matched pairs of quotations, `'', ``' or `"', form parts of a word; metacharacters in these strings, including blanks and tabs, do not form separate words. These quotations have semantics to be described later. Within pairs of `´' or `"' characters, a newline preceded by a `\' gives a true newline character.
When the shell's input is not a terminal, the character `#' introduces a comment that continues to the end of the input line. It is prevented this special meaning when preceded by `\' and in quotations using ``', `´', and `"'.
Any of the above may be placed in `(' `)' to form a simple command (that may be a component of a pipeline, etc.). It is also possible to separate pipelines with `||' or `&&' showing, as in the C language, that the second is to be executed only if the first fails or succeeds respectively. (See Expressions.)
showing 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 wish to do something else you may hit
the key ^Z
(control-Z) which sends a STOP signal to
the current job. The shell will then normally show that the job has been
`Stopped', and print another prompt. You can then manipulate the state of
this job, putting it in the background with the
bg command, or run some other commands and eventually
bring the job back into the foreground with the foreground
command fg. A ^Z
takes effect
immediately and is like an interrupt in that pending output and unread input
are discarded when it is typed. There is another special key
^Y
that does not generate a STOP signal until a
program attempts to read(2) it.
This request can usefully be typed ahead when you have prepared some
commands for a job that you wish to stop after it has read them.
A job being run in the background will stop if it tries to read from the terminal. Background jobs are normally allowed to produce output, but this can be disabled by giving the command ``stty tostop''. If you set this tty 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 wish to refer to job number 1, you can name it as `%1'. Just naming a job brings it to the foreground; thus `%1' is a synonym for `fg %1', bringing job number 1 back into the foreground. Similarly saying `%1 &' resumes job number 1 in the background. Jobs can also be named by prefixes of the string typed in to start them, if these prefixes are unambiguous, thus `%ex' would normally restart a suspended ex(1) job, if there were only one suspended job whose name began with the string `ex'. It is also possible to say `%?string' which specifies 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 about jobs, the current job is marked with a `+' and the previous job with a `-'. The abbreviation `%+' refers to the current job and `%-' refers to the previous job. For close analogy with the syntax of the history mechanism (described below), `%%' is also a synonym for the current job.
The job control mechanism requires that the
stty(1) option
new
be set. It is an artifact from a
new implementation of the tty driver that allows
generation of interrupt characters from the keyboard to tell jobs to stop.
See stty(1) for details on
setting options in the new tty driver.
When you try to leave the shell while jobs are stopped, you will be warned that `You have stopped jobs.' You may use the jobs command to see what they are. If you try to exit again immediately, the shell will not warn you a second time, and the suspended jobs will be terminated.
set
),
csh
will interactively complete file names and user
names from unique prefixes, when they are input from the terminal followed by
the escape character (the escape key, or control-[) For example, if the
current directory looks like
DSC.OLD bin cmd lib xmpl.c DSC.NEW chaosnet cmtest mail xmpl.o bench class dev mbox xmpl.out
and the input is
% vi ch<escape>
csh
will complete the prefix ``ch'' to the
only matching file name ``chaosnet'', changing the input line to
% vi chaosnet
However, given
% vi D<escape>
csh
will only expand the input to
% vi DSC.
and will sound the terminal bell to indicate that the expansion is incomplete, since there are two file names matching the prefix ``D''.
If a partial file name is followed by the end-of-file character
(usually control-D), then, instead of completing the name,
csh
will list all file names matching the prefix.
For example, the input
% vi D<control-D>
causes all files beginning with ``D'' to be listed:
DSC.NEW DSC.OLD
while the input line remains unchanged.
The same system of escape and end-of-file can also be used to expand partial user names, if the word to be completed (or listed) begins with the character ``~''. For example, typing
cd ~ro<escape>
may produce the expansion
cd ~root
The use of the terminal bell to signal errors or multiple matches can be inhibited by setting the variable nobeep.
Normally, all files in the particular directory are candidates for name completion. Files with certain suffixes can be excluded from consideration by setting the variable fignore to the list of suffixes to be ignored. Thus, if fignore is set by the command
% set fignore = (.o
.out)
then typing
% vi x<escape>
would result in the completion to
% vi xmpl.c
ignoring the files "xmpl.o" and "xmpl.out". However, if the only completion possible requires not ignoring these suffixes, then they are not ignored. In addition, fignore does not affect the listing of file names by control-D. All files are listed regardless of their suffixes.
Commands input from the terminal that consist of one or more words are saved on the history list. The history substitutions reintroduce sequences of words from these saved commands into the input stream. The size of the history list is controlled by the history variable; the previous command is always retained, regardless of the value of the history variable. Commands are numbered sequentially from 1.
For example, consider the following output from the history command:
09 write michael 10 ex write.c 11 cat oldwrite.c 12 diff *write.c
The commands are shown with their event numbers. It is not usually necessary to use event numbers, but the current event number can be made part of the prompt by placing an `!' in the prompt string.
With the current event 13 we can refer to previous events by event number `!11', relatively as in `!-2' (referring to the same event), by a prefix of a command word as in `!d' for event 12 or `!wri' for event 9, or by a string contained in a word in the command as in `!?mic?' also referring to event 9. These forms, without further change, simply reintroduce the words of the specified events, each separated by a single blank. As a special case, `!!' refers to the previous command; thus `!!' alone is a redo.
To select words from an event we can follow the event specification by a `:' and a designator for the desired words. The words of an input line are numbered from 0, the first (usually command) word being 0, the second word (first argument) being 1, etc. The basic word designators are:
The `:' separating the event specification from the word designator can be omitted if the argument selector begins with a `↑', `$', `*', `-' or `%'. After the optional word designator can be placed a sequence of modifiers, each preceded by a `:'. The following modifiers are defined:
Unless preceded by a `g' the change is applied only to the first modifiable word. With substitutions, it is an error for no word to be applicable.
The left hand side of substitutions are not regular expressions in the sense of the editors, but instead strings. Any character may be used as the delimiter in place of `/'; a `\' quotes the delimiter into the l and r strings. The character `&' in the right hand side is replaced by the text from the left. A `\' also quotes `&'. A null l (`//') uses the previous string either from an l or from a contextual scan string s in `!?s\?'. The trailing delimiter in the substitution may be omitted if a newline follows immediately as may the trailing `?' in a contextual scan.
A history reference may be given without an event specification, e.g., `!$'. Here, the reference is to the previous command unless a previous history reference occurred on the same line in which case this form repeats the previous reference. Thus `!?foo?↑ !$' gives the first and last arguments from the command matching `?foo?'.
A special abbreviation of a history reference occurs when the first non-blank character of an input line is a `↑'. This is equivalent to `!:s↑' providing a convenient shorthand for substitutions on the text of the previous line. Thus `↑lb↑lib' fixes the spelling of `lib' in the previous command. Finally, a history substitution may be surrounded with `{' and `}' if necessary to insulate it from the characters that follow. Thus, after `ls -ld ~paul' we might do `!{l}a' to do `ls -ld ~paula', while `!la' would look for a command starting with `la'.
In both cases the resulting text becomes (all or part of) a single word; only in one special case (see Command Substitution below) does a `"' quoted string yield parts of more than one word; `´' quoted strings never do.
Thus if the alias for `ls' is `ls -l' the command `ls /usr' would map to `ls -l /usr', the argument list here being undisturbed. Similarly if the alias for `lookup' was `grep !↑ /etc/passwd' then `lookup bill' would map to `grep bill /etc/passwd'.
If an alias is found, the word transformation of the input text is performed and the aliasing process begins again on the reformed input line. Looping is prevented if the first word of the new text is the same as the old by flagging it to prevent further aliasing. Other loops are detected and cause an error.
Note that the mechanism allows aliases to introduce parser metasyntax. Thus, we can `alias print ´pr \!* | lpr´' to make a command that pr's its arguments to the line printer.
The values of variables may be displayed and changed by using the
set and unset commands. Of the
variables referred to by the shell a number 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 that causes command
input to be echoed. The setting of this variable results from the
-v
command line option.
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 additional 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 `"'s where it always occurs, and within `´'s where it never occurs. Strings quoted by ``' are interpreted later (see Command substitution 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.
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 `"' 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.
The following metasequences are provided for introducing variable values into the shell input. Except as noted, it is an error to reference a variable that is not set.
The modifiers `:e', `:h', `:t', `:r', `:q' and `:x' may be applied to the substitutions above as may `:gh', `:gt' and `:gr'. If braces `{' '}' appear in the command form then the modifiers must appear within the braces. The current implementation allows only one `:' modifier on each `$' expansion.
The following substitutions may not be modified with `:' modifiers.
In any case, the single final newline does not force a new word. Note that it is thus possible for a command substitution to yield only part of a word, even if the command outputs a complete line.
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 (inclusive).
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 variable home. 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 does not appear at the beginning of a word, it is left undisturbed.
The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'. Left to right order is preserved, with results of matches being sorted separately at a low level to preserve this order. This construct may be nested. Thus, `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c /usr/source/s1/ls.c' without chance of error if the home directory for `source' is `/usr/source'. Similarly `../{memo,*box}' might expand to `../memo ../box ../mbox'. (Note that `memo' was not sorted with the results of the match to `*box'.) As a special case `{', `}' and `{}' are passed undisturbed.
If the variable noclobber is set, then the file must not exist or be a character special file (e.g., a terminal or `/dev/null') or an error results. This helps prevent accidental destruction of files. Here, the `!' forms can be used to suppress this check.
The forms involving `&' route the standard error output into the specified file as well as the standard output. Name is expanded in the same way as `<' input filenames are.
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. Note that the default standard input for a command run detached is not modified to be the empty file /dev/null; instead the standard input remains as 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 will be notified (see Jobs above).
The standard error output may be directed through a pipe with the standard output. Simply use the form `|&' instead of just `|'.
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 pattern (containing, e.g., `*'s, `?'s and instances of `[...]') against which the left hand operand is matched. This reduces the need for use of the switch statement 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 result 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 that are syntactically significant to the parser (`&' `|' `<' `>' `(' `)'), they should be surrounded by spaces.
Also available in expressions as primitive operands are command
executions enclosed in `{' and `}' and file enquiries of the form
-l
name where
l
is one of:
r read access w write access x execute access e existence o ownership z zero size f plain file d directory
The specified name is command and filename expanded and then tested to see if it has the specified relationship to the real user. If the file does not exist or is inaccessible then all enquiries return false, i.e., `0'. Command executions succeed, returning true, i.e., `1', if the command exits with status 0, otherwise they fail, returning false, i.e., `0'. If more detailed status information is required then the command should be executed outside an expression and the variable status examined.
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 as shown below.
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 goto's will succeed on non-seekable inputs.)
alias
alias
namealias
name wordlistbg
bg
%
job ...break
end
of the
nearest enclosing foreach
or
while
. The remaining commands on the current line
are executed. Multi-level breaks are thus possible by writing them all on
one line.
breaksw
switch
, resuming after the
endsw
.
case
label:switch
statement as discussed below.
cd
cd
namechdir
chdir
namecdpath
is checked to see if it has a subdirectory
name. Finally, if all else fails but
name is a shell variable whose value begins with
`/', then this is tried to see if it is a directory.
continue
while
or foreach
. The rest of the commands on the
current line are executed.
default
:switch
statement. The
default should come after all case
labels.
dirs
echo
wordlistecho
-n
wordlist-n
option is specified.
else
end
endif
endsw
foreach
,
if
, switch
, and
while
statements below.
eval
arg ...eval
.
exec
commandexit
exit
(expr)status
variable (first form) or with the value of
the specified expr
(second form).
fg
fg
%
job ...foreach
name (wordlist)end
name
is successively set to each
member of wordlist
and the sequence of commands
between this command and the matching end
are
executed. (Both foreach
and
end
must appear alone on separate lines.) The
builtin command continue
may be used to continue
the loop prematurely and the builtin command break
to terminate it prematurely. When this command is read from the terminal,
the loop is read once prompting with `?' before any statements in the loop
are executed. If you make a mistake typing in a loop at the terminal you
can rub it out.
glob
wordlistecho
but no `\' escapes are recognized and
words are delimited by null characters in the output. Useful for programs
that wish to use the shell to filename expand a list of words.
goto
wordword
is filename and command
expanded to yield a string of the form `label'. The shell rewinds its
input as much as possible and searches for a line of the form `label:'
possibly preceded by blanks or tabs. Execution continues after the
specified line.
hashstat
exec
´s). 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 `/'.
history
history
nhistory
-r
nhistory
-h
n-r
option reverses the order of printout to be
most recent first instead of oldest first. The -h
option causes the history list to be printed without leading numbers. This
format produces files suitable for sourcing using the -h option to
source
.
if
(expr) commandif
command.
Command must be a simple command, not a pipeline, a
command list, or a parenthesized command list. Input/output redirection
occurs even if expr is false, i.e., when command is
not executed (this is a bug).
if
(expr) then
else
if
(expr2)
then
else
endif
else
are executed; otherwise if
expr2 is true then the commands up to the second
else
are executed, etc. 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
.)
jobs
jobs
-l
-l
option lists process
id's in addition to the normal information.
kill
%
jobkill
pid ...kill
-l
[exit_status]kill
-s
signal_name pid ...kill
-
signal_name
pid ...kill
-
signal_number
pid ...<signal.h>
, stripped of
the prefix ``SIG''). The signal names are listed by ``kill -l''; if an
exit_status is specified, only the corresponding
signal name will be written. There is no default, just saying `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 will be sent a CONT
(continue) signal as well.
limit
limit
resourcelimit
resource maximum-uselimit
-h
limit
-h
resourcelimit
-h
resource maximum-useIf the -h
flag is given, the hard
limits are used instead of the current limits. The hard limits impose a
ceiling on the values of the current limits. Only the super-user may
raise the hard limits, but a user may lower or raise the current limits
within the legal range.
Resources controllable currently include:
The maximum-use may be given as a (floating point or integer) number followed by a scale factor. For all limits other than cputime the default scale is `k' or `kilobytes' (1024 bytes); a scale factor of `m' or `megabytes' may also be used. For cputime the default scale is `seconds'; a scale factor of `m' for minutes or `h' for hours, or a time of the form `mm:ss' giving minutes and seconds also may be used.
For both resource names and scale factors, unambiguous prefixes of the names suffice.
Limits of an arbitrary process can be displayed or set using the sysctl(8) utility. See the getrlimit(2) and setrlimit(2) man pages for an additional description of system resource limits.
login
logout
ignoreeof
is set.
nice
nice
+numbernice
commandnice
+number commandif
statements apply.
nohup
nohup
commandnohup
´ed.
notify
notify
%
job ...notify
is set.
onintr
onintr
-
onintr
labelIn any case, if the shell is running detached and interrupts
are being ignored, all forms of onintr
have no
meaning and interrupts continue to be ignored by the shell and all
invoked commands. Finally onintr
statements are
ignored in the system startup files where interrupts are disabled
(/etc/csh.cshrc, /etc/csh.login).
popd
popd
+npushd
pushd
namepushd
+npushd
exchanges the top two
elements of the directory stack. Given a name
argument, pushd
changes to the new directory (ala
cd
) and pushes the old current working directory
(as in cwd
) onto the directory stack. With a
numeric argument, pushd
rotates the
n´th argument of the directory stack around
to be the top element and changes to it. The members of the directory
stack are numbered from the top starting at 0.
rehash
path
variable to be recomputed. This is needed if
new commands are added to directories in the path
while you are logged in. This should only be necessary if you add commands
to one of your own directories, or if a systems programmer changes the
contents of a system directory.
repeat
count commandif
statement above, is executed
count times. I/O redirections occur exactly once,
even if count is 0.
set
set
nameset
name=wordset
name[index]=wordset
name=(wordlist)These arguments may be repeated to set multiple values in a single set command. Note however, that variable expansion happens for all arguments before any setting occurs.
setenv
setenv
namesetenv
name valueUSER
,
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.
shift
shift
variableargv
are shifted to the left,
discarding argv
[1]. It is an error for
argv
not to be set or to have less than one word
as value. The second form performs the same function on the specified
variable.
source
namesource
-h
nameSource
commands may be nested; if they are nested
too deeply the shell may run out of file descriptors. An error in a
source
at any level terminates all nested
source
commands. Normally input during
source
commands is not placed on the history list;
the -h option causes the commands to be placed on the history list without
being executed.
stop
stop
%
job ...suspend
^Z
. This is most often used to stop
shells started by su(1).
switch
(string)case
str1: breaksw
default
: breaksw
endsw
breaksw
causes execution to
continue after the endsw
. Otherwise control may
fall through case labels and the default label as in C. If no label
matches and there is no default, execution continues after the
endsw
.
time
time
commandtime
variable is printed. If necessary, an extra shell is created to print the
time statistic when the command completes.
umask
umask
valueunalias
patternunaliased
.
unhash
unlimit
unlimit
resourceunlimit
-h
unlimit
-h
resource-h
is given, the corresponding hard limits are
removed. Only the super-user may do this.
unset
patternunset
.
unsetenv
patternsetenv
command above and
printenv(1).
wait
which
commandwhile
(expr)end
while
and the matching
end
are evaluated. Break
and continue
may be used to terminate or continue
the loop prematurely. (The while
and
end
must appear alone on their input lines.)
Prompting occurs here the first time through the loop as for the
foreach
statement if the input is a terminal.
%
job%
job
&
@
@
name= expr@
name[index]= exprThe operators `*=', `+=', etc are available as in C. The space separating the name from the assignment operator is optional. Spaces are, however, mandatory in separating components of expr which would otherwise be single words.
Special postfix `++' and `--' operators increment and decrement name respectively, i.e., `@ i++'.
The shell copies the environment variable
USER
into the variable user,
TERM
into term, and
HOME
into home, and copies
these back into the environment whenever the normal shell variables are
reset. The environment variable PATH
is likewise
handled; it is not necessary to worry about its setting other than in the
file .cshrc as inferior csh
processes will import the definition of path from the
environment, and re-export it if you then change it.
argv
cdpath
cwd
echo
-x
command line option is given.
Causes each command and its arguments to be echoed just before it is
executed. For non-builtin commands all expansions occur before echoing.
Builtin commands are echoed before command and filename substitution,
since these substitutions are then done selectively.filec
histchars
histfile
history
home
ignoreeof
mail
If the first word of the value of mail is numeric it specifies a different mail checking interval, in seconds, than the default, which is 10 minutes.
If multiple mail files are specified, then the shell says `New mail in name' when there is mail in the file name.
noclobber
noglob
nonomatch
notify
path
-c
nor the -t
option will normally hash the contents of the directories in the
path variable after reading
.cshrc, and each time the path
variable is reset. If new commands are added to these directories while
the shell is active, it may be necessary to do a
rehash
or the commands may not be found.prompt
savehist
shell
status
time
%c
%D
%E
%F
%I
%K
%k
%M
%O
%P
%R
%r
%S
%s
%U
%W
%w
%X
The default summary is "%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww"
verbose
-v
command line option, causes the
words of each command to be printed after history substitution.-c
nor a -t
option, the shell
will hash the names in these directories into an internal table so that it
will only try an exec
in a directory if there is a
possibility that the command resides there. This shortcut greatly speeds
command location when many directories are present in the search path. If this
mechanism has been turned off (via unhash
), or if the
shell was given a -c
or -t
argument, and in any case for each directory component of
path that does not begin with a `/', the shell
concatenates with the given command name to form a path name of a file which
it then attempts to execute.
Parenthesized commands are always executed in a subshell. Thus
(cd; pwd); pwd
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
chdir
from affecting the current shell.
If the file has execute permissions but is not an executable binary to the system, then it is assumed to be a file containing shell commands and a new shell is spawned to read it.
If there is an alias
for
shell
then the words of the alias will be prepended
to the argument list to form the shell command. The first word of the
alias
should be the full path name of the shell
(e.g., `$shell'). Note that this is a special, late occurring, case of
alias
substitution, and only allows words to be
prepended to the argument list without change.
&
or the
bg
or %... &
commands) are
immune to signals generated from the keyboard, including hangups. Other
signals have the values which the shell inherited from its parent. The shell's
handling of interrupts and terminate signals in shell scripts can be
controlled by onintr
. Login shells catch the
terminate signal; otherwise this signal is passed on to
children from the state in the shell's parent. Interrupts are not allowed when
a login shell is reading the file .logout.
alias
substitutions on a
single line to 20.
An introduction to the C shell.
csh
appeared in 2BSD. It was a
first implementation of a command language interpreter incorporating a history
mechanism (see History
substitutions), job control facilities (see
Jobs), interactive file name and user name
completion (see File Name
Completion), and a C-like syntax. There are now many shells that also have
these mechanisms, plus a few more (and maybe some bugs too), which are
available through the usenet.
Shell builtin 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 shell will 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, i.e., `( a ; b ; c )'.
Control over tty output after processes are started is primitive; perhaps this will inspire someone to work on a good virtual terminal interface. 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, prompted for by `?', are not placed on the
history
list. Control structure 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 `;' metasyntax.
It should be possible to use the `:' modifiers on the output of command substitutions.
The way the filec
facility is implemented
is ugly and expensive.
August 8, 2016 | NetBSD 9.4 |