GNO Shell User's Manual

By Tim Meekins, Albert Chin, and Jawaid Bazyar

Edited by Andrew Roughan

Table of Contents

Chapter 1 Getting started with the GNO Shell

- Introduction
  Customizing the Shell Environment
  Invoking gsh

Chapter 2 Interacting with the GNO Shell

- Executing Commands
  Command-line Editor
  Command Input
  Command Editing
  History Editing Keys
  Command, Filename and Variable completion

Chapter 3 Using the GNO Shell more productively

- What does this command do?
  Option Arguments
  Entering Multiple commands
  Using Aliases as Shorthand
  Redirecting Input and Output
  Pipelines
  Job Control
  Working with Pathnames
  Pathname Expansion
  Quoting Special Characters
  How gsh Finds a Command

Chapter 4 Built-in Commands

- Built-ins vs EXE Commands
  Shell Commands
  Kernel Commands
  Environment Commands

Chapter 5 Shell Variables

- Using shell variables
  Scope
  Description of Pre-defined Shell Variables
  Accessing shell variables

Appendix A Sample gsh session

Appendix B Prefix Conventions

Appendix C Errors

Appendix D Signals

Appendix E Non-Compliant Applications

Appendix F Termcaps

Glossary

Index 63

Chapter 1

Getting started with the GNO Shell

"Computer operating systems are among the most complex objects created by mankind..."

Douglas Comer, Operating System Design, The Xinu Approach

Introduction

The GNO shell is an integral part of the GNO Multitasking Environment (GNO/ME). The GNO shell provides the interface between the user and the GNO Kernel. While both work together, the jobs they perform are quite different. This manual documents the functions of the shell.

The user interacts with the shell through a command-line interface. Command-line interfaces provide a unique way of interacting with the operating system. Unlike GUIs (Graphical User Interfaces), with which you are already familiar with by using programs such as the Finder and ShrinkIt! GS, all commands are typically entered using the keyboard. The shell interprets commands and passes them to the kernel for control and execution.

The command-line interface will be unfamiliar to some people However, once the command-line interface has been mastered, the user should have no difficulty using any current or future GNO applications. Those of you already familiar with Unix interfaces, such as the C shell, Bourne shell, and Korn shell, or the ORCA shell on the Apple IIGS, will begin to realize the advantages which GNO/ME is able to provide.

The way this manual is presented allows the complete beginner to simply work through the chapters in a chronological prder. Chapter 2 familiarises the user with entering basic commands whereas the more powerful GNO/ME features are introduced in Chapter 3. Chapter 4 documents the commands which are built into the GNO Shell and Chapter 5 explains shell variables which give the user control over how thier installation functions.

Customizing the Shell Environment

When gsh, the implimentation of the GNO Shell, is executed, it reads in and processes the gshrc file. This file contains start-up instructions for the shell, which can be used to customize the operation of the shell and other aspects of the system. It is created by the GNO Installer during the installation process.

The following is a sample gshrc file (line numbers have been added for convenience):

    1	###
    2	#
    3	# GNO 2.0 gshrc file
    4	#
    5	###
    6	#
    7	# Initialize our environment
    8	#
    9	set path=":hard:gno:bin :hard:gno:usr:bin"
    10	set prompt="[%h] %S%t%s %C> "
    11	set home=":hard:gno:user:root"
    12	set term=gnocon
    13	export path prompt home term
    14	setenv history=100 savehist=25
    15	###
    16	#
    17	#Set up standard prefixes for utilities.
    18	#
    19	###
    20	prefix 2 :software:orca:libraries
    21	prefix 3 :software:orca
    22	prefix 4 :software:orca:shell
    23	prefix 5 :software:orca:languages
    24	prefix 6 :software:orca:utilities
    25	prefix 7 :tmp
    26	###
    27	#
    28	# Set up prefixes for Orca2.0(tm)'s benefit
    29	#
    30	###
    31	prefix 13 :software:orca:libraries
    32	prefix 14 :software:orca
    33	prefix 15 :software:orca:shell
    34	prefix 16 :software:orca:languages
    35	prefix 17 :software:orca:utilities
    36	alias ls 'ls -CF'
    37	alias dir 'ls -al'
    38	alias cp 'cp -i'
    39	alias rm 'cp -p rm'
    40	alias mv 'cp -p mv'
    41	setenv usrman='/usr/man'
    42	set fignore='.a .root .sym'
    43	alias zcat 'compress -cd'
    44	setenv pager=less
    45	setenv less=-e
    46	set nonewline=1
    47	#
    48	# Move to home directory
    49	#
    50	cd line

When you install GNO/ME, the GNO installer knows where to find the GNO utilities and any ORCA utilities you may have. Unfortunately it does not know where all the other utilities and applications that you may wish to use are located. It is therefore necessary to edit the setup file in order to tell the GNO shell where these programs are on your hard disk.

The setup file, gshrc, is located in the /usr directory of the path where you installed GNO/ME. You can use any text editor from the desktop to edit the gshrc file, or if you are already familiar with the editor vi you can use this utility after launching the GNO kernel.

Line 9 is the statement that we are concerned with. Hard represents the name of your particular hard drive volume where you have installed GNO/ME.

set path=":hard:gno:bin :hard:gno:usr:bin" line #9

You will see that spaces have been inserted between pathnames. The space is the pathname separator and the colon has been used as the path delimiter for this specific variable, PATH. As an exercise, add your system directory to this statement. Line 9 should now look like this:

set path=":hard:gno:bin :hard:gno:usr:bin :hard:system"

What you have just done allows the GNO shell to find the Finder application. Now go ahead and add any pathnames that hold utilities or applications that you will use frequently from GNO/ME. It should also be noted that it is possible to have more than one pathname containing EXE, SYS16, or EXEC files; this is impossible under ORCA. The PATH variable is discussed thoroughly in Chapter 5.

For now, the remaining lines of the gshrc file do not need editing. As you gain an understanding of the system you may wish to make further changes to the gshrc file. Make sure you save the file before you exit the editor.

It is possible to modify these instructions while the GNO shell is active, but any changes will be lost upon exiting gsh. If you wish the changes to remain effective for the next session you must add them to the gshrc file.

By customizing the gshrc file it is possible to make the GNO environment more like U NIX, the ORCA environment, or something completly different. Customization of the GNO environment leads to greater user productivity.

Invoking .i.gsh

GNO/ME can be launched from a program launcher, such as the System 6.0 Finder. Launch the GNO Kernel program, kern by double clicking on it. The GNO kernel automatically executes the supplied GNO shell, gsh.

The prompt, "`[1] 2:00am root` `%`", indicates that gsh is ready to receive input from the keyboard.

To start a new gsh from the command-line simply type gsh. If multiple copies of the gsh process are undesirable, use the command source gsh instead. This is useful for testing changes made to the gshrc file. Source is a built-in comand which is discussed in Chapter 4 Shell commands.

Chapter 2

Interacting with the GNO Shell

Executing Commands

A command consists of two parts: a name and its arguments. The command name is the name used to start the command. The name is usually the name of a file which can be executed. The only exceptions are commands which are built-in to the shell. These commands are documented in Chapter 4 Built-In Commands. Any shell utility command with a filetype of EXE, SYS16, or EXEC, can be executed in this fashion. The command name must be separated from the command arguments with a space.

The command arguments are parameters that the command takes as data to work with (In Applesoft BASIC, "HELLO WORLD" would be an argument for the PRINT command). Command arguments are separated from each other with a space. Note that although arguments extend the usefulness of a command, not all commands have arguments. Any arguments entered after the command will be passed by the shell to the program when it starts exectuting.

The examples below use the following commands:

qtime displays time in English text.

echo prints arguments to the screen.

Examples:

% qtime

It's almost five.

% echo II Infinitum

II Infinitum

At the simplest level the user enters commands to the shell by typing them on the keyboard. Gsh includes a command-line editor to help the user enter and edit commands. The editor also provides a way to modify and execute previous commands. Additionally the editor can help complete the names of commands, filenames and variables.

Command-line Editor

Below is a complete description of the functions of the command-line editor with short examples depicting how each editing key works.

Throughout the examples the underline character, "_", will be used to represent the current cursor position. In addition, "OA" is used to represent the Open Apple key and the term word is used to indicate a string of characters consisting of only letters, digits, and underscores. To the right of a editing key entry is the bindkey function name which is used to remap editing functions to new keys. This information is included for reference purposes only. See Chapter 4 Shell Commands for more information on the bindkey command.

It should be pointed out that at this stage that the user should not be concerned with what the actual commands used in the examples do, rather the user should concentrate on how the command-line editor functions work.

Command Input

These command-line editor keys deal with entering text directly on the command-line.

RETURN newline

> The return key is used to terminate line input. gsh then interprets the command on the line and acts accordingly. The position of the cursor on the command-line does not matter.

> Before

> % echo f o o bar (RETURN)

> After

> foo bar

> % _

CTRL-D <no bindkey name>

> Exits gsh if it was the first character typed on the command-line. If there are still jobs running in the background or stopped, gsh will display "There are stopped jobs." If you press CTRL-D a second time without an intervening command, gsh will terminate all the jobs in the job list and exit.

CTRL-R redraw

> Moves to the next line and re-displays the current command-line. Use this to redraw the current line if the screen becomes garbled.

CTRL-L clear-screen

> Clears the screen, moves the cursor to the top line, and redraws the prompt and any command-line that was in the process of being edited.

Command Editing

These command-line editor keys allow editing of the command-line text.

CTRL-B backward-char

> LEFT-ARROW Moves the cursor one character to the left. You cannot move past the first character on the line. If so, gsh will output an error beep.

> Before After

> % print f o o bar (LEFT-ARROW) % print f oo bar

CTRL-F forward-char

RIGHT-ARROW Moves the cursor one character to the right. You cannot move past the last character on the line. If so, gsh will output an error beep.

Before After

% print f o o bar (RIGHT-ARROW) % print fo o bar

DELETE backward-delete-char

Deletes the character to the left of the cursor. You can delete up to the first character on the command-line.

Before After

% print f o o bar (DELETE) % print o o bar

CLEAR kill-whole-line

CTRL-X Deletes all characters on the command line and positions the cursor after the prompt.

Before After

% prin t foo bar (CTRL-X) % _

CTRL-Y; kill-end-of-line

Deletes all characters from the cursor to the end of the command-line.

Before After

% print f o o bar (CTRL-Y) % print f_

CTRL-D delete-char

OA-D Deletes the character under the cursor.

Before After

% print fo o bar (OA-D) % print fo bar

CTRL-A beginning-of-line

OA-< Moves the cursor to the beginning of the line.

Before After

% print f oo bar (OA-<) % p rint foo bar

CTRL-E end-of-line

OA-> Moves the cursor to the first position past the last character on the line.

Before After

% print f oo bar (OA->) % print foo bar_

OA-RIGHT-ARROW forward-word

Moves the cursor right to the last character of the current word.

Before After

% print f oo bar (OA-RIGHT-ARROW) % print fo o bar

OA-LEFT ARROW backward-word

Moves the cursor left to the beginning of the current word.

Before After

% print f o o bar (OA-LEFT ARROW) % print f oo bar

% print foo b ar (OA-LEFT ARROW) % print f oo bar

OA-E toggle-cursor

Toggles input mode between insert and overstrike. Overstrike mode is distinguished by a solid inverse cursor and insert mode by a blinking '_' cursor. In overstrike mode, any characters that are typed directly over-write those characters below the cursor. In insert mode, the characters typed are inserted before the character below the cursor.

History Editing Keys

These command-line editor keys allow access to previously entered commands. The GNO shell automatically keeps track of previous commands in what is called a history buffer.

The maximum number of command-lines saved in the history buffer is determined by the shell variable . A default value for this variable is set in the gshrc file that the GNO Installer creates. The lines saved to the history buffer are kept between sessions. That is, when you exit gsh, $SAVEHIST command-lines are saved to the history file in your $HOME directory. When gsh is invoked again, all command-lines saved in the history buffer will be available using history editing keys. See Chapter 5 Description of Predefined Shell Variables for more informtation on the HISTORY and SAVEHIST variables.

- CTRL-P up-history

  UP-ARROW Fetches the previous command-line. If the current command-line is the first line in the history buffer, the next line fetched will be an empty command-line. If invoked again, the last line in the history buffer will be displayed.

  Before After

  % print foo bar

  % echo Apple II

  % echo GNO/ME

  % _ (UP-ARROW) % echo GNO/ME_

  % echo GNO/ME_ (UP-ARROW) % echo Apple II_

  CTRL-N down-history

  DOWN-ARROW Fetches the next command-line. If the current command-line is the last command line in the history buffer, the next line fetched will be the first command-line in the history buffer.

  Before After

  % print foo bar

  % echo Apple II

  % echo GNO/ME

  % _ (DOWN-ARROW) % print foo bar_

  % print foo bar_ (DOWN-ARROW) % echo Apple II_

  Command, Filename and Variable completion

  These command-line editor keys can be used to complete filenames, commands and variables.

  CTRL-D list-choices

  Lists commands and pathnames that match the current word.

  Before

  % print foo_ bar (CTRL-D)

  After

  foo.c fool foo.m

  % print foo_ bar

  TAB complete-word

  Command, pathname and variable completion. If the cursor is positioned on the first word of the command-line, command pathname is performed, else pathname or variable completion is performed. The word is expanded to the closest matching command, pathname or variable. Characters are appended up to the point that they would cause more than one. If a complete pathname results for pathname completion, gsh appends a "/" if the pathname is a directory; otherwise, it appends a space.

  Before After

  % ca_ (TAB) % cat_

  % mo_ foo.c (TAB) % more_ foo.c

  % more fo_ (TAB) % more foo_

  % echo $TERMC_ (TAB) % echo $TERMCAP_

  Note that if there is more than one match for the partial command, gsh will sound a beep on the speaker. You can use the CTRL-D (list-choices) command to see the list of possible matches, and should either finish entering the command manually or type enough additional characters to guarantee a unique match.

  If the $FIGNORE variable is set, gsh ignores filenames (when doing completion) that end with any of the suffixes in $FIGNORE. See Chapter 5 Description of Pre-defined Shell Variables for more information regarding the $FIGNORE variable.

Other ways of entering commands

Terminal Input

An example involving the connection of a terminal; will be dealt with in Chapter 3 Redirecting Input and Output but it is necessary to mention here that when using .i.gsh over a terminal, some keystrokes must be slightly modified. This is because there are no terminals that can transmit the OA key. Instead, a two-key sequence must be used which replaces OA with ESC. For example, instead of pressing OA-E to toggle insert mode, you can type ESC-E over a terminal to do the same thing.

If you will be using terminals seriously then you should install the Remote Access package.

- Script File

While you would normally type commands on the command-line, you can also store a series of often used commands in a file. A file containing such a series of commands is called a script. A script is normally created by using a text editor.

By typing the name of the script file, the shell will execute it, line by line, as if you had typed each command separately. The gshrc file presented in Chapter 1 Customizing the Shell Environment is an example of a script file.