Tue Mar 13 21:04:57 2018 UTC ()
Try to improve markup of the redirections definitions.


(uwe)
diff -r1.184 -r1.185 src/bin/sh/sh.1

cvs diff -r1.184 -r1.185 src/bin/sh/sh.1 (expand / switch to unified diff)

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