On Sat, Jan 21, 2023 at 11:37 AM Warner Losh <imp@bsdimp.com> wrote:

Yea. Like many things, there was a transition... the most important bit is the shell. And that was more tricky to read through with the phone at breakfast...

OK. I've dug a bit further and Clem and I have chatted...  Here's the summary.

We don't have V4's shell, alas, since all we have from that time period is the C kernel a few months before the 4th edition release. V5 /bin/sh closes fd2 and then dups fd1 to fd2. This creates fd2 as something special. V6 closes all FD's larger than 1 (2-15) and then does the dup(1) which it makes sure returns 2 or it closes the file. While there were features in V6 to allow use of fd2/stderr, few programs used then.

And neither crypt nor passwd reads from fd2. crypt reads from fd0, while passwd doesn't read. It just replaces the hashed password with the new password. I've also looked at pr because

>I do remember that pr -p actually read from FD 2. It probably still does.

and that's not true in V7 at least... pr didn't have a 'p' arg :). Maybe later programs started to do these things, but most of what went on with V7 was a transition to most error messages on stderr, which typically went to stdout in V6.

So, people remembering it coming in with V7 are right, in the sense it was the first release to do it consistently. And the people remembering V4 or V5 are also right, in a different sense because the shell was ensuring fd2 was a copy of fd1 there, which a couple of programs (diff) used for errors. And I believe that the impetus for the V7 changes was phototypesetting 'file not found' too often...  But that last bit is mostly because I want to believe.

Warner