From ihaka@stat.auckland.ac.nz  Sun Dec  9 15:05:45 2001
Return-Path: <ihaka@stat.auckland.ac.nz>
Received: from mailhost.auckland.ac.nz (mailhost.auckland.ac.nz [130.216.1.4])
	by hub.freebsd.org (Postfix) with ESMTP id DB0E937B405
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  9 Dec 2001 15:05:42 -0800 (PST)
Received: from stat1.stat.auckland.ac.nz (stat1.stat.auckland.ac.nz [130.216.93.1])
	by mailhost.auckland.ac.nz (8.9.2/8.9.2/8.9.2-ua) with ESMTP id MAA07447
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 10 Dec 2001 12:05:36 +1300 (NZDT)
Received: (from ihaka@localhost)
	by stat1.stat.auckland.ac.nz (8.10.2+Sun/8.8.8) id fB9N5a017671
	for FreeBSD-gnats-submit@freebsd.org; Mon, 10 Dec 2001 12:05:36 +1300 (NZDT)
Message-Id: <200112092305.fB9N5a017671@stat1.stat.auckland.ac.nz>
Date: Mon, 10 Dec 2001 12:05:36 +1300 (NZDT)
From: ihaka@stat.auckland.ac.nz
To: FreeBSD-gnats-submit@freebsd.org
Subject: sed incompatibility

>Number:         32657
>Category:       bin
>Synopsis:       sed file handing is non-standard
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    ceri
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Dec 09 15:10:02 PST 2001
>Closed-Date:    Sun Jun 08 11:02:25 PDT 2003
>Last-Modified:  Sun Jun 08 11:02:25 PDT 2003
>Originator:     Ross Ihaka
>Release:        FreeBSD 4.2-RELEASE i386
>Organization:
Statistics Department, University of Auckland
>Environment:

        not relevant

>Description:

        The sed manual entry says:

          The ``r'' and ``w'' functions take an optional file parameter,
          which should be separated from the function letter by white
          space.  Each file given as an argument to sed is created
          (or its contents truncated) before any input processing
          begins.

        Under FreeBSD (and possibly other BSD systems) the file parameter
        is mandatory -- sed terminates with an error message if an
        editing command of one of the forms
                /pattern/r
                /pattern/w
        is encountered.  Other sed versions (e.g. GNU and Solaris) silently
        ignore such constructions.

        This kind constructions appears in scripts generated by autoconf
        which work on other platforms, but not FreeBSD.

>How-To-Repeat:

        Utter the command:
                sed '/pattern/r'

>Fix:

        In /usr/src/usr.bin/sed/compile.c in the function compile_stream,
        (cases WFILE and RFILE) there are lines

                        if (*p == '\0')
                                errx(1, "%lu: %s: filename expected", linenum, fname);
                        else
                                cmd->t = duptoeol(p, "read command");

        removing the first three of these lines will cause the filename
        "" to be passed on for later processing.  This will produce
        the same effect as specifying a file which does not exist
        (the problem is silently ignored).

        This change would produce a warning message from duptoeol about
        trailing white space.  This message does not seem to occur in
        other sed variants.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: sheldonh 
State-Changed-When: Mon Dec 10 04:11:02 PST 2001 
State-Changed-Why:  
FreeBSD's sed(1) demands a file parameter because it's not optional for 
the w flag in POSIX.2 ('92 edition).  The semantics for the r flag are 
taken from the w flag. 

This change would meet with less resistence if you could find a more 
recent standard that prescribes optional arguments to the w flag (and 
possible the r flag). 

If you need help getting such information, try the freebsd-standards 
mailing list. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=32657 
State-Changed-From-To: feedback->closed 
State-Changed-By: ceri 
State-Changed-When: Sun Jun 8 11:02:24 PDT 2003 
State-Changed-Why:  
Feedback timeout (6 months or more). 
I will handle any feedback that this closure generates. 


Responsible-Changed-From-To: freebsd-bugs->ceri 
Responsible-Changed-By: ceri 
Responsible-Changed-When: Sun Jun 8 11:02:24 PDT 2003 
Responsible-Changed-Why:  
Feedback timeout (6 months or more). 
I will handle any feedback that this closure generates. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=32657 
>Unformatted:
