On Wed, Aug 12, 2015 at 10:39 AM, Rudolf Sykora <[email protected]> wrote:
> Hello,
>
> is this as expected?
>
> perseus=; echo -n aaa | 9 sed 's/^/</'
> <aaa
> perseus=; echo -n aaa | sed 's/^/</'
> <aaaperseus=;
>
>
> For me the linux sed does what I expect,
> but not the p9p one (it adds a newline). Why?
>
> Thanks!
> Ruda
>

In case you were still wondering about the 'why' of the behaviour of
sed you encountered. See below.

P9p sed
-----------
/usr/local/plan9/src/cmd/sed.c:1316,1324
void
putline(Biobuf *bp, Rune *buf, int n)
{
    while (n--)
        Bputrune(bp, *buf++);
    Bputc(bp, '\n');
    if(lflag)
        Bflush(bp);
}

Plan9 sed
-------------
/sys/src/cmd/sed.c:1315,1321
void
putline(Biobuf *bp, Rune *buf, int n)
{
       while (n--)
               Bputrune(bp, *buf++);
       Bputc(bp, '\n');
 }

Modified local copy
--------------------------
/usr/$user/src/nsed.c:1315,1321
void
putline(Biobuf *bp, Rune *buf, int n)
{
        while (n--)
                Bputrune(bp, *buf++);
        /* Bputc(bp, '\n'); */
}

term% echo -n aaa | sed 's/^/</'
<aaa
term% echo -n aaa | nsed 's/^/</'
<aaaterm%

Reply via email to