| Summary: | sed file handing is non-standard | ||
|---|---|---|---|
| Product: | Base System | Reporter: | ihaka <ihaka> |
| Component: | bin | Assignee: | Ceri Davies <ceri> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 4.2-RELEASE | ||
| Hardware: | Any | ||
| OS: | Any | ||
State Changed
From-To: open->feedback
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.
State Changed From-To: feedback->closed Feedback timeout (6 months or more). I will handle any feedback that this closure generates. Responsible Changed From-To: freebsd-bugs->ceri Feedback timeout (6 months or more). I will handle any feedback that this closure generates. |
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. 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. How-To-Repeat: Utter the command: sed '/pattern/r'