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