2 ms·
Bourne shell syntax is inspired by Algol 68¹, of which Bourne was a fan — the shell itself² was written in a highly idiosyncratic dialect of C, using the prepro
by kps 12y ago
Bourne shell syntax is inspired by Algol 68¹, of which Bourne was a fan — the shell itself² was written in a highly idiosyncratic dialect of C, using the preprocessor to provide an Algol68ish syntax for control structures:
WHILE i--
DO t=trapcom[i];
IF t==0 ORF *t
THEN clrsig(i);
FI
trapflg[i]=0;
OD
The parser³ is straightforward recursive-descent in 400 lines including comments & blanks (the whole shell is about 4000 lines of code).
¹ http://en.wikipedia.org/wiki/ALGOL_68 http://en.wikipedia.org/wiki/ALGOL_68
² http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/sh http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/...
³ http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/sh/cmd.c http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/...