@kick I have not seen the original bourne shell source, no. I have read a decent subset of dash, and a little bit of bash, and I reckon both suck
@kick yeah, this is pretty awful. I don't think that it's fair to point at UNIX as an example of bad code, though. Consider that this codebase started in assembly, designed C for the purpose of rewriting it in, rewrote it in _pre_ ANSI C, then rewrote some of it in ANSI C, then was promptly abandoned. I can clearly see the lineage from all of these steps in its history in this source file.
@kick can also totally see the influence of FORTRAN people who were forced to work on UNIX and bastardized C (an as of yet unproven language) to fit their square shaped peg into it
@kick ah, well, FORTRAN has ALGOL in its lineage. I wasn't alive for any of this, cut me some slack 😉
@sir Bourne Shell was first in v7 UNIX, and was never written in any dialect of assembly. There is no other tool in the v7 source tree that’s as quite as demented as this, though a few come close. Bourne was just a psychopath. My favorite thing ever is that the original IOCCC announcement on Usenet was directly caused by someone having to fix a bug in Bourne’s awful “C”!
*Q: How did the IOCCC get started? A: One day (23 March 1984 to be exact), back Larry Bassel and I (Landon Curt Noll) were working for National Semiconductor’s Genix porting group, we were both in our offices trying to fix some very broken code. Larry had been trying to fix a bug in the classic Bourne shell (C code #defined to death to sort of look like Algol) and I had been working on the finger program from early BSD (a bug ridden finger implementation to be sure). We happened to both wander (at the same time) out to the hallway in Building 7C to clear our heads.
We began to compare notes: ‘’You won’t believe the code I am trying to fix’’. And: ‘’Well you cannot imagine the brain damage level of the code I’m trying to fix’’. As well as: ‘’It’s more than bad code, the author really had to try to make it this bad!’’.*