include malloc.h
[unix-history] / usr / src / old / sh / sh.1
CommitLineData
3d51b67b 1.\" @(#)sh.1 6.3 (Berkeley) %G%
5a218bfe 2.\"
95a327d9 3.TH SH 1 ""
5a218bfe
KM
4.AT 3
5.SH NAME
a9e94614 6sh, for, case, if, while, \fB:\fP, \fB.\fP, break, continue, cd, eval, exec, exit, export, login, read, readonly, set, shift, times, trap, umask, wait \- command language
5a218bfe
KM
7.SH SYNOPSIS
8.B sh
9[
10.B \-ceiknrstuvx
11] [ arg ] ...
12.ds OK [\|
13.ds CK \|]
14.ds LT \s-2<\s0
15.ds GT \s-2>\s0
16.ds LE \s-2<\s0
17.ds ST *
18.SH DESCRIPTION
19.I Sh
a9e94614
KM
20is a command programming language that executes commands read from a terminal
21or a file. See
5a218bfe
KM
22.B invocation
23for the meaning of arguments to the shell.
24.PP
25.B Commands.
26.br
27A
28.I simple-command
29is a sequence of non blank
30.I words
31separated by blanks (a blank is a
32.B tab
33or a
34.BR space ).
a9e94614
KM
35The first word specifies the name of the command to be executed.
36Except as specified below the remaining words are passed as arguments
5a218bfe 37to the invoked command.
a9e94614
KM
38The command name is passed as argument 0 (see
39.IR execve (2)).
5a218bfe
KM
40The
41.I value
42of a simple-command is its exit status
a9e94614
KM
43if it terminates normally or 200+\fIstatus\fP if it terminates abnormally (see
44.IR sigvec (2)
45for a list of status values).
5a218bfe
KM
46.LP
47A
48.I pipeline
49is a sequence of one or more
50.I commands
51separated by
52.B \(or.
a9e94614 53The standard output of each command but the last is connected by a
5a218bfe
KM
54.IR pipe (2)
55to the standard input of the next command.
56Each command is run as a separate process;
57the shell waits for the last command to terminate.
58.LP
59A
60.I list
61is a sequence of one or more
62.I pipelines
63separated by
64.BR ; ,
65.BR & ,
66.B &&
67or
68.B \(or\|\(or
69and optionally terminated by
70.B ;
71or
72.BR & .
73.B ;
74and
75.B &
a9e94614 76have equal precedence which is lower than that of
5a218bfe
KM
77.B &&
78and
79.BR \(or\|\(or ,
80.B &&
81and
82.B \(or\|\(or
83also have equal precedence.
a9e94614 84A semicolon causes sequential execution; an ampersand causes the preceding
5a218bfe 85.I pipeline
a9e94614 86to be executed without waiting for it to finish. The symbol
5a218bfe
KM
87.B &&
88.RB ( \(or\|\(or )
89causes the
90.I list
91following to be executed only if the preceding
92.I pipeline
a9e94614 93returns a zero (non zero) value. Newlines may appear in a
5a218bfe 94.I list,
a9e94614 95instead of semicolons, to delimit commands.
5a218bfe
KM
96.LP
97A
98.I command
a9e94614 99is either a simple-command or one of the following.
5a218bfe
KM
100The value returned by a command is that of the
101last simple-command executed in the command.
102.TP
103\fBfor \fIname\fR \*(OK\fBin \fIword\fR ...\*(CK \fBdo \fIlist \fBdone\fR
104Each time a
105.B for
106command is executed
107.I name
108is set to the next word in the
109.B for
c4d63d4e 110word list.
5a218bfe
KM
111If
112.BI in \ word
113\&...
a9e94614 114is omitted,
5a218bfe
KM
115.B
116in "$@"
a9e94614 117is assumed. Execution ends when there are no more words in the list.
5a218bfe
KM
118.TP
119\fBcase \fIword \fBin\fR \*(OK\fIpattern \fR\*(OK \fB\(or \fIpattern \fR\*(CK ... \fB) \fIlist \fB;;\fR\*(CK ... \fBesac\fR
120A
121.B case
122command executes the
123.I list
a9e94614 124associated with the first pattern that matches
5a218bfe 125.I word.
a9e94614 126The form of the patterns is the same as that used for file name generation.
5a218bfe
KM
127.TP
128\fBif \fIlist \fBthen \fIlist\fR \*(OK\fBelif \fIlist \fBthen \fIlist\fR\*(CK ... \*(OK\fBelse \fIlist\fR\*(CK \fBfi\fR
129The
130.I list
131following
132.B if
133is executed and if it returns zero the
134.I list
135following
136.B then
a9e94614 137is executed. Otherwise, the
5a218bfe
KM
138.I list
139following
140.B elif
a9e94614 141is executed and if its value is zero the
5a218bfe
KM
142.I list
143following
144.B then
a9e94614 145is executed. Failing that the
5a218bfe
KM
146.B else
147.I list
148is executed.
149.TP
150\fBwhile \fIlist\fR \*(OK\fBdo \fIlist\fR\*(CK \fBdone\fR
151A
152.B while
153command repeatedly executes the
154.B while
155.I list
156and if its value is zero executes the
157.B do
158.I list;
a9e94614 159otherwise the loop terminates. The value returned by a
5a218bfe 160.B while
a9e94614 161command is that of the last executed command in the
5a218bfe
KM
162.B do
163.I list.
164.B until
165may be used in place of
166.B while
a9e94614 167to negate the loop termination test.
5a218bfe
KM
168.TP
169.BI ( " list " )
170Execute
171.I list
172in a subshell.
173.TP
174.BI { " list " }
175.I list
176is simply executed.
177.LP
a9e94614 178The following words are only recognized as the first word of a command
5a218bfe
KM
179and when not quoted.
180.IP
181.B
182if then else elif fi case in esac for while until do done { }
183.PP
184.B Command substitution.
185.br
a9e94614 186The standard output from a command enclosed in a pair of back quotes
5a218bfe 187.RB ( \`\|\` )
a9e94614 188may be used as part or all of a word; trailing newlines are removed.
5a218bfe
KM
189.PP
190.B Parameter substitution.
191.br
192The character
193.B $
a9e94614 194is used to introduce substitutable parameters.
5a218bfe
KM
195Positional parameters may be assigned values by
196.BR set .
197Variables may be set by writing
198.IP
199.IB name = value
200[
201.IB name = value
202] ...
203.TP
204$\fB\|{\fIparameter\fB\|}\fR
205A
206.I parameter
207is a sequence of letters, digits or underscores (a
208.IR name ),
a9e94614 209a digit, or any of the characters
5a218bfe
KM
210.B
211* @ # ? \- $ !\|.
212The value, if any, of the parameter is substituted.
213The braces are required only when
214.I parameter
215is followed by a letter, digit, or underscore
a9e94614 216that is not to be interpreted as part of its name. If
5a218bfe 217.I parameter
a9e94614 218is a digit, it is a positional parameter. If
5a218bfe
KM
219.I parameter
220is
221.BR * " or" " @"
a9e94614 222then all the positional parameters, starting with
5a218bfe
KM
223.SM
224.BR $1 ,
a9e94614 225are substituted separated by spaces.
5a218bfe
KM
226.SM
227.B $0
a9e94614 228is set from argument zero when the shell is invoked.
5a218bfe
KM
229.TP
230$\fB\|{\fIparameter\|\-word\|\fB}\fR
231If
232.I parameter
a9e94614 233is set, substitute its value; otherwise substitute
5a218bfe
KM
234.I word.
235.TP
236$\fB\|{\fIparameter\|\(eq\|word\|\fB}\fR
237If
238.I parameter
a9e94614 239is not set, set it to
5a218bfe
KM
240.I word;
241the value of the parameter is then substituted.
a9e94614 242Positional parameters may not be assigned to in this way.
5a218bfe
KM
243.TP
244$\fB\|{\fIparameter\|?\|word\|\fB}\fR
245If
246.I parameter
a9e94614 247is set, substitute its value; otherwise, print
5a218bfe 248.I word
a9e94614 249and exit from the shell. If
5a218bfe 250.I word
a9e94614 251is omitted, a standard message is printed.
5a218bfe
KM
252.TP
253$\fB\|{\fIparameter\|\(plword\|\fB}\fR
254If
255.I parameter
a9e94614 256is set, substitute
5a218bfe
KM
257.I word;
258otherwise substitute nothing.
259.LP
260In the above
261.I word
a9e94614
KM
262is not evaluated unless it is to be used as the substituted string.
263(So that, for example, echo ${d\-\'pwd\'} will only execute
5a218bfe
KM
264.I pwd
265if
266.I d
267is unset.)
268.LP
269The following
270.I parameters
271are automatically set by the shell.
272.RS
273.TP
274.B #
275The number of positional parameters in decimal.
276.PD 0
277.TP
278.B \-
279Options supplied to the shell on invocation or by
280.BR set .
281.TP
282.B ?
a9e94614 283The value returned by the last executed command in decimal.
5a218bfe
KM
284.TP
285.B $
286The process number of this shell.
287.TP
288.B !
289The process number of the last background command invoked.
290.PD
291.RE
292.LP
293The following
294.I parameters
295are used but not set by the shell.
296.RS
297.TP
298.B
299.SM HOME
300The default argument (home directory) for the
301.B cd
302command.
303.PD 0
304.TP
305.B
306.SM PATH
307The search path for commands (see
308.BR execution ).
309.TP
310.B
311.SM MAIL
312If this variable is set to the name of
a9e94614 313a mail file, the shell informs the user of
5a218bfe
KM
314the arrival of mail in the specified file.
315.SM
316.TP
317.B PS1
a9e94614 318Primary prompt string, by default '$ '.
5a218bfe
KM
319.TP
320.SM
321.B PS2
a9e94614 322Secondary prompt string, by default '> '.
5a218bfe
KM
323.TP
324.SM
325.B IFS
a9e94614 326Internal field separators, normally
5a218bfe
KM
327.BR space ,
328.BR tab ,
329and
330.BR newline .
3d51b67b
KM
331.B IFS
332is ignored if
333.I sh
334is running as root or if the effective user id differs from the real user id.
5a218bfe
KM
335.PD
336.RE
337.PP
338.B Blank interpretation.
339.br
340After parameter and command substitution,
341any results of substitution are scanned for internal field separator
342characters (those found in
343.SM
344.BR $IFS \*S)
345and split into distinct arguments where such characters are found.
346Explicit null arguments ("" or \'\') are retained.
a9e94614 347Implicit null arguments (those resulting from
5a218bfe
KM
348.I parameters
349that have no values) are removed.
350.PP
351.B File name generation.
352.br
a9e94614 353Following substitution, each command word is scanned for the characters
5a218bfe
KM
354.BR * ,
355.B ?
356and
357.B \*(OK.
a9e94614
KM
358If one of these characters appears, the word is regarded as a pattern.
359The word is replaced with alphabetically sorted file names that match the
360pattern. If no file name is found that matches the pattern,
361the word is left unchanged. The character
5a218bfe 362.B .
a9e94614 363at the start of a file name or immediately following a
5a218bfe
KM
364.BR / ,
365and the character
366.BR / ,
367must be matched explicitly.
368.TP
369.B \*(ST
370Matches any string, including the null string.
371.PD 0
372.TP
373.B ?
374Matches any single character.
375.TP
376.B \*(OK...\*(CK
a9e94614 377Matches any one of the characters enclosed.
5a218bfe
KM
378A pair of characters separated by
379.B \-
a9e94614 380matches any character lexically between the pair.
5a218bfe
KM
381.PD
382.PP
383.B Quoting.
384.br
385The following characters have a special meaning to the shell
386and cause termination of a word unless quoted.
387.LP
388 \fB; & ( ) \(or \*(LT \*(GT newline space tab\fP
389.LP
390A character may be
391.I quoted
a9e94614 392by preceding it with a
5a218bfe
KM
393.B
394\\\|.
395.B \\\\newline
396is ignored.
397All characters enclosed between a pair of quote marks (\fB\'\|\'\fP),
a9e94614 398except a single quote, are quoted. Inside double quotes (\fB"\|"\fP)
5a218bfe
KM
399parameter and command substitution occurs and
400.B
401\\
402quotes the characters
403.B
a9e94614 404\\ \' "
5a218bfe
KM
405and
406.BR $ \|.
407.LP
408.B
409"$*"
410is equivalent to
411.SM
412.B
413"$1 $2 ..."
414whereas
415.br
416.B
417"$@"
418is equivalent to
419.SM
420.B
421"$1" "$2" ... .
422.PP
423.B Prompting.
424.br
a9e94614 425When used interactively, the shell prompts with the value of
5a218bfe
KM
426.SM
427PS1
428before reading a command.
429If at any time a newline is typed and further input is needed
a9e94614 430to complete a command, the secondary prompt
5a218bfe
KM
431.RB ( \s-2$PS2\s0 )
432is issued.
433.PP
434.B Input output.
435.br
436Before a command is executed its input and output
437may be redirected using a special notation interpreted by the shell.
438The following may appear anywhere in a simple-command
439or may precede or follow a
440.I command
441and are not passed on to the invoked command.
442Substitution occurs before
443.I word
444or
445.I digit
446is used.
447.TP
448\*(LT\fI\|word\fP
449Use file
450.I word
451as standard input (file descriptor 0).
452.PD
453.TP
454\*(GT\fI\|word\fP
455Use file
456.I word
457as standard output (file descriptor 1).
a9e94614 458If the file does not exist, it is created;
5a218bfe
KM
459otherwise it is truncated to zero length.
460.TP
461\*(GT\*(GT\fI\|word\fP
462Use file
463.I word
464as standard output.
a9e94614 465If the file exists, output is appended (by seeking to the end);
5a218bfe
KM
466otherwise the file is created.
467.TP
468\*(LT\*(LT\fI\|word\fP
469The shell input is read up to a line the same as
470.IR word ,
471or end of file.
a9e94614 472The resulting document becomes the standard input.
5a218bfe
KM
473If any character of
474.I word
a9e94614 475is quoted, no interpretation is placed upon the characters of the document;
5a218bfe
KM
476otherwise, parameter and command substitution occurs,
477.B
478\\newline
a9e94614 479is ignored, and
5a218bfe
KM
480.B
481\\
482is used to quote the characters
483.B
a9e94614 484\\ $ \'
5a218bfe
KM
485and the first character of
486.I word.
487.TP
488\*(LT\|&\|\fIdigit\fP
489The standard input is duplicated from file descriptor
490.I digit;
491see
492.IR dup (2).
493Similarly for the standard output using \*(GT\|.
494.TP
495\*(LT\|&\|\-
496The standard input is closed.
497Similarly for the standard output using \*(GT\|.
498.PD
499.LP
a9e94614
KM
500If one of the above is preceded by a digit, the
501file descriptor created is that specified by the digit
502(instead of the default 0 or 1). For example,
5a218bfe
KM
503.LP
504 \&... 2\*(GT&1
505.LP
506creates file descriptor 2 to be a duplicate
507of file descriptor 1.
508.LP
509If a command is followed by
510.B &
a9e94614 511then the default standard input for the command is the empty file
5a218bfe
KM
512(/dev/null).
513Otherwise, the environment for the execution of a command contains the
514file descriptors of the invoking shell as modified by input
515output specifications.
516.PP
517.B Environment.
518.br
a9e94614
KM
519The environment is a list of name-value pairs that is passed to
520an executed program in the same way as a normal argument list; see
521.IR execve (2)
5a218bfe 522and
a9e94614 523.IR environ (7).
5a218bfe 524The shell interacts with the environment in several ways.
a9e94614 525On invocation, the shell scans the environment and creates a
5a218bfe 526.I parameter
a9e94614 527for each name found, giving it the corresponding value.
5a218bfe
KM
528Executed commands inherit the same environment.
529If the user modifies the values of these
530.I parameters
a9e94614 531or creates new ones, none of these affects the environment unless the
5a218bfe
KM
532.B export
533command is used to bind the shell's
534.I parameter
535to the environment.
536The environment seen by any executed command is thus composed
537of any unmodified name-value pairs originally inherited by the shell,
a9e94614 538plus any modifications or additions, all of which must be noted in
5a218bfe
KM
539.B export
540commands.
541.LP
542The environment for any
543.I simple-command
544may be augmented by prefixing it with one or more assignments to
545.I parameters.
546Thus these two lines are equivalent
547.IP
548TERM=450 cmd args
549.br
550(export TERM; TERM=450; cmd args)
551.LP
552If the
553.B \-k
554flag is set,
555.I all
556keyword arguments are placed in the environment,
557even if the occur after the command name.
a9e94614 558The following prints 'a=b c' and 'c':
5a218bfe
KM
559.nf
560echo a=b c
561set \-k
562echo a=b c
563.fi
564.PP
565.B Signals.
566.br
567The INTERRUPT and QUIT signals for an invoked
568command are ignored if the command is followed by
569.BR & ;
a9e94614 570otherwise signals have the values inherited by the shell from its parent.
5a218bfe
KM
571(But see also
572.BR trap. )
573.PP
574.B Execution.
575.br
a9e94614
KM
576Each time a command is executed the above substitutions are carried out.
577Except for the 'special commands' listed below a new process is created and
5a218bfe 578an attempt is made to execute the command via an
a9e94614 579.IR execve (2).
5a218bfe
KM
580.LP
581The shell parameter
582.B
583.SM $PATH
a9e94614
KM
584defines the search path for the directory containing the command.
585Each alternative directory name is separated by a colon
5a218bfe
KM
586.RB ( : ).
587The default path is
588.BR :/bin:/usr/bin .
a9e94614
KM
589If the command name contains a /, the search path is not used.
590Otherwise, each directory in the path is searched for an executable file.
5a218bfe
KM
591If the file has execute permission but is not an
592.I a.out
a9e94614 593file, it is assumed to be a file containing shell commands.
5a218bfe 594A subshell (i.e., a separate process) is spawned to read it.
a9e94614 595A parenthesized command is also executed in a subshell.
5a218bfe
KM
596.PP
597.B Special commands.
598.br
599The following commands are executed in the shell process
600and except where specified
601no input output redirection is permitted for such commands.
602.TP
3d51b67b
KM
603.B #
604For non-interactive shells, everything following the
605.B #
606is treated as a comment, i.e. the rest of the line is ignored.
607For interactive shells, the
608.B #
609has no special effect.
610.TP
5a218bfe
KM
611.B :
612No effect; the command does nothing.
613.PD 0
614.TP
615.BI . \ file
616Read and execute commands from
617.I file
a9e94614 618and return. The search path
5a218bfe
KM
619.B
620.SM $PATH
621is used to find the directory containing
622.IR file .
623.TP
624\fBbreak\fR \*(OK\fIn\fR\*(CK
625Exit from the enclosing
626.B for
627or
628.B while
629loop, if any.
630If
631.I n
a9e94614 632is specified, break
5a218bfe
KM
633.I n
634levels.
635.TP
636\fBcontinue\fR \*(OK\fIn\fR\*(CK
637Resume the next iteration of the enclosing
638.B for
639or
640.B while
a9e94614 641loop. If
5a218bfe 642.I n
a9e94614 643is specified, resume at the
5a218bfe
KM
644.IR n -th
645enclosing loop.
646.TP
647\fBcd\fR \*(OK\fIarg\fR\*(CK
648Change the current directory to
649.I arg.
a9e94614 650The shell parameter
5a218bfe
KM
651.B
652.SM $HOME
653is the default
654.IR arg .
655.TP
656\fBeval\fR \*(OK\fIarg \fR...\*(CK
a9e94614 657The arguments are read as input to the shell
5a218bfe
KM
658and the resulting command(s) executed.
659.TP
660\fBexec\fR \*(OK\fIarg \fR...\*(CK
a9e94614 661The command specified by the arguments is executed in place of this shell
5a218bfe
KM
662without creating a new process.
663Input output arguments may appear and if no other
a9e94614 664arguments are given cause the shell input output to be modified.
5a218bfe
KM
665.TP
666\fBexit\fR \*(OK\fIn\fR\*(CK
a9e94614 667Causes a non interactive shell to exit with the exit status specified by
5a218bfe
KM
668.I n.
669If
670.I n
a9e94614 671is omitted, the exit status is that of the last command executed.
5a218bfe
KM
672(An end of file will also exit from the shell.)
673.TP
674\fBexport\fR \*(OK\fIname\fR ...\*(CK
a9e94614 675The given names are marked for automatic export to the
5a218bfe
KM
676.I environment
677of subsequently-executed commands.
a9e94614 678If no arguments are given, a list of exportable names is printed.
5a218bfe
KM
679.TP
680\fBlogin\fR \*(OK\fIarg\fR ...\*(CK
a9e94614 681Equivalent to 'exec login arg ...'.
5a218bfe
KM
682.TP
683.BI read \ name\ ...
684One line is read from the standard input;
a9e94614 685successive words of the input are assigned to the variables
5a218bfe 686.I name
a9e94614 687in order, with leftover words to the last variable.
5a218bfe
KM
688The return code is 0 unless the end-of-file is encountered.
689.TP
690\fBreadonly\fR \*(OK\fIname \fR...\*(CK
691The given names are marked readonly and
692the values of the these names may not be changed
693by subsequent assignment.
a9e94614 694If no arguments are given, a list of all readonly names is printed.
5a218bfe
KM
695.TP
696\fBset\fR \*(OK\fB\-eknptuvx\fR \*(OK\fIarg \fR...\*(CK\*(CK
697.RS
698.PD 0
699.TP 3m
700.B \-e
a9e94614 701If non interactive, exit immediately if a command fails.
5a218bfe
KM
702.TP
703.B \-k
704All keyword arguments are placed in the environment for a command,
705not just those that precede the command name.
706.TP
707.B \-n
708Read commands but do not execute them.
709.TP
710.B \-t
711Exit after reading and executing one command.
712.TP
713.B \-u
714Treat unset variables as an error when substituting.
715.TP
716.B \-v
717Print shell input lines as they are read.
718.TP
719.B \-x
720Print commands and their arguments as they are executed.
721.TP
722.B \-
723Turn off the
724.B \-x
725and
726.B \-v
727options.
728.PD
729.LP
730These flags can also be used upon invocation of the shell.
731The current set of flags may be found in
732.BR $\- .
733.LP
734Remaining arguments are positional
735parameters and are assigned, in order, to
736.SM
737.BR $1 ,
738.SM
739.BR $2 ,
a9e94614 740etc. If no arguments are given, the values of all names are printed.
5a218bfe
KM
741.RE
742.TP
743.B shift
744The positional parameters from
745.SM
746.BR $2 ...
747are renamed
748.SM
749.BR $1 ...
750.TP
751.B times
a9e94614 752Print the accumulated user and system times for processes run from the shell.
5a218bfe
KM
753.TP
754\fBtrap\fR \*(OK\fIarg\fR\*(CK \*(OK\fIn\fR\*(CK ...
755.I Arg
a9e94614 756is a command to be read and executed when the shell receives signal(s)
5a218bfe
KM
757.I n.
758(Note that
759.I arg
a9e94614
KM
760is scanned once when the trap is set and once when the trap is taken.)
761Trap commands are executed in order of signal number. If
5a218bfe 762.I arg
a9e94614 763is absent, all trap(s)
5a218bfe 764.I n
a9e94614 765are reset to their original values.
5a218bfe
KM
766If
767.I arg
768is the null
a9e94614 769string, this signal is ignored by the shell and by invoked commands.
5a218bfe
KM
770If
771.I n
a9e94614 772is 0, the command
5a218bfe 773.I arg
a9e94614 774is executed on exit from the shell, otherwise upon receipt of signal
5a218bfe
KM
775.I n
776as numbered in
a9e94614 777.IR sigvec (2).
5a218bfe 778.I Trap
a9e94614 779with no arguments prints a list of commands associated with each signal number.
5a218bfe
KM
780.TP
781\fBumask \fR[ \fInnn\fR ]
a9e94614 782The user file creation mask is set to the octal value
5a218bfe
KM
783.I nnn
784(see
785.IR umask (2)).
786If
787.I nnn
788is omitted, the current value of the mask is printed.
789.TP
790\fBwait\fP \*(OK\fIn\fP\*(CK
a9e94614 791Wait for the specified process and report its termination status. If
5a218bfe 792.I n
a9e94614
KM
793is not given, all currently active child processes are waited for.
794The return code from this command is that of the process waited for.
5a218bfe
KM
795.PD
796.LP
797.PP
798.B Invocation.
799.br
800If the first character of argument zero is
801.BR \- ,
802commands are read from
803.BR \s-2$HOME\s0/.\|profile ,
804if such a file exists.
805Commands are then read as described below.
a9e94614 806The following flags are interpreted by the shell when it is invoked.
5a218bfe
KM
807.PD 0
808.TP 11n
809.BI \-c \ string
810If the
811.B \-c
a9e94614 812flag is present, commands are read from
5a218bfe
KM
813.I string\|.
814.TP 11n
815.B \-s
816If the
817.B \-s
a9e94614 818flag is present or if no arguments remain
5a218bfe 819then commands are read from the standard input.
a9e94614 820Shell output is written to file descriptor 2.
5a218bfe
KM
821.TP 11n
822.B \-i
823If the
824.B \-i
825flag is present or
826if the shell input and output are attached to a terminal (as told by
827.IR gtty )
828then this shell is
829.I interactive.
a9e94614
KM
830In this case the terminate signal SIGTERM (see
831.IR sigvec (2))
832is ignored (so that 'kill 0'
5a218bfe 833does not kill an interactive shell) and the interrupt signal
a9e94614 834SIGINT is caught and ignored (so that
5a218bfe 835.B wait
a9e94614 836is interruptible).
5a218bfe
KM
837In all cases SIGQUIT is ignored by the shell.
838.PD
839.LP
840The remaining flags and arguments are described under the
841.B set
842command.
843.SH FILES
844.RB $HOME/ . \^profile
845.br
846/tmp/sh*
847.br
848/dev/null
849.SH SEE ALSO
850csh(1),
851test(1),
a9e94614
KM
852execve(2),
853environ(7)
5a218bfe 854.SH DIAGNOSTICS
a9e94614 855Errors detected by the shell, such as syntax errors cause the shell
5a218bfe
KM
856to return a non zero exit status.
857If the shell is being used non interactively
858then execution of the shell file is abandoned.
859Otherwise, the shell returns the exit status of
860the last command executed (see also
861.BR exit ).
862.SH BUGS
a9e94614
KM
863If \*(LT\*(LT is used to provide standard input to an asynchronous
864process invoked by &, the shell gets mixed up about naming the input document.
5a218bfe
KM
865A garbage file /tmp/sh* is created, and the shell complains about
866not being able to find the file by another name.