1csh(1)                           User Commands                          csh(1)
2
3
4

NAME

6       csh - shell command interpreter with a C-like syntax
7

SYNOPSIS

9       csh [-bcefinstvVxX] [argument]...
10
11

DESCRIPTION

13       csh, the C shell, is a command interpreter with a syntax reminiscent of
14       the C language. It provides a number of convenient features for  inter‐
15       active  use  that  are  not  available with the Bourne shell, including
16       filename completion, command aliasing, history substitution,  job  con‐
17       trol,  and a number of built-in commands. As with the Bourne shell, the
18       C shell provides variable, command and filename substitution.
19
20   Initialization and Termination
21       When first started, the C shell normally  performs  commands  from  the
22       .cshrc  file  in  your home directory, provided that it is readable and
23       you either own it or your real group ID matches its group  ID.  If  the
24       shell  is  invoked with a name that starts with `', as when started by
25       login(1), the shell runs as a login shell.
26
27
28       If the shell is a login shell, this is  the  sequence  of  invocations:
29       First,  commands  in  /etc/.login are executed. Next, commands from the
30       .cshrc file your home directory are executed. Then the  shell  executes
31       commands  from the .login file in your home directory; the same permis‐
32       sion checks as those for .cshrc are applied to  this  file.  Typically,
33       the  .login  file  contains  commands  to specify the terminal type and
34       environment. (For an explanation of file interpreters, see Command Exe‐
35       cution and exec(2).)
36
37
38       As a login shell terminates, it performs commands from the .logout file
39       in your home directory; the same permission checks as those for  .cshrc
40       are applied to this file.
41
42   Interactive Operation
43       After  startup  processing  is  complete, an interactive C shell begins
44       reading commands from the terminal, prompting with hostname% (or  host‐
45       name#  for the privileged user). The shell then repeatedly performs the
46       following actions: a line of command input  is  read  and  broken  into
47       words.  This  sequence  of words is placed on the history list and then
48       parsed, as described under USAGE. Finally, the shell executes each com‐
49       mand in the current line.
50
51   Noninteractive Operation
52       When running noninteractively, the shell does not prompt for input from
53       the terminal. A noninteractive C shell can execute a  command  supplied
54       as  an argument on its command line, or interpret commands from a file,
55       also known as a script.
56

OPTIONS

58       The following options are supported:
59
60       -b    Forced a "break" from option processing. Subsequent command  line
61             arguments are not interpreted as C shell options. This allows the
62             passing of options to a script without confusion. The shell  does
63             not run set-user-ID or set-group-ID scripts unless this option is
64             present.
65
66
67       -c    Executes the first argument, which  must  be  present.  Remaining
68             arguments  are  placed  in  argv, the argument-list variable, and
69             passed directly to csh.
70
71
72       -e    Exits if a command terminates abnormally or yields a nonzero exit
73             status.
74
75
76       -f    Fast  start.  Reads  neither the .cshrc file, nor the .login file
77             (if a login shell) upon startup.
78
79
80       -i    Forced interactive. Prompts for command line input, even  if  the
81             standard  input  does not appear to be a terminal (character-spe‐
82             cial device).
83
84
85       -n    Parses (interprets), but does not execute commands.  This  option
86             can be used to check C shell scripts for syntax errors.
87
88
89       -s    Takes commands from the standard input.
90
91
92       -t    Reads  and  executes a single command line. A `\' (backslash) can
93             be used to escape each newline for continuation  of  the  command
94             line onto subsequent input lines.
95
96
97       -v    Verbose.  Sets  the verbose predefined variable. Command input is
98             echoed after history substitution, but before other substitutions
99             and before execution.
100
101
102       -V    Sets verbose before reading .cshrc.
103
104
105       -x    Echo. Sets the echo variable. Echoes commands after all substitu‐
106             tions and just before execution.
107
108
109       -X    Sets echo before reading .cshrc.
110
111
112
113       Except with the options -c, -i, -s, or -t, the first nonoption argument
114       is  taken  to be the name of a command or script. It is passed as argu‐
115       ment zero, and subsequent arguments are added to the argument list  for
116       that command or script.
117

USAGE

119   Filename Completion
120       When  enabled by setting the variable filec, an interactive C shell can
121       complete a partially typed filename or user name. When  an  unambiguous
122       partial  filename is followed by an ESC character on the terminal input
123       line, the shell fills in the remaining characters of a  matching  file‐
124       name from the working directory.
125
126
127       If  a  partial filename is followed by the EOF character (usually typed
128       as Control-d), the shell  lists  all  filenames  that  match.  It  then
129       prompts  once  again, supplying the incomplete command line typed in so
130       far.
131
132
133       When the last (partial)  word  begins  with  a  tilde  (~),  the  shell
134       attempts completion with a user name, rather than a file in the working
135       directory.
136
137
138       The terminal bell signals errors or multiple matches. This bell  signal
139       can  be inhibited by setting the variable nobeep. You can exclude files
140       with certain suffixes by listing those suffixes in  the  variable  fig‐
141       nore.  If,  however,  the only possible completion includes a suffix in
142       the list, it is not ignored. fignore does not  affect  the  listing  of
143       filenames by the EOF character.
144
145   Lexical Structure
146       The  shell  splits  input lines into words at space and tab characters,
147       except as noted below. The characters &, |, ;, <, >, (, and ) form sep‐
148       arate  words;  if  paired,  the  pairs  form  single words. These shell
149       metacharacters can be made part of other words, and their special mean‐
150       ing  can be suppressed by preceding them with a `\' (backslash). A new‐
151       line preceded by a \ is equivalent to a space character.
152
153
154       In addition, a string enclosed in matched pairs of  single-quotes  ('),
155       double-quotes ("), or backquotes (`), forms a partial word. Metacharac‐
156       ters in such a string, including any space or tab  characters,  do  not
157       form  separate words. Within pairs of backquote (`) or double-quote (")
158       characters, a newline preceded by a `\' (backslash) gives a  true  new‐
159       line  character.  Additional  functions  of  each  type  of  quote  are
160       described, below, under Variable  Substitution,  Command  Substitution,
161       and Filename Substitution.
162
163
164       When  the shell's input is not a terminal, the character # introduces a
165       comment that continues to the end of the input line. Its special  mean‐
166       ing is suppressed when preceded by a \ or enclosed in matching quotes.
167
168   Command Line Parsing
169       A  simple  command  is  composed of a sequence of words. The first word
170       (that is not part of an I/O redirection) specifies the  command  to  be
171       executed.  A simple command, or a set of simple commands separated by |
172       or |& characters, forms a pipeline. With |, the standard output of  the
173       preceding  command  is  redirected to the standard input of the command
174       that follows. With |&, both the standard error and the standard  output
175       are redirected through the pipeline.
176
177
178       Pipelines  can  be  separated by semicolons (;), in which case they are
179       executed sequentially. Pipelines that are separated by &&  or  ||  form
180       conditional  sequences in which the execution of pipelines on the right
181       depends upon the success or failure, respectively, of the  pipeline  on
182       the left.
183
184
185       A  pipeline or sequence can be enclosed within parentheses `()' to form
186       a simple command that can be a component in a pipeline or sequence.
187
188
189       A sequence of pipelines can be executed asynchronously or "in the back‐
190       ground"  by  appending  an `&'; rather than waiting for the sequence to
191       finish before issuing a prompt, the shell displays the job number  (see
192       Job Control, below) and associated process IDs and prompts immediately.
193
194   History Substitution
195       History  substitution  allows  you  to  use words from previous command
196       lines in the command line you are typing. This simplifies spelling cor‐
197       rections  and the repetition of complicated commands or arguments. Com‐
198       mand lines are saved in the history list, the size  of  which  is  con‐
199       trolled by the history variable. The most recent command is retained in
200       any case. A history substitution begins with  a  !  (although  you  can
201       change  this  with  the  histchars variable) and occurs anywhere on the
202       command line; history substitutions do not nest. The ! can  be  escaped
203       with \ to suppress its special meaning.
204
205
206       Input lines containing history substitutions are echoed on the terminal
207       after being expanded, but before any other substitutions take place  or
208       the command gets executed.
209
210   Event Designators
211       An  event designator is a reference to a command line entry in the his‐
212       tory list.
213
214       !
215
216           Start a history substitution, except when followed by a space char‐
217           acter, tab, newline, = or (.
218
219
220       !!
221
222           Refer to the previous command. By itself, this substitution repeats
223           the previous command.
224
225
226       !n
227
228           Refer to command line n.
229
230
231       !-n
232
233           Refer to the current command line minus n.
234
235
236       !str
237
238           Refer to the most recent command starting with str.
239
240
241       !?str?
242
243           Refer to the most recent command containing str.
244
245
246       !?str? additional
247
248           Refer to the most recent command containing str  and  append  addi‐
249           tional to that referenced command.
250
251
252       !{command} additional
253
254           Refer  to the most recent command beginning with command and append
255           additional to that referenced command.
256
257
258       ^previous_word^replacement^
259
260           Repeat the previous command line replacing the string previous_word
261           with the string replacement. This is equivalent to the history sub‐
262           stitution:
263
264             !:s/previous_word/replacement/.
265
266
267           To re-execute a specific previous command AND make such a substitu‐
268           tion, say, re-executing command #6,
269
270             !:6s/previous_word/replacement/.
271
272
273
274
275   Word Designators
276       A  `:' (colon) separates the event specification from the word designa‐
277       tor. It can be omitted if the word designator begins with a ^, $, *,  
278       or %. If the word is to be selected from the previous command, the sec‐
279       ond ! character can  be  omitted  from  the  event  specification.  For
280       instance,  !!:1  and  !:1  both refer to the first word of the previous
281       command, while !!$ and !$ both refer to the last word in  the  previous
282       command. Word designators include:
283
284       #         The entire command line typed so far.
285
286
287       0         The first input word (command).
288
289
290       n         The n'th argument.
291
292
293       ^         The first argument, that is, 1.
294
295
296       $         The last argument.
297
298
299       %         The word matched by the ?s search.
300
301
302       xy       A range of words; y abbreviates 0−y.
303
304
305       *         All  the arguments, or a null value if there is just one word
306                 in the event.
307
308
309       x*        Abbreviates x−$.
310
311
312       xLike x* but omitting word $.
313
314
315   Modifiers
316       After the optional word designator, you can add one  of  the  following
317       modifiers, preceded by a :.
318
319       h         Remove a trailing pathname component, leaving the head.
320
321
322       r         Remove  a  trailing  suffix  of  the form `.xxx', leaving the
323                 basename.
324
325
326       e         Remove all but the suffix, leaving the Extension.
327
328
329       s/l/r/    Substitute r for l.
330
331
332       t         Remove all leading pathname components, leaving the tail.
333
334
335       &         Repeat the previous substitution.
336
337
338       g         Apply the change to the first occurrence of a match  in  each
339                 word, by prefixing the above (for example, g&).
340
341
342       p         Print the new command but do not execute it.
343
344
345       q         Quote the substituted words,escaping further substitutions.
346
347
348       x         Like  q, but break into words at each space character, tab or
349                 newline.
350
351
352
353       Unless preceded by a g, the modification is applied only to  the  first
354       string that matches l; an error results if no string matches.
355
356
357       The  left-hand  side  of substitutions are not regular expressions, but
358       character strings. Any character can be used as the delimiter in  place
359       of  /.  A backslash quotes the delimiter character. The character &, in
360       the right hand side, is replaced by the text from  the  left-hand-side.
361       The & can be quoted with a backslash. A null l uses the previous string
362       either from a l or from a contextual scan string s from  !?s.  You  can
363       omit  the  rightmost  delimiter if a newline immediately follows r; the
364       rightmost ? in a context scan can similarly be omitted.
365
366
367       Without an event specification, a history reference  refers  either  to
368       the previous command, or to a previous history reference on the command
369       line (if any).
370
371   Quick Substitution
372       ^l^r^    This is equivalent to the history substitution:
373
374                  !:s/l/r/.
375
376
377
378
379   Aliases
380       The C shell maintains a list of aliases that you can  create,  display,
381       and  modify  using the alias and unalias commands. The shell checks the
382       first word in each command to see if it matches the name of an existing
383       alias. If it does, the command is reprocessed with the alias definition
384       replacing its name; the history substitution mechanism is  made  avail‐
385       able  as  though that command were the previous input line. This allows
386       history substitutions, escaped with a backslash in the  definition,  to
387       be  replaced with actual command line arguments when the alias is used.
388       If  no  history  substitution  is  called  for,  the  arguments  remain
389       unchanged.
390
391
392       Aliases  can  be  nested.  That is, an alias definition can contain the
393       name of another alias. Nested aliases are expanded before  any  history
394       substitutions is applied. This is useful in pipelines such as
395
396         alias lm 'ls -l \!* | more'
397
398
399
400
401       which when called, pipes the output of ls(1) through more(1).
402
403
404       Except  for the first word, the name of the alias can not appear in its
405       definition, nor in any alias referred to by its definition. Such  loops
406       are detected, and cause an error message.
407
408   I/O Redirection
409       The  following  metacharacters indicate that the subsequent word is the
410       name of a file to which the command's standard input, standard  output,
411       or  standard  error  is redirected; this word is variable, command, and
412       filename expanded separately from the rest of the command.
413
414       <              Redirect the standard input.
415
416
417       <<word         Read the standard input, up to a line that is  identical
418                      with  word, and place the resulting lines in a temporary
419                      file. Unless word is escaped  or  quoted,  variable  and
420                      command  substitutions  are  performed  on  these lines.
421                      Then, the pipeline is invoked with the temporary file as
422                      its  standard  input. word is not subjected to variable,
423                      filename, or command substitution, and each line is com‐
424                      pared  to  it  before any substitutions are performed by
425                      the shell.
426
427
428       > >! >& >&!    Redirect the standard output to a file. If the file does
429                      not  exist, it is created. If it does exist, it is over‐
430                      written; its previous contents are lost.
431
432                      When set, the variable noclobber prevents destruction of
433                      existing  files.  It also prevents redirection to termi‐
434                      nals and /dev/null, unless one of the ! forms  is  used.
435                      The  & forms redirect both standard output and the stan‐
436                      dard error (diagnostic output) to the file.
437
438
439       >> >>& >>! >>&!            Append the  standard  output.  Like  >,  but
440                                  places  output at the end of the file rather
441                                  than overwriting it. If noclobber is set, it
442                                  is  an  error  for  the  file  not to exist,
443                                  unless one of the ! forms  is  used.  The  &
444                                  forms  append  both  the  standard error and
445                                  standard output to the file.
446
447
448   Variable Substitution
449       The C shell maintains a set of variables, each of which is composed  of
450       a  name  and a value. A variable name consists of up to 128 letters and
451       digits, and starts with a letter. An underscore  (_)  is  considered  a
452       letter).  A  variable's value is a space-separated list of zero or more
453       words. If the shell supports a variable name upto  128  characters  the
454       variable  SUNW_VARLEN is defined. If a variable name of up to 128 char‐
455       acters is not supported, then an older version of the  shell  is  being
456       used, and the shell variable name length has a maximum length of 20.
457
458
459       To  refer  to  a variable's value, precede its name with a `$'. Certain
460       references (described below) can be used to select specific words  from
461       the  value,  or to display other information about the variable. Braces
462       can be used to insulate the  reference  from  other  characters  in  an
463       input-line word.
464
465
466       Variable  substitution  takes  place  after the input line is analyzed,
467       aliases are resolved, and I/O redirections are applied.  Exceptions  to
468       this  are  variable  references in I/O redirections (substituted at the
469       time the redirection is made), and backquoted strings (see Command Sub‐
470       stitution).
471
472
473       Variable  substitution  can  be suppressed by preceding the $ with a \,
474       except within double-quotes where it always occurs. Variable  substitu‐
475       tion  is suppressed inside of single-quotes. A $ is escaped if followed
476       by a space character, tab or newline.
477
478
479       Variables can be created, displayed, or destroyed  using  the  set  and
480       unset commands. Some variables are maintained or used by the shell. For
481       instance, the argv variable contains an image of the  shell's  argument
482       list.  Of  the  variables  used by the shell, a number are toggles; the
483       shell does not care what their value is, only whether they are  set  or
484       not.
485
486
487       Numerical  values can be operated on as numbers (as with the @ built-in
488       command). With numeric operations, an empty value is considered  to  be
489       zero.  The second and subsequent words of multiword values are ignored.
490       For instance, when the verbose variable is set to any value  (including
491       an empty value), command input is echoed on the terminal.
492
493
494       Command  and filename substitution is subsequently applied to the words
495       that result from the variable substitution, except when  suppressed  by
496       double-quotes,  when noglob is set (suppressing filename substitution),
497       or when the reference is quoted with the :q  modifier.  Within  double-
498       quotes, a reference is expanded to form (a portion of) a quoted string;
499       multiword values are expanded to a string with embedded  space  charac‐
500       ters.  When the :q modifier is applied to the reference, it is expanded
501       to a list of space-separated words, each of which is quoted to  prevent
502       subsequent command or filename substitutions.
503
504
505       Except  as  noted  below, it is an error to refer to a variable that is
506       not set.
507
508       $var             These are replaced by words from  the  value  of  var,
509       ${var}           each  separated  by  a  space  character. If var is an
510                        environment variable, its value is returned  (but  `:'
511                        modifiers  and  the  other  forms  given below are not
512                        available).
513
514
515       $var[index]      These select only the indicated words from  the  value
516       ${var[index]}    of  var.  Variable  substitution  is applied to index,
517                        which can consist of (or result in)  a  either  single
518                        number,  two  numbers separated by a `', or an aster‐
519                        isk. Words are indexed starting from 1; a `*'  selects
520                        all  words.  If the first number of a range is omitted
521                        (as with $argv[−2]), it defaults to  1.  If  the  last
522                        number  of  a range is omitted (as with $argv[1−]), it
523                        defaults to $#var (the word count). It is not an error
524                        for  a  range  to  be  empty if the second argument is
525                        omitted (or within range).
526
527
528       $#name           These give the number of words in the variable.
529       ${#name}
530
531       $0               This substitutes the name of the file from which  com‐
532                        mand  input  is  being  read  except  for setuid shell
533                        scripts. An error occurs if the name is not known.
534
535
536       $n               Equivalent to $argv[n].
537       ${n}
538
539       $*               Equivalent to $argv[*].
540
541
542
543       The modifiers :e, :h, :q, :r, :t, and :x can be  applied  (see  History
544       Substitution),  as can :gh, :gt, and :gr. If {} (braces) are used, then
545       the modifiers must appear within the braces. The current implementation
546       allows only one such modifier per expansion.
547
548
549       The following references can not be modified with : modifiers.
550
551       $?var      Substitutes  the  string  1  if var is set or 0 if it is not
552       ${?var}    set.
553
554
555       $?0        Substitutes 1 if the current input filename is known or 0 if
556                  it is not.
557
558
559       $$         Substitutes the process number of the (parent) shell.
560
561
562       $<         Substitutes  a line from the standard input, with no further
563                  interpretation thereafter. It can be used to read  from  the
564                  keyboard in a C shell script.
565
566
567   Command and Filename Substitutions
568       Command and filename substitutions are applied selectively to the argu‐
569       ments of built-in commands. Portions of expressions that are not evalu‐
570       ated are not expanded. For non-built-in commands, filename expansion of
571       the command name is done separately from that  of  the  argument  list;
572       expansion occurs in a subshell, after I/O redirection is performed.
573
574   Command Substitution
575       A  command  enclosed  by backquotes (`...`) is performed by a subshell.
576       Its standard output is broken into separate words at each space charac‐
577       ter,  tab and newline; null words are discarded. This text replaces the
578       backquoted string on the current command  line.  Within  double-quotes,
579       only  newline  characters force new words; space and tab characters are
580       preserved. However, a final newline is ignored. It is therefore  possi‐
581       ble for a command substitution to yield a partial word.
582
583   Filename Substitution
584       Unquoted  words  containing any of the characters *, ?, [ or {, or that
585       begin with ~, are expanded (also known as globbing)  to  an  alphabeti‐
586       cally sorted list of filenames, as follows:
587
588       *                       Match any (zero or more) characters.
589
590
591       ?                       Match any single character.
592
593
594       [...]                   Match  any  single  character  in  the enclosed
595                               list(s) or range(s). A  list  is  a  string  of
596                               characters. A range is two characters separated
597                               by a dash (), and includes all the  characters
598                               in between in the ASCII collating sequence (see
599                               ascii(5)).
600
601
602       {str, str, ... }        Expand to  each  string  (or  filename-matching
603                               pattern)  in  the  comma-separated list. Unlike
604                               the  pattern-matching  expressions  above,  the
605                               expansion  of this construct is not sorted. For
606                               instance, {b,a} expands to `b'  `a',  (not  `a'
607                               `b'). As special cases, the characters { and },
608                               along with the string  {},  are  passed  undis‐
609                               turbed.
610
611
612       ~[user]                 Your  home directory, as indicated by the value
613                               of the variable home, or that of user, as indi‐
614                               cated by the password entry for user.
615
616
617
618       Only  the  patterns  *,  ?  and  [...] imply pattern matching; an error
619       results if no filename matches a pattern that contains  them.  The  `.'
620       (dot  character), when it is the first character in a filename or path‐
621       name component, must be matched explicitly. The / (slash) must also  be
622       matched explicitly.
623
624   Expressions and Operators
625       A  number of C shell built-in commands accept expressions, in which the
626       operators are similar to those of C and have the same precedence. These
627       expressions  typically  appear  in  the @, exit, if, set and while com‐
628       mands, and are often used to regulate the flow of control for executing
629       commands. Components of an expression are separated by white space.
630
631
632       Null  or missing values are considered 0. The result of all expressions
633       is a string, which can represent decimal numbers.
634
635
636       The following C shell operators are grouped in order of precedence:
637
638       (...)              grouping
639
640
641       >~                 one's complement
642
643
644       !                  logical negation
645
646
647       * / %              multiplication, division, remainder. These are right
648                          associative,  which  can lead to unexpected results.
649                          Combinations  should  be  grouped  explicitly   with
650                          parentheses.
651
652
653       + −                addition, subtraction (also right associative)
654
655
656       << >>              bitwise shift left, bitwise shift right
657
658
659       < > <= >=          less  than,  greater  than,  less  than or equal to,
660                          greater than or equal to
661
662
663       == != =~ !~        equal to, not equal to,  filename-substitution  pat‐
664                          tern  match (described below), filename-substitution
665                          pattern mismatch
666
667
668       &                  bitwise AND
669
670
671       ^                  bitwise XOR (exclusive or)
672
673
674       |                  bitwise inclusive OR
675
676
677       &&                 logical AND
678
679
680       ||                 logical OR
681
682
683
684       The operators: ==, !=, =~, and !~ compare their arguments  as  strings;
685       other operators use numbers. The operators =~ and !~ each check whether
686       or not a string to the left matches a filename substitution pattern  on
687       the  right.  This  reduces the need for switch statements when pattern-
688       matching between strings is all that is required.
689
690
691       Also available are file inquiries:
692
693       -rfilename     Return true, or 1 if the user has read access. Otherwise
694                      it returns false, or 0.
695
696
697       -wfilename     True if the user has write access.
698
699
700       -xfilename     True  if the user has execute permission (or search per‐
701                      mission on a directory).
702
703
704       -efilename     True if filename exists.
705
706
707       -ofilename     True if the user owns filename.
708
709
710       -z filename    True if filename is of zero length (empty).
711
712
713       -ffilename     True if filename is a plain file.
714
715
716       -dfilename     True if filename is a directory.
717
718
719
720       If filename does not exist  or  is  inaccessible,  then  all  inquiries
721       return false.
722
723
724       An inquiry as to the success of a command is also available:
725
726       { command}    If command runs successfully, the expression evaluates to
727                     true, 1. Otherwise, it evaluates to false, 0. Note:  Con‐
728                     versely,  command itself typically returns 0 when it runs
729                     successfully, or some other  value  if  it  encounters  a
730                     problem.  If  you want to get at the status directly, use
731                     the value of the status variable rather than this expres‐
732                     sion.
733
734
735   Control Flow
736       The shell contains a number of commands to regulate the flow of control
737       in scripts and within limits, from the terminal. These commands operate
738       by forcing the shell either to reread input (to loop), or to skip input
739       under certain conditions (to branch).
740
741
742       Each occurrence of a foreach, switch, while, if...then and else  built-
743       in command must appear as the first word on its own input line.
744
745
746       If  the  shell's  input  is not seekable and a loop is being read, that
747       input is buffered. The shell performs seeks within the internal  buffer
748       to  accomplish  the  rereading implied by the loop. (To the extent that
749       this allows, backward goto commands succeeds on nonseekable inputs.)
750
751   Command Execution
752       If the command is a C shell built-in command,  the  shell  executes  it
753       directly.  Otherwise,  the  shell searches for a file by that name with
754       execute access. If the command name contains a /, the shell takes it as
755       a pathname, and searches for it. If the command name does not contain a
756       /, the shell attempts to resolve  it  to  a  pathname,  searching  each
757       directory  in  the  path variable for the command. To speed the search,
758       the shell uses its hash table (see  the  rehash  built-in  command)  to
759       eliminate  directories  that have no applicable files. This hashing can
760       be disabled with the -c or -t, options, or the unhash built-in command.
761
762
763       As a special case, if there is no / in the name of the script and there
764       is  an  alias  for  the word shell, the expansion of the shell alias is
765       prepended (without  modification)  to  the  command  line.  The  system
766       attempts  to  execute  the  first word of this special (late-occurring)
767       alias, which should be a full pathname. Remaining words of the  alias's
768       definition, along with the text of the input line, are treated as argu‐
769       ments.
770
771
772       When a pathname is found that has proper execute permissions, the shell
773       forks  a  new  process  and passes it, along with its arguments, to the
774       kernel using the execve() system call (see exec(2)).  The  kernel  then
775       attempts  to  overlay  the new process with the desired program. If the
776       file is an executable binary (in a.out(4) format) the  kernel  succeeds
777       and  begins  executing  the new process. If the file is a text file and
778       the first line begins with #!, the next word is taken to be  the  path‐
779       name of a shell (or command) to interpret that script. Subsequent words
780       on the first line are taken as  options  for  that  shell.  The  kernel
781       invokes (overlays) the indicated shell, using the name of the script as
782       an argument.
783
784
785       If neither of the above conditions holds, the kernel cannot overlay the
786       file  and  the  execve()  call  fails  (see  exec(2)). The C shell then
787       attempts to execute the file by spawning a new shell, as follows:
788
789           o      If the first character of the file is a  #,  a  C  shell  is
790                  invoked.
791
792           o      Otherwise, a Bourne shell is invoked.
793
794   Signal Handling
795       The  shell normally ignores QUIT signals. Background jobs are immune to
796       signals generated from the keyboard,  including  hangups  (HUP).  Other
797       signals  have  the  values that the C shell inherited from its environ‐
798       ment. The shell's handling of interrupt and  terminate  signals  within
799       scripts  can be controlled by the onintr built-in command. Login shells
800       catch the TERM signal. Otherwise, this signal is  passed  on  to  child
801       processes.  In  no  case  are  interrupts allowed when a login shell is
802       reading the .logout file.
803
804   Job Control
805       The shell associates a numbered job with each command sequence to  keep
806       track of those commands that are running in the background or have been
807       stopped with TSTP signals (typically Control-z). When a command or com‐
808       mand  sequence  (semicolon separated list) is started in the background
809       using the & metacharacter, the shell displays a line with the job  num‐
810       ber in brackets and a list of associated process numbers:
811
812         [1] 1234
813
814
815
816
817       To see the current list of jobs, use the jobs built-in command. The job
818       most recently stopped (or put into the background if none are  stopped)
819       is referred to as the current job and is indicated with a `+'. The pre‐
820       vious job is indicated with a `'. When the current job  is  terminated
821       or  moved  to the foreground, this job takes its place (becomes the new
822       current job).
823
824
825       To manipulate jobs, refer to the bg, fg, kill,  stop,  and  %  built-in
826       commands.
827
828
829       A  reference  to  a  job begins with a `%'. By itself, the percent-sign
830       refers to the current job.
831
832       % %+ %%     The current job.
833
834
835       %−          The previous job.
836
837
838       %j          Refer to job j as in: `kill -9 %j'. j can be a job  number,
839                   or  a  string  that  uniquely specifies the command line by
840                   which it was started; `fg %vi' might bring a stopped vi job
841                   to the foreground, for instance.
842
843
844       %?string    Specify  the  job  for which the command line uniquely con‐
845                   tains string.
846
847
848
849       A job running in the background stops when it attempts to read from the
850       terminal.  Background jobs can normally produce output, but this can be
851       suppressed using the `stty tostop' command.
852
853   Status Reporting
854       While running interactively, the shell tracks the status  of  each  job
855       and  reports  whenever the job finishes or becomes blocked. It normally
856       displays a message to this effect as it issues a prompt,  in  order  to
857       avoid  disturbing  the  appearance  of your input. When set, the notify
858       variable indicates that the shell is to report status  changes  immedi‐
859       ately.  By default, the notify command marks the current process; after
860       starting a background job, type notify to mark it.
861
862   Commands
863       Built-in commands are executed within the C shell. If a  built-in  com‐
864       mand  occurs as any component of a pipeline except the last, it is exe‐
865       cuted in a subshell.
866
867       :                         Null command. This  command  is  interpreted,
868                                 but performs no action.
869
870
871       alias [ name [ def ] ]    Assign  def  to the alias name. def is a list
872                                 of words that can  contain  escaped  history-
873                                 substitution  metasyntax. name is not allowed
874                                 to be alias or unalias. If  def  is  omitted,
875                                 the  current definition for the alias name is
876                                 displayed. If both name and def are  omitted,
877                                 all  aliases are displayed with their defini‐
878                                 tions.
879
880
881       bg [ %job ... ]           Run the current  or  specified  jobs  in  the
882                                 background.
883
884
885       break                     Resume execution after the end of the nearest
886                                 enclosing foreach or while loop. The  remain‐
887                                 ing  commands  on  the  current line are exe‐
888                                 cuted. This allows multilevel  breaks  to  be
889                                 written  as  a list of break commands, all on
890                                 one line.
891
892
893       breaksw                   Break  from  a  switch,  resuming  after  the
894                                 endsw.
895
896
897       case label:               A label in a switch statement.
898
899
900       cd [dir ]                 Change   the  shell's  working  directory  to
901       chdir [dir ]              directory  dir.  If  no  argument  is  given,
902                                 change  to the home directory of the user. If
903                                 dir is a relative pathname not found  in  the
904                                 current  directory,  check  for  it  in those
905                                 directories listed in the cdpath variable. If
906                                 dir  is  the  name  of a shell variable whose
907                                 value starts with a /, change to  the  direc‐
908                                 tory named by that value.
909
910
911       continue                  Continue  execution  of the next iteration of
912                                 the nearest enclosing while or foreach loop.
913
914
915       default:                  Labels the default case in  a  switch  state‐
916                                 ment.  The default should come after all case
917                                 labels. Any remaining commands on the command
918                                 line are first executed.
919
920
921       dirs [-l]                 Print the directory stack, most recent to the
922                                 left. The first directory shown is  the  cur‐
923                                 rent directory. With the -l argument, produce
924                                 an unabbreviated printout; use of the ~ nota‐
925                                 tion is suppressed.
926
927
928       echo [-n] list            The  words in list are written to the shell's
929                                 standard output, separated by  space  charac‐
930                                 ters. The output is terminated with a newline
931                                 unless  the  -n  option  is  used.  csh,   by
932                                 default,  invokes  its built-in echo, if echo
933                                 is called without the full pathname of a Unix
934                                 command,  regardless  of the configuration of
935                                 your PATH (see echo(1)).
936
937
938       eval argument...          Reads the arguments as input to the shell and
939                                 executes  the  resulting  command(s). This is
940                                 usually used to execute commands generated as
941                                 the  result  of command or variable substitu‐
942                                 tion. See tset(1B) for an example of  how  to
943                                 use eval.
944
945
946       exec command              Execute  command  in  place  of  the  current
947                                 shell, which terminates.
948
949
950       exit [(expr)]             The calling  shell  or  shell  script  exits,
951                                 either  with the value of the status variable
952                                 or with the value specified by the expression
953                                 expr.
954
955
956       fg [%job ]                Bring  the  current or specified job into the
957                                 foreground.
958
959
960       foreach var(wordlist)     The variable var is successively set to  each
961       ...                       member  of wordlist. The sequence of commands
962       end                       between this command and the matching end  is
963                                 executed  for  each  new  value  of var. Both
964                                 foreach and end must appear alone on separate
965                                 lines.
966
967                                 The  built-in command continue can be used to
968                                 terminate the execution of the current itera‐
969                                 tion  of  the  loop  and the built-in command
970                                 break can be used to terminate  execution  of
971                                 the  foreach  command.  When  this command is
972                                 read from the terminal, the loop is read once
973                                 prompting with ? before any statements in the
974                                 loop are executed.
975
976
977       glob wordlist
978
979           Perform filename expansion on wordlist. Like echo, but no \ escapes
980           are  recognized. Words are delimited by NULL characters in the out‐
981           put.
982
983
984       gotolabel
985
986           The specified label is a filename and a command expanded to yield a
987           label. The shell rewinds its input as much as possible and searches
988           for a line of the form label: possibly preceded  by  space  or  tab
989           characters.  Execution continues after the indicated line. It is an
990           error to jump to a label that occurs between a while or for  built-
991           in command and its corresponding end.
992
993
994       hashstat
995
996           Print  a statistics line indicating how effective the internal hash
997           table for the path variable has  been  at  locating  commands  (and
998           avoiding  execs).  An  exec  is attempted for each component of the
999           path where the hash function indicates a possible hit and  in  each
1000           component  that  does  not  begin with a `/'. These statistics only
1001           reflect the effectiveness of the  path  variable,  not  the  cdpath
1002           variable.
1003
1004
1005       history [-hr] [n]
1006
1007           Display  the  history  list; if n is given, display only the n most
1008           recent events.
1009
1010           -r    Reverse the order of printout to be most recent first  rather
1011                 than oldest first.
1012
1013
1014           -h    Display  the  history  list  without leading numbers. This is
1015                 used to produce files suitable  for  sourcing  using  the  -h
1016                 option to source.
1017
1018
1019
1020       if (expr )command
1021
1022           If  the  specified expression evaluates to true, the single command
1023           with arguments is executed. Variable substitution on  command  hap‐
1024           pens  early,  at  the same time it does for the rest of the if com‐
1025           mand. command must be a simple command, not a pipeline,  a  command
1026           list, or a parenthesized command list. Note: I/O redirection occurs
1027           even if expr is false, when command is  not  executed  (this  is  a
1028           bug).
1029
1030
1031       if (expr) then
1032       ...
1033       else if (expr2) then
1034       ...
1035       else
1036       ...
1037       endif
1038
1039           If expr is true, commands up to the first else are executed. Other‐
1040           wise, if expr2 is true, the commands between the else  if  and  the
1041           second  else are executed. Otherwise, commands between the else and
1042           the endif are executed. Any number of else if  pairs  are  allowed,
1043           but  only  one  else. Only one endif is needed, but it is required.
1044           The words else and endif must be the first nonwhite characters on a
1045           line. The if must appear alone on its input line or after an else.
1046
1047
1048       jobs [-l]
1049
1050           List the active jobs under job control.
1051
1052           -l    List process IDs, in addition to the normal information.
1053
1054
1055
1056       kill [sig ] [ pid ] [ %job ] ...
1057       kill -l
1058
1059           Send  the TERM (terminate) signal, by default, or the signal speci‐
1060           fied, to the specified process ID, the job indicated, or  the  cur‐
1061           rent  job.  Signals are either given by number or by name. There is
1062           no default. Typing kill does not send a signal to the current  job.
1063           If  the signal being sent is TERM (terminate) or HUP (hangup), then
1064           the job or process is sent a CONT (continue) signal as well.
1065
1066           -l    List the signal names that can be sent.
1067
1068
1069
1070       limit [-h] [resource [max-use ] ]
1071
1072           Limit the consumption by the current  process  or  any  process  it
1073           spawns,  each  not to exceed max-use on the specified resource. The
1074           string unlimited requests  that  the  current  limit,  if  any,  be
1075           removed.  If  max-use  is  omitted,  print  the  current  limit. If
1076           resource is omitted, display all limits. Run the sysdef(1M) command
1077           to  display  maximum  limits  for  certain resources in your system
1078           (although it does not report stack size). The values  reported  are
1079           in  hexadecimal,  but  can be translated into decimal numbers using
1080           the bc(1) command.
1081
1082           -h    Use hard limits instead of the current  limits.  Hard  limits
1083                 impose  a  ceiling  on the values of the current limits. Only
1084                 the privileged user can raise the hard limits.
1085
1086           resource is one of:
1087
1088           cputime                Maximum CPU seconds per process.
1089
1090
1091           filesize               Largest single file allowed. Limited to  the
1092                                  size of the filesystem. (See df(1M)).
1093
1094
1095           datasize (heapsize)    Maximum  data size (including stack) for the
1096                                  process. This is the size  of  your  virtual
1097                                  memory See swap(1M).
1098
1099
1100           stacksize              Maximum  stack  size  for  the  process. The
1101                                  default stack size is 2^64  bytes.  You  can
1102                                  use limit(1) to change this default within a
1103                                  shell.
1104
1105
1106           coredumpsize           Maximum size of a  core  dump  (file).  This
1107                                  limited to the size of the filesystem.
1108
1109
1110           descriptors            Maximum number of file descriptors. Run sys‐
1111                                  def().
1112
1113
1114           memorysize             Maximum size of virtual memory.
1115
1116           max-use is a number, with an optional scaling factor, as follows:
1117
1118           nh       Hours (for cputime).
1119
1120
1121           nk       n kilobytes. This is the default for all but cputime.
1122
1123
1124           nm       n megabytes or minutes (for cputime).
1125
1126
1127           mm:ss    Minutes and seconds (for cputime).
1128
1129           Example of limit: To limit the size  of  a  core  file  dump  to  0
1130           Megabytes, type the following:
1131
1132             limit coredumpsize 0M
1133
1134
1135
1136
1137       login [username| -p ]
1138
1139           Terminate  a  login  shell and invoke login(1). The .logout file is
1140           not processed. If username is omitted, login prompts for  the  name
1141           of a user.
1142
1143           -p    Preserve the current environment (variables).
1144
1145
1146
1147       logout
1148
1149           Terminate a login shell.
1150
1151
1152       nice [+n |-n ] [command ]
1153
1154           Increment  the  process priority value for the shell or for command
1155           by n. The higher the priority value, the lower the  priority  of  a
1156           process,  and the slower it runs. When given, command is always run
1157           in a subshell, and the restrictions placed on commands in simple if
1158           commands  apply.  If  command is omitted, nice increments the value
1159           for the current shell. If no increment is specified, nice sets  the
1160           process  priority  value to 4. The range of process priority values
1161           is from −20 to 20. Values of n outside this range set the value  to
1162           the lower, or to the higher boundary, respectively.
1163
1164           +n    Increment the process priority value by n.
1165
1166
1167           -n    Decrement  by n. This argument can be used only by the privi‐
1168                 leged user.
1169
1170
1171
1172       nohup [command ]
1173
1174           Run command with HUPs  ignored.  With  no  arguments,  ignore  HUPs
1175           throughout the remainder of a script. When given, command is always
1176           run in a subshell, and the restrictions placed on commands in  sim‐
1177           ple  if  statements apply. All processes detached with & are effec‐
1178           tively nohup'd.
1179
1180
1181       notify [%job] ...
1182
1183           Notify the user asynchronously when the status of the  current  job
1184           or specified jobs changes.
1185
1186
1187       onintr [| label]
1188
1189           Control  the  action of the shell on interrupts. With no arguments,
1190           onintr restores the default action of the shell on interrupts. (The
1191           shell  terminates shell scripts and returns to the terminal command
1192           input level). With the argument, the  shell  ignores  all  inter‐
1193           rupts.  With a label argument, the shell executes a goto label when
1194           an interrupt is received or a child process terminates  because  it
1195           was interrupted.
1196
1197
1198       popd [+n ]
1199
1200           Pop  the  directory stack and cd to the new top directory. The ele‐
1201           ments of the directory stack are numbered from 0  starting  at  the
1202           top.
1203
1204           +n    Discard the n'th entry in the stack.
1205
1206
1207
1208       pushd [+n |dir]
1209
1210           Push  a  directory  onto  the  directory  stack. With no arguments,
1211           exchange the top two elements.
1212
1213           +n     Rotate the n'th entry to the top of the stack and cd to it.
1214
1215
1216           dir    Push the current working directory onto the stack and change
1217                  to dir.
1218
1219
1220
1221       rehash
1222
1223           Recompute  the  internal  hash table of the contents of directories
1224           listed in the path variable to  account  for  new  commands  added.
1225           Recompute  the  internal  hash table of the contents of directories
1226           listed in the cdpath variable to account for new directories added.
1227
1228
1229       repeat count command
1230
1231           Repeat command count times. command is subject to the same restric‐
1232           tions as with the one-line if statement.
1233
1234
1235       set [var [= value ] ]
1236       set var[n] = word
1237
1238           With  no arguments, set displays the values of all shell variables.
1239           Multiword values are displayed as a parenthesized  list.  With  the
1240           var  argument alone, set assigns an empty (null) value to the vari‐
1241           able var. With arguments of the form var = value set assigns  value
1242           to var, where value is one of:
1243
1244           word          A single word (or quoted string).
1245
1246
1247           (wordlist)    A space-separated list of words enclosed in parenthe‐
1248                         ses.
1249
1250           Values are command and filename expanded before being assigned. The
1251           form  setvar[n]  = word replaces the n'th word in a multiword value
1252           with word.
1253
1254
1255       setenv [VAR [word ] ]
1256
1257           With no arguments, setenv displays all environment variables.  With
1258           the VAR argument, setenv sets the environment variable VAR  to have
1259           an empty (null) value. (By convention,  environment  variables  are
1260           normally given upper-case names.) With both VAR and word arguments,
1261           setenv sets the environment variable NAME to the value word,  which
1262           must  be either a single word or a quoted string. The most commonly
1263           used environment variables, USER, TERM, and PATH, are automatically
1264           imported  to  and  exported  from the csh variables user, term, and
1265           path. There is no need to use setenv for these.  In  addition,  the
1266           shell  sets  the PWD environment variable from the csh variable cwd
1267           whenever the latter changes.
1268
1269           The environment variables LC_CTYPE, LC_MESSAGES,  LC_TIME,  LC_COL‐
1270           LATE,  LC_NUMERIC,  and  LC_MONETARY  take  immediate  effect  when
1271           changed within the C shell.
1272
1273           If any of  the  LC_*  variables  (LC_CTYPE,  LC_MESSAGES,  LC_TIME,
1274           LC_COLLATE,  LC_NUMERIC,  and LC_MONETARY) (see environ(5)) are not
1275           set in the environment, the operational behavior of  csh  for  each
1276           corresponding  locale  category  is  determined by the value of the
1277           LANG environment variable. If LC_ALL is set, its contents are  used
1278           to  override both the LANG and the other LC_* variables. If none of
1279           the above variables is set in the environment, the "C" (U.S. style)
1280           locale determines how csh behaves.
1281
1282           LC_CTYPE       Determines how csh handles characters. When LC_CTYPE
1283                          is set to a valid value, csh can display and  handle
1284                          text  and  filenames containing valid characters for
1285                          that locale.
1286
1287
1288           LC_MESSAGES    Determines how diagnostic and  informative  messages
1289                          are  presented. This includes the language and style
1290                          of the messages and the correct form of  affirmative
1291                          and  negative responses. In the "C" locale, the mes‐
1292                          sages are presented in the default form found in the
1293                          program itself (in most cases, U.S./English).
1294
1295
1296           LC_NUMERIC     Determines the value of the radix character, decimal
1297                          point, (.) in the "C" locale) and  thousand  separa‐
1298                          tor, empty string ("") in the "C" locale).
1299
1300
1301
1302       shift [variable ]
1303
1304           The  components  of  argv, or variable, if supplied, are shifted to
1305           the left, discarding the first component. It is an  error  for  the
1306           variable not to be set or to have a null value.
1307
1308
1309       source [-h] name
1310
1311           Reads  commands  from  name.  source commands can be nested, but if
1312           they are nested too deeply the shell can run out of  file  descrip‐
1313           tors. An error in a sourced file at any level terminates all nested
1314           source commands.
1315
1316           -h    Place commands from the file name on the history list without
1317                 executing them.
1318
1319
1320
1321       stop %jobid ...
1322
1323           Stop the current or specified background job.
1324
1325
1326       stop pid ...
1327
1328           Stop the specified process, pid. (see ps(1)).
1329
1330
1331       suspend
1332
1333           Stop  the  shell  in its tracks, much as if it had been sent a stop
1334           signal with ^Z. This is most often used to stop shells  started  by
1335           su.
1336
1337
1338       switch (string)
1339       case label:
1340       ...
1341       breaksw
1342       ...
1343       default:
1344       ...
1345       breaksw
1346       endsw
1347
1348           Each  label  is successively matched, against the specified string,
1349           which is first command and filename expanded. The file  metacharac‐
1350           ters *, ? and [...] can be used in the case labels, which are vari‐
1351           able expanded. If none of the labels match before a "default" label
1352           is  found,  execution  begins  after  the  default label. Each case
1353           statement and the default statement must appear at the beginning of
1354           a  line.  The  command breaksw continues execution after the endsw.
1355           Otherwise control falls through subsequent case and default  state‐
1356           ments  as with C. If no label matches and there is no default, exe‐
1357           cution continues after the endsw.
1358
1359
1360       time [command ]
1361
1362           With no argument, print a summary of time used by this C shell  and
1363           its children. With an optional command, execute command and print a
1364           summary of the time it uses. As of this writing, the time  built-in
1365           command does NOT compute the last 6 fields of output, rendering the
1366           output to erroneously report the value 0 for these fields.
1367
1368             example %time ls -R
1369                     9.0u 11.0s 3:32 10% 0+0k 0+0io 0pf+0w
1370
1371
1372           (See the Environment Variables and Predefined Shell Variables  sub-
1373           section on the time variable.)
1374
1375
1376       umask [value ]
1377
1378           Display  the  file creation mask. With value, set the file creation
1379           mask. With value given in octal, the user can turn  off  any  bits,
1380           but  cannot  turn  on  bits to allow new permissions. Common values
1381           include 077, restricting all permissions from everyone  else;  002,
1382           giving  complete  access  to  the  group,  and  read (and directory
1383           search) access to  others;  or  022,  giving  read  (and  directory
1384           search) but not write permission to the group and others.
1385
1386
1387       unalias pattern
1388
1389           Discard  aliases  that  match  (filename substitution) pattern. All
1390           aliases are removed by `unalias *'.
1391
1392
1393       unhash
1394
1395           Disable the internal hash tables for the path and cdpath variables.
1396
1397
1398       unlimit [-h] [resource ]
1399
1400           Remove a limitation on resource. If no resource is specified,  then
1401           all  resource  limitations  are removed. See the description of the
1402           limit command for the list of resource names.
1403
1404           -h    Remove corresponding hard limits. Only  the  privileged  user
1405                 can do this.
1406
1407
1408
1409       unset pattern
1410
1411           Remove variables whose names match (filename substitution) pattern.
1412           All variables are removed by `unset *'; this  has  noticeably  dis‐
1413           tasteful side effects.
1414
1415
1416       unsetenv variable
1417
1418           Remove variable from the environment. As with unset, pattern match‐
1419           ing is not performed.
1420
1421
1422       wait
1423
1424           Wait for background jobs to finish (or  for  an  interrupt)  before
1425           prompting.
1426
1427
1428       while (expr)
1429       ...
1430       end
1431
1432           While  expr is true (evaluates to nonzero), repeat commands between
1433           the while and the matching end statement. break and continue can be
1434           used  to  terminate or continue the loop prematurely. The while and
1435           end must appear alone on their input lines. If the shell's input is
1436           a  terminal, it prompts for commands with a question-mark until the
1437           end command is entered and then performs the commands in the loop.
1438
1439
1440       % [job ] [&]
1441
1442           Bring the current or indicated job  to  the  foreground.  With  the
1443           ampersand, continue running job in the background.
1444
1445
1446       @ [var =expr]
1447       @ [var[n]=expr]
1448
1449           With no arguments, display the values for all shell variables. With
1450           arguments, set the variable var, or the n'th word in the  value  of
1451           var, to the value that expr evaluates to. (If [n] is supplied, both
1452           var and its n'th component must already exist.)
1453
1454           If the expression contains the characters >, <, &, or  |,  then  at
1455           least this part of expr must be placed within parentheses.
1456
1457           The  operators  *=,  +=,  and  so forth, are available as in C. The
1458           space separating the name from the assignment operator is optional.
1459           Spaces  are,  however,  mandatory  in separating components of expr
1460           that would otherwise be single words.
1461
1462           Special postfix operators, ++ and −−, increment or decrement  name,
1463           respectively.
1464
1465
1466   Environment Variables and Predefined Shell Variables
1467       Unlike  the  Bourne  shell, the C shell maintains a distinction between
1468       environment variables, which are automatically exported to processes it
1469       invokes,  and  shell  variables, which are not. Both types of variables
1470       are treated similarly under variable substitution. The shell  sets  the
1471       variables  argv,  cwd,  home, path, prompt, shell, and status upon ini‐
1472       tialization. The shell copies the environment variable  USER  into  the
1473       shell  variable  user,  TERM  into term, and HOME into home, and copies
1474       each back into the respective environment variable whenever  the  shell
1475       variables are reset. PATH and path are similarly handled. You need only
1476       set path once in the .cshrc or .login file.  The  environment  variable
1477       PWD  is  set  from cwd whenever the latter changes. The following shell
1478       variables have predefined meanings:
1479
1480       argv         Argument list. Contains the list of command line arguments
1481                    supplied  to  the  current  invocation  of the shell. This
1482                    variable determines the value of the positional parameters
1483                    $1, $2, and so on.
1484
1485
1486       cdpath       Contains  a  list of directories to be searched by the cd,
1487                    chdir, and popd commands, if the directory  argument  each
1488                    accepts is not a subdirectory of the current directory.
1489
1490
1491       cwd          The full pathname of the current directory.
1492
1493
1494       echo         Echo commands (after substitutions) just before execution.
1495
1496
1497       fignore      A  list  of  filename  suffixes  to ignore when attempting
1498                    filename completion. Typically the single word `.o'.
1499
1500
1501       filec        Enable filename completion, in which  case  the  Control-d
1502                    character  EOT and the ESC character have special signifi‐
1503                    cance when typed in at the end of a terminal input line:
1504
1505                    EOT    Print a list of all filenames that start  with  the
1506                           preceding string.
1507
1508
1509                    ESC    Replace the preceding string with the longest unam‐
1510                           biguous extension.
1511
1512
1513
1514       hardpaths    If set, pathnames in the directory stack are  resolved  to
1515                    contain no symbolic-link components.
1516
1517
1518       histchars    A  two-character string. The first character replaces ! as
1519                    the history-substitution character.  The  second  replaces
1520                    the carat (^) for quick substitutions.
1521
1522
1523       history      The  number  of  lines  saved  in the history list. A very
1524                    large number can use up all of the C  shell's  memory.  If
1525                    not set, the C shell saves only the most recent command.
1526
1527
1528       home         The  user's  home  directory.  The filename expansion of ~
1529                    refers to the value of this variable.
1530
1531
1532       ignoreeof    If set, the shell ignores EOF from  terminals.  This  pro‐
1533                    tects  against  accidentally killing a C shell by typing a
1534                    Control-d.
1535
1536
1537       mail         A list of files where the C shell checks for mail. If  the
1538                    first  word  of the value is a number, it specifies a mail
1539                    checking interval in seconds (default 5 minutes).
1540
1541
1542       nobeep       Suppress the bell during command  completion  when  asking
1543                    the C shell to extend an ambiguous filename.
1544
1545
1546       noclobber    Restrict output redirection so that existing files are not
1547                    destroyed by accident. > redirections can only be made  to
1548                    new  files.  >>  redirections can only be made to existing
1549                    files.
1550
1551
1552       noglob       Inhibit filename substitution.  This  is  most  useful  in
1553                    shell  scripts once filenames (if any) are obtained and no
1554                    further expansion is desired.
1555
1556
1557       nonomatch    Return the filename substitution pattern, rather  than  an
1558                    error,  if  the pattern is not matched. Malformed patterns
1559                    still result in errors.
1560
1561
1562       notify       If set, the shell notifies you  immediately  as  jobs  are
1563                    completed, rather than waiting until just before issuing a
1564                    prompt.
1565
1566
1567       path         The list of directories in which to search  for  commands.
1568                    path  is  initialized  from the environment variable PATH,
1569                    which the C shell updates whenever path  changes.  A  null
1570                    word  ('') specifies the current directory. The default is
1571                    typically (/usr/bin .).  One  can  override  this  initial
1572                    search  path  upon csh start-up by setting it in .cshrc or
1573                    .login (for login shells only).  If  path  becomes  unset,
1574                    only  full  pathnames execute. An interactive C shell nor‐
1575                    mally hashes the contents of the directories listed  after
1576                    reading  .cshrc,  and  whenever path is reset. If new com‐
1577                    mands are added, use the rehash command to update the  ta‐
1578                    ble.
1579
1580
1581       prompt       The  string an interactive C shell prompts with. Noninter‐
1582                    active shells leave the prompt variable unset. Aliases and
1583                    other  commands  in  the  .cshrc file that are only useful
1584                    interactively, can be placed after the following test: `if
1585                    ($?prompt  ==  0) exit', to reduce startup time for nonin‐
1586                    teractive shells. A ! in the prompt string is replaced  by
1587                    the  current event number. The default prompt is hostname%
1588                    for mere mortals, or hostname# for the privileged user.
1589
1590                    The setting of $prompt has three meanings:
1591
1592                    $prompt not set          non-interactive    shell,    test
1593                                             $?prompt.
1594
1595
1596                    $prompt set but == ""    .cshrc  called  by  the  which(1)
1597                                             command.
1598
1599
1600                    $prompt set and != ""    normal interactive shell.
1601
1602
1603
1604       savehist     The number of lines from the history list that  are  saved
1605                    in  ~/.history  when  the  user logs out. Large values for
1606                    savehist slow down the C shell during startup.
1607
1608
1609       shell        The file in which the C shell resides.  This  is  used  in
1610                    forking  shells  to interpret files that have execute bits
1611                    set, but that are not executable by the system.
1612
1613
1614       status       The status returned by the most recent  command.  If  that
1615                    command  terminated  abnormally, 0200 is added to the sta‐
1616                    tus. Built-in commands that fail return exit status 1; all
1617                    other built-in commands set status to 0.
1618
1619
1620       time         Control automatic timing of commands. Can be supplied with
1621                    one or two values. The first is the reporting threshold in
1622                    CPU seconds. The second is a string of tags and text indi‐
1623                    cating which resources to report on. A tag  is  a  percent
1624                    sign  (%) followed by a single upper-case letter (unrecog‐
1625                    nized tags print as text):
1626
1627                    %D    Average amount of unshared data space used in  Kilo‐
1628                          bytes.
1629
1630
1631                    %E    Elapsed (wallclock) time for the command.
1632
1633
1634                    %F    Page faults.
1635
1636
1637                    %I    Number of block input operations.
1638
1639
1640                    %K    Average amount of unshared stack space used in Kilo‐
1641                          bytes.
1642
1643
1644                    %M    Maximum real memory used  during  execution  of  the
1645                          process.
1646
1647
1648                    %O    Number of block output operations.
1649
1650
1651                    %P    Total  CPU  time  —  U (user) plus S (system) — as a
1652                          percentage of E (elapsed) time.
1653
1654
1655                    %S    Number of seconds of CPU time consumed by the kernel
1656                          on behalf of the user's process.
1657
1658
1659                    %U    Number  of seconds of CPU time devoted to the user's
1660                          process.
1661
1662
1663                    %W    Number of swaps.
1664
1665
1666                    %X    Average amount of shared memory used in Kilobytes.
1667
1668                    The default summary display outputs from the %U,  %S,  %E,
1669                    %P, %X, %D, %I, %O, %F, and %W tags, in that order.
1670
1671
1672       verbose      Display  each  command  after  history  substitution takes
1673                    place.
1674
1675
1676   Large File Behavior
1677       See largefile(5) for the  description  of  the  behavior  of  csh  when
1678       encountering files greater than or equal to 2 Gbyte (2^31 bytes).
1679

FILES

1681       ~/.cshrc       Read at beginning of execution by each shell.
1682
1683
1684       ~/.login       Read by login shells after .cshrc at login.
1685
1686
1687       ~/.logout      Read by login shells at logout.
1688
1689
1690       ~/.history     Saved history for use at next login.
1691
1692
1693       /usr/bin/sh    The  Bourne shell, for shell scripts not starting with a
1694                      `#'.
1695
1696
1697       /tmp/sh*       Temporary file for `<<'.
1698
1699
1700       /etc/passwd    Source of home directories for `~name'.
1701
1702

ATTRIBUTES

1704       See attributes(5) for descriptions of the following attributes:
1705
1706
1707
1708
1709       ┌─────────────────────────────┬─────────────────────────────┐
1710       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
1711       ├─────────────────────────────┼─────────────────────────────┤
1712       │Availability                 │SUNWcsu                      │
1713       ├─────────────────────────────┼─────────────────────────────┤
1714       │CSI                          │Enabled                      │
1715       └─────────────────────────────┴─────────────────────────────┘
1716

SEE ALSO

1718       bc(1),  echo(1),  limit(1),   login(1),   ls(1),   more(1),   pfcsh(1),
1719       pfexec(1), ps(1), sh(1), shell_builtins(1), tset(1B), which(1), df(1M),
1720       swap(1M), sysdef(1M), access(2), exec(2), fork(2),  pipe(2),  a.out(4),
1721       ascii(5), attributes(5), environ(5), largefile(5), termio(7I)
1722

DIAGNOSTICS

1724       You have stopped jobs.    You  attempted  to  exit  the  C  shell  with
1725                                 stopped jobs under job control. An  immediate
1726                                 second  attempt to exit succeeds, terminating
1727                                 the stopped jobs.
1728
1729

WARNINGS

1731       The use of setuid shell scripts is strongly discouraged.
1732

NOTES

1734       Words can be no longer than 1024  bytes.  The  system  limits  argument
1735       lists to 1,048,576 bytes. However, the maximum number of arguments to a
1736       command for which filename expansion applies is 1706. Command substitu‐
1737       tions can expand to no more characters than are allowed in the argument
1738       list. To detect looping, the shell restricts the number of  alias  sub‐
1739       stitutions on a single line to 20.
1740
1741
1742       When a command is restarted from a stop, the shell prints the directory
1743       it started in if this is different from the current directory; this can
1744       be  misleading  (that is, wrong) as the job might have changed directo‐
1745       ries internally.
1746
1747
1748       Shell  built-in  functions  are  not   stoppable/restartable.   Command
1749       sequences  of the form a b c are also not handled gracefully when stop‐
1750       ping is attempted. If you suspend b, the shell never executes  c.  This
1751       is especially noticeable if the expansion results from an alias. It can
1752       be avoided by placing the sequence in parentheses to force  it  into  a
1753       subshell.
1754
1755
1756       Commands within loops, prompted for by ?, are not placed in the history
1757       list.
1758
1759
1760       Control structures should be parsed rather  than  being  recognized  as
1761       built-in  commands. This would allow control commands to be placed any‐
1762       where, to be combined with |, and to be used with & and ; metasyntax.
1763
1764
1765       It should be possible to use the : modifiers on the output  of  command
1766       substitutions. There are two problems with : modifier usage on variable
1767       substitutions: not all of the modifiers are  available,  and  only  one
1768       modifier per substitution is allowed.
1769
1770
1771       The  g (global) flag in history substitutions applies only to the first
1772       match in each word, rather than all matches in all  words.  The  common
1773       text editors consistently do the latter when given the g flag in a sub‐
1774       stitution command.
1775
1776
1777       Quoting conventions are confusing. Overriding the escape  character  to
1778       force  variable  substitutions within double quotes is counterintuitive
1779       and inconsistent with the Bourne shell.
1780
1781
1782       Symbolic links can fool the shell. Setting the hardpaths variable alle‐
1783       viates this.
1784
1785
1786       It is up to the user to manually remove all duplicate pathnames accrued
1787       from using built-in commands as
1788
1789         set path = pathnames
1790
1791
1792
1793
1794       or
1795
1796         setenv PATH = pathnames
1797
1798
1799
1800
1801       more than once. These often occur because a shell script  or  a  .cshrc
1802       file does something like
1803
1804         `set path=(/usr/local /usr/hosts $path)'
1805
1806
1807
1808
1809       to ensure that the named directories are in the pathname list.
1810
1811
1812       The  only  way  to  direct the standard output and standard error sepa‐
1813       rately is by invoking a subshell, as follows:
1814
1815         command > outfile ) >& errorfile
1816
1817
1818
1819
1820       Although robust enough for general use, adventures  into  the  esoteric
1821       periphery of the C shell can reveal unexpected quirks.
1822
1823
1824       If  you start csh as a login shell and you do not have a .login in your
1825       home directory, then the csh reads in the /etc/.login.
1826
1827
1828       When the shell executes a shell script that attempts to execute a  non-
1829       existent command interpreter, the shell returns an erroneous diagnostic
1830       message that the shell script file does not exist.
1831

BUGS

1833       As of this writing, the time built-in command does not compute the last
1834       6  fields  of  output,  rendering  the output to erroneously report the
1835       value 0 for these fields:
1836
1837         example %time ls -R
1838                 9.0u 11.0s 3:32 10% 0+0k 0+0io 0pf+0w
1839
1840
1841
1842
1843
1844SunOS 5.11                        27 Jul 2007                           csh(1)
Impressum