[comp.unix.wizards] sed bug?

stanonik@nprdc.navy.mil (Ron Stanonik) (08/15/90)

We've run into what appears to be a sed bug in sunos4.X (sun3 snd sun4)
and in sysVr3 (on a 3b2).  Here's a little sed program to demonstrate it

1 s/.*/&/p
d

I'd expect this to print only the first line, and indeed that's what happens
in 4.3bsd (on a vax 780).  In sunos4.X and sysVr3, however, nothing is printed.

If the program is changed to

1p
d

then the first line is printed.

Bug?

Thanks,

Ron Stanonik
stanonik@nprdc.navy.mil

jfh@rpp386.cactus.org (John F. Haugh II) (08/16/90)

In article <24172@adm.BRL.MIL> stanonik@nprdc.navy.mil (Ron Stanonik) writes:
>We've run into what appears to be a sed bug in sunos4.X (sun3 snd sun4)
>and in sysVr3 (on a 3b2).  Here's a little sed program to demonstrate it
>
>1 s/.*/&/p
>d
>
>I'd expect this to print only the first line, and indeed that's what happens
>in 4.3bsd (on a vax 780).  In sunos4.X and sysVr3, however, nothing is printed.

By all accounts it is fixed in BSD 4.3 and broken in every other version of
SED I've had my hands on.

The way the bug was reported for AIX 3.1 was

% sed -e 's/abc/ABC/p' -e d << EOF
abc
abc123
EOF

and the output should have been

ABC
ABC123

but instead, nothing at all was printed.

>Bug?

Yes.  Bug.
-- 
John F. Haugh II                             UUCP: ...!cs.utexas.edu!rpp386!jfh
Ma Bell: (512) 832-8832                           Domain: jfh@rpp386.cactus.org

guy@auspex.auspex.com (Guy Harris) (08/17/90)

>Bug?

Or misfeature, although some scripts in S5 (among others, "lint", I
think) depend on that behavior.  As I remember, the behavior exhibited
by S5 was also exhibited in UNIX/32V (or, at least, the part of the code
that differs was basically the same as in S5), while in V7 it worked the
BSD way. 

I think the 32V code was older (yes, 32V was allegedly a V7 port to the
VAX, but they may have started with something older than V7), so it
*seems* the change from the 32V/S5 behavior to the V7/BSD behavior might
have been intended as a bug fix or improvement.  I think the S5 "lint"s
dependency on the 32V/S5 behavior can be fixed; I think there are cases
where dependency on the V7/BSD behavior cannot.

POSIX 1003.2 may specify that this has to be done the V7/BSD way.