Rc (Unix shell)

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 present in 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, short for Bourne-Again SHell, is a shell program and command language supported by the Free Software Foundation and first developed for the GNU Project by Brian Fox. Designed as a 100% free software alternative for the Bourne shell, it was initially released in 1989. Its moniker is a play on words, referencing both its predecessor, the Bourne shell, and the concept of rebirth.

<span class="mw-page-title-main">Shell script</span> Script written for the shell, or command line interpreter, of an operating system

A shell script is a computer program designed to be run by a Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be command languages. Typical operations performed by shell scripts include file manipulation, program execution, and printing text. A script which sets up the environment, runs the program, and does any necessary cleanup or logging, is called a wrapper.

<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">Terminal emulator</span> Program that emulates a video terminal

A terminal emulator, or terminal application, is a computer program that emulates a video terminal within some other display architecture. Though typically synonymous with a shell or text terminal, the term terminal covers all remote terminals, including graphical interfaces. A terminal emulator inside a graphical user interface is often called a terminal window.

<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 command-line interface software tool that performs actions ordered by configured dependencies as defined in a configuration file called a makefile. It is commonly used for build automation to build executable code from source code. But, not limited to building, Make can perform any operation available via the operating system shell.

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. The concept of redirection is quite old, dating back to the earliest operating systems (OS). A discussion of the design goals for redirection can be found already in the 1971 description of the input-output subsystem of the Multics OS. However, prior to the introduction of UNIX OS with its "pipes", redirection in operating systems was hard or even impossible to do.

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 [.

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 Berkeley Software Distribution (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 an interactive and more user-friendly alternative to the non-interactive interface available with punched cards.

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.