SoftwareUnixBourne shellCAlgol 68tech history
Steve Bourne wrote the Unix shell's C code with macros that turn it into Algol: IF, THEN, FI and OD in mac.h
Bell Labs' shell author came from an Algol 68 compiler job and wanted that syntax in a C project, so he rebuilt the language with a header file. The shell's source also helped inspire a contest for the strangest C ever written.

Open the Bourne shell source from Seventh Edition Unix and the first thing you hit is a file called mac.h. It starts with a three-line credit: “UNIX shell, S. R. Bourne, Bell Telephone Laboratories.” Then it starts redefining C.
#define IF if(. #define THEN ){. #define FI ;}. Those three lines are the whole trick. Put them together and a C if statement gets the shape of the one you type in a shell script: IF, THEN, something, FI. The file goes on to cover loops (#define DO ){, #define OD ;}), BEGIN and END for braces, LOOP and POOL for an infinite for(;;){, and a SWITCH that closes with ENDSW. It even defines ANDF as && and DIV as /, so division got a word too.
The payoff is in the other source files. In service.c there’s a line that reads IF (n=to-from)<=1 THEN return FI, which is a perfectly ordinary C early return wearing a costume. Another reads IF scanp!=path THEN *argp++='/' FI. A sort loop in the same file runs FOR j=1; j<=n; j*=2 DONE, and the macro file defines DONE as );, so an empty loop body ends the header and keeps going. The compiler never sees a single capital letter. The preprocessor swaps them out first, and what gets compiled is plain C.
Why bother? Russ Cox answered that in a 2008 post, and it comes down to Bourne’s résumé. “Steve Bourne worked on an Algol 68 compiler at the Cambridge University Computer Lab before moving to Bell Labs,” Cox wrote. Then comes the line that explains the header: “More comfortable with Algol but stuck with C, Bourne found a way to cope.” Bell Labs had C. Bourne had Algol habits. A header file reconciled them without touching the compiler.
Cox says the preference shows up twice. It’s in the shell language itself, which closes an if with fi and a case with esac, both Algol-style keywords written backward. And, as he puts it, “Bourne’s preference for Algol syntax is, surprisingly, also evident in the shell source.” So the man page and the source code share a dialect. (Not the same dialect everywhere: the shell closes a case with esac, while the C side uses ENDSW. Even Bourne had to give a macro a different name.)
The shell code had a second life, according to Cox’s post. He says it, along with the 4.2BSD finger implementation, “was the impetus for the International Obfuscated C Code Contest.” Bourne was after code that felt familiar to him. The contest was after code that confuses everyone else. Same preprocessor, opposite goals. It’s the Bourne Identity: a C program living under an Algol alias.
The practical catch is that the C preprocessor can redefine anything, including if. Read this source without mac.h open beside it and every capitalized word is a mystery, because none of them is a keyword until the macros expand. The header is the language manual, and it comes first.
Cox’s post leaves one question open: why function bodies in the shell source got plain braces instead of BEGIN and END. The macro was right there in the file.