| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | .\" $NetBSD: sh.1,v 1.183 2018/03/13 20:40:52 uwe Exp $ | | 1 | .\" $NetBSD: sh.1,v 1.184 2018/03/13 20:48:00 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 |
| @@ -890,67 +890,67 @@ Duplicate standard output (or | | | @@ -890,67 +890,67 @@ Duplicate standard output (or |
890 | to | | 890 | to |
891 | .Ar n2 . | | 891 | .Ar n2 . |
892 | .It Oo Ar n Oc Ns >&- | | 892 | .It Oo Ar n Oc Ns >&- |
893 | Close standard output (or n). | | 893 | Close standard output (or n). |
894 | .It Oo Ar n Oc Ns <> Ar file | | 894 | .It Oo Ar n Oc Ns <> Ar file |
895 | Open | | 895 | Open |
896 | .Ar file | | 896 | .Ar file |
897 | for reading and writing on standard input (or | | 897 | for reading and writing on standard input (or |
898 | .Ar n ) . | | 898 | .Ar n ) . |
899 | .El | | 899 | .El |
900 | .Pp | | 900 | .Pp |
901 | The following redirection is often called a | | 901 | The following redirection is often called a |
902 | .Dq here-document . | | 902 | .Dq here-document . |
903 | .Bl -item -offset indent | | 903 | .Bd -literal -offset indent |
904 | .It | | 904 | [n]<< delimiter |
905 | .Li [n]<< delimiter | | 905 | \&... here-doc-text ... |
906 | .Dl here-doc-text ... | | 906 | delimiter |
907 | .Li delimiter | | 907 | .Ed |
908 | .El | | | |
909 | .Pp | | 908 | .Pp |
910 | The | | 909 | The |
911 | .Dq here-doc-text | | 910 | .Dq here-doc-text |
912 | starts immediately after the next unquoted newline character following | | 911 | starts immediately after the next unquoted newline character following |
913 | the here-doc redirection operator. | | 912 | the here-document redirection operator. |
914 | If there is more than one here-document redirection on the same | | 913 | If there is more than one here-document redirection on the same |
915 | line, then the text for the first (from left to right) is read | | 914 | line, then the text for the first (from left to right) is read |
916 | first, and subsequent here-doc-text for later here-doc redirections | | 915 | first, and subsequent here-doc-text for later here-document redirections |
917 | follows immediately after, until all such redirections have been | | 916 | follows immediately after, until all such redirections have been |
918 | processed. | | 917 | processed. |
919 | .Pp | | 918 | .Pp |
920 | All the text on successive lines up to the delimiter, | | 919 | All the text on successive lines up to the delimiter, |
921 | which must appear on a line by itself, with nothing other | | 920 | which must appear on a line by itself, with nothing other |
922 | than an immediately following newline, is | | 921 | than an immediately following newline, is |
923 | saved away and made available to the command on standard input, or file | | 922 | saved away and made available to the command on standard input, or file |
924 | descriptor n if it is specified. | | 923 | descriptor n if it is specified. |
925 | If the delimiter as specified on the initial line is | | 924 | If the delimiter as specified on the initial line is |
926 | quoted, then the here-doc-text is treated literally; otherwise, the text is | | 925 | quoted, then the here-doc-text is treated literally; otherwise, the text is |
927 | treated much like a double quoted string, except that | | 926 | treated much like a double quoted string, except that |
928 | .Sq \&" | | 927 | .Sq \&" |
929 | characters have no special meaning, and are not escaped by | | 928 | characters have no special meaning, and are not escaped by |
930 | .Sq \&\e , | | 929 | .Sq \&\e , |
931 | and is subjected to parameter expansion, command substitution, and arithmetic | | 930 | and is subjected to parameter expansion, command substitution, and arithmetic |
932 | expansion as described in the | | 931 | expansion as described in the |
933 | .Sx Word Expansions | | 932 | .Sx Word Expansions |
934 | section below. | | 933 | section below. |
935 | If the operator is | | 934 | If the operator is |
936 | .Dq <<\(mi | | 935 | .Dq <<\(mi |
937 | instead of | | 936 | instead of |
938 | .Dq << , | | 937 | .Dq << , |
939 | then leading tabs in all lines in the here-doc-text, including before the | | 938 | then leading tabs in all lines in the here-doc-text, including before the |
940 | end delimiter, are stripped. | | 939 | end delimiter, are stripped. |
941 | If the delimiter is not quoted, lines in here-doc-text that end with | | 940 | If the delimiter is not quoted, lines in here-doc-text that end with |
942 | an unquoted \e are joined to the following line, the \e and following | | 941 | an unquoted \e are joined to the following line, the \e and following |
943 | newline are simply removed while reading the here-doc, which thus guarantees | | 942 | newline are simply removed while reading the here-document, |
| | | 943 | which thus guarantees |
944 | that neither of those lines can be the end delimiter. | | 944 | that neither of those lines can be the end delimiter. |
945 | .Pp | | 945 | .Pp |
946 | It is a syntax error for the end of the input file (or string) to be | | 946 | It is a syntax error for the end of the input file (or string) to be |
947 | reached before the delimiter is encountered. | | 947 | reached before the delimiter is encountered. |
948 | .Ss Search and Execution | | 948 | .Ss Search and Execution |
949 | There are three types of commands: shell functions, built-in commands, and | | 949 | There are three types of commands: shell functions, built-in commands, and |
950 | normal programs \(em and the command is searched for (by name) in that order. | | 950 | normal programs \(em and the command is searched for (by name) in that order. |
951 | A command that contains a slash | | 951 | A command that contains a slash |
952 | .Sq \&/ | | 952 | .Sq \&/ |
953 | in its name is always a normal program. | | 953 | in its name is always a normal program. |
954 | They each are executed in a different way. | | 954 | They each are executed in a different way. |
955 | .Pp | | 955 | .Pp |
956 | When a shell function is executed, all of the shell positional parameters | | 956 | When a shell function is executed, all of the shell positional parameters |