The shok command shell
shok.io
shok.io
The command line feeds directly into the C compiler. The C compiler can JIT, and the "HolyC"[1] language has modifications which make it much nicer for command-line use.
The author added default args to C, and parentheses are optional on functions with no arguments (or all default) so:
Dir; is shorthand for Dir("*.*", FALSE);
Even cooler, it's possible to go in and edit the Dir command on the fly; since it's JITed, your changes will be there the next time you run it.[1] OK, the name is quirky but most of the changes from C have sound reasons.
It is quite primitive as languages go, though, and has some ugly quirks, but I think it's a mistake to look at it and say it needs to be changed to be more like things not designed to treat running programs as primitives. I'd rather see something from someone who said "bash is great but could be so much better!" than someone who said "bash is TEERRRRRUUUBLE and we must replace it!"
That said what I want so much more than a new shell is one that isn't stuck letting me only reason about the machine I'm logged in on. There's been a few things that call themselves distributed shells, but they're really more orchestration tools.
Makefiles make me feel the same way, but here I have little choice. You can structure them "well" but they remain essentially undebuggable bits of hell that always seem to fall apart at the worst time.
I've worked with systems that had multi-thousand-line batch files and shell scripts, and my reaction has been "this crap is unsalvageable". A lot of those systems are still in production, and the people on them hate their lives. The code is a mass of spaghetti with a bunch of behavior modified by global and environment variables.
About 30 years ago I made the statement that "BASIC programs should self-destruct after 50 edits", as a way to encourage users of that language to move on to something more better, and to limit the damage that a "mission critical" 2 KSLOC hunk of bad code incurs. I maintain this would be desirable for bash and batch-like stuff, too...
I agree that the surface syntax is bad. Unlike other languages with clear Algol influences it never got past thinking writing if backwards to end the block is clever. I'm all for fixing these sorts of things, if you're going to break compatibility with posix anyways.
Also, you miss one particularly elegant aspect of shell programming: the pipeline. It's a powerful facility of concatenative programming, but most people haven't realize it. Try to write "find . -name '*.py' | xargs cat | wc -l" in other languages. You end up either with some parentheses or intermediate variables or a loop, and in any case, much longer code.
Even erlang can be a shell and wrap around the system toolset making your basic shell scripts work concurrently.
For everyday usage the core ash shell is perfect for scripting and zsh csh or korn for interactive usage.
In my experience, most people have great difficulty correctly writing a simple loop to renames a set of files in a directory. I sumultaneously appreciate UNIX philosophy, and think the shell can be much improved by moving away from POSIX.
This is where some of the warts on a higher level than syntax come in, though, to be fair. Your example above fails in confusing -- and maybe even dangerous, depending on the command at the end -- ways if there's spaces in the filenames. One thing I would like would be a more rigid sense of arguments vs. strings and how they come out of such situations. Having to add -print0 to find and --null to xargs to make it safe for that situation is tedious and unfriendly.
Yes, that's one of the problems I'm trying to solve :)
Powershell solves this by having pipelines pass .NET objects, but I found them too heavyweight.
Here's a comparison of code to do the same thing written in Ruby:
Dir['**/*.py'].map{|f| File.readlines(f).length }.inject(:+)
find . -name '*.py' | xargs cat | wc -l
That's 60 characters versus 39 (most of these are just because the "commands" are longer – and I don't think anyone would even try to argue that 'cat' or 'wc' is more readable than 'File.readlines' or 'length').I ran them on Python 2.7's library directory and my version counted four lines more – I didn't investigate, but I think yours missed lines when cating files without trailing newline. I'd argue that's a bug in your code :)
xs.filter(p).map(f)
with filter p xs | map f
(Suppose filter and map are implemented such that they accept input either on the command line or from pipeline.) map f $ filter p xs
what, don't like the reverse order? That's fixable.
If we define # as reverse function application, it's xs # filter p # map f
or filter p xs # map f
which is quite similar to what you are looking for. import pipe
find(name='*.py') | xargs(cat) | wc().lines
The implementation of the functions is left as an exercise for the reader, but the syntax is valid.This is kind of the point.
Languages are not only about what they make possible, but also about what they encourage.
It's still in the stage of design (even the name is not actually decided!), but I've implemented a few components here and there, most notably syntax highlighting, tab completions for file names, running external programs and pipelines for external programs. I will announce it when I personally use it day to day. :)
I guess it has to do with the fact that the set of nix commands is the library, every shell has to support the process calling mechanism and conventions like environment variables and every shell must really provide concise syntax for files, streams, IPC, environment variables and jobs - which in "normal" programming languages is less of use.
This bugged me so much that I tried to find if there have been any alternatives for nix shells that are completely different from the POSIX shells - and the only ones that I found interesting are ES and SCSH: https://news.ycombinator.com/item?id=6979170
My preference is for ES. However there seems to not be much of community around. I would really love to see a bit of love for these projects.
rush Ruby Shell [1] might qualify, but it has the problem of any "innovative" shell: different special syntax and doing something so different that the transition curve is too steep for most people.
Zsh is kind of weird because it feels academic with the option of having every feature imaginable AND not having hashes or signatures with releases. The good thing about zsh is that most of it isn't loaded by default. It has modules. It has lots of neat options lacking in other shells such as case-correction and interactive completion. That's all kinds of innovative.
Bash is the mysql of shells. It's pervasive so there's loads of pressure not to innovate.
I would like to see shells' community get more like node by having minimal, focused packages of added functionality that each do one thing well, because having to declare the same primitive functions to do something DRY and useful is a pain.
[1] https://adam.heroku.com/past/2008/2/19/rush_the_ruby_shell/
[1] http://stuff.mit.edu/afs/sipb/user/yandros/doc/es-usenix-win...
[2] https://github.com/wryun/es-shell
[3] http://scsh.net/
Perhaps the open source community is currently working on something like PowerShell's PSDrives, but adoption by the teams producing large apps would be critical to its success.
Anyway, the AREXX ports from the AmigaOS era are back again. The world has come full circle.
plan 9 (http://plan9.bell-labs.com/plan9/). Virtually all of plan9's system services are exposed as filesystem servers (http://plan9.bell-labs.com/sys/man/4/INDEX.html). Some of these may astonish you - a windowing system, a FTP client, an SSH server, an authentication agent... Overall, the system is much simpler than PSDrive - PSDrive providers are full-fledged .NET objects, plan9 FS are just directory structure plus text files. Yet they achieve roughly the same thing. (Actually plan 9 does more, but I believe in principle PSDrive can be used to do these as well.)
Similar things (exposing system service as fs) is actually possible in Linux or BSD, with FUSE. You can actually wrap utilities and expose them as file servers, and there has been some limited success. But as long as upstream utilities are not adopting the FS as the primary API (which is unlikely), I don't think it's really going to take off.
I find myself using %x() while in irb all the time.
My typing barrier for %x(ls) is too high.
You could totally make Ruby turn ": ls" into "%w(ls)", or whatever other symbol.
This just seems a lot more work for the same thing.
shok could have put ruby or python or some other language behind its {} syntax. That would be less NIH-syndrome, but maybe there's merit to trying something more ambitious. Or maybe not.
{#!python
do dome python...
}Also, I'll just leave this here: http://devopsanywhere.blogspot.com/2011/09/how-ruby-is-beati...
(Actually plan9 rc is earlier than that.)
that's all you need. ls is a little more tricky but nothing that a very simple init.py couldn't fix, then you'd have the full and awesome power of python to do shell things. We don't need a new *sh that half assed implements a language otherwise we'll just end up with another syntactically primitive language like bash, zsh, etc.