Command Shells - The Quirks, The Pros and The Cons 17
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.
bash, bourne, ksh, csh (Score:3)
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
Oops. (Score:2)
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
Migration/learning curves (Score:2)
tcsh has limited spell checking (Score:1)
Don't forget zsh... (Score:2)
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!
--
Intersting pages, comparing theses shells (Score:1)
http://www.nscp.umd.edu/shells.html
http://www.ntlug.org/~cbbrowne/unixshells.html
Re:Oops. (Score:1)
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
tcsh tab completion (Score:1)
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.
Re:Don't forget zsh... (Score:1)
TCSH (Score:1)
Re:Don't forget zsh... (Score:2)
63132 /bin/ash /bin/bash /bin/ksh /bin/tcsh /bin/zsh
373176
166544
262184
340548
(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.
What's the difference btwn ksh/bash for scripts? (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--
Re:Don't forget zsh... (Score:1)
63132
373176
166544
262184
340548
(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.
--