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

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

Re: sed --posix does not catch incomplete arguments


From: Paolo Bonzini
Subject: Re: sed --posix does not catch incomplete arguments
Date: Sun, 25 Jul 2010 03:19:57 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100621 Fedora/3.0.5-1.fc13 Lightning/1.0b2pre Thunderbird/3.0.5

On 07/19/2010 11:06 PM, Ralf Wildenhues wrote:
Hello,

* Paolo Bonzini wrote on Mon, Jul 05, 2010 at 12:18:24PM CEST:
On Sun, Jul 4, 2010 at 18:36, Bruno Haible<address@hidden>  wrote:
So, I'm asking: Can GNU 'sed' be changed so that in --posix mode it rejects
either all incomplete fragments, or at least those that currently represent
a real portability problem (namely, those which end in a backslash)? [1][2]

The latter can be done.

Create a file F containing the two characters a\ without a final newline.
If I understand Posix correctly, then the following things should fail:

echo a | sed --posix -f F
echo a | sed --posix 'a\'
echo a | sed --posix 'c\'
echo a | sed --posix 'i\'
echo a | sed --posix -e 'a\' -e x
echo a | sed --posix -e 'c\' -e x
echo a | sed --posix -e 'i\' -e x

And removing --posix, the respective commands should pass, no matter
what the setting of POSIXLY_CORRECT.

Further, the following should still pass:

echo a | sed --posix -e \{ -e \}
echo a | sed --posix -e 't x' -e :x

The attached patch implements this behavior.

Posix also specifies that the text after a c i commands as having one or
more lines.  The patch does not enforce this.  Since the sed script need
not have a final newline, I guess that requirement means that there is a
newline after the 'a\', which then really means the above requirement.

Queued for after 4.2.2.

Paolo



reply via email to

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