views:

833

answers:

7

I use bash, and have done so for over a decade - but occasionally I wonder whether there has been any significant new developments in the world of Linux shells.

A few years back Microsoft released PowerShell, which seemed very interesting. Is there any comparable innovation going on in Linux shells?

+7  A: 

I'd take a look at zsh or fishshell.

stonea
One consideration about zsh and fishshell is we aren't allowed to use either at work. And I don't seem to be alone. So although they are nice, they aren't as valuable as bash in the work place, unless you can choose for yourself.
Robert Gould
Seems like changing shells would be easy. You don't have to have it as the login shell, you could just run it once you have logged in.
stimms
+4  A: 

I think the "original improved shell" is ksh93. bash came into existence at a time when the ksh source code was proprietary; if ksh had been open-source then, it might not have been deemed necessary to have a new shell (though with the FSF you never know). ksh is worth studying, especially for its ability to be extended through C modules, but it's not a clear win over bash. bash's autocompletion is clearly superior, which may be enough to make bash a win overall. In any case bash and ksh have made substantial effort to converge, so differences are minor.

The other interesting shell is zsh, which attempts to be everything that ksh is while also including csh. Since I never saw any point or use to csh, I am not the right person to advocate for zsh. I will point out one unusual incompatibility: by default, in zsh a variable $var always expands to a single token, even if it contains spaces. This behavior is incompatible with all other sh-derived shells, and it is occasionally inconvenient, but really it makes a lot more sense than the original, and it saves a hell of a lot of quoting.

csh was the first shell to have job control, but in my mind it (and its successors) has been superseded by bash and ksh. It was never mucn fun to write scripts in.

Finally, there are many tiny shells designed for rescue floppies (!) and other Spartan environments, but it sounds like you have little interest in those.

(In the matter of innovation, I should add that more than half the scripts I used to write as shell scripts are now Lua scripts. Others could say the same for Python or Ruby, or back in the day, Perl or Tcl. So I think the real innovation is migration away from the shell for programmable interaction at the command line.)

Norman Ramsey
ksh (or pdksh) is very easy to hack, in fact you can link it against the same line editor and autocompletion library that bash uses. What you aren't going to get is all of the GNU extensions beyond POSIX (i.e associative arrays in bash 4.0). With any shell, its easy to switch parser/grammar to use a modern language on the command line. If you google for "blue programming language", you'll see how easy it is to drop into bash.
Tim Post
+3  A: 

IIRC, Powershell is Object Oriented, whereas most unix shells and utilities operate on text. On that regard, Squirrel Shell might interest you. I've never used it, though.

Jean Azzopardi
+12  A: 

You do realize bash 4 has very recently been released with a load of new features and language additions?

  • Shell options globstar (**/foo) does a recursive search, dirspell fixes typos during pathname expansion.
  • Associative arrays, map strings to strings, instead of just numbers to strings.
  • The autocd shell option allows changing directories by just typing the directory path instead of having to put cd in front.
  • Coprocesses
  • &>> and |& redirection operators that redirect both stdout and stderr
  • Loads of additions to existing builtins for improved scripting convenience.

Check out:

lhunath
+2  A: 
cheduardo
+4  A: 

One of the least touted features of Bash (and several other shells) is the ability to write your own loadables, and have the shell run them as builtins.

Lets say you write the loadable 'on' .. and you want it to work like this:

on node 123 run some command
on class nodes run some command
on all nodes run some command

... etc ..

You can follow simple examples on how to write a loadable, then enable it as a bash built in via enable -f /path/to/loadable loadable_name

So in our case, enable -f /opt/bash/loadables/on on

... in your bashrc , and you've got it.

So, if you want to have bash interpret your spiffy new language natively, you would write a loadable named 'use' or 'switch_to', then modify the parser to load a different grammar / runtime if a certain environment variable was set.

I.e.:

#/bin/bash

switch_to my-way-cool-language

funkyfunc Zippy(int p) [[
   jive.wassup(p) ]]

Most people are not going to want to hack their shell, however. I did want to point out that facilities exist to take Bash and make it the way you want it, without fiddling too much with core code.

See /path-to-bash-source/examples/loadables, you might be able to get that to fly where you work, since you're still using Bash.

Tim Post
+5  A: 

You can run PowerShell on Linux via Pash. It uses Mono the way PowerShell uses .NET.

John D. Cook