What's GNU
Last month we described the origins of Plan 9, the sam editor, and the 9term terminal emulator. Well, what about the shell to run inside the window? Here too, the Plan 9 authors took the opportunity to rethink the issue of just how should a shell work. The Plan 9 shell is called rc, because it “runs commands”.
Although in many ways the Bourne shell is a simple, elegant, high-level programming language, it has a serious flaw, in that it was designed to be much like a macro-processing language. Input text is scanned, rescanned, and rescanned again, as each stage of processing is performed. (This is carried to an almost absurd length in the Korn shell, with something like eleven different processing stages.) This leads to rather complicated and baroque quoting rules, with the need for nested escape sequences.
In rc, the input text is scanned and parsed exactly once. The language has a real yacc-based grammar, making it clear what everything means. The quoting rules are very simple. Quoted text must be enclosed between single quotes. To get a single quote inside a quoted string, double it (as in FORTRAN). An explicit operator is used to provide string concatenation, and variables can be lists of strings, not just single strings.
The syntax is closer to that of C or awk, instead of Bourne's Algol 68. This leads to less clutter, avoiding unnecessary keywords and semi-colons. It is much more like C than the fabled csh is.
rc provides shell functions, and signal handlers are written as functions with special names (sighup, sigterm, etc.), instead of using strings. I/O redirection is also more powerful, with a notation for hooking up file descriptors besides 0 and 1 to the input and output ends of a pipe.
A freely distributable clone of rc is available. It was written by Byron Rakitzis, and implements the language described in the rc paper, with some extensions. The beauty of rc is that it is small and fast, and shell programs can be quite elegant. It also runs on just about any kind of Unix system.
When using rc with 9term, it is conventional to set the primary prompt to be just a single semi-colon, and the secondary prompt to be empty. This allows you to snarf entire commands, including the prompt, and resend them. The semi-colon is treated as a simple null statement. The use of double-clicking to select the whole line, and the default saved action of the menus make sending and resending the same line over again extremely simple; most of the work can be done with just the mouse.
The Resources sidebar lists the ftp location of the rc shell. There is also a mailing list of people who use rc.
es is the “extensible shell”. Paul Haahr and Byron Rakitzis thought it would be interesting to try and combine some of the capabilities of functional languages with those of Unix shells. Many internal capabilities of the shell (such as I/O redirection and setting up pipelines) are available as built-in functions in the language, and program fragments can be passed around as arguments to functions.
es provides first class functions, lexical scope, an exception system, and rich return values (i.e. functions can return values other than just numbers). Most of this is beyond the scope of this article to explain. es is described in a paper in the Winter 1993 Usenix Conference Proceedings. It helps to read this paper, and also to go through the archives of the mailing list to see how the language evolved. For the full details on es, you'll need to read the paper, the man page, and the file initial.es in the es distribution. It is a good idea to also look at the sample .esrc file, too.
Basically, the idea behind es is to take the primitive operations that a shell does, such as forking processes, creating pipes, and setting up I/O redirections, and make them available as functions that a user program can call directly. In turn, traditional shell syntax is built on top of these primitive operations.
Lexical scoping allows you to save the definition of an operation, and then replace it with your own operation on top of the previous one. Here is an example from the paper on es. This code implements a pipeline profiler. It saves the definition of %pipe, which creates pipes, and provides a new one that times each component of the pipeline, using the old %pipe to actually create the pipeline. (es is the prompt from es used for examples in the paper. The default prompt is a semi-colon.)
es > let (pipe = $fn-%pipe) {
{
fn %pipe first out in rest {
{
if (~ $#out 0) {
time first
} {
$pipe { time $first } $out
$in { %pipe $rest }
}
}
es> cat paper9 tr -cs a-zA-Z0-9 '\012' | sort |
uniq -c | sort | -nr sed 6q
213 the
150 a
120 to
115 of
109 is
96 and
2r 0.3u 0.2s cat paper9
2r 0.3u 0.2s tr -cs a-zA-Z0-9 \012
2r 0.5u 0.2s sort
2r 0.4u 0.2s uniq -c
3r 0.2u 0.1s sed 6q
3r 0.6u 0.2s sort -nr
This is a simple example, yet it illustrates some of the power available in es. es really deserves a column on its own. For more information, see the above sources and the mailing list archive.
The sidebar lists the ftp location for es, and a mailing list is also available.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- New Products
- Linux Systems Administrator
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Web & UI Developer (JavaScript & j Query)
- Designing Electronics with Linux
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




3 hours 28 min ago
14 hours 8 min ago
19 hours 54 min ago
20 hours 12 min ago
22 hours 5 min ago
23 hours 58 min ago
1 day 6 hours ago
1 day 7 hours ago
1 day 9 hours ago
1 day 14 hours ago