== The (Unix) shell is not just for running programs In the Reddit comments on [[yesterday's entry BourneShellOutsourcedBits]], I ran across [[the following comment https://www.reddit.com/r/bash/comments/4mcmdl/one_thing_that_makes_the_bourne_shell_an_odd/d3v27ss]]: > No. The shell literally has the sole purpose of running external > programs. Anything more is extra. > > The V1 shell read a line, split on whitespace, and executed the > command from /bin. You could change the current directory from in the > shell, that was it. On any version of Unix as far back as at least V7, this is false. The Unix shell may have started out simply being a way to run programs, but it long ago stopped being just that. Since the V7 shell is a ground up rewrite, one cannot even argue that the shell simply drifted into these additional features for convenience. The V7 shell was consciously designed from scratch, and as part of that design it included major programming features including control flow constructs drawn directly from the general Algol line of computer language design. Inclusion of these programming features is not an accident and not a drift over time; it is a core part of the shell's design and thus its intended purpose. The V7 shell is there both to run programs *and* to write programs (shell scripts), and this is completely intended. (In terms of control flow, I'm thinking here of _if_, _while_, and _for_, and there's also _case_.) In short, the shell as in part a programming language is part of Unix's nature from at least the first really popular Unix version (V7 became the base of many further lines of Unix). To the extent that the Unix design ethos or philosophy exists as a coherent thing, it demonstrably includes a strongly programmable shell. You can make an argument that the V6 shell (the 'Mashey shell') shows this too, but it was apparently a derivative of and deliberately backwards compatible with the original 'just run things' [[Thompson shell https://en.wikipedia.org/wiki/Thompson_shell]]. The V7 Bourne shell is a clear, from scratch break with the original Thompson shell, and it was demonstrably accepted by Research Unix as being, well, proper Unix. (If you want even more proof that Research Unix's view of the shell includes programming, the shell was reimplemented once again for Version 10 and Plan 9 in the form of [[Tom Duff's _rc_ shell https://en.wikipedia.org/wiki/Rc]] and, you guessed it, that included programmability too, this time with more C-like syntax instead of the Algol-like syntax of the Bourne shell.) (You can argue that this conjoining of 'just run programs for people' and 'write shell scripts' in a single program is a mistake and these roles should be split apart into two programs, but that's a different argument. [[I happen to think that it's also wrong WhyShellLanguages]], and [[on more than one level WhyShellLanguagesII]].)