The following issue has been SUBMITTED. 
====================================================================== 
https://austingroupbugs.net/view.php?id=1786 
====================================================================== 
Reported By:                eblake
Assigned To:                
====================================================================== 
Project:                    Issue 8 drafts
Issue ID:                   1786
Category:                   Shell and Utilities
Type:                       Clarification Requested
Severity:                   Objection
Priority:                   normal
Status:                     New
Name:                       Eric Blake 
Organization:               Red Hat 
User Reference:             ebb.ed 
Section:                    XCU ed 
Page Number:                2801 
Line Number:                92899 
Final Accepted Text:         
====================================================================== 
Date Submitted:             2023-11-02 15:13 UTC
Last Modified:              2023-11-02 15:13 UTC
====================================================================== 
Summary:                    ed behavior on non-existing filename
Description: 
This bug was created as fallout from investigating
https://austingroupbugs.net/view.php?id=251, investigating
whether <i>ed</i> can create pathnames containing a newline.

It turns out that the standard is silent on what happens when the <b>e</b>,
<b>f</b> or <b>w</b> commands are used with a filename (whether explicit or
implicit) that does not yet exist.  Existing implementations differ on
whether <b>e</b> can create a file:

GNU ed:<blockquote>
$ rm -f hi
$ echo q | ed hi
hi: No such file or directory
$ echo $?
0
$ echo f | ed hi
hi: No such file or directory
hi
$ echo $?
0
$ ls hi
ls: cannot access 'hi': No such file or directory
$ echo w | ed hi
hi: No such file or directory
0
$ ls hi
hi</blockquote>

whereas on FreeBSD 13:<blockquote>
# rm -f hi
# echo q | ed hi
hi: No such file or directory
# echo $?
2
# echo f | ed hi
hi: No such file or directory
# echo $?
2
# echo w | ed hi
hi: No such file or directory
# ls hi
ls: hi: No such file or directory</blockquote>

However, all implementations I tested appear to allow <b>f</b> and <b>w</b>
allow a filename argument that does not yet exist, at which point <b>w</b>
creates that file (which matches the requirement for <b>w</b> at line
93110):<blockquote>

</blockquote>
$ rm -f hi
$ printf 'f hi\nw\n' | ed
hi
0
$ ls hi
hi</blockquote>

Back in the context of https://austingroupbugs.net/view.php?id=251, where we
stated that the <i>file</i>
command line argument to <i>ed</i> is treated the same as an explicit
argument to the <b>e</b> command, other than the possibility of including a
newline in the name, whether or not you can use <i>ed</i> to create a
filename with a newline then depends on the behavior of whether a
non-existing pathname is permitted with the <b>e</b> command.  However, the
proposed wording here is intended to apply as-is regardless of whether we
also include the changes in https://austingroupbugs.net/view.php?id=251.

Desired Action: 
In XCU ed EXTENDED DESCRIPTION, page 2801 line 92901, in the Edit Command
text, after the sentence:<blockquote>If no pathname is given, the currently
remembered pathname, if any, shall be used (see
the <b>f</b> command).</blockquote>insert another sentence<blockquote>If
the pathname names a file that does not exist, it is unspecified whether
this is treated as an error, or whether a warning is emitted in place of a
byte count and the resulting buffer is left empty.</blockquote>

On page 2802 line 92918, in the Filename Command text,
change:<blockquote>If <i>file</i> is given, the <b>f</b> command shall
change the currently remembered pathname to
<i>file</i>;</blockquote>to:<blockquote>If <i>file</i> is given, the
<b>f</b> command shall change the currently remembered pathname to
<i>file</i>, whether or not <i>file</i> names an existing
file;</blockquote>


====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2023-11-02 15:13 eblake         New Issue                                    
2023-11-02 15:13 eblake         Name                      => Eric Blake      
2023-11-02 15:13 eblake         Organization              => Red Hat         
2023-11-02 15:13 eblake         User Reference            => ebb.ed          
2023-11-02 15:13 eblake         Section                   => XCU ed          
2023-11-02 15:13 eblake         Page Number               => 2801            
2023-11-02 15:13 eblake         Line Number               => 92899           
======================================================================


  • [Issue 8 dra... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [Issue ... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [Issue ... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [Issue ... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [Issue ... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [Issue ... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [Issue ... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [Issue ... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [Issue ... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [Issue ... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [Issue ... Austin Group Bug Tracker via austin-group-l at The Open Group

Reply via email to