 |
 |
What are the relative merits of different shells like tcsh, bash, etc?
|
 |
|
 |
|
Forum Regular
Join Date: Jun 2002
Location: New York
Status:
Offline
|
|
Hello,
I started using UNIX last year when I went off to school, got a new iBook with 10.0 (!) and an account on my university's *NIX cluster.
At some point I found out that the default shell on OS X is tcsh and that I was using bash on the cluster.
Aside from cosmetic differences, I can't see the merits of using one over another.
I imagine that shell selection is an important and rationalized decision for bigtime UNIX savages but is somewhat meaningless if one only plans to use the 100 or so most-used commands.
What are the factors that come into play when selecting a shell? Why use one instead of another? Why did Apple choose tcsh?
Thanks,
Peter
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2001
Location: Provo, UT
Status:
Offline
|
|
I think a lot of people like tcsh for their interactive shell. Other popular ones are zsh and bash. Bash is popular on Linux and a lot of people prefer in on their OSX machines as well. Zsh does a little bit more automatically for you as I understand.
By and large though most have the same basic features and unless you are using the shell a lot you'd not care too much.
For scripting you should use sh as csh implementations seem to vary from machine to machine a lot. So code you think works may function subtly differently on other systems. Because of this there is a general consensus that one ought normally avoid csh programming. (Although I have a few csh scripts, since that's what I learned to script on way back in college)
Bash is a superset of sh optimized for interactive use and it adds a few exra scripting features. I can't recall if it comes standard on OSX though. I think you have to install it with Fink, although I could be wrong.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: May 2001
Location: Earth
Status:
Offline
|
|
Originally posted by clarkgoble:
Bash is a superset of sh optimized for interactive use and it adds a few exra scripting features. I can't recall if it comes standard on OSX though. I think you have to install it with Fink, although I could be wrong.
I think bash comes preinstalled with Jaguar. No need to install it with fink.
|
|
|
| |
|
|
|
 |
|
 |
|
Moderator 
Join Date: Apr 2000
Location: Gothenburg, Sweden
Status:
Offline
|
|
If you're used to bash, keep using bash. Both zsh and tcsh are more powerful, but us mortals usually don't even notice. The difference lies in programmable completion and history features, stuff most people don't bother with.
Zsh and bash are reasonably similar, but tcsh is a very different bird. If you feel that you need some feature thatbash doesn't have, try zsh first as it will feel more familiar to a bash switcher.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Apr 2001
Location: Bethesda, MD
Status:
Offline
|
|
Tom Christiansen, the Perl guru, wrote a big, long treatise about why scripting in csh bad compared to sh.
But I still use tcsh for interacting and simple scripts. I started using csh in college many years ago, and stuck with tcsh because I never saw a need for anything else. For more complicated things I use perl.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2001
Location: Provo, UT
Status:
Offline
|
|
There is a faq on zsh I found as well.
http://www.faqs.org/faqs/unix-faq/shell/zsh/
I don't do enough in the shell to really justify things that much. Generally 99% of what I do is copying files, opening files via BBEdit, and occasional compiling. For anything more complex I either use Python or Applescript. I do a bit of scripting with sh, but must admit that I like the syntax of csh better. But even there 90% of my scripts are just entering commands with little by way of loops or so forth.
I did a little Perl programming a few years back, and I'm seriously thinking of checking it out again for dealing with text parsing stuff I may need to do. Python will do that, but I've been told it is a little simpler in Perl (once you get past the archane syntax)
After playing around with tcsh and bash (on my server) I decided that the main differences were over things where you are using the keyboard to do EVERYTHING. While that may be great for keyboard purists, I can think of better things to do with my memory than memorize all those commands. Generally if I want to modify slightly a command from three lines earlier I'll just break out the mouse and copy and paste. Much easier and I don't have to remember some mixture of vi and emacs commands.
|
|
|
| |
|
|
|
 |
|
 |
|
Moderator 
Join Date: Apr 2000
Location: Gothenburg, Sweden
Status:
Offline
|
|
Originally posted by davechen:
Tom Christiansen, the Perl guru, wrote a big, long treatise about why scripting in csh bad compared to sh.
But I still use tcsh for interacting and simple scripts. I started using csh in college many years ago, and stuck with tcsh because I never saw a need for anything else. For more complicated things I use perl.
That treatise is a bit outdated - tcsh fixes most of those bugs, and the only real problem is the stupdity about stderr and stdout. If we're quoting Perl gurus, I'd like to enter one:
"It is easier to port a shell than a shell script." -- Larry Wall
(Larry Wall is the author of Perl, and the author of more quotes than I care to count...)
A script language like Perl or Python is many times a better choice than writing a shell script. The overhead associated is not large enough to be an issue - and if you really need speed, you should be writing in C anyway.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Dec 2002
Status:
Offline
|
|
I think the important thing is to pick a shell that has a syntax you both like and can understand.
I started out years ago, I think it was 1994, on Ultrix using sh. Today I do almost all of my interactive work in bash, regardless of whether it is on Solaris, Linux or OS X, and almost all of my shell programming in ksh -- I can see a time not too far out when all of my scripts will be in bash too.
Bottom line is pick one you like so you can become proficient with it.
BTW - Perl is an excellent scripting language and I've written lots of stuff using it but Larry Wall is wrong, a well-written shell script ports easily.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|