30 November 2011
Why you should not use C shell
Before POSIX shells became generally available, many people used the C shell as their interactive shell. It has a number of features that were lacking in the Bourne shell, including arithmetic and command history. However, when it comes to writing scripts, it has many drawbacks.
The best-known argument against csh
programming
is Tom Christiansen's article,
Csh Programming Considered Harmful
Bruce Barnett has described many of the problems in his articles Top Ten Reasons not to use the C shell and C shell problems.
In the first of those articles, he expands on these 10 problems:
- The Ad Hoc Parser
- Multiple-line quoting difficult
- Quoting can be confusing and inconsistent
- If/while/foreach/read cannot use redirection
- Getting input a line at a time
- Aliases are line oriented
- Limited file I/O redirection
- Poor management of signals and sub-processes
- Fewer ways to test for missing variables
- Inconsistent use of variables and commands.
Since, as Bruce says in the first of the above
articles, "UNIX was hard enough to learn, and spending
months to learn two shells seemed silly", I recommend
using a Bourne-type interactive shell, and I specifically
recommend bash
.
The only reason to use csh
is to maintain
existing code, and even then, I'd recommend converting it to a
better shell.
It will save you time and headaches in the long run.
If you really do need help with a csh
problem,
try
Bruce's csh page.
Modified 01 Feb 2021