Classic Computer Magazine Archive START VOL. 1 NO. 1 / SUMMER 1986



Micro C-Shell

David Beckemeyer Development Tools
592 Jean St. #304
Oakland, CA 94610
(415) 658-5318

The GEM environment is an excellent computer interface, especially for the novice user. However, sometimes an interface such as the GEM Desktop can be a hinderance. Programmers need more power than such a simple interface can support, and most types of utilities a developer needs are text oriented, not icon-based.

Micro C-Shell is a type of program commonly called a "CLI," for Command Line Interpreter and presents the user with a more traditional interface for disk files management. It isn't necessarily easy to use (though it is easy to learn) or pretty on the eyes, but it is fast and can perform several different tasks with one command line.

Micro C-Shell is based for the most part on a CLI written for Unix machines, called "csh," short for "C-Shell." It is called a shell because it acts like one, sitting over the normal operating system interface. It provides the user with a powerful, unified environment.

Csh was developed at the computer science department of the University of California at Berkeley. The Berkeley group has a long-standing reputation for its innovative additions to Unix's functionality. (Unix, by the way, is an operating system developed at Bell Labs, widely used on mini- and micro-computers.) Although part of csh's allure is its ease of use in multi-user environments, its power makes it perfectly viable on single-user machines.

Beckemeyer's Micro C-Shell package also includes many useful utilities found on Unix systems. Non-programmers will find many of these utilities useful (such as the line/word/character counter and file string search facilities) but it is the serious developer who will appreciate the added power these programs provide.

Micro C-Shell doesn't use the GEM interface at all (except for an occasional error alert) and takes its input from the keyboard. You enter commands at the Micro C-Shell prompt. The commands may either be "built-in" to the shell, or be separate utilities on the disk (with a .PRG extender). Micro C-Shell is provided with the commands and utilities described in the accompanying sidebar.

Some of these commands are separate programs loaded in by the shell - you can add whatever commands you like to Micro C-Shell just by adding new programs. Those listed here are only the ones supplied in the currently sold package.

If all Micro C-Shell did was perform the commands listed above, it would be a great package. The more advanced features of the shell, however, are what make it especially valuable and powerful.

Typically, Unix systems have three assigned, default "devices" available to programs:

Standard Input
Standard Output
Standard Error

All three of these devices are normally set to the "console" device - the monitor screen for output and the keyboard for input. However, a program can redirect these to any other supported device. For example, you can optionally send output normally intended for the screen to the printer, to a disk file, or even to another program! (This is the subtle reason for the third device, the Standard Error device. This allows a program to send error or prompting messages to a device usually guaranteed to be the screen, even if the standard output is routed elsewhere. The standard error device can sometimes, however, be redirected just like the others -for example, if you'd like error messages sent to the printer instead.)

Unix uses the analogy of "pipes" in dealing with data. The "flow" of information can be redirected to another location, "piped" to another program, and even sent two different ways at once using a "tee".

Let's take an example. You want a directory listing sent to a disk file, instead of the screen, so that you can edit it into some documents. The standard directory command is:


(The "%" character is the standard Micro C-Shell prompt; you only would type the "ls" followed by a carriage return.) This prints a listing of all files and directories in the working directory to the standard output device, normally the monitor screen. In this case, you follow the command with a ">" character, followed by the file you'd like the standard output sent to, as in:

% ls >a:directry.txt

Now, instead of the directory being printed on the screen, it will be written to a file on drive A called DIRECTRY.TXT. You could, in turn, take the edited DIRECTRY.TXT file and print it to the printer using the "lpr" command.

When you send the standard output to another program, that program must be a "filter." This is a program which takes some input, manipulates it in some way, then outputs the result. Filters take their input either from a command line as a normal command, or from the standard input. Thus, when you send the standard output of one program to another, that data becomes the standard input for the next program. (Again, using the pipes analogy, this would resemble a filter in a pipe which removes dirt from a stream of water before passing the water on somewhere else.)

With "pipes" we can reduce this process to one command. If we were to type the following command:

% ls | lpr

the "|" character (ASCII 124) tells the shell that we want the standard output from the ls program sent (or "piped") as standard input to the lpr program.

Piping can get quite involved, and if used correctly can perform some powerful tasks. For example, the command sequence:

% grep -n register *.c | pr -h "found register:" | lpr

does the following:

  1. finds each file in the working directory with a ".c" extender (typical of C source files).

  2. in each file in turn, finds each line which contains the word "register" (including the line numbers where they were found).

  3. formats the output into page size chunks with the phrase, "found register:" at the top of each page.

  4. ships the whole kit'n'kaboodle to the printer.
A "tee" sends output two different directions at once, much like its analogous "tee pipe fitting". For example:

% ls -l tee directry.txt

sends a long directory listing to both the screen and the disk file called DIRECTRYTXT in the working directory. Adding one more pipe,

% ls -1| tee directry.txt | lpr

sends to both the disk file and the printer.

As mentioned above, you can create "aliases" for a string. This, in effect, extends the "language" of the shell. For example, let's say that you have your working assembler source files in the following subdirectory:


In Desktop terminology, this would be the folder WORKING, inside the folder SOURCES, inside the folder ASSEMBLR, on drive A. If all of your source files have an "ASM" extender, you could get a long directory-listing filenames, sizes and modification dates-using the following command:

% ls -l a: \ assemblr \ sources \working \ * .asm

If you're going to be doing that a lot, though, it's a pain to type it every time. You could, instead, type:

% alias asmdir ls -l a: \assemblr\sources\workmg\ *.asm

which makes "asmdir" a synonym of that long command line. From then on, every time you enter:

% asmdir

at the shell prompt, its alias is substituted in its place and you get the directory you're looking for.

Micro C-Shell also maintains its own set of variables, which you can alter and add to. The following are defined by the system:

$path A collection of pathnames. Whenever you type in a command, if it needs to be loaded, the shell looks in every directory in the $path variable to find it. This helps keep you from having to know the location of every utility on every disk - the shell just keeps referring to $path until it finds what it's looking for or runs out of places to look.

$prompt The shell prompt. Normally a "%" character, you can change this to whatever you like.

$include, $temp, $symb: These three are used by the cc command for use with the Alcyon C compiler and the AS68 assembler, and describe the pathnames for C #include files, assembler temporary files, and where the AS68 symbol file can be found, respectively.

$home The "home" directory If you jump around between directories a lot, but want to use one particularly as a "home base", you can easily set it by typing % cd $home

$cwd The current directory This variable can't be changed, but can be referenced like any other.

Micro C-Shell always remembers the last 16 commands entered. The history command prints them out for you. You can refer to any of these commands, and execute them again, by typing "!" followed by the command's history number, as in:

     % history
    1 ls -l
           2 cd tools
          3 history
% !ls

executes the command "ls -1" again. You can also refer to previous commands by strings; that is:

% !ls

given the above history would do the same thing. (The shell looks backwards through the list until it finds one that begins with the string you've given, executing the first one it finds.) You can refer to the immediately preceding command by typing:

% !!

and by referring to a previous command by its offset as a negative value from the current history number. So, above, we're at history number 4 at the second prompt, and typing:

% !-3

would also execute the "ls -1" command.

Another powerful feature is the ability to edit previous commands. Let's say that you want a directory and type:

% ls -l a: \ assembir \ sources \workjng \ * .asm

Oops! The third subdirectory is supposed to be "working" instead of "workjng", and the shell tells you it can't find what you've asked. Instead of retyping the whole line, just to correct one error, you can type:

% ^workjng^working

which repeats the preceding word again.

There are other ways to edit previous commands, and you're not limited to just the most recently typed. For example:

% !10:gs/tmp/temp

executes the command with history number 10, substituting all occurances of "tmp" with "temp."

The Micro C-Shell disk comes with a new "standard I/O" library for Alcyon C programmers. This library fixes many of the problems with the libraries supplied by Atari, and is also faster and smaller.

The manual, though brief, is good. It is split into two parts: the first half is a short tutorial for newcomers, and the second half is a reference manual describing each of the commands in turn.

This package has its faults. It could definitely use more documentation. Some of the commands don't work as advertised in the manual, and indeed, some aren't documented at all.

In general, though, Micro C-Shell is worth every penny especially if you're a developer. It has saved me hours of hassle, and I find more innovative ways to use it every day. I recommend it without hesitation.


  • A User Guide to the Unix system by R. Thomas and Jean Yates, OSBORNE/McGraw-Hill, Berkeley, CA.

  • Introducing the Unix system by H. McGilton and Rachel Morgan, BYTE/McGraw-Hill, New York, NY.

  • The Unix Programming Environment by B.W Kernighan and Rob Pike, Prentice-Hall, Englewood Cliffs, NJ.


alias Lets you define a sort of "macro" which replaces a given key word.

cat "Concatenates" (appends together) one or mare disk files and prints them to the standard output device.

cc A short cut for programmers using the C language compiler sold in the developer's kit from Atari. It allows you to run a C source file through all of the various subprograms necessary to produce a linkable object file.

cd Changes to a new "working" directory or subdirectory It's like opening a folder with the Desktop program.

chmod Allows you to change the "permissions" of files. You can make files "read only" "hidden" from directory searches, and designate "system" files.

cmp Compares two disk files and tells you if they differ, and if so, the line number and byte position of the first difference.

cp Makes a copy of one or more disk files.

date Allows you to change the real-time clock to a given date and time.

df Tells you how much free space you have on a given disk.

diff Compares two text files. If they differ, it can construct a script telling what lines must change in each file to make them equal. This script can be interpreted directly by the "sed" command, which will perform the necessary editing for you. This command is very useful for programmers - if you make a number of changes to a working source code file (and possibly forget everything you've changed) diff can tell you after the fact what those changes were.

echo Echoes the "tail" (the words following a command itself) expanding all shell variables and wildcard file designators.

fcp Does a track-by-track copy of an entire disk.

fmt Formats a disk.

gem Assuming there is enough RAM left this command allows you to directly run a GEM-based program from the shell prompt. This keeps you from exiting to the Desktop to run a GEM-based program.

grep "grep" is shorthand for "Global Regular Expression Printer" It searches files for a string pattern. There are many different options, allowing you to search for a wide range of expressions. One common use for programmers is to find a label's occurance over a range of source code files.

head Prints a given number of lines at the "head" or start of one or more text files.

history A very powerful command, which tells you up to the last 16 commands that you have entered. These past commands can be referenced by number, or by name, and you can edit a past command, It lets you correct typing mistakes on long command lines, instead of typing the whole line again. It also lets you perform the same function over a range of files.

logout Exits to whatever program loaded Micro C-Shell (normally the Desktop program).

lpr This function is called a "filter" and prints one or more text files to the printer. You con specify page length and width, and make the printer pause between pages for single sheet entry.

ls List the contents of a directory. There are several options to this command allowing for a wide range of directory formats.

mkdir Makes a new directory or sub-directory

more Takes a text file and prints it out one screen at a time, pausing so that you can peruse the file at your leisure. You can also search for strings, backup to previous positions, and so on.

mv Moves (or renames) files. When you move a file from one directory to another, it deletes the original copy of the file so that only the destination copy exists. This is unlike the Desktop program, which only lets you copy a file to another drive or folder. When you move a file within the same directory you are effectively renaming it.

pr Prints one or more files to the standard output device, with or without an optional header line.

pwd Tells you the present "working" directory (that is, the current default directory).

rm Deletes one or more files from the disk.

rmdir Deletes one or more directories from the disk, which must be emptied first.

sed The "Stream EDitor." This program copies a file to the standard output device, using a script file (see diff) which sed uses to make on the fly editing changes while it's printing. This is a short cut method of loading a file manually into a text editor and keying in the changes yourself diff can create such scripts, and sed in turn rounds out an automated editing process.

set Allows you to set a shell variable. Some shell variables are used by the shell itself. You can create your own variables to reference in command lines.

tail Prints a given number of lines from the "tail" or end of one or more text files.

tee tee copies a file from the standard input device to both a named file or device and the standard output device.

wc Provides the number of words, lines, and/or characters in a text file.