Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [ -d (#i)Temp ]



Ray Andrews <rayandrews@xxxxxxxxxxx> writes:

Yeah, it strikes me a very strange that '[' is a binary, guess you'd
have to have been there back when the shells were being
written.

The first Unix shell was the Thompson shell, released in 1971. (The Bourne shell appeared in 1979 as part of Version 7 Unix.) A 1976 paper describes the reasoning behind how shell control structures were implemented:

The more complex shell control structures are actually implemented as
independent commands that cooperate with the shell, but are not
actually part of it. They are designed specifically for use in shell procedures, but are treated as ordinary commands. This separation of function allows the shell to remain a small program, efficient for on-line use, but still able to support powerful control structures in
procedures.
-- https://grosskurth.ca/bib/1976/mashey-command.pdf, p. 5

In 1976, Version 6 Unix ran on PDP-11s whose bus width ranged from 16 to 22 bits; 22 bits allows directly addressing at most 512k of memory. The Thompson shell was designed to be small to maximise the space available for the programs it was running.

Then issues of 'backwards compatibility' did the rest[a].


Alexis.

[a] Notoriously, the reason Makefiles today need to use tabs is because the author of the original `make`, Stuart Feldman, was concerned about backwards compatibility:

Why the tab in column 1? Yacc was new, Lex was brand new. I hadn't tried either, so I figured this would be a good excuse to learn. After
getting myself snarled up with my first stab at Lex, I just did
something simple with the pattern newline-tab. It worked, it
stayed. And then a few weeks later I had a user population of about a dozen, most of them friends, and I didn't want to screw up my embedded
base. The rest, sadly, is history.




Messages sorted by: Reverse Date, Date, Thread, Author