C shell
Encyclopedia
The C shell is a Unix shell
Unix shell
A Unix shell is a command-line interpreter or shell that provides a traditional user interface for the Unix operating system and for Unix-like systems...

 that was created by Bill Joy
Bill Joy
William Nelson Joy , commonly known as Bill Joy, is an American computer scientist. Joy co-founded Sun Microsystems in 1982 along with Vinod Khosla, Scott McNealy and Andy Bechtolsheim, and served as chief scientist at the company until 2003...

 while a graduate student at University of California, Berkeley
University of California, Berkeley
The University of California, Berkeley , is a teaching and research university established in 1868 and located in Berkeley, California, USA...

 in the late 1970s. It has been distributed widely, beginning with the 2BSD release of the BSD
Berkeley Software Distribution
Berkeley Software Distribution is a Unix operating system derivative developed and distributed by the Computer Systems Research Group of the University of California, Berkeley, from 1977 to 1995...

 Unix system that Joy began distributing in 1978. Other early contributors to the ideas or the code were Michael Ubell, Eric Allman
Eric Allman
Eric Paul Allman is an American computer programmer who developed sendmail and its precursor delivermail in the late 1970s and early 1980s at UC Berkeley.-Education and training:...

, Mike O'Brien and Jim Kulp.

The C shell is a command processor that's typically run in a text window, allowing the user to type commands which cause actions. The C shell can also read commands from a file, called a script
Shell script
A shell script is a script written for the shell, or command line interpreter, of an operating system. It is often considered a simple domain-specific programming language...

. Like all Unix shells, it supports filename wildcarding
Wildcard character
-Telecommunication:In telecommunications, a wildcard character is a character that may be substituted for any of a defined subset of all possible characters....

, piping
Pipeline (Unix)
In Unix-like computer operating systems , a pipeline is the original software pipeline: a set of processes chained by their standard streams, so that the output of each process feeds directly as input to the next one. Each connection is implemented by an anonymous pipe...

, here documents, command substitution
Command substitution
In computing, command substitution is a facility originally introduced in the Unix shells that allows a command to be run and its output to be pasted back on the command line as arguments to another command...

, variables
Variable (programming)
In computer programming, a variable is a symbolic name given to some known or unknown quantity or information, for the purpose of allowing the name to be used independently of the information it represents...

 and control structures
Control flow
In computer science, control flow refers to the order in which the individual statements, instructions, or function calls of an imperative or a declarative program are executed or evaluated....

 for condition-testing and iteration
Iteration
Iteration means the act of repeating a process usually with the aim of approaching a desired goal or target or result. Each repetition of the process is also called an "iteration," and the results of one iteration are used as the starting point for the next iteration.-Mathematics:Iteration in...

. What differentiated the C shell, especially in the 1980s, were its interactive features and overall style. Its new features made it easier and faster to use. The overall style of the language looked more like C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 and was seen as more readable.

Today, csh on most machines is actually tcsh
Tcsh
tcsh is a Unix shell based on and compatible with the C shell . It is essentially the C shell with programmable command line completion, command-line editing, and a few other features.-History:...

, an improved version of csh. As a practical matter, tcsh is csh: One file containing the tcsh executable has links
Hard link
In computing, a hard link is a directory entry that associates a name with a file on a file system. . The term is used in file systems which allow multiple hard links to be created for the same file. This has the effect of creating multiple names for the same file, causing an aliasing effect: e.g...

 to it as both "csh" and "tcsh" so that either name refers to the same improved version of the C shell.

tcsh added filename and command completion and command line editing concepts borrowed from the Tenex system, which is where the "t" came from. Because it only added functionality and didn't change what was there, tcsh remained backward compatible with the original C shell. And though it started as a side branch from the original source tree Joy had created, tcsh is now the main branch for ongoing development. tcsh is very stable but new releases continue to appear roughly once a year, consisting mostly of minor bug fixes.

Design objectives and features

The main design objectives for the C shell were that it should look more like the C programming language
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 and that it should be better for interactive use.

More like C

The Unix system had been written almost exclusively in C, so the C shell's first objective was a command language that was more stylistically consistent with the rest of the system. The keywords, the use of parentheses and the C shell's built-in expression grammar and support for arrays were all strongly influenced by C.

By today's standards, csh may not seem particularly more C-like than many other popular scripting languages. But through the 80s and 90s, the difference was seen as striking, particularly when compared to sh
Bourne shell
The Bourne shell, or sh, was the default Unix shell of Unix Version 7 and most Unix-like systems continue to have /bin/sh - which will be the Bourne shell, or a symbolic link or hard link to a compatible shell - even when more modern shells are used by most users.Developed by Stephen Bourne at AT&T...

, the then-dominant shell written by Stephen Bourne at AT&T
AT&T
AT&T Inc. is an American multinational telecommunications corporation headquartered in Whitacre Tower, Dallas, Texas, United States. It is the largest provider of mobile telephony and fixed telephony in the United States, and is also a provider of broadband and subscription television services...

. This example illustrates the C shell's more conventional expression operators
Operator (programming)
Programming languages typically support a set of operators: operations which differ from the language's functions in calling syntax and/or argument passing mode. Common examples that differ by syntax are mathematical arithmetic operations, e.g...

 and syntax.
sh lacked an expression grammar
Expression (programming)
An expression in a programming language is a combination of explicit values, constants, variables, operators, and functions that are interpreted according to the particular rules of precedence and of association for a particular programming language, which computes and then produces another value...

. The square bracketed condition had to be evaluated by the slower means of running the external test
Test (Unix)
test is a command in Unix that evaluates conditional expressions.-Description:The test command evaluates the expression parameter. In some shells , it is actually a shell builtin, even though external version still exists. In the second form of the command, the [ ] must be surrounded by blank...

 program. sh's if command took its argument words as a new command to be run as a child process
Process (computing)
In computing, a process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system , a process may be made up of multiple threads of execution that execute instructions concurrently.A computer program is a...

. If the child exited with a zero return code, sh would look for a then clause (a separate statement, but often written joined on the same line with a semicolon) and run that nested block. Otherwise it would run the else. Hard-linking
Hard link
In computing, a hard link is a directory entry that associates a name with a file on a file system. . The term is used in file systems which allow multiple hard links to be created for the same file. This has the effect of creating multiple names for the same file, causing an aliasing effect: e.g...

 the test program as both "test" and "[" gave the notational advantage of the square brackets and the appearance that the functionality of test was part of the sh language. sh's use of a reversed keyword to mark the end of a control block was a style borrowed from ALGOL 68
ALGOL 68
ALGOL 68 isan imperative computerprogramming language that was conceived as a successor to theALGOL 60 programming language, designed with the goal of a...

.

By contrast, csh could evaluate the expression directly, which made it faster. It also claimed better readability: Its expressions used a grammar
Formal grammar
A formal grammar is a set of formation rules for strings in a formal language. The rules describe how to form strings from the language's alphabet that are valid according to the language's syntax...

 and a set of operators mostly copied from C, none of its keywords were reversed and the overall style was also more like C.

Here is a second example, comparing scripts that calculate the first 10 powers of 2.
Again because of the lack of an expression grammar, the sh script uses command substitution
Command substitution
In computing, command substitution is a facility originally introduced in the Unix shells that allows a command to be run and its output to be pasted back on the command line as arguments to another command...

 and the expr
Expr
expr is a command line Unix utility which evaluates an expression and outputs the corresponding value. It first appeared in Unix v7 as a standalone program, and was later incorporated into the shell as a built-in command.Syntax: expr ...

 command. The @ statement in C shell is a pun
Pun
The pun, also called paronomasia, is a form of word play which suggests two or more meanings, by exploiting multiple meanings of words, or of similar-sounding words, for an intended humorous or rhetorical effect. These ambiguities can arise from the intentional use and abuse of homophonic,...

: it's the "at-sign-ment" statement.

Finally, here's a third example, showing the differing styles for a switch statement
Switch statement
In computer programming, a switch, case, select or inspect statement is a type of selection control mechanism that exists in most imperative programming languages such as Pascal, Ada, C/C++, C#, Java, and so on. It is also included in several other types of languages...

.
In the sh script, ";;" marks the end of each case. That's distinguished because sh disallows null statements otherwise.

Improvements for interactive use

The second objective was that the C shell should be better for interactive use. In support of that, it introduced numerous new features that made it easier, faster and more friendly to use by someone sitting at a terminal, typing commands. Users could get things done with a lot fewer keystrokes and it ran faster. The most significant of these new features were the history and editing mechanisms, aliases, directory stacks, tilde notation, cdpath, job control and path hashing. These new features proved very popular and many of them have since been copied by other Unix shells.

History

History allows users to recall previous commands and rerun them by typing only a few quick keystrokes. For example, two exclamation marks, "!!", typed as a command and referred to as "bang, bang," means run the immediately preceding command. Other short keystroke combinations, e.g., "!$" to mean just the last argument of the previous command, allow bits and pieces of previous commands to be pasted together and edited to form a new command.

Editing operators

Editing can be done not only on the text of a previous command, but also on variable substitutions. Operators range from simple string search/replace to parsing a pathname to extract a specific segment.

Aliases

Aliases allow the user to type the name of an alias and have the C shell expand it internally into whatever set of words the user has defined. For many simple situations, e.g., running the "fgrep" command by typing "f", it runs faster and it's more convenient than creating a script.

Directory stack

The directory stack
Stack (data structure)
In computer science, a stack is a last in, first out abstract data type and linear data structure. A stack can have any abstract data type as an element, but is characterized by only three fundamental operations: push, pop and stack top. The push operation adds a new item to the top of the stack,...

 allows the user to push or pop
Stack (data structure)
In computer science, a stack is a last in, first out abstract data type and linear data structure. A stack can have any abstract data type as an element, but is characterized by only three fundamental operations: push, pop and stack top. The push operation adds a new item to the top of the stack,...

 the current working directory, making it easier to jump back and forth between two different places in the filesystem without having to do much typing.

Tilde notation

Tilde notation offers a shorthand way of specifying pathnames relative to the home
Home directory
A Home directory is a file system directory on a multi-user operating system containing files for a given user of the system. The specifics of the home directory is defined by the operating system involved; for example, Windows systems between 2000 and 2003 keep home directories in a folder...

 directory using the "~" character.

Interactive filename completion

The escape key
Esc key
On computer keyboards, the Esc key is a key labeled Esc or Escape that is used to generate the ASCII Escape character , the character code traditionally used to initiate an escape sequence...

 could be used interactively to show possible completions of a filename at the end of the current command line.

Cdpath

Cdpath extends the notion of a search path
Path (variable)
PATH is an environment variable on Unix-like operating systems, DOS, OS/2, and Microsoft Windows, specifying a set of directories where executable programs are located...

 to the cd (change directory) command: If the specified directory isn't in the current directory, csh will try to find it in the cdpath directories.

Job control

Job control addressed the problem that, well into the 1980s, most users had only simple character-mode terminals. Under sh, a user could only do one thing at a time. A user who started to edit a file had to finish or at least save his work and get out before doing anything else. A user couldn't simply open another window. The C shell's job control solved that by allowing the user to suspend the current activity and create a new instance of the C shell, called a job, by typing ^Z
Control-Z
In computing, is a control character in ASCII code, also known as the substitute character or a keyboard shortcut. Strictly speaking, is not a printable character at all but a code for control purposes, though it is sometimes rendered by two characters as ^Z. It is generated by pressing the key...

. The user could then switch back-and-forth between jobs using the fg command. The active job was said to be in the foreground. Other jobs were said to be either suspended (stopped) or running in the background.

Path hashing

Path hashing speeds up the C shell's search for executable files. Rather than doing filesystem calls in each path directory, one-at-a-time, until it either finds the file or runs out of possibilities, the C shell consults an internal hash table built by scanning the path directories. That table can usually tell the C shell where to find the file, if it exists, without having to search, and can be refreshed with the "rehash" command.

Overview of the language

The C shell operates line-at-a-time. Each line is tokenized
Lexical analysis
In computer science, lexical analysis is the process of converting a sequence of characters into a sequence of tokens. A program or function which performs lexical analysis is called a lexical analyzer, lexer or scanner...

 into a set of words separated by spaces or other characters with special meaning, including parentheses, the piping and i/o redirection operators and the semicolon or ampersand.

Basic statements

A basic statement is one that simply runs a command. The first word is taken as name of the command to be run and may be either an internal command, e.g., "echo," or an external command. The rest of the words are passed as arguments to the command.

At the basic statement level, here are some of the features of the grammar:

Wildcarding

The C shell, like all Unix shells, wildcards any command-line arguments. If a word contains wildcard characters, it's taken as a pattern and replaced by the list of all the filenames that match.

* matches any number of characters.
? matches any single character.
[...] matches any of the characters inside the square brackets. Ranges are allowed, using the hyphen.
[!...] matches any character not in the set.

The C shell also introduced several notational conveniences, since copied by other Unix shells.

abc{def,ghi} is alternation and expands to abcdef and abcghi.
~ means the current user's home directory.
~user means users home directory.

Multiple directory-level wildcards, e.g., "*/*.c", are supported.

Having the shell do wildcarding was an important decision on Unix. It meant wildcarding would always work with every command, it would always work the same way and only the shell would need code to do it. But the decision depended on the fact that Unix could pass very long argument lists very efficiently through the exec
Exec (operating system)
The exec collection of functions of Unix-like operating systems cause the running process to be completely replaced by the program passed as an argument to the function...

 system call that csh uses to create child processes
Process (computing)
In computing, a process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system , a process may be made up of multiple threads of execution that execute instructions concurrently.A computer program is a...

. By contrast, even though modern Windows can pass command lines of up to roughly 32K Unicode
Unicode
Unicode is a computing industry standard for the consistent encoding, representation and handling of text expressed in most of the world's writing systems...

 characters, wildcarding is conventionally done by each application (through C run-time code before main
Main function (programming)
In many programming languages, the main function is where a program starts execution. It is responsible for the high-level organization of the program's functionality, and typically has access to the command arguments given to the program when it was executed....

is invoked) because of its MS-DOS
MS-DOS
MS-DOS is an operating system for x86-based personal computers. It was the most commonly used member of the DOS family of operating systems, and was the main operating system for IBM PC compatible personal computers during the 1980s to the mid 1990s, until it was gradually superseded by operating...

 heritage: MS-DOS only allowed a 128-byte command line to be passed to an application, making wildcarding by the DOS command prompt impractical.

I/O redirection

By default, when csh runs a command, the command inherits the csh's stdio file handles for stdin, stdout and stderr, which normally all point to the console window where the C shell is running. The i/o redirection operators allow the command to use a file instead for input or output.

> file means stdout will be written to file, overwriting it if it exists, and creating it if it doesn't. Errors still come to the shell window.
>& file means both stdout and stderr will be written to file, overwriting it if it exists, and creating it if it doesn't.
>> file means stdout will be appended at the end of file.
>>& file means both stdout and stderr will be appended at the end of file.
< file means stdin will be read from file.
<< string is a here document. Stdin will read the following lines up to the one that matches string.

Joining

Commands can be joined on the same line.

; means run the first command and then the next.
&& means run the first command and, if it succeeds with a 0 return code, run the next.
|| means run the first command and, if it fails with a non-zero return code, run the next.

Piping

Commands can be connected together using pipes, which causes the output of one command to be fed into the input of the next. Both commands run concurrently.

| means connect stdout to stdin of the next command. Errors still come to the shell window.
|& means connect both stdout and stderr to stdin of the next command.

Variable substitution

If a word contains a Dollar sign, "$", the following characters are taken as the name of a variable and the reference is replaced by the value of that variable. Various editing operators, typed as suffixes to the reference, allow pathname editing (e.g., to extract just the extension) and other operations.

Quoting and escaping

Quoting mechanisms allow otherwise special characters, e.g., whitespace, wildcards, parentheses, Dollar signs, etc., to be taken as literal text.

\ means take the next character as an ordinary literal character.
"string" is a weak quote. Enclosed whitespace and wildcards are taken as literals, but variable and command substitutions are still performed.
'string' is a strong quote. The entire enclosed string is taken as a literal.

Command substitution

Command substitution allows the output of one command to be used as arguments to another.

`command` means take the output of command, parse it into words and paste them back into the command line.

Background execution

Normally, when the C shell starts a command, it waits for the command to finish before giving the user another prompt signaling that a new command can be typed.

command & means start command in the background and prompt immediately for a new command.

Subshells

A subshell is a separate child copy of the shell that inherits the current state but can then make changes, e.g., to the current directory, without affecting the parent.

( commands ) means run commands in a subshell.

Control structures

The C shell provides control structures for both condition-testing and iteration
Iteration
Iteration means the act of repeating a process usually with the aim of approaching a desired goal or target or result. Each repetition of the process is also called an "iteration," and the results of one iteration are used as the starting point for the next iteration.-Mathematics:Iteration in...

. The condition-testing control structures are the if and switch statements. The iteration control structures are the while, foreach and repeat statements.

if statement

There are two forms of the if statement. The short form is typed on a single line and but can specify only a single command if the expression is true.

if ( expression ) command

The long form uses then, else and endif keywords to allow for blocks of commands to be nested inside the condition.

if ( expression1 ) then
commands
else if ( expression2 ) then
commands
...
else
commands
endif

If the else and if keywords appear on the same line, csh chains, rather than nests them; the block is terminated with a single endif.

switch statement

The switch statement compares a string against a list of patterns, which may contain wildcard characters. If nothing matches, the default action, if there is one, is taken.

switch ( string )
case pattern1:
commands
breaksw
case pattern2:
commands
breaksw
...
default:
commands
breaksw
endsw

while statement

The while statement evaluates an expression. If it's true, it runs the nested commands and then repeats.

while ( expression )
commands
end

foreach statement

The foreach statement takes a list of values, usually a list of filenames produced by wildcarding, and then for each, sets the loop-variable to that value and runs the nested commands.

foreach loop-variable ( list-of-values )
commands
end

repeat statement

The repeat statement repeats a single command an integer number of times.

repeat integer command

Variables

The C shell implements both shell and environment variable
Environment variable
Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer.They can be said in some sense to create the operating environment in which a process runs...

s. Environment variables, created using the setenv statement, are always simple strings, passed to any child processes
Process (computing)
In computing, a process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system , a process may be made up of multiple threads of execution that execute instructions concurrently.A computer program is a...

, which retrieve these variables via the envp[] argument to main
Main function (programming)
In many programming languages, the main function is where a program starts execution. It is responsible for the high-level organization of the program's functionality, and typically has access to the command arguments given to the program when it was executed....

.

Shell variables, created using the set or @ statements, are internal to C shell. They are not passed to child processes. Shell variables can be either simple strings or arrays of strings. Some of the shell variables are predefined and used to control various internal C shell options, e.g., what should happen if a wildcard fails to match anything.

In current versions of csh, strings can be of arbitrary length, well into millions of characters.

Expressions

The C shell implements a 32-bit integer expression grammar with operators borrowed from C but with a few additional operators for string comparisons and filesystem tests, e.g., testing for the existence of a file. Operators must be separated by whitespace from their operands. Variables are referenced as $name.

Operator precedence is also borrowed from C, but with different operator associativity
Operator associativity
In programming languages and mathematical notation, the associativity of an operator is a property that determines how operators of the same precedence are grouped in the absence of parentheses...

 rules to resolve the ambiguity of what comes first in a sequence of equal precedence operators. In C, the associativity is left-to-right for most operators; in C shell, it's right-to-left. For example,
The parentheses in the C shell example are to avoid having the bit-shifting operators confused as I/O redirection operators. In either language, parentheses can always be used to explicitly specify the desired order of evaluation, even if only for clarity.

Criticism

Though popular for interactive use because of its many innovative features, csh has never been as popular for scripting. Initially, and through the 1980s, csh couldn't be guaranteed to be present on all Unix systems. sh could, which made it a better choice for any scripts that might have to run on other machines. By the mid-1990s, csh was widely available, but the use of csh for scripting faced new criticism by the POSIX
POSIX
POSIX , an acronym for "Portable Operating System Interface", is a family of standards specified by the IEEE for maintaining compatibility between operating systems...

 committee, which specified there should only be one preferred shell for both interactive and scripting purposes and that that one preferred shell should be the Korn Shell
Korn shell
The Korn shell is a Unix shell which was developed by David Korn in the early 1980s and announced at USENIX on July 14, 1983. Other early contributors were AT&T Bell Labs developers Mike Veach, who wrote the emacs code, and Pat Sullivan, who wrote the vi code...

. C shell also faced criticism from others over the C shell's alleged defects in the syntax, missing features and poor implementation.

Syntax defects were generally simple but unnecessary inconsistencies in the definition of the language. For example, the set, setenv and alias commands all did basically the same thing, namely, associate a name with a string or set of words. But all three had slight, but completely unnecessary differences. An equal sign was required for a set but not for setenv or alias; parentheses were required around a word list for a set but not for setenv and alias, etc. Similarly, the if, switch and the looping constructs use needlessly different keywords (endif, endsw and end) to terminate the nested blocks.

Missing features most commonly cited are the lack of ability to manipulate the stdio file handles independently and support for functions. Whereas Bourne shell functions lacked only local variables, Csh's aliases - the closest analogue in Csh to functions - were restricted to single lines of code, despite most flow control constructs requiring newlines to be recognized. As a result, Csh scripts could not be functionally broken down as C programs themselves could be, and larger projects tended to shift to either Bourne shell scripting or C code instead.

The implementation, which used an ad hoc parser
Parsing
In computer science and linguistics, parsing, or, more formally, syntactic analysis, is the process of analyzing a text, made of a sequence of tokens , to determine its grammatical structure with respect to a given formal grammar...

, has drawn the most serious criticism. By the early 1970s, compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...

 technology was sufficiently mature that most new language implementations used either a top-down
Top-down parsing
Top-down parsing is a type of parsing strategy where in one first looks at the highest level of the parse tree and works down the parse tree by using the rewriting rules of a formal grammar...

 or bottom-up parser
Bottom-up parsing
Bottom-up parsing is a strategy for analyzing unknown information that attempts to identify the most fundamental units first, and then to infer higher-order structures from them...

 capable of recognizing a fully recursive grammar
Formal grammar
A formal grammar is a set of formation rules for strings in a formal language. The rules describe how to form strings from the language's alphabet that are valid according to the language's syntax...

. It's not known why an ad hoc design was chosen instead for the C shell. It may be simply that, as Joy put it in an interview in 2009, "When I started doing this stuff with Unix, I wasn't a very good programmer." But that choice of an ad hoc design meant that the C shell language was not fully recursive. There was a limit to how complex a command it could handle.

It worked for most things users typed interactively, but on the more complex commands a user might take time to write in a script it didn't work well and could easily fail, producing only a cryptic error message or an unwelcome result. For example, the C shell could not support piping between control structures. Attempting to pipe the output of a foreach command into grep
Grep
grep is a command-line text-search utility originally written for Unix. The name comes from the ed command g/re/p...

simply didn't work. (The work-around, which works for many of the complaints related to the parser, is to break the code up into separate scripts. If the foreach is moved to a separate script, piping works because scripts are run by forking a new copy of csh that does inherit the correct stdio handles.)

Another example is the unwelcome behavior in the following fragments. Both of these appear to mean, "If 'myfile' does not exist, create it by writing 'mytext' into it." But the version on the right always creates an empty file because the C shell's order of evaluation is to look for and evaluate I/O redirection operators on each command line as it reads it, before examining the rest of the line to see if contains a control structure.
The implementation is also criticized for its notoriously poor error messages, e.g., "0 event not found", which yields no information about what the problem is.

Influence

The C shell was extremely successful in introducing a large number of ideas including the history mechanism, aliases, tilde notation, interactive filename completion, an expression grammar built into the shell, etc., that have since been copied by other Unix shells. But in contrast to sh
Bourne shell
The Bourne shell, or sh, was the default Unix shell of Unix Version 7 and most Unix-like systems continue to have /bin/sh - which will be the Bourne shell, or a symbolic link or hard link to a compatible shell - even when more modern shells are used by most users.Developed by Stephen Bourne at AT&T...

, which has spawned a large number of independently-developed clones, including ksh
Korn shell
The Korn shell is a Unix shell which was developed by David Korn in the early 1980s and announced at USENIX on July 14, 1983. Other early contributors were AT&T Bell Labs developers Mike Veach, who wrote the emacs code, and Pat Sullivan, who wrote the vi code...

 and bash, only two csh clones are known. (tcsh is not considered a clone of csh because it was not independently-developed. tcsh was based on the same code originally written by Bill Joy and only added features.)

In 1986, Allen Holub
Allen Holub
Allen Holub is a computer scientist, author, educator, and consultant. He has written extensively on the C, C++, and Java programming languages, and on object-oriented programming in general...

 wrote, On Command: Writing a Unix-Like Shell for MS-DOS
MS-DOS
MS-DOS is an operating system for x86-based personal computers. It was the most commonly used member of the DOS family of operating systems, and was the main operating system for IBM PC compatible personal computers during the 1980s to the mid 1990s, until it was gradually superseded by operating...

, a book describing a program he'd written called "SH" but which in fact copied the language design and features of csh, not sh. Companion diskettes containing full source for SH and for a basic set of Unix-like utilities (cat, cp, grep, etc.) were available for $25 and $30, respectively, from the publisher. The control structures, expression grammar, history mechanism and other features in Holub's SH were identical to those of the C shell.

In 1988, Hamilton Laboratories began shipping Hamilton C shell
Hamilton C shell
Hamilton C shell is a clone of the Unix C shell and utilities for Microsoft Windows created by Nicole Hamilton at Hamilton Laboratories. It was first released on OS/2 on December 12 1988 and on Windows NT in July 1992...

 for OS/2
OS/2
OS/2 is a computer operating system, initially created by Microsoft and IBM, then later developed by IBM exclusively. The name stands for "Operating System/2," because it was introduced as part of the same generation change release as IBM's "Personal System/2 " line of second-generation personal...

. In 1992, Hamilton C shell was released for Windows NT
Windows NT
Windows NT is a family of operating systems produced by Microsoft, the first version of which was released in July 1993. It was a powerful high-level-language-based, processor-independent, multiprocessing, multiuser operating system with features comparable to Unix. It was intended to complement...

. The Windows version continues to be actively supported but the OS/2 version was discontinued in 2003. Hamilton C shell was written by Nicole Hamilton and includes both a csh clone and a set of Unix-like utilities. An early quick reference described the intent as "full compliance with the entire C shell language (except job control)" but with improvements to the language design and adaptation to the differences between Unix and a PC. The most important improvement was a top-down parser
Top-down parsing
Top-down parsing is a type of parsing strategy where in one first looks at the highest level of the parse tree and works down the parse tree by using the rewriting rules of a formal grammar...

 that allowed control structures to be nested or piped, something the original C shell could not support, given its ad hoc parser. Hamilton also added new language features including built-in and user-defined procedures, block-structured local variables and floating point arithmetic. Adaptation to a PC included support for the filename and other conventions on a PC and the use of threads
Thread (computer science)
In computer science, a thread of execution is the smallest unit of processing that can be scheduled by an operating system. The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process...

 instead of fork
Fork (operating system)
In computing, when a process forks, it creates a copy of itself. More generally, a fork in a multithreading environment means that a thread of execution is duplicated, creating a child thread from the parent thread....

 (which wasn't available under either OS/2 or Windows) to achieve parallelism
Parallel computing
Parallel computing is a form of computation in which many calculations are carried out simultaneously, operating on the principle that large problems can often be divided into smaller ones, which are then solved concurrently . There are several different forms of parallel computing: bit-level,...

, e.g., in setting up a pipeline.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK