standards/96236: [PATCH] [POSIX] sed.1 incorrectly describes a
function-list
Andreas Kohn
andreas at syndrom23.de
Sun Apr 23 21:40:29 UTC 2006
>Number: 96236
>Category: standards
>Synopsis: [PATCH] [POSIX] sed.1 incorrectly describes a function-list
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-standards
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: doc-bug
>Submitter-Id: current-users
>Arrival-Date: Sun Apr 23 21:40:18 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator: Andreas Kohn
>Release: FreeBSD 7.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD 7.0-CURRENT #41: Fri Mar 17 12:01:02 CET 2006
root at klamath.syndrom23.de:/usr/obj/usr/src/sys/KLAMATH
>Description:
sed.1 says about a function-list:
This is a list of sed functions separated by newlines, as follows:
The ``{'' can be preceded by white space and can be followed by white
space. The function can be preceded by white space. The terminating
``}'' must be preceded by a newline or optional white space.
According to SUS, this is incorrect:
The <right-brace> shall be preceded by a <newline> and can be preceded or followed by <blank>s.
The sed command does follow SUS, see attached test case.
GNU sed (4.1.4 tested) also allows that the } is only preceeded by whitespace, see attached test case.
A simple fix would be to replace the "or" with an "and", as in the patch.
>How-To-Repeat:
Try the test case from sed-check.shar with both SED=sed and SED=gsed. Compare with documentation and SUS.
>Fix:
--- sed-check.shar begins here ---
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# sed-check
# sed-check/Makefile
# sed-check/testcase.gsed
# sed-check/testcase.txt
#
echo c - sed-check
mkdir -p sed-check > /dev/null 2>&1
echo x - sed-check/Makefile
sed 's/^X//' >sed-check/Makefile << 'END-of-sed-check/Makefile'
X# Check for [2addr] function-list functionaly of sed
X
X# try with gsed
XSED?=sed
X
Xtest:
X if ! ${SED} -e '/start/,/end/ { s/foobar/barbaz/ }' testcase.txt > testcase.out; then \
X echo FAILED ; \
X else \
X if ! cmp -s testcase.gsed testcase.out; then \
X echo FAILED ; \
X else \
X echo PASSED ; \
X fi \
X fi
X
X
END-of-sed-check/Makefile
echo x - sed-check/testcase.gsed
sed 's/^X//' >sed-check/testcase.gsed << 'END-of-sed-check/testcase.gsed'
Xsome text which should not be touched
Xalthough it does contain the search strings "foobar"
X
Xstart
Xhere is some text that also contains barbaz, which should be changed.
Xsome more text.
Xend
X
Xthe next foobar should stay foobar.
X
END-of-sed-check/testcase.gsed
echo x - sed-check/testcase.txt
sed 's/^X//' >sed-check/testcase.txt << 'END-of-sed-check/testcase.txt'
Xsome text which should not be touched
Xalthough it does contain the search strings "foobar"
X
Xstart
Xhere is some text that also contains foobar, which should be changed.
Xsome more text.
Xend
X
Xthe next foobar should stay foobar.
X
END-of-sed-check/testcase.txt
exit
--- sed-check.shar ends here ---
--- sed.1-function-list.diff begins here ---
Index: sed.1
===================================================================
RCS file: /storage/freebsd/cvs/src/usr.bin/sed/sed.1,v
retrieving revision 1.43
diff -u -r1.43 sed.1
--- sed.1 14 Jun 2005 11:50:52 -0000 1.43
+++ sed.1 23 Apr 2006 21:29:32 -0000
@@ -280,7 +280,7 @@
The function can be preceded by white space.
The terminating
.Dq }
-must be preceded by a newline or optional white space.
+must be preceded by a newline and optional white space.
.Pp
.Bl -tag -width "XXXXXX" -compact
.It [2addr] function-list
--- sed.1-function-list.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-standards
mailing list