From: Rob Pike <robpike@gmail.com>
To: dave@horsfall.org
Cc: tuhs@tuhs.org
Subject: Re: [TUHS] Article on the history of cat(1)
Date: Wed, 14 Nov 2018 10:21:37 +1100 [thread overview]
Message-ID: <CAKzdPgwsf-h+V8b1yMq25PcFNu2Ux==q2Lpbvzitb3f7P-UKcA@mail.gmail.com> (raw)
In-Reply-To: <alpine.BSF.2.21.9999.1811140957280.60610@aneurin.horsfall.org>
[-- Attachment #1: Type: text/plain, Size: 2381 bytes --]
I was offended by the -u flag in v7 cat, which was a necessary but
unfortunate consequence of preserving the original's semantics while
converting it to use the new standard I/O library. Dennis felt it was
important as a proof of the value of stdio; to me it was an indication that
stdio couldn't do everything. I rewrote cat to use just read and write, as
nature intended. I don't recall if my version is in any of v8 v9 v10 but
it, or something very like it, is in Plan 9:
% cat cat.c
#include <u.h>
#include <libc.h>
void
cat(int f, char *s)
{
char buf[8192];
long n;
while((n=read(f, buf, (long)sizeof buf))>0)
if(write(1, buf, n)!=n)
sysfatal("write error copying %s: %r", s);
if(n < 0)
sysfatal("error reading %s: %r", s);
}
void
main(int argc, char *argv[])
{
int f, i;
argv0 = "cat";
if(argc == 1)
cat(0, "<stdin>");
else for(i=1; i<argc; i++){
f = open(argv[i], OREAD);
if(f < 0)
sysfatal("can't open %s: %r", argv[i]);
else{
cat(f, argv[i]);
close(f);
}
}
exits(0);
}
%
-rob
P.S. I learned today that cat.c has a spurious trailing newline.
On Wed, Nov 14, 2018 at 10:15 AM Dave Horsfall <dave@horsfall.org> wrote:
> On Wed, 14 Nov 2018, Warren Toomey wrote:
>
> >> Didn't know that cat(1) was still written in assembly on Edition 6...
> >
> > https://minnie.tuhs.org/cgi-bin/utree.pl?file=V6/usr/source/s1/cat.s
>
> Thanks; then again, I never had a reason to poke around cat(1) (but I do
> remember adding a "-h" flag to pr(1) for a sub-header or something).
>
> In fact, the only assembler stuff I remember modifying was deep in the
> kernel, to take advantage of Unibus timing (on the /40 at least), where
> the "obvious" code was sub-optimal; can't remember the details, but it
> saved a bus cycle or two.
>
> Hell, I wish I still had that "CSU Tape"; it was Edition 6 with as much of
> Edition 7 (and AUSAM) that I could shoe-horn in, such as XON/XOFF for the
> TTY driver. I was known as "Mr Unix 6-1/2" at the time...
>
> Completely rewrote the 200-UT driver so that it actually worked (IanJ's
> driver was a horrible mess) and worked around an egregious bug on the
> Kronos side which they said was baked-in so deep that it couldn't be
> fixed.
>
> Rewrote the plotter driver and Versatec LV-11 driver to use the buffer
> pool instead of the character queues, so they went like a bat out of hell.
>
> Etc.
>
> -- Dave
>
[-- Attachment #2: Type: text/html, Size: 16991 bytes --]
next prev parent reply other threads:[~2018-11-13 23:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-13 21:55 Warren Toomey
2018-11-13 22:44 ` Dave Horsfall
2018-11-13 22:49 ` Warren Toomey
2018-11-13 23:10 ` Arthur Krewat
2018-11-13 23:14 ` Dave Horsfall
2018-11-13 23:21 ` Rob Pike [this message]
[not found] ` <20181114004018.GA23816@minnie.tuhs.org>
2018-11-14 2:51 ` Dave Horsfall
2018-11-13 23:27 Norman Wilson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKzdPgwsf-h+V8b1yMq25PcFNu2Ux==q2Lpbvzitb3f7P-UKcA@mail.gmail.com' \
--to=robpike@gmail.com \
--cc=dave@horsfall.org \
--cc=tuhs@tuhs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).