A Shell? A Programming Language? Relax! It’s Both!

0

Every time we publish a Linux hack that uses a shell script, someone will chime in about how awful it is to program shell scripts. While we like the ubiquity and efficiency, we can’t disagree that the shell is a bit of a hack itself. [Axel Lijencrantz] wants to change your shell to be a full-blow programming language called Crush.

On the face of it, it looks like a shell. Want to see the contents of the current directory? Simple: ls.

The difference is underneath. In Crush, ls is a built-in and it returns data in rows like a database. You can manipulate that database with SQL-like commands: ls | where {type=="directory"}.

You can still treat I/O as binary streams. But Crush also knows about CSV files, JSON, line-oriented files, and several other formats. So if you were trying to feed the output of ls to a program and need it in JSON form, that’s simple: ls | json:to ./listing.json.

Crush can also do math without resorting to trickery like older shells or strange syntax like bash. The shell supports closures that you can assign to a variable to make what amounts to a function. Another welcome feature is that Crush understands the idea of namespaces.

There are a few oddities like using % as a wildcard instead of * because the * is for multiplication. However, we like a lot of the features, including simplified remote execution and the ability to create custom types.

Crush is similar to Nu, but has some different goals with respect to programming languages. If you are still writing programs in traditional shells like bash, be sure to run a linter.

For the latest tech news and updates, Install TechCodex App, and follow us on Google News,  Facebook, and Twitter. Also, if you like our efforts, consider sharing this story with your friends, this will encourage us to bring more exciting updates for you.

Source

Get real time updates directly on you device, subscribe now.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. AcceptRead More