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

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

Re: sed : * final newline


From: Stepan Kasal
Subject: Re: sed : * final newline
Date: Thu, 10 Jul 2003 10:19:23 +0200
User-agent: Mutt/1.2.5.1i

Hello Paolo,

On Wed, Jul 09, 2003 at 11:42:00AM +0200, Paolo Bonzini wrote:
>     static bool pre_newline = false;
>     if (pre_newline)
>       fwrite ("\n", 1, 1, stdout);
> 
>     ...
>     pre_newline = !chomped;
> 
> (more or less -- there's some complication regarding `w' files, but that's 
> the idea)

yes, so the `pre_newline' is an attribute of the output file,
not a mere static variable.

(I had this in mind, too, when speaking about ``the three-state solution,''
but I didn't want to go into details.)

Paolo, one more question, to be sure: I suppose that in the following

        echo -n one >one
        echo -n two >two
        sed '/two/d' one two

the output line ("one") should not contain the terminating newline.
If this assumption is wrong, please tell me.

Paolo also wrote:
> Yes.  Changing to always append the new line does not affect only a
> curiosity like sed : or sed -n p, but also real sed commands.

I understand this.  That's why I wrote:

: ... sed contains the hack which tries to preserve the ending for
: simple sed scripts.  But this hack causes problems when the program is
: not so trivial or when sed gets several input files.

But I respect your decision, ``the hack'' will stay there.

Stepan Kasal




reply via email to

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