Reactionary Software / Needed - by fschmidt

Better Shell

Bash is the shell that I recommend. But it is far from ideal. It is old and clunky and is cryptic for writing shell scripts. But since modern culture is incapaple of making anything good, you should stick with Bash. But in this post I will describe my fantasy shell that won't be implemented.

One thing that Bash gets right is conceptual simplicity. And a key part of that is being completely typeless. No need for types like booleans, numbers, maps, lists, etc. Just byte streams and strings, nothing more. Tcl is another language with typeless simplicity. But the implementation of Tcl evolved from first implementing everything as strings, and then later having a hidden internal type system. An ideal shell would follow this example.

There should be 2 types: data and function. Data would be like in Bash - conceptually a byte stream or string. Functions should be like Elvish functions.

Output capture should be syntactically like Elvish as in (echo hi), not like Bash as in $(echo hi). Statements like if, while, etc should be implemented as built-in commands taking conditional arguments and function arguments like in Elvish. Conditional arguments should evaluate to the strings "true" or "false". Any other value is an error. Numeric expressions should use the same command/prefix syntax as everything else, like in Elvish.

One nasty quirk of Bash is that with whatever $(echo hello world), whatever gets passed 2 args "hello" and "world". For 1 arg, you must do whatever "$(echo hello world)". Elvish gets this right and doesn't require quotes. My shell is the same, and whatever (echo hello world) would pass 1 arg "hello world".

There is no need for Bash's <, >, or &. Instead of whatever <file do cat file | whatever. Instead of whatever >file do whatever | to file. Instead of whatever & do background {whatever}. This is conceptually simpler.

Variables also don't deserve special treatments in a shell language. Instead of NAME=Bob; echo $NAME do set NAME Bob; echo (get NAME). Don't tell me that this is too verbose. A shell language is not for writing big programs. And my way is conceptually simpler. It is also more flexible, allowing one to simulate arrays and maps like this:

set i 1 set a[(get i)] first echo (get a[(get i)])

Yes this is verbose. As Alan Kay said "Simple things should be simple; complex things should be possible.". This example is a complex thing for a shell.

I could go on, but you get the idea. Just show this page to any member of modern culture and see how much they hate it. That would be proof that this is a good idea. If you have an idea that would be even more hated than mine, then it would be a better idea. Anyway, no one is going to implement any of this. But this idea is at least an example of reactionary design.