Rc
Encyclopedia
rc is the command line interpreter for Version 10 Unix
Version 10 Unix
Tenth Edition Unix, also known as Version 10 Unix or V10, was the last version of the Research Unix operating system developed and used internally at Bell Labs. "Released" in 1989, it was the successor of V9...

 and Plan 9 from Bell Labs
Plan 9 from Bell Labs
Plan 9 from Bell Labs is a distributed operating system. It was developed primarily for research purposes as the successor to Unix by the Computing Sciences Research Center at Bell Labs between the mid-1980s and 2002...

 operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

s. It resembles the Bourne shell
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...

, but its syntax is somewhat simpler. It was created by Tom Duff
Tom Duff
Thomas Douglas Selkirk Duff is a computer programmer. He was born in Toronto, Ontario, Canada and grew up in Toronto and Leaside. In 1974 he graduated from the University of Waterloo with a B.Math and, two years later, got an M.Sc...

, who is better known for an unusual 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....

 construct called Duff's device
Duff's device
In computer science, Duff's device is an optimized implementation of a serial copy that uses a technique widely applied in assembly language for loop unwinding. Its discovery is credited to Tom Duff in November of 1983, who at the time was working for Lucasfilm. It is perhaps the most dramatic...

.

A port of the original rc to Unix is part of Plan 9 from User Space
Plan 9 from User Space
Plan 9 from User Space is a port of many Plan 9 from Bell Labs libraries and applications to Unix-like operating systems...

. A rewrite of rc for Unix-like
Unix-like
A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....

 operating systems by Byron Rakitzis
Byron Rakitzis
- Biography :He studied in Princeton University, obtaining the title of Bachelor of Arts in Physics in 1990.The same year he won the IOCCC contest, in the Best Utility category....

 is also available but includes some incompatible changes.

Rc uses 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....

-like control structures instead of ALGOL
ALGOL
ALGOL is a family of imperative computer programming languages originally developed in the mid 1950s which greatly influenced many other languages and became the de facto way algorithms were described in textbooks and academic works for almost the next 30 years...

-like, as the original Bourne shell
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...

 uses, except that it uses a construct if not instead of else and has a Bourne-like for loop to iterate over lists. In rc all variables are lists of strings, which eliminates the need for constructs like "$@".

Examples

For example, the Bourne shell script


if test "$1" = hello; then
echo hello, world
else
case "$2" in
1) echo $# 'hey' "jude's"$3;;
2) echo `date` :$*: :"$@":;;
*) echo why not 1>&2
esac
for i in a b c; do
echo $i
done
fi


is expressed in rc as


if(~ $1 hello)
echo hello, world
if not {
switch($2) {
case 1
echo $#* 'hey' 'judes'^$3
case 2
echo `{date} :$"*: :$*:
case *
echo why not >[1=2]
}
for(i in a b c)
echo $i
}


Because if and if not are two different statements, they must be grouped in order to be used in certain situations.

Rc also supports more dynamic piping:


a |[2] b # pipe only standard error of a to b — in Bourne shell as a 3>&2 2>&1 >&3 | b
a <>b # opens b as a's standard input and standard output
a <{b} <{c} # becomes a {standard output of b} {standard output of c}

External links

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