Slashdot Mirror


Which Shell Do You Prefer?

Pascal de Bruijn asks: "I recently started to use NetBSD, the first thing I noticed was that it didn't have a command-line history. So I immediately wanted to switch my shell, being on BSD my first instinct was to change to tcsh, but many people told me it wasn't any good. Others recommended zsh. I would really like to hear your opinions about shells." The submitter is particularly interested in shell memory usage, and the features you like...and dislike...from the current options that are available, today.

28 of 138 comments (clear)

  1. command line history by eXtro · · Score: 5, Informative

    did you try enabling it, it's off by default

    set history=1000
    - or maybe -
    history = 1000
    - or possibly -
    set history 1000

    I've never seen a shell without command line history, but I've logged into a lot of places where it wasn't turned on by default.

  2. conch by dynoman7 · · Score: 4, Funny

    nuff said

    --
    Blarf.
  3. Huh? by Anonymous Coward · · Score: 3, Informative

    I recently started to use NetBSD, the first thing I noticed was that it didn't have a command-line history.

    It? Command-line history isn't a feature of an operating system, it's a feature of a shell.

    my first instinct was to change to tcsh, but many people told me it wasn't any good.

    Read csh programming considered harmful. It's not really sensible to write shell scripts using one shell and use another, so steer clear of csh.

    Many people like zsh for it's completion routines, but I believe bash has similar facilities by now.

    1. Re:Huh? by AtrN · · Score: 3, Informative
      Command-line history isn't a feature of an operating system, it's a feature of a shell.

      It can be a feature of the operating system. With pty's you can insert arbitrary filters into the input stream allowing consistent editing across all programs that do terminal input. I've used ile in the past to do this. The benefits include one editor interface and programs not needing to know about and include the editor. There's a trade off (of course), without knowledge of the editor the programs can't tailor it to specific uses, such as programmable completion. It could be but the editors need to provide facilities to allow such control and they don't AFAIK. It would nice if they did.

  4. I prefer... by orthogonal · · Score: 3, Funny

    Conch shells.

    If your plane crashes on a deserted island, and you get the conch shell, you 0\/\/n3rs the island.

  5. bash by Apreche · · Score: 3, Insightful

    I like bash. It's common, fairly standard. It has history and tab completion. That's all I really need or use. I have it in linux/solaris/cygwin so I'm rarely forced to use something else. Never really cared or needed to use something else.

    --
    The GeekNights podcast is going strong. Listen!
  6. I use gdb by sigwinch · · Score: 3, Funny

    Hands down the most powerful shell there is.

    --

    --
    Kuro5hin.org: where the good times never end. ;-)

  7. zsh by dhall · · Score: 3, Informative

    I originally chose this shell back in '92 for the right hand prompt. A 'spiff' feature for a shell chocked full of features. It was also the first shell to have a truly programmable completion. It has all the interactive add-on's for tcsh, with the base template built off of Korn Shell (so you don't have issues with scripting in something separate from a Bourne derivative).

    The z-shell is so filled with features at this point, it's nearly become the "emacs" of shells, and yet, it's memory footprint for the same tasks is smaller than either bash or tcsh.

  8. Which Shell? by Captain+Large+Face · · Score: 3, Funny

    Royal Dutch?

    "When you absolutely, positively have to murder every Ogoni protester in the Niger Delta, accept no substitute."
  9. Bash is the One True Shell, ksh is very close by afabbro · · Score: 4, Informative
    Yes, I'm (mostly, as much as ever) serious.

    When picking a shell, you should consider:

    • how easy it is to work with interactively
    • how easy it is to code (yes, I write 99% of my stuff in perl or whatever, but you will need to script some day, mark my words...if nothing else, system startup scripts for Solaris, AIX, etc.)
    • how standard is it on what type of Unices you work on.

    The candidates:

    sh is too primitive in terms of user features, period. No one uses the Bourne shell if they can help it.

    csh/tcsh...well, google for "csh Programming Considered Harmful" to see its many internal bugs. Also, most of the major Unices don't use it (Solaris, AIX, Linux - I guess *BSD might still) for their system stuff. If it's not considered a good scripting platform AND most Unices don't use it for their scripts...

    zsh - From what I've read, a good shell, but very nonstandard. Do you really want to lug a shell around and install it (and set up /etc/shells or whatever each time, etc.) for every machine you log into?

    ksh - sh scripting with all the good interactive features. A really solid shell and a very good choice. All the sh goodness with the t/csh interactive features added.

    bash - I think bash is a little better than ksh because some of its interactive features are better. Tab-completion is better than ESC-\. The way the shell handles tab completion is better (X possibilities, do you want to see?) Lots of little things like that. Benefits greatly from reimplementing ksh. Installed by default on all Linux distros (except tiny niche players) and Solaris since Solaris 8...easy to build and install on AIX or *BSD (and HP-UX I'd guess, I don't know)

    bash is the best shell in my opinion and I have no qualms about defending it. ksh is a reasonable second choice and some people prefer it. zsh may be in the running but never caught on widely. Everything else is inferior.

    --
    Advice: on VPS providers
    1. Re:Bash is the One True Shell, ksh is very close by keramida · · Score: 3, Interesting
      No one said the shell you use has to be the one you program in. I prefer to use tcsh for my interactive shell (it does everything that I need it to), but use sh for shell scripting (since it's on every platform I work on).

      True, true. There are times though that one has to type on the prompt things like:

      $ for fname in $( cmd | sed | awk | grep ) ; do \
      stuff "${fname}" ; done

      The scriptability of the shell right there on the command prompt, is probably the only reason I use bash as my login shell even on BSDs.

      --

      --
      My other computer runs FreeBSD too.
    2. Re:Bash is the One True Shell, ksh is very close by eyez · · Score: 3, Informative

      csh/tcsh...well, google for "csh Programming Considered Harmful" to see its many internal bugs. Also, most of the major Unices don't use it (Solaris, AIX, Linux - I guess *BSD might still) for their system stuff. If it's not considered a good scripting platform AND most Unices don't use it for their scripts...

      Um. I'm sorry, but I don't see how (t)csh scripting equates to it's value as a login shell. Yes, it can be ugly to script in csh, mainly due to it's lack of function support, but it's a very nice shell to use for day-to-day use. It's completion system is extremely sane, and it has lots of extra convenience setups, and many cool extras.

      zsh - From what I've read, a good shell, but very nonstandard. Do you really want to lug a shell around and install it (and set up /etc/shells or whatever each time, etc.) for every machine you log into?

      Zsh is actually my favorite shell. The way I have it set up, if I run into a machine where zsh isn't available, I have a backup tcsh config which works very similarly to my zsh config. Thing is, most of what I do with zsh also works on bash, too.

      Of course, that's not WHY I use zsh. Well, it may be part of it, but more importantly is that zsh really is designed to be the most configurable shell around. you can make it do /anything/, given a certain varying amount of work. I'm far too tired to go into any sizeable amount of detail about it, but there's plenty of documentation on zsh's site.

      My point, though, is that EVERYTHING bash can do, zsh can do at least as well and often better. So even if you have the extra power of ZSH on your most-used machines that you may have control over (and many administrators, as long as they're not total jackasses, will listen to someone who asks for a zsh install), and another shell (I use tcsh because i like the syntax of their while/if/etc stuff better, but it doesn't matter that much) anywhere you can't get it, and not suffer too badly over it. You'd just miss out on the extra nicenesses of zsh on machines you didn't have the authority/energy to make it work on.

      And one smaller point: Zsh's POSIX-sh compliance is actually better in compliant mode than Bash's is in sh-compliant mode. You really do get a lot out of zsh as a shell, even if it can be a bit harder to configure.

      --
      get 0wned. irc.w30wnzj00.com
  10. GDB is my shell. by Anonymous Coward · · Score: 3, Funny

    Real men have a perl script to search through all .h's and .so's on the system, and make up an executable including and linking them all, and just printing "hello, world.".

    Then they run that in GDB and break. Instead of rm they use "p unlink("file");" Occasionally they might break down and use "system("shell command\n"); but only if no one is looking.

  11. Zork shell! by tm2b · · Score: 4, Funny

    I prefer the adventure shells.

    The core cannot defend itself. It dies.

    --
    "It is our blasphemy which has made us great, and will sustain us, and which the gods secretly admire in us." - Zelazny
  12. Shells aren't for scripting. by mellon · · Score: 4, Interesting

    We use bash/bourne shell for scripting because it's available on every operating system, and its behavior is reasonably predictable. It would be insane to write a shell script in tcsh, for example (not that I haven't done it... :').

    However, if you really want to write a quick script, something like Perl or Python is a better choice, unless you really need that portability. And if you really want a nice UI, well, you should use what works for you.

    On that basis, I use tcsh. it is not superior to bash - if anything, bash is, taken as a whole, superior to tcsh. Likewise ksh. But I'm not using all the features of ksh or bash, and because of my own personal history - what I imprinted on - I find tcsh much more predictable. Its behavior is also more similar to emacs' behavior than bash's behavior, and I use emacs. So for me, tcsh is the right choice.

    You said you use tcsh elsewhere. So to some degree you've probably imprinted on it. It's brave of you to decide to check out the competition, but it's going to come down to a matter of personal preference, so my advice to you is to personally check out the competition - don't take our word for it. This is a productivity tool, so pick the one that works nicely for *you*.

    Having said that, the obvious competition to tcsh is bash, and it's getting to the point where it's pretty much ubiquitous, so that is what I'd suggest you check out. Switch to bash for a month. Try to customize it to your liking. After a month, switch back to tcsh. If you find yourself missing bash, switch back to bash. If you find yourself happy and relieved to be back home, stick with tcsh. If you find yourself still on the fence, use bash, because it's more likely to be installed on random machines that you log into (into which you log?).

  13. A few more details by devphil · · Score: 5, Informative


    Some random facts:

    • Anyone spending more than a brief amount of time on a *nix system should learn how to use the basic sh commands, even if it's not their login shell? Why? Because 1) most system-level scripts are written in sh, and 2) when major programming languages perform a "shell" call, e.g., system(), it uses sh to do the work.
    • There is a POSIX specification of sh which cleans up all the wacky historical bugs. The resulting shell is actually ksh.
    • The csh/tcsh family were originally meant to be more friendly to programmers (a C-style syntax), but it all seriously backfired. Every other shell allows the user to write subroutines. Not csh. Instead, you get a goto command. No, I'm not joking.
    • tcsh is just some user-friendly features added to csh, but the annoyances and lack of comparative features just doesn't make up for it.

    The only real choices today as far as user login shells go are bash 2.x, ksh (ksh93, not ksh88), and zsh, all of which continue to cross-pollinate good ideas.

    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
  14. zsh by honold · · Score: 4, Informative

    i was convinced by adam spier's page and the zsh faq to give zsh a try - it was even a netbsd system that prompted it. i got sick of administering freebsd/opensbd/netbsd with different shells and i wanted to standardize on something with the features i wanted.

    bash was tried first, but when i started playing with misc options like vi mode, got deeper into completion, etc i realized that bash/ksh weren't appropriate long-term choices for me. auto cd to directories, amazing completion options, typo correction, shared history, and a proper vi mode (see this for the confession from gnu's docs).

    'knowing' zsh will largely translate to bash/ksh systems when you use them and zsh is not available - you'll just be reminded of their shortcomings :) the basics are largely identical.

    the new unix power tools book also makes much mention of zsh.

  15. what the fudge? by josepha48 · · Score: 3, Insightful
    Hmmm.

    This is a preference thing more than anything else. If you want tcsh on NetBSD cd /usr/pkgsrc/shells/tcsh && make install

    I've used csh, sh, tcsh, ksh, and bash. I think at one point I used zsh. I found that tcsh, bash and zsh are usually similarly setup, and allow using the arrow keys and tab completion. History is something that you set up, and in these 3 shells its always been setup for me. In using ksh, csh and sh, my experience was eew eew eew, but that is just me. I was used to bash at that point. Bash can be a hog or so I am told. I never measured, ub tit does a lot and it is probably not something you'd want if you were building a flopy based distro. Tcsh is not that bad, and can be added nowadays to just about any UNIX platform. Zsh is supposedly better, but I never used it enough to know if it truely was.

    If you are going to do shell scripting then I'd suggest sh for shell scripting. Of course you can write scripts in sh and use tcsh or any other shell if you know what you are doing. Uisng sh for scripting is more portable than perl, tcsh, ksh or bash, as sh is going to be on all modern unix systems. Perl may be on all systems, but don't rely on it. Csh does not allow shell functions, which are kinda handy. Ksh is Suns shell (I think) and I know it is not available on every platforms.

    What do you prefer to use that is the real question. Personally I can make just about any shell work for me if I have to....

    --

    Only 'flamers' flame!

  16. Korn shell by Cuchullain · · Score: 3, Interesting

    Korn is a great shell, and he is constantly working on it, so it is getting better and better.

    It is the shell I find most often on the commercial boxen that I need to work with, so I use it on linux and freebsd too. I'm certain that there is a version available for netbsd too. pdksh is a distant second to the real thing, so go grab the official ksh! It isn't pure from an open source viewpoint, but I am answering in terms of practicality not idealism.

    You can grab it from att labs' page if I remember correctly. It is the gold standard for 'correct' behavior as far as I am concerned, and is what you will find on a whole slew of different *nix boxes.

    I try to avoid bash, because though it is a really nice shell, I never find it on commercial systems, and I want my shell to behave consistently wherever I am.

    Cuchullain

    --
    "If sharing a thing in no way diminishes it, it is not rightly owned if it is not shared." -St. Augustine
  17. duh (-1 redundant) by GiMP · · Score: 4, Funny

    I'll be modded down for this but:

    root shells.

  18. Re:bash by SN74S181 · · Score: 3, Insightful

    bash is an extend-and-embrace version of /bin/sh: it encourages people to write broken shell scripts.

    On some of the GNU systems, i.e. Linux, /bin/bash is the automatic replacement for a nonexistent /bin/sh, so people write what they think are generic shell scripts, but carelessly include bash-only features. Then their scripts won't work on systems without /bin/bash.

    bash is sorta like Microsoft's Java implementation in that way.

  19. should make a poll out of this by zatz · · Score: 4, Informative

    I would vote for zsh, personally.

    I've actually had bash segfault on me a few times, which zsh has never done. and zsh uses less memory unless you do abusive things via scripting or the command line editor. zsh scripting is a superset of sh, so the things I try generally work; csh users can have a similar experience after setting a few options. (But remember, csh programming Considered Harmful.) I've become accustomed to spiffy zsh features like reporting when other users log in and out (before the prompt, just like new mail), extended globbing, very customizable completion behavior, being able to tab-expand history references (makes trying "!rm" much less dangerous), and so forth.

    It's even the little things. Like, zsh expands commands when it prints a job completion report, but bash doesn't; so if you have a loop which does something on a bunch of items, each of which can complete in the background, under bash you get a report where each item looks like "[%] Done wget $i" or something equally useless, but under zsh you can see the actual text of the command that finished.

    I have 100+ lines invested in the four rc files for zsh by now, so something new might not be immediately superior for me. I have been meaning to seriously try out es and rc for years.

    --

    Java: the COBOL of the new millenium.
  20. zsh is the supreme power user's shell by mbogosian · · Score: 4, Interesting

    csh/tcsh...

    I'm really disappointed that this is the default shell in OS X. Using tcsh is downright painful for anyone used to real tab-completion (e.g., zsh, bash).

    zsh - From what I've read, a good shell, but very nonstandard. Do you really want to lug a shell around and install it (and set up /etc/shells or whatever each time, etc.) for every machine you log into? ...

    bash - I think bash is a little better than ksh...


    If you're a bash user for the interactive benefits (i.e., tab completion, etc.), then you should really consider converting to zsh. It will take you a day, but you'll be glad you spent the time and you'll never go back (unless you're forced to, in which case it will be painful).

    Aside from the "embrace and extend" approach of these shells that a previous poster mentioned, zsh wins by a light year compared to anything else, especially with its tab completion libraries (imagine being able to hit TAB after typing cvs to get a list of the subcommands). Not only that, but zsh history/command-line editing are far superior (with a true emacs-style kill ring and real multi-line command editing). The learning curve can be steep, but there are plenty of tutorials out there to get you started. zsh is the power user's shell of choice if you spend any time in the shell (this is coming from a six-year bash zealot).

  21. eshell actually *is* a useful choice by LeninZhiv · · Score: 3, Informative

    Of course I realise you're joking, but Emacs actually does come with a built-in shell, eshell.

    What rocks about it is that it's written in Emacs lisp, so you can use it on anything Emacs runs on. It's very nice to be able to fire up a Unix-like shell on Windows for those of use who prefer a cli approach and have never adapted to the MS-DOS tradition.

    Still though, when I am in a Unix environment I like zsh for my login shell, which still has a more features.

  22. Re:bash by divbyzero · · Score: 3, Insightful

    Whatever the intentions of Bash's authors with regard to "embrace and extend" tactics, it can be used perfectly safely, and may well be convenient for the poster.

    Bash is one of those programs which acts differently depending on the filename of its executable. When invoked from a copy or a link named /bin/sh, it emulates the traditional Bourne shell without GNU extensions.

    Thus, always write your scripts with the traditional #!/bin/sh shebang. If Bash is masquerading as Bourne, it won't hurt you that way. You can still benefit from Bash's extensions for interactive use (such as command editing and history) by setting your shell to /bin/bash via chsh.

    --
    But my grandest creation, as history will tell,
    Was Firefrorefiddle, the Fiend of the Fell.
  23. UNIX shell FAQ by scubacuda · · Score: 5, Informative

    While surfing the web for FAQs on UNIX shells, I came across this popular FAQ on the differences between shells and how to choose.

    There's a great table in there that lists the features of each.

  24. Nope, bash has that too. by devphil · · Score: 3, Informative


    Programmable completion has been in bash for a while now. See the original project page for more, or use the debian bash package, which includes the completion libraries by default.

    I actually had to disable the cvs-subcommand-autocomplete. I would try to complete the name of an actual file, and the cvs-completion would fire... generating network traffic to the CVS server... taking forever... when all I wanted was a local filename.

    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
  25. why I use csh instead of sh... by Jamie+Zawinski · · Score: 3, Interesting

    I never write scripts in csh (I use perl or sh) but I still use csh as my interactive shell, because (aside from trivially launching programs) the most common thing I use any of the actual syntax of the shell for is pounding out stuff like:

    • foreach f ( *.jpg )
      djpeg $f | pnmscale ... | cjpeg > $f:r-thumb.jpg
      end

    sh/bash don't support the $var:r and related syntaxes, and so it's a lot more typing to do:

    • for f in *.jpg ; do
      djpeg $f | pnmscale ... | cjpeg > \
      `echo $f | sed 's/\..*/-thumb.jpg/'`
      end