[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sed --posix does not catch incomplete arguments
From: |
Ralf Wildenhues |
Subject: |
Re: sed --posix does not catch incomplete arguments |
Date: |
Mon, 19 Jul 2010 23:06:05 +0200 |
User-agent: |
Mutt/1.5.20 (2010-04-22) |
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.
Cheers,
Ralf
patch
Description: Text document