Chris F.A. Johnson
Unix shell programming notes

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:

  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.

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 28 Mar 2013