bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bash manual page does not describe the redirection form "n>&-".


From: Dale R. Worley
Subject: bash manual page does not describe the redirection form "n>&-".
Date: Thu, 29 May 2014 15:03:46 -0400

Version:  GNU bash, version 4.2.47(1)-release (x86_64-redhat-linux-gnu)

Problem:  Manual page does not describe the redirection form "n>&-".

The manual page section "Duplicating File Descriptors" is as follows:

   Duplicating File Descriptors
       The redirection operator

              [n]<&word

       is used to duplicate input file descriptors.  If word expands to one or
       more digits, the file descriptor denoted by n is made to be a  copy  of
       that  file  descriptor.   If  the  digits in word do not specify a file
       descriptor open for input, a redirection error occurs.  If word  evalu‐
       ates  to  -,  file  descriptor n is closed.  If n is not specified, the
       standard input (file descriptor 0) is used.

       The operator

              [n]>&word

       is used similarly to duplicate output file descriptors.  If  n  is  not
       specified,  the  standard  output  (file descriptor 1) is used.  If the
       digits in word do not specify a file descriptor open for output, a  re‐
       direction  error  occurs.  As a special case, if n is omitted, and word
       does not expand to one or more digits, the standard output and standard
       error are redirected as described previously.

However, the last paragraph does not describe the form "n>&-" (which
does close descriptor n).  Perhaps that is implied by "similarly", but
it would be better to spell it out:

       is used similarly to duplicate output file descriptors.  If
       word expands to one or more digits, the file descriptor denoted
       by n is made to be a copy of that file descriptor.  If the
       digits in word do not specify a file descriptor open for
       output, a redirection error occurs.  If word expands to -,
       file descriptor n is closed.  If n is not specified, the
       standard output (file descriptor 1) is used.  As a special
       case, if n is omitted, and word does not expand to one or more
       digits, the standard output and standard error are redirected
       as described previously.

In addition, the word "evaluates" in the first paragraph should be
"expands".

The change to file bash.1 is:

--- /home/worley/temp/b0        2014-05-29 14:56:17.631508858 -0400
+++ /home/worley/temp/b1        2014-05-29 14:59:00.596458326 -0400
@@ -17,7 +17,7 @@
 do not specify a file descriptor open for input, a redirection error occurs.
 If
 .I word
-evaluates to
+expands to
 .BR \- ,
 file descriptor
 .I n
@@ -31,12 +31,24 @@
 [\fIn\fP]\fB>&\fP\fIword\fP
 .RE
 .PP
-is used similarly to duplicate output file descriptors.  If
+is used similarly to duplicate output file descriptors.
+If
+.I word
+expands to one or more digits, the file descriptor denoted by
 .I n
-is not specified, the standard output (file descriptor 1) is used.
+is made to be a copy of that file descriptor.
 If the digits in
 .I word
 do not specify a file descriptor open for output, a redirection error occurs.
+If
+.I word
+expands to
+.BR \- ,
+file descriptor
+.I n
+is closed.  If
+.I n
+is not specified, the standard output (file descriptor 1) is used.
 As a special case, if \fIn\fP is omitted, and \fIword\fP does not
 expand to one or more digits, the standard output and standard
 error are redirected as described previously.

Dale



reply via email to

[Prev in Thread] Current Thread [Next in Thread]