Slashdot Mirror


Command Shells - The Quirks, The Pros and The Cons

OctaneZ asks "I am not trying to start a flame war here, but I would personally be very interested in seeing an analysis, both pros and cons, of all of the common shells: bourne, bash, csh, tcsh, and korn. I understand that a lot of linux users swear by bash because it is the default, but they all have there own "personalities" what does everyone think?" Interesting question. I'd be interested in hearing why some folks prefer csh over bash.

17 comments

  1. bash, bourne, ksh, csh by josepha48 · · Score: 3
    I have tried some of the different shells. Here is my review.

    csh: This is used as the default shell on AIX. It has some newt features like ! and !! which allow a user to automajically execute a command in the history. Bash also support shis. In fact most of what csh can do bash can do to. I often find myself usinjg csh commands in bash as I work on an AIX server machine at work. csh uses setenv where bash uses export

    ksh: or korn. I hate the name core shell it makes me think of something that wel .. it allows one to set up a command line editor. If you like vi you can have a vi on the command line sort of feeling.

    bourne: I believe the bourne shell is used on the BSD's. I did try freebsd once and believe that I was using bournce shell. I found it primative compaared to bash. There was a greater learning curve. There seemed to be more to setup, but that could have been FreeBSD itself. There was a history, but I was not sure hw to access it.

    Now bash: bash allows one to use ther arrow keys tonavigate thru the history to make executing commands easier. However this is not the only way to execute the history, one can the ! or !! (!69 will execute teh 69 th command in the history file). both ksh and bash use sthe export command to set envariables. I also believe that you can set vi as your command line editor to execute vi commands in the bash shell. To me bash is more like DOS, and thus you do not deal with the quirks of a command shell as much as you deal with the learning the unix commands, thus it is easier to use.

    just muy .02 cents. I am sure that others have there opinions. So send flames > /dev/null and moderate -1G

    send flames > /dev/null

    --

    Only 'flamers' flame!

  2. shell choice by Anonymous Coward · · Score: 0

    Personally I prefer ksh for scripting and bash for interactive use.
    I'd die without bash's command line recall.
    Korn has some very nice scripting features and works nicely when writing parallel processes.

  3. Oops. by Wakko+Warner · · Score: 2
    On all the AIX boxes I've ever administered, the default shell was ksh, not csh. Even root's shell was ksh, as was every user shell by default. I can't stand ksh as an interactive shell; it's best used for scripting, IMO. Its only saving graces as a login shell are the command-history and editing support, the first of which every other decent shell has and the second of which I've not found all that useful.

    FreeBSD's default shell is also csh. I personally cannot stand csh, but find tcsh to be perfect for an interactive command-line shell. (I prefer bash for scripting, however, but that wasn't part of the original question.) tcsh also has command-line history which can be accessed with the arrow keys like in bash.

    I tried switching my default shell from tcsh to bash this summer as a test (to become more of a stereotypical second-wave unix dork, I guess), but found it very annoying in many respects compared to tcsh, mostly in the way it handles tab-completion. Needless to say, I'm still using tcsh and probably always will be.

    (To sum it up: tcsh is the way to go for me. Stay the hell away from csh, and, if you use and like ksh, I'm worried about you.)

    - A.P.
    --


    "One World, one Web, one Program" - Microsoft promotional ad

    --
    "Remember when the U.S. had a drug problem, and then we declared a War On Drugs, and now you can't buy drugs anymore?"
    1. Re:Oops. by josepha48 · · Score: 1
      AIX uses ksh as its default? I wonder why the site I am at uses csh instead as the default for all the users and ksh for root (I had root access a few tinmes). I wonder then if csh is better for scripting than ksh, as all our scripts are in csh.

      I never tried tcsh and generally uses /bin/sh for my scripts.

      I was not aware that FreeBSD used csh, I guess that the configuration of all the aliases we have set up on our system by default has made made it easier to use. I still prefer bash.

      send flames > /dev/null

      --

      Only 'flamers' flame!

    2. Re:Oops. by Anonymous Coward · · Score: 0

      Well, one of the first things that I do with a new AIX or HP-UX box is to set up tcsh, otherwise I have the crippled troika of ksh/sh/csh to work with and that's it. I also tend to set up bash these days as all the kids ask for it. That warms my heart, by the way. Nice to see some new blood in UNIX, no matter how they are getting there (i.e., I am not sure that Linux is "real UNIX" just yet, but I am not going to look a gift horse in the mouth). Personally, I try to keep root tcsh because most old-timers are expecting that it is csh or sh, generally the former. No reason to startle anyone while they are in as root, after all!

  4. Migration/learning curves by Demona · · Score: 2

    Coming from MS-DOS and JP Software's 4DOS, I found bash the easiest shell to adapt to, as a lot of good ideas in 4DOS appear to have come from bash (most notably the up/down arrow keys to navigate command history, and tab completion). bash is a little more demanding on system resources than most of the competition, if you're limited to somewhat older hardware. I think of bash as the mutt of shells, if a bit more bloated than mutt compared to other mail agents.

    --
    Fuck Slashdot
  5. tcsh has limited spell checking by nlucent · · Score: 1

    tcsh has limited spell checking that can become quite a crutch if you use it long enough. I often find my self hitting 'y' after seeing I mispell something immediately after I hit enter expecting it to execute cat instead of car etc when Im in bash. Wow, do I get an award for that run-on sentence? Maybe fiona apple will name her next cd after this post.

  6. Don't forget zsh... by osu-neko · · Score: 2
    I'd really recommend looking at the Z shell (zsh). The tab completion in the latest versions (>=3.1) is a lot better than any I've seen in previous shells. I don't know of any features in any other shell that aren't in zsh. History (both arrows and !), command line editing, mail checking, very powerful scripting, etc, etc, etc. I think pretty much any good idea from any other shell eventually makes it into zsh, plus some original ideas as well. Downside: it is huge. This ain't the shell you want on your memory starved 386. And the man pages were so big it's actually split into 13 sections ("man zsh" will give you a list of the other 12 sections, for things like "man zshbuiltins" etc.), although I actually consider that a feature (instead of wading through the entire manual I can just bring up the section I'm looking for information from).

    Here's a sample zsh script to get the feel for it:

    #!/bin/zsh
    for file in "$@"
    do
    if [ "${file}" != "${(L)file}" -a ! -e "${(L)file}" ]
    then
    echo "${file} => ${(L)file}"
    mv "${file}" "${(L)file}"
    fi
    done

    Which naturally takes renames any file whose name is not all lowercase to be all lowercase. Great for junk imported from brain-damaged operating systems.

    Anyways, try it out yourself. Worst that can happen is you won't like it and stop using it. I doubt it, though. Try it, you'll like it!

    --

    --
    "Convictions are more dangerous enemies of truth than lies."
    1. Re:Don't forget zsh... by crbill · · Score: 1

      Agreed! ZSH is very nifty stuff, especially the customizable/programmable completion. For those that don't know, you can have zsh call different completion functions depending on the context in which the completion was requested. For example, zsh could fill in a command line like this: ssh -l {[TAB]->fill in a username} {[TAB]->fill in hostname}.

    2. Re:Don't forget zsh... by rwg · · Score: 2
      I use zsh daily on a 386/33 with 8 megs of RAM -- it really isn't any larger or smaller than its siblings.

      63132 /bin/ash
      373176 /bin/bash
      166544 /bin/ksh
      262184 /bin/tcsh
      340548 /bin/zsh
      (executable sizes)

      According to ps, memory usage among tcsh/bash/zsh is pretty close. ksh and ash have considerably smaller footprints.

      rwg 17543 0.0 0.1 1116 372 pts/7 S 01:14 0:00 ash
      rwg 17544 0.0 0.3 1680 896 pts/7 S 01:14 0:00 bash
      rwg 17545 0.0 0.1 1236 488 pts/7 S 01:14 0:00 ksh
      rwg 17546 0.0 0.4 1948 1068 pts/7 S 01:14 0:00 -csh
      rwg 17626 1.0 0.3 1700 956 pts/7 S 01:15 0:00 zsh

      I've found that zsh's usefulness outweighs any excessive memory usage it may have. Little things like being able to change directories without using cd make it almost unbearable to go back to bash or [t]csh.

    3. Re:Don't forget zsh... by osu-neko · · Score: 1
      I use zsh daily on a 386/33 with 8 megs of RAM -- it really isn't any larger or smaller than its siblings.

      63132 /bin/ash
      373176 /bin/bash
      166544 /bin/ksh
      262184 /bin/tcsh
      340548 /bin/zsh
      (executable sizes)

      Well, bash is another shell that fits into the "extremely bloated" category. Not that I consider that necessarily bad with today's typical RAM configurations. Both take a healthy chunk or real-estate more than their "competition" if you're looking at small configurations (i.e. what shell do you put on RAM disk image for your diskless net-boot machine).

      According to ps, memory usage among tcsh/bash/zsh is pretty close. ksh and ash have considerably smaller
      footprints.

      rwg 17543 0.0 0.1 1116 372 pts/7 S 01:14 0:00 ash
      rwg 17544 0.0 0.3 1680 896 pts/7 S 01:14 0:00 bash
      rwg 17545 0.0 0.1 1236 488 pts/7 S 01:14 0:00 ksh
      rwg 17546 0.0 0.4 1948 1068 pts/7 S 01:14 0:00 -csh
      rwg 17626 1.0 0.3 1700 956 pts/7 S 01:15 0:00 zsh

      Wow! That surprises me. I never bothered to check since I just plain don't use csh (the inability to easily redirect stderr makes it all but useless in my book); I never would have guessed it's such a memory pig!

      I've found that zsh's usefulness outweighs any excessive memory usage it may have. Little things like being able to change directories without using cd make it almost unbearable to go back to bash or [t]csh.

      I agree entirely. I merely brought it up because for some people, memory use is an issue. If it is, stay away from zsh and bash (and apparently csh too). If you've got a healthy chunk of memory, though, I think zsh is worth it.

      --

      --
      "Convictions are more dangerous enemies of truth than lies."
  7. Intersting pages, comparing theses shells by Khalid · · Score: 1

    You may have a look at these pages

    http://www.nscp.umd.edu/shells.html
    http://www.ntlug.org/~cbbrowne/unixshells.html

  8. tcsh by Anonymous Coward · · Score: 0

    I started to run TCSH because I wanted a shell with completion that didn't take a while to start up my programs on my DEC 5000/200. Bash took a few seconds to start up programs, while tcsh did them instantly. I believe that tcsh has a smaller memory footprint as well. Scripting should be left to bourne or ksh.

  9. tcsh tab completion by Paul+Carver · · Score: 1

    I use bash on my Linux box because the NCR and Solaris machines at work all use ksh. The struggle of constantly switching back and forth between ksh and tcsh was too much for me. Switching between bash and ksh just means fewer features rather than different commands (e.g. setenv vs. export).

    The only problem is that tab completion in both bash and ksh is brain dead; tcsh is the only shell I've used that does it properly.

    In bash you have two completion settings. 1) Complete only if there is a unique match. If there is ambiguous match, be stubborn and force the user to type more characters.
    2) Cycle through all possible matches on multiple tab presses. This is done right in tcsh, but in bash if there is a unique match this style of completion won't complete it. You have to type it manually.

  10. TCSH by evguenii · · Score: 1

    I'm using tcsh, mainly because of good completion mechanism and history access (by arrows)

  11. What's the difference btwn ksh/bash for scripts? by Mr+Z · · Score: 1

    Bourne Again Shell (aka bash) and Korn Shell (aka ksh) both are very similar at a scripting level. What scripting features are available in ksh that aren't as nice in bash?

    --Joe
    --
  12. tcsh by Anonymous Coward · · Score: 0

    I would suggest (and only suggest) that you give tcsh a try. It seems to be fundamentally different in "feel" to bash, sort of like vi (or a vi variant) is to emacs. I like vi (actually, I do fine with ed) because it is clean. But then again, I am not a code monkey (I am a hardware monkey, really), so I suspect that I just don't see the many obvious benefits of emacs. Oh well. I like vi, it is fast and clean, and tcsh has exactly the same minimal and "right" feel to it.

    If you like tcsh and vi, perhaps you should take a look at MH or nmh for a mail handler? Just a thought. You may never go back ...

    And yes, I have corrupted a lot of ksh users who were learning emacs (and were constantly angry) and hating pine this way. UNIX (any, including Linux) really ought to be clean and quick, and tcsh gives me that.

    I don't know why people like ksh. Really. I think that they are mostly unaware of the alternatives. I know that some shops would not allow any non-vendor-supplied shells, so you were stuck with SV-standard ksh or sh/csh, both of which are far less flexible than ksh, so that may be it. Which is not to say that ksh is bad for scripts -- it is great for scripts, just less great (IMHO) than tcsh or bash or zsh or almost any other modern shell.

    Here are some places to look:

    http://wwwcip.informatik.uni-erlangen.de/tree/tc sh/top.html

    http://www.eeng.brad.ac.uk/Unixhelp/Pages/shell/ oview1.1.html

    comp.unix.shell


    I used to have a mailing list for tcsh that you could subscribe to, but I cannot find it anywhere now. Anyone want to help this fellow out?