C shell

C shell

The C shell (csh) is a Unix shell developed by Bill Joy for the BSD Unix system. It was originally derived from the 6th Edition Unix /bin/sh (which was the Thompson shell), the predecessor of the Bourne shell. Its syntax is modeled after the C programming language. The C shell added many feature improvements over the Bourne shell, such as aliases and command history. Today, the original C shell is not in wide use on Unix; it has been superseded by other shells such as the Tenex C shell (tcsh) based on the original C shell code, but adding filename completion and command line editing, comparable with the Korn shell (ksh), and the GNU Bourne-Again shell (bash). An independently-developed and modernized C shell, created by Nicole Hamilton, also survives on Windows in the form of Hamilton C shell.

Features

The C shell has the typical Unix shell structure: each line of input (or line of a script file) is interpreted as a separate command to execute, with backslashes "escaping" newlines where needed (so that multiple input lines can comprise a single command to be executed).

New features

These features were first introduced in C shell, though most are now common to many Unix and Unix-like shells.;Job control :The ability to suspend an interactive job and resume it at a later time, or send it into the "background".;History substitution :The !-substitution feature allowed previous commands to be re-executed or edited in a variety of ways.;Arrays :Variables could contain multiple elements, which could be numerically indexed.;~ expansion :Home directory by username lookup, using ~ was popular enough that most modern, Unix-based Web servers now support it [ [http://httpd.apache.org/docs/2.0/urlmapping.html#user Mapping URLs to Filesystem Locations - Apache HTTP Server] ] , in addition to most shells.;Aliases :A command could be aliased to another command or command sequence.;Math operations :Provided arithmetical operations which sh does not provide except by calling external programs.

Syntax differences

The most obvious difference between C shell and Bourne shell syntax was the use of parentheses for built-in conditional operations that Bourne shell called out to test for using square brackets (later versions of Bourne shell would rectify this by using a built-in test operator).

Variable assignment was also performed slightly differently with "set a = b" rather than Bourne shell's "a=b".

Criticism

While the C shell introduced many innovative features in interactive mode, the C shell's scripting capabilities came under criticism in the early-to-mid 1990s for their ambiguity, especially with respect to quoting and redirection. Combined with the fact that Bourne shell is guaranteed to be present on all Single UNIX Specification-compliant systems, sh is usually used for scripting purposes over C shell on Unix.

An example of possibly unwelcome behaviour of csh scripts is the following: if ( ! -e foo ) echo bar > fooIt would appear to say "if file 'foo' does not exist, create it with contents 'bar'". But it will in fact create an empty file, as the line is parsed such that the output redirect is set up before the file existence is tested. (These and other criticisms do not, however, apply to the more-modern Hamilton C shell variant of the csh language. Also, if the above example were written using the full 'if then endif' construct, then the file 'foo' will contain the word 'bar' and hence csh does what was intended.)

If scripts are written in csh, it is often useful to run the script with the -f flag, (e.g. by starting with the line #!/bin/csh -f) in order to avoid running the user's setup file as this may affect the script's behaviour.

Another known problem of csh is its message "0 event not found", which yields no information about what the problem is.

ee also

* Comparison of computer shells
* test (Unix)
* tcsh, a Unix shell based on and compatible with the C shell (csh)

References

External links

* [http://www.kitebird.com/csh-tcsh-book/csh-intro.pdf "An Introduction to the C shell"] by William Joy
* [http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ "Csh Programming Considered Harmful"] by Tom Christiansen
* [http://www.grymoire.com/Unix/CshTop10.txt "Top 10 Reasons not to use the C shell"] by Bruce Barnett
* [http://www.hamiltonlabs.com/cshell.htm Hamilton C shell]


Wikimedia Foundation. 2010.

Look at other dictionaries:

  • Shell-Gabon — Shell (entreprise) Pour les articles homonymes, voir Shell. Shell Logo de Shell …   Wikipédia en Français

  • Shell (compagnie) — Shell (entreprise) Pour les articles homonymes, voir Shell. Shell Logo de Shell …   Wikipédia en Français

  • Shell Gabon — Shell (entreprise) Pour les articles homonymes, voir Shell. Shell Logo de Shell …   Wikipédia en Français

  • Shell Sénégal — Shell (entreprise) Pour les articles homonymes, voir Shell. Shell Logo de Shell …   Wikipédia en Français

  • Shell Nigeria — is the colloquial name for Royal Dutch Shell s Nigerian operations carried out through four subsidiaries primarily through Shell Petroleum Development Company of Nigeria Limited (SPDC). Royal Dutch Shell accounts for more than 40% of Nigeria s… …   Wikipedia

  • Shell in situ conversion process — Shell ICP Process type chemical Industrial sector(s) chemical industry, oil industry Feedstock oil shale Product(s) shale oil Leading companies …   Wikipedia

  • Shell — Shell, n. [OE. shelle, schelle, AS. scell, scyll; akin to D. shel, Icel. skel, Goth. skalja a tile, and E. skill. Cf. {Scale} of fishes, {Shale}, {Skill}.] 1. A hard outside covering, as of a fruit or an animal. Specifically: (a) The covering, or …   The Collaborative International Dictionary of English

  • Shell bit — Shell Shell, n. [OE. shelle, schelle, AS. scell, scyll; akin to D. shel, Icel. skel, Goth. skalja a tile, and E. skill. Cf. {Scale} of fishes, {Shale}, {Skill}.] 1. A hard outside covering, as of a fruit or an animal. Specifically: (a) The… …   The Collaborative International Dictionary of English

  • Shell button — Shell Shell, n. [OE. shelle, schelle, AS. scell, scyll; akin to D. shel, Icel. skel, Goth. skalja a tile, and E. skill. Cf. {Scale} of fishes, {Shale}, {Skill}.] 1. A hard outside covering, as of a fruit or an animal. Specifically: (a) The… …   The Collaborative International Dictionary of English

  • Shell cameo — Shell Shell, n. [OE. shelle, schelle, AS. scell, scyll; akin to D. shel, Icel. skel, Goth. skalja a tile, and E. skill. Cf. {Scale} of fishes, {Shale}, {Skill}.] 1. A hard outside covering, as of a fruit or an animal. Specifically: (a) The… …   The Collaborative International Dictionary of English

  • Shell flower — Shell Shell, n. [OE. shelle, schelle, AS. scell, scyll; akin to D. shel, Icel. skel, Goth. skalja a tile, and E. skill. Cf. {Scale} of fishes, {Shale}, {Skill}.] 1. A hard outside covering, as of a fruit or an animal. Specifically: (a) The… …   The Collaborative International Dictionary of English

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”