NetBSD-Bugs archive

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

Re: standards/40554 : >& -operator incorrectly documented in sh(1)



The following reply was made to PR standards/40554; it has been noted by GNATS.

From: Robert Elz <kre%munnari.OZ.AU@localhost>
To: gnats-bugs%www.NetBSD.org@localhost
Cc: 
Subject: Re: standards/40554 : >& -operator incorrectly documented in sh(1)
Date: Mon, 15 Apr 2019 13:49:42 +0700

 I am planning on changing sh(1) to say:
 
            [n1]>& n2   Redirect standard output (or n1) to be a duplicate of
                        n2.
 
 and similarly for <&
 
            [n1]<& n2   Redirect standard input (or n1) from a duplicate of
                        file descriptor n2.
 
 (The <& case comes first, so is a little more wordy, the reader is
 supposed to be able to fill in the blanks...)
 
 As well as those changes (and in that, note the insertion of a space
 between ">&" and "n2" to make it clear that white space is permitted
 there, the same change is made for >& - (etc) as well).
 
 Does this seem likely (to one and all) to be a reasonable way of
 writing it, or at least, no worse than we currently have?
 
 I am also planning on enhancing the prelude to the Redirections section
 of sh(1) to appear as below (except the real thing will have correct
 markup - which I deleted for e-mail and especially gnats).
 
 What is below is all of that section (as proposed - but not yet spell
 checked, I will do that...) from the section heading down to, but not
 including the here-doc redirection operator (nothing from that point
 onwards is going to change in this update - if it happens).
 
 kre
 
 
    Redirections
      Redirections are used to change where a command reads its input or sends
      its output.  In general, redirections open, close, or duplicate an
      existing reference to a file.  The overall format used for redirection
      is:
 
            [n]redir-op file
 
      where redir-op is one of the redirection operators mentioned previously.
      A list of the possible redirections, and their meanings, follows.
 
      The [n] is an optional number, as in `3' (not `[3]'), that refers to a
      file descriptor.  If present it must occur immediately before the
      redirection operator, with no intervening white space, and becomes a part
      of that operator.  If file descriptor n was open prior to the
      redirection, its previous use is closed.
 
      All redirections have a single word file argument following the operator
      (white space is allowed between the redirection operator and file),
      though it is sometimes expressed as n2.  That argument is expanded (see
      Word Expansions below) using tilde expansion, parameter expansion,
      arithmetic expansion, command substitution and quote removal to produce
      the path name (or file descriptor) to be used.  No field splitting or
      pathname expansion takes place.  In the list below, where the file is
      given as n2 the result of the expansions must be a number which refers
      to a suitable open file descriptor.
 
            [n]> file   Redirect standard output (or n) to file.
 
            [n]>| file  The same, but override the -C option.
 
            [n]>> file  Append standard output (or n) to file.
 
            [n]< file   Redirect standard input (or n) from file.
 
            [n1]<& n2   Redirect standard input (or n1) from a duplicate of
                        file descriptor n2.
 
            [n]<& -     Close standard input (or n).  Note that the `-' is
                        minus sign (or hyphen) given literally or resulting
                        from the expansion of file (or n2) for this format.
                        When given literally there is usually no space between
                        the redirection operator and the `-', though that is
                        just a convention.
 
            [n1]>& n2   Redirect standard output (or n1) to be a duplicate of
                        n2.
 
            [n]>& -     Close standard output (or n).
 
            [n]<> file  Open file for reading and writing on standard input (or
                        n).
 
 


Home | Main Index | Thread Index | Old Index