NetBSD-Users archive

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

Re: uniq on open streams



At Tue, 23 Apr 2019 13:45:40 +0200, Andreas Krey <a.krey%gmx.de@localhost> wrote:
Subject: Re: uniq on open streams
>
> On Tue, 23 Apr 2019 05:51:19 +0000, JP wrote:
> > I had a need to run uniq on an open stream.  It doesn't seem to print
> > the most recent line.
> >
> > $ lua -e 'print("a");print("b");print("c"); repeat until false' |uniq
> > a
> > b
> >
> > ^ should print the c as well, no?
>
> Yes, but. 'uniq -c' can only print the 'c' line once it gets a different input line
> or EOF, and I'd bet that the code doesn't try to behave differently when run without -c.

So, this surprised me, and so I tried this command-line in the first
open window I could paste it into, and was surprised to see the 'c'!

It turns out I had pasted into a macOS window.

Thinking "Oh, so it should work on FreeBSD too...", I opened a window to
my recently installed FreeBSD-12.0 machine, and after rewriting the Lua
code into AWK, I was surprised to see absolutely no output at all!

Then I made the mistake of looking at the recent FreeBSD code.  Oy!
Such churn!  I've no idea why it doesn't output anything.

So I checked opensource.apple.com.  Their version (in "text_cmds") is
somewhat behind the most recent FreeBSD churn, but is none the less
derived from an earlier version of the FreeBSD code.

I then looked at the OpenSolaris version (and the UNIX SysVr4 code from
which it came), and I thought at first glance that it might spit out the
'c' too, but alas it does not.

Neither does OpenBSD's.

Also, what about lack of a trailing newline on the last line when the
line before has the same content?  Is the newline part of the line?
Some (FreeBSD and SysVr4/OpenSolaris) would say not.

--
					Greg A. Woods <gwoods%acm.org@localhost>

+1 250 762-7675                           RoboHack <woods%robohack.ca@localhost>
Planix, Inc. <woods%planix.com@localhost>     Avoncote Farms <woods%avoncote.ca@localhost>

Attachment: pgpArWSmFNteS.pgp
Description: OpenPGP Digital Signature



Home | Main Index | Thread Index | Old Index