正当我满心欢喜,打算看看C Shell到底是何方神圣,并重新温习一下的时候,我居然发现了这篇文章,既然发现了,就转载一下吧。
正如作者最后说的一样,别重复犯他犯过的错误, ^_^
=================================================
Top Ten Reasons not to use the C shell
=================================================
Written by Bruce Barnett
With MAJOR help from
Peter Samuelson
Chris F.A. Johnson
Jesse Silverman
and of course Tom Christiansen
Updated:
September 22, 2001
November 26, 2002
July 12, 2004
February 27, 2006
October 3, 2006
January 17. 2007
November 22, 2007
Thanks to the following for finding typo’s etc.
Ed Morton
In the late 80’s, the C shell was the most popular interactive
shell. The Bourne shell was too “bare-bones.” The Korn shell had to
be purchased, and the Bourne Again shell wasn’t created yet.
I’ve used the C shell for years, and on the surface it has a
lot of good points. It has arrays (the Bourne shell only has one). It
has test(1), basename(1) and expr(1) built-in, while the Bourne shell
needed external programs. UNIX was hard enough to learn, and spending
months to learn two shells seemed silly when the C shell seemed
adequate for the job. So many have decided that since they were using
the C shell for their interactive session, why not use it for writing
scripts.
THIS IS A *BIG* MISTAKE.
Oh - it’s okay for a 5-line script. The world isn’t going to
end if you use it. However, many of the posters on USENET treat it as
such. I’ve used the C shell for very large scripts and it worked fine
in most cases. There are ugly parts, and work-arounds. But as your
script grows in sophistication, you will need more work-arounds and
eventually you will find yourself bashing your head against a wall
trying to work around the problem.
I know of many people who have read Tom Christiansen’s essay
about the C shell (http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
), and they were not really convinced. A lot of Tom’s examples were
really obscure, and frankly I’ve always felt Tom’s argument wasn’t as
convincing as it could be. So I decided to write my own version of
this essay - as a gentle argument to a current C shell programmer from
a former C shell fan.
[Note - since I compare shells, it can be confusing. If the line starts
with a “%” then I’m using the C shell. If in starts with a “$” then it
is the Bourne shell.
————————————-
Top Ten reasons not to use the C shell
————————————-
1. The Ad Hoc Parser
2. Multiple-line quoting difficult
3. Quoting can be confusing and inconsistent
4. If/while/foreach/read cannot use redirection
5. Getting input a line at a time
6. Aliases are line oriented
7. Limited file I/O redirection
8. Poor management of signals and sub-processes
9. Fewer ways to test for missing variables
10. Inconsistent use of variables and commands.
阅读全文 »
Share This