Rc

Last updated
rc
Paradigm imperative, pipeline
Designed by Tom Duff
Developer Bell Labs
First appeared1989;35 years ago (1989)
Typing discipline weak
OS Cross-platform (Version 10 Unix, Plan 9, Plan 9 from User Space)
Website doc.cat-v.org/plan_9/4th_edition/papers/rc
Dialects
Byron's rc
Influenced by
Bourne shell
Influenced
es, The Inferno shell.
An rc session Plan 9 from Bell Labs (process management).png
An rc session

rc (for "run commands") is the command line interpreter for Version 10 Unix and Plan 9 from Bell Labs operating systems. It resembles the Bourne shell, but its syntax is somewhat simpler. It was created by Tom Duff, who is better known for an unusual C programming language construct ("Duff's device"). [1]

Contents

A port of the original rc to Unix is part of Plan 9 from User Space. A rewrite of rc for Unix-like operating systems by Byron Rakitzis is also available but includes some incompatible changes.

Rc uses C-like control structures instead of the original Bourne shell's ALGOL-like structures, except that it uses an if not construct 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 " $@ ". Variables are not re-split when expanded. The language is described in Duff's paper. [1]

Influences

es

es (for "extensible shell") is an open source, command line interpreter developed by Rakitzis and Paul Haahr [2] that uses a scripting language syntax influenced by the rc shell. [3] [4] It was originally based on code from Byron Rakitzis's clone of rc for Unix. [5] [6]

Extensible shell is intended to provide a fully functional programming language as a Unix shell. [7] It does so by introducing "program fragments" in braces as a new datatype, lexical scoping via let, and some more minor improvements. The bulk of es development occurred in the early 1990s, after the shell was introduced at the Winter 1993 USENIX conference in San Diego, [8] Official releases appear to have ceased after 0.9-beta-1 in 1997, [9] and es lacks features as compared to more popular shells, such as zsh and bash. [10] A public domain fork of es is active as of 2019. [11]

Examples

The Bourne shell script:

if["$1"="hello"];thenechohello,world elsecase"$2"in1)echo$#'hey'"jude's"$3;;2)echo`date`:$*::"$@":;;*)echowhynot1>&2esacforiinabc;doecho$idonefi

is expressed in rc as:

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

Rc also supports more dynamic piping:

a |[2] b    # pipe only standard error of a to b — equivalent to '3>&2 2>&1 >&3 | b' in Bourne shell  [1] :Advanced I/O Redirection a <>b       # opens file b as a's standard input and standard output  a <{b} <{c} # becomes a {standard output of b} {standard output of c},             # better known as "process substitution" [1] :Pipeline Branching

Related Research Articles

<span class="mw-page-title-main">Bash (Unix shell)</span> GNU replacement for the Bourne shell

Bash is a Unix shell and command language written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell. The shell's name is an acronym for Bourne Again Shell, a pun on the name of the Bourne shell that it replaces and the notion of being "born again". First released in 1989, it has been used as the default login shell for most Linux distributions and it was one of the first programs Linus Torvalds ported to Linux, alongside GCC. A version is also available for Windows 10 and Windows 11 via the Windows Subsystem for Linux. It is also the default user shell in Solaris 11. Bash was also the default shell in BeOS, and in versions of Apple macOS from 10.3 to 10.15, which changed the default shell to zsh, although Bash remains available as an alternative shell.

<span class="mw-page-title-main">Unix shell</span> Command-line interpreter for Unix operating system

A Unix shell is a command-line interpreter or shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command language and a scripting language, and is used by the operating system to control the execution of the system using shell scripts.

<span class="mw-page-title-main">Bourne shell</span> Command-line interpreter for operating systems

The Bourne shell (sh) is a shell command-line interpreter for computer operating systems.

<span class="mw-page-title-main">C shell</span> Unix shell

The C shell is a Unix shell created by Bill Joy while he was a graduate student at University of California, Berkeley in the late 1970s. It has been widely distributed, beginning with the 2BSD release of the Berkeley Software Distribution (BSD) which Joy first distributed in 1978. Other early contributors to the ideas or the code were Michael Ubell, Eric Allman, Mike O'Brien and Jim Kulp.

Almquist shell is a lightweight Unix shell originally written by Kenneth Almquist in the late 1980s. Initially a clone of the System V.4 variant of the Bourne shell, it replaced the original Bourne shell in the BSD versions of Unix released in the early 1990s.

In software development, Make is a build automation tool that builds executable programs and libraries from source code by reading files called makefiles which specify how to derive the target program. Though integrated development environments and language-specific compiler features can also be used to manage a build process, Make remains widely used, especially in Unix and Unix-like operating systems.

cron Job scheduler for Unix-like operating systems

The cron command-line utility is a job scheduler on Unix-like operating systems. Users who set up and maintain software environments use cron to schedule jobs, also known as cron jobs, to run periodically at fixed times, dates, or intervals. It typically automates system maintenance or administration—though its general-purpose nature makes it useful for things like downloading files from the Internet and downloading email at regular intervals.

<span class="mw-page-title-main">Redirection (computing)</span> Form of interprocess communication

In computing, redirection is a form of interprocess communication, and is a function common to most command-line interpreters, including the various Unix shells that can redirect standard streams to user-specified locations.

bc, for basic calculator, is "an arbitrary-precision calculator language" with syntax similar to the C programming language. bc is typically used as either a mathematical scripting language or as an interactive mathematical shell.

In computing, echo is a command that outputs the strings that are passed to it as arguments. It is a command available in various operating system shells and typically used in shell scripts and batch files to output status text to the screen or a computer file, or as a source part of a pipeline.

<span class="mw-page-title-main">Comparison of command shells</span>

A command shell is a command-line interface to interact with and manipulate a computer's operating system.

more (command) Terminal pager available on various operating systems

In computing, more is a command to view the contents of a text file one screen at a time. It is available on Unix and Unix-like systems, DOS, Digital Research FlexOS, IBM/Toshiba 4690 OS, IBM OS/2, Microsoft Windows and ReactOS. Programs of this sort are called pagers. more is a very basic pager, originally allowing only forward navigation through a file, though newer implementations do allow for limited backward movement.

test is a command-line utility found in Unix, Plan 9, and Unix-like operating systems that evaluates conditional expressions. test was turned into a shell builtin command in 1981 with UNIX System III and at the same time made available under the alternate name [.

In computing, a shebang is the character sequence consisting of the characters number sign and exclamation mark at the beginning of a script. It is also called sharp-exclamation, sha-bang, hashbang, pound-bang, or hash-pling.

sort (Unix) Standard UNIX utility

In computing, sort is a standard command line program of Unix and Unix-like operating systems, that prints the lines of its input or concatenation of all files listed in its argument list in sorted order. Sorting is done based on one or more sort keys extracted from each line of input. By default, the entire input is taken as sort key. Blank space is the default field separator. The command supports a number of command-line options that can vary by implementation. For instance the "-r" flag will reverse the sort order.

od is a command on various operating systems for displaying ("dumping") data in various human-readable output formats. The name is an acronym for "octal dump" since it defaults to printing in the octal data format.

The script command is a Unix utility that records a terminal session. It dates back to the 1979 3.0 BSD.

In computing, command substitution is a facility that allows a command to be run and its output to be pasted back on the command line as arguments to another command. Command substitution first appeared in the Bourne shell, introduced with Version 7 Unix in 1979, and has remained a characteristic of all later Unix shells. The feature has since been adopted in other programming languages as well, including Perl, PHP, Ruby and Microsoft's Powershell under Windows. It also appears in Microsoft's CMD.EXE in the FOR command and the ( ) command.

<span class="mw-page-title-main">Command-line interface</span> Computer interface that uses text

A command-line interface (CLI) is a means of interacting with a computer program by inputting lines of text called command-lines. Command-line interfaces emerged in the mid-1960s, on computer terminals, as a user-friendly alternative to punched cards.

In computing, process substitution is a form of inter-process communication that allows the input or output of a command to appear as a file. The command is substituted in-line, where a file name would normally occur, by the command shell. This allows programs that normally only accept files to directly read from or write to another program.

References

  1. 1 2 3 4 Duff, Tom (1990). ""Rc — The Plan 9 Shell"". cat-v. Retrieved 2024-01-26.
  2. Fischer, Manfred M. (13 December 1996). Spatial Analytical Perspectives on GIS. CRC Press. ISBN   9780748403400.
  3. "Ubuntu Manpage: es - extensible shell". Manpages.ubuntu.com. 1992-03-05. Archived from the original on 2014-02-24. Retrieved 2012-08-24.
  4. "Extensible Shell". FOLDOC. Retrieved 2012-08-24.
  5. "Shells Available for Linux". LUV. Retrieved 2012-08-24.
  6. Jones, Tim. "Evolution of shells in Linux". IBM. Retrieved 14 March 2014.
  7. "Linux Journal 12: What's GNU". Archived from the original on 2013-01-17. Retrieved 2012-08-24.
  8. Es: A shell with higher-order functions by Byron Rakitzis, NetApp, Inc, and Paul Haahr, Adobe Systems Incorporated; Archived at Archive.Org.
  9. "UNIX shell differences". Faqs.org. Retrieved 2012-08-24.
  10. Haggerty, James (13 March 2020). "wryun/es-shell: a shell with higher-order functions". GitHub.