| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | .\" $NetBSD: sh.1,v 1.184 2018/03/13 20:48:00 uwe Exp $ | | 1 | .\" $NetBSD: sh.1,v 1.185 2018/03/13 21:04:57 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 |
| @@ -849,71 +849,76 @@ where | | | @@ -849,71 +849,76 @@ where |
849 | is one of the redirection operators mentioned previously. | | 849 | is one of the redirection operators mentioned previously. |
850 | The following is a list of the possible redirections. | | 850 | The following is a list of the possible redirections. |
851 | The | | 851 | The |
852 | .Bq n | | 852 | .Bq n |
853 | is an optional number, as in | | 853 | is an optional number, as in |
854 | .Sq 3 | | 854 | .Sq 3 |
855 | (not | | 855 | (not |
856 | .Sq Bq 3 ) , | | 856 | .Sq Bq 3 ) , |
857 | that refers to a file descriptor. | | 857 | that refers to a file descriptor. |
858 | If present it must occur immediately before the redirection | | 858 | If present it must occur immediately before the redirection |
859 | operator, with no intervening white space, and becomes a | | 859 | operator, with no intervening white space, and becomes a |
860 | part of that operator. | | 860 | part of that operator. |
861 | .Bl -tag -width aaabsfiles -offset indent | | 861 | .Bl -tag -width aaabsfiles -offset indent |
862 | .It Oo Ar n Oc Ns > Ar file | | 862 | .It Oo Ar n Oc Ns Ic > Ar file |
863 | Redirect standard output (or n) to | | 863 | Redirect standard output (or |
| | | 864 | .Ar n ) |
| | | 865 | to |
864 | .Ar file . | | 866 | .Ar file . |
865 | .It Oo Ar n Oc Ns >| file | | 867 | .It Oo Ar n Oc Ns Ic >| Ar file |
866 | The same, but override the | | 868 | The same, but override the |
867 | .Fl C | | 869 | .Fl C |
868 | option. | | 870 | option. |
869 | .It Oo Ar n Oc Ns >> Ar file | | 871 | .It Oo Ar n Oc Ns Ic >> Ar file |
870 | Append standard output (or n) to | | 872 | Append standard output (or |
| | | 873 | .Ar n ) |
| | | 874 | to |
871 | .Ar file . | | 875 | .Ar file . |
872 | .It Oo Ar n Oc Ns < Ar file | | 876 | .It Oo Ar n Oc Ns Ic < Ar file |
873 | Redirect standard input (or | | 877 | Redirect standard input (or |
874 | .Ar n ) | | 878 | .Ar n ) |
875 | from | | 879 | from |
876 | .Ar file . | | 880 | .Ar file . |
877 | .It Oo Ar n1 Oc Ns <& Ns Ar n2 | | 881 | .It Oo Ar n1 Oc Ns Ic <& Ns Ar n2 |
878 | Duplicate standard input (or | | 882 | Duplicate standard input (or |
879 | .Ar n1 ) | | 883 | .Ar n1 ) |
880 | from file descriptor | | 884 | from file descriptor |
881 | .Ar n2 . | | 885 | .Ar n2 . |
882 | .Ar n2 | | 886 | .Ar n2 |
883 | is expanded if not a digit string, the result must be a number. | | 887 | is expanded if not a digit string, the result must be a number. |
884 | .It Oo Ar n Oc Ns <&- | | 888 | .It Oo Ar n Oc Ns Ic <&- |
885 | Close standard input (or | | 889 | Close standard input (or |
886 | .Ar n ) . | | 890 | .Ar n ) . |
887 | .It Oo Ar n1 Oc Ns >& Ns Ar n2 | | 891 | .It Oo Ar n1 Oc Ns Ic >& Ns Ar n2 |
888 | Duplicate standard output (or | | 892 | Duplicate standard output (or |
889 | .Ar n1 ) | | 893 | .Ar n1 ) |
890 | to | | 894 | to |
891 | .Ar n2 . | | 895 | .Ar n2 . |
892 | .It Oo Ar n Oc Ns >&- | | 896 | .It Oo Ar n Oc Ns Ic >&- |
893 | Close standard output (or n). | | 897 | Close standard output (or |
894 | .It Oo Ar n Oc Ns <> Ar file | | 898 | .Ar n ) . |
| | | 899 | .It Oo Ar n Oc Ns Ic <> Ar file |
895 | Open | | 900 | Open |
896 | .Ar file | | 901 | .Ar file |
897 | for reading and writing on standard input (or | | 902 | for reading and writing on standard input (or |
898 | .Ar n ) . | | 903 | .Ar n ) . |
899 | .El | | 904 | .El |
900 | .Pp | | 905 | .Pp |
901 | The following redirection is often called a | | 906 | The following redirection is often called a |
902 | .Dq here-document . | | 907 | .Dq here-document . |
903 | .Bd -literal -offset indent | | 908 | .Bd -unfilled -offset indent |
904 | [n]<< delimiter | | 909 | .Oo Ar n Oc Ns Ic << Ar delimiter |
905 | \&... here-doc-text ... | | 910 | .Li \&... here-doc-text ... |
906 | delimiter | | 911 | .Ar delimiter |
907 | .Ed | | 912 | .Ed |
908 | .Pp | | 913 | .Pp |
909 | The | | 914 | The |
910 | .Dq here-doc-text | | 915 | .Dq here-doc-text |
911 | starts immediately after the next unquoted newline character following | | 916 | starts immediately after the next unquoted newline character following |
912 | the here-document redirection operator. | | 917 | the here-document redirection operator. |
913 | If there is more than one here-document redirection on the same | | 918 | If there is more than one here-document redirection on the same |
914 | line, then the text for the first (from left to right) is read | | 919 | line, then the text for the first (from left to right) is read |
915 | first, and subsequent here-doc-text for later here-document redirections | | 920 | first, and subsequent here-doc-text for later here-document redirections |
916 | follows immediately after, until all such redirections have been | | 921 | follows immediately after, until all such redirections have been |
917 | processed. | | 922 | processed. |
918 | .Pp | | 923 | .Pp |
919 | All the text on successive lines up to the delimiter, | | 924 | All the text on successive lines up to the delimiter, |
| @@ -922,29 +927,29 @@ than an immediately following newline, i | | | @@ -922,29 +927,29 @@ than an immediately following newline, i |
922 | saved away and made available to the command on standard input, or file | | 927 | saved away and made available to the command on standard input, or file |
923 | descriptor n if it is specified. | | 928 | descriptor n if it is specified. |
924 | If the delimiter as specified on the initial line is | | 929 | If the delimiter as specified on the initial line is |
925 | quoted, then the here-doc-text is treated literally; otherwise, the text is | | 930 | quoted, then the here-doc-text is treated literally; otherwise, the text is |
926 | treated much like a double quoted string, except that | | 931 | treated much like a double quoted string, except that |
927 | .Sq \&" | | 932 | .Sq \&" |
928 | characters have no special meaning, and are not escaped by | | 933 | characters have no special meaning, and are not escaped by |
929 | .Sq \&\e , | | 934 | .Sq \&\e , |
930 | and is subjected to parameter expansion, command substitution, and arithmetic | | 935 | and is subjected to parameter expansion, command substitution, and arithmetic |
931 | expansion as described in the | | 936 | expansion as described in the |
932 | .Sx Word Expansions | | 937 | .Sx Word Expansions |
933 | section below. | | 938 | section below. |
934 | If the operator is | | 939 | If the operator is |
935 | .Dq <<\(mi | | 940 | .Ic <<- |
936 | instead of | | 941 | instead of |
937 | .Dq << , | | 942 | .Ic << , |
938 | then leading tabs in all lines in the here-doc-text, including before the | | 943 | then leading tabs in all lines in the here-doc-text, including before the |
939 | end delimiter, are stripped. | | 944 | end delimiter, are stripped. |
940 | If the delimiter is not quoted, lines in here-doc-text that end with | | 945 | If the delimiter is not quoted, lines in here-doc-text that end with |
941 | an unquoted \e are joined to the following line, the \e and following | | 946 | an unquoted \e are joined to the following line, the \e and following |
942 | newline are simply removed while reading the here-document, | | 947 | newline are simply removed while reading the here-document, |
943 | which thus guarantees | | 948 | which thus guarantees |
944 | that neither of those lines can be the end delimiter. | | 949 | that neither of those lines can be the end delimiter. |
945 | .Pp | | 950 | .Pp |
946 | It is a syntax error for the end of the input file (or string) to be | | 951 | It is a syntax error for the end of the input file (or string) to be |
947 | reached before the delimiter is encountered. | | 952 | reached before the delimiter is encountered. |
948 | .Ss Search and Execution | | 953 | .Ss Search and Execution |
949 | There are three types of commands: shell functions, built-in commands, and | | 954 | 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. | | 955 | normal programs \(em and the command is searched for (by name) in that order. |