| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | .\" $NetBSD: sh.1,v 1.178 2018/03/13 19:43:52 uwe Exp $ | | 1 | .\" $NetBSD: sh.1,v 1.179 2018/03/13 20:08:11 uwe Exp $ |
2 | .\" Copyright (c) 1991, 1993 | | 2 | .\" Copyright (c) 1991, 1993 |
3 | .\" The Regents of the University of California. All rights reserved. | | 3 | .\" The Regents of the University of California. All rights reserved. |
4 | .\" | | 4 | .\" |
5 | .\" This code is derived from software contributed to Berkeley by | | 5 | .\" This code is derived from software contributed to Berkeley by |
6 | .\" Kenneth Almquist. | | 6 | .\" Kenneth Almquist. |
7 | .\" | | 7 | .\" |
8 | .\" Redistribution and use in source and binary forms, with or without | | 8 | .\" Redistribution and use in source and binary forms, with or without |
9 | .\" modification, are permitted provided that the following conditions | | 9 | .\" modification, are permitted provided that the following conditions |
10 | .\" are met: | | 10 | .\" are met: |
11 | .\" 1. Redistributions of source code must retain the above copyright | | 11 | .\" 1. Redistributions of source code must retain the above copyright |
12 | .\" notice, this list of conditions and the following disclaimer. | | 12 | .\" notice, this list of conditions and the following disclaimer. |
13 | .\" 2. Redistributions in binary form must reproduce the above copyright | | 13 | .\" 2. Redistributions in binary form must reproduce the above copyright |
14 | .\" notice, this list of conditions and the following disclaimer in the | | 14 | .\" notice, this list of conditions and the following disclaimer in the |
| @@ -540,27 +540,27 @@ or | | | @@ -540,27 +540,27 @@ or |
540 | .Fl V , | | 540 | .Fl V , |
541 | must be enabled for this to work. | | 541 | must be enabled for this to work. |
542 | .El | | 542 | .El |
543 | .Ss Lexical Structure | | 543 | .Ss Lexical Structure |
544 | The shell reads input in terms of lines from a file and breaks it up into | | 544 | The shell reads input in terms of lines from a file and breaks it up into |
545 | words at whitespace (blanks and tabs), and at certain sequences of | | 545 | words at whitespace (blanks and tabs), and at certain sequences of |
546 | characters that are special to the shell called | | 546 | characters that are special to the shell called |
547 | .Dq operators . | | 547 | .Dq operators . |
548 | There are two types of operators: control operators and redirection | | 548 | There are two types of operators: control operators and redirection |
549 | operators (their meaning is discussed later). | | 549 | operators (their meaning is discussed later). |
550 | The following is a list of operators: | | 550 | The following is a list of operators: |
551 | .Bl -ohang -offset indent | | 551 | .Bl -ohang -offset indent |
552 | .It "Control operators:" | | 552 | .It "Control operators:" |
553 | .Dl & && \&( \&) \&; ;; ;& | || <newline> | | 553 | .Dl & && \&( \&) \&; ;; ;& \&| || <newline> |
554 | .It "Redirection operators:" | | 554 | .It "Redirection operators:" |
555 | .Dl < > >| << >> <& >& <<- <> | | 555 | .Dl < > >| << >> <& >& <<- <> |
556 | .El | | 556 | .El |
557 | .Ss Quoting | | 557 | .Ss Quoting |
558 | Quoting is used to remove the special meaning of certain characters or | | 558 | Quoting is used to remove the special meaning of certain characters or |
559 | words to the shell, such as operators, whitespace, or keywords. | | 559 | words to the shell, such as operators, whitespace, or keywords. |
560 | There are four types of quoting: | | 560 | There are four types of quoting: |
561 | matched single quotes, | | 561 | matched single quotes, |
562 | matched double quotes, | | 562 | matched double quotes, |
563 | backslash, | | 563 | backslash, |
564 | and | | 564 | and |
565 | dollar preceding matched single quotes (enhanced C style strings.) | | 565 | dollar preceding matched single quotes (enhanced C style strings.) |
566 | .Ss Backslash | | 566 | .Ss Backslash |
| @@ -1071,27 +1071,27 @@ being a reserved word, must be separated | | | @@ -1071,27 +1071,27 @@ being a reserved word, must be separated |
1071 | white space (or other operators, perhaps redirects) and is only | | 1071 | white space (or other operators, perhaps redirects) and is only |
1072 | recognized as the reserved word when it appears in a command word | | 1072 | recognized as the reserved word when it appears in a command word |
1073 | position (such as at the beginning of a pipeline.) | | 1073 | position (such as at the beginning of a pipeline.) |
1074 | .Pp | | 1074 | .Pp |
1075 | The standard output of all but | | 1075 | The standard output of all but |
1076 | the last command in the sequence is connected to the standard input | | 1076 | the last command in the sequence is connected to the standard input |
1077 | of the next command. | | 1077 | of the next command. |
1078 | The standard output of the last | | 1078 | The standard output of the last |
1079 | command is inherited from the shell, as usual, | | 1079 | command is inherited from the shell, as usual, |
1080 | as is the standard input of the first command. | | 1080 | as is the standard input of the first command. |
1081 | .Pp | | 1081 | .Pp |
1082 | The format for a pipeline is: | | 1082 | The format for a pipeline is: |
1083 | .Pp | | 1083 | .Pp |
1084 | .Dl [!] command1 [ | command2 ...] | | 1084 | .Dl [!] command1 [ \&| command2 ...] |
1085 | .Pp | | 1085 | .Pp |
1086 | The standard output of command1 is connected to the standard input of | | 1086 | The standard output of command1 is connected to the standard input of |
1087 | command2. | | 1087 | command2. |
1088 | The standard input, standard output, or both of each command is | | 1088 | The standard input, standard output, or both of each command is |
1089 | considered to be assigned by the pipeline before any redirection specified | | 1089 | considered to be assigned by the pipeline before any redirection specified |
1090 | by redirection operators that are part of the command are performed. | | 1090 | by redirection operators that are part of the command are performed. |
1091 | .Pp | | 1091 | .Pp |
1092 | If the pipeline is not in the background (discussed later), the shell | | 1092 | If the pipeline is not in the background (discussed later), the shell |
1093 | waits for all commands to complete. | | 1093 | waits for all commands to complete. |
1094 | .Pp | | 1094 | .Pp |
1095 | The commands in a pipeline can either be simple commands, | | 1095 | The commands in a pipeline can either be simple commands, |
1096 | or one of the compound commands described below. | | 1096 | or one of the compound commands described below. |
1097 | The simplest case of a pipeline is a single simple command. | | 1097 | The simplest case of a pipeline is a single simple command. |
| @@ -1110,27 +1110,27 @@ the pipeline status is the exit | | | @@ -1110,27 +1110,27 @@ the pipeline status is the exit |
1110 | status of the last command in the pipeline, | | 1110 | status of the last command in the pipeline, |
1111 | and the exit status of any other commands in the pipeline is ignored. | | 1111 | and the exit status of any other commands in the pipeline is ignored. |
1112 | .Pp | | 1112 | .Pp |
1113 | If the reserved word ! precedes the pipeline, the exit status | | 1113 | If the reserved word ! precedes the pipeline, the exit status |
1114 | becomes the logical NOT of the pipeline status as determined above. | | 1114 | becomes the logical NOT of the pipeline status as determined above. |
1115 | That is, if the pipeline status is zero, the exit status is 1; | | 1115 | That is, if the pipeline status is zero, the exit status is 1; |
1116 | if the pipeline status is other than zero, the exit status is zero. | | 1116 | if the pipeline status is other than zero, the exit status is zero. |
1117 | If there is no ! reserved word, the pipeline status becomes the exit status. | | 1117 | If there is no ! reserved word, the pipeline status becomes the exit status. |
1118 | .Pp | | 1118 | .Pp |
1119 | Because pipeline assignment of standard input or standard output or both | | 1119 | Because pipeline assignment of standard input or standard output or both |
1120 | takes place before redirection, it can be modified by redirection. | | 1120 | takes place before redirection, it can be modified by redirection. |
1121 | For example: | | 1121 | For example: |
1122 | .Pp | | 1122 | .Pp |
1123 | .Dl $ command1 2>&1 | command2 | | 1123 | .Dl $ command1 2>&1 \&| command2 |
1124 | .Pp | | 1124 | .Pp |
1125 | sends both the standard output and standard error of command1 | | 1125 | sends both the standard output and standard error of command1 |
1126 | to the standard input of command2. | | 1126 | to the standard input of command2. |
1127 | .Pp | | 1127 | .Pp |
1128 | Note that unlike some other shells, each process in the pipeline is a | | 1128 | Note that unlike some other shells, each process in the pipeline is a |
1129 | child of the invoking shell (unless it is a shell built-in, in which case | | 1129 | child of the invoking shell (unless it is a shell built-in, in which case |
1130 | it executes in the current shell -- but any effect it has on the | | 1130 | it executes in the current shell -- but any effect it has on the |
1131 | environment is wiped). | | 1131 | environment is wiped). |
1132 | .Pp | | 1132 | .Pp |
1133 | A pipeline is a simple case of an AND-OR-list (described below.) | | 1133 | A pipeline is a simple case of an AND-OR-list (described below.) |
1134 | A ; or | | 1134 | A ; or |
1135 | .Aq newline | | 1135 | .Aq newline |
1136 | terminator causes the preceding pipeline, or more generally, | | 1136 | terminator causes the preceding pipeline, or more generally, |