bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: sed --posix


From: Eric Blake
Subject: Re: sed --posix
Date: Wed, 27 May 2009 05:52:59 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Simon Josefsson on 5/27/2009 4:33 AM:
> address@hidden:~/src/libidn master$ echo 'version 2  '|sed -e 's/version 
> \(2\|2\.1\)\([ ,]\)/version 3\2/g'
> version 3  
> 
> But adding --posix makes it fail:
> 
> address@hidden:~/src/libidn master$ echo 'version 2  '|sed --posix -e 
> 's/version \(2\|2\.1\)\([ ,]\)/version 3\2/g'
> version 2  
> 
> I'm using GNU sed v4.2 from debian testing.  I suspected the final g
> parameter to s/// but removing that didn't help.
> 
> Is this a sed bug?  It kind of seems like it, but I'm not certain.

While we already determined that the expression is using the non-portable
\|, and thus using --posix is allowed to change the behavior, I think we
have also found an actual bug in sed 4.2.  My preference would be that
'sed --posix' failed with a verbose error message when undefined input
like \| is detected, rather than silently changing behavior.  POSIX
permits either action for unspecified input (treating it as a valid
extension, or rejecting it); but from the perspective of a script writer
trying to guarantee that they are only using POSIX-specified input, an
error message identifying the unspecified use is much friendlier than a
silent change in behavior.  In other words, I would much rather see sed
- --posix behave like it does for other forms of non-POSIX input:

$ echo hi | sed/sed v || echo $?
hi
$ echo hi | sed/sed --posix v || echo $?
sed/sed: -e expression #1, char 1: unknown command: `v'
1
$ echo hi | POSIXLY_CORRECT=1 sed/sed v || echo $?
hi

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkodKZsACgkQ84KuGfSFAYCOBQCfbcXnzhYXqpv/HHOp8oE2f5Wc
2h8An08mo/X5Jq3uulguNmNlsb1OYSPS
=8rFa
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]