sh — Inferno 1.1ed
sh
Synopsis
sh [file]
Description
The sh program provides a user level interface (a shell) to the Inferno system. It reads input lines, identifies a command and arguments for that command, and arranges for execution of the corresponding Inferno module.If a file is named as a command line argument, that file is the source of input; otherwise, standard input is read.
There are features that allow input/output redirection, creating pipelines, and performing tasks in background.
Starting the Shell
In desktop-oriented configurations, the shell is started as part of system initialization. The shell can also be started from an existing shell (e.g., to process a script file), or from another program (e.g., the window manager has a button for creating new shells).
Command Line Syntax
Each line consists of one or more command pipelines each separated by either an ampersand (&) (which indicates that the pipeline should be run in background) or a semi-colon (;). The semi-colon need not be provided for the last command pipeline on a line.Command pipelines are not allowed to span lines.
Each command pipeline consists of one or more commands separated by a vertical bar (|) character. The standard output of one command is made the standard input of the next command to the right.
Re-direction of input/output to pipes takes precedence over re-direction from/to files.
In the limit case, a command pipeline consists of a single command with no pipes.
A command consists of one or more fields. The first (leftmost) field is the command field. It is used to determined the executable file to be loaded and run; see below. The remaining fields are parsed and become command line arguments that are passed to the module's init function as a list of strings.
Finding the Module
The command field is converted to the pathname of the Dis file of some module. That field can be either an absolute pathname, starting from /, or a relative pathname from the current directory.As a convenience, the user need not specify the .dis suffix to the filename. If missing, it will be added by the shell.
If the load fails there is, in general, a second attempt to load the module by resolving the pathname relative to the /dis directory (the general system repository of Dis files).
There are two exceptions to this second attempt. The second load attempt is not performed if the command field provides an absolute pathname or a relative pathname starting with dot-slash (./). Such explicit naming is taken to mean that the user will accept no substitutions.
The shell requires that the Dis file implement a module with an interface equivalent to the Command module as specified in /module/sh.m. Otherwise, the named file will not load.
File Name Expansion
Command line arguments (including the command field itself) are expanded by the shell according to the regular expression rules described in filepat .
This expansion is not applied to the filenames used for input/output redirection.
Comments
Any input following a # on a line is discarded. Quoting
The shell special characters can be stripped of their special meaning and treated as literals by enclosing them in single quotes. Examples:
pcsrb.mh.lucent.com$ echo '''' ' pcsrb.mh.lucent.com$ echo 'don''t' don't pcsrb.mh.lucent.com$ echo 'hello' 'world sh: unmatched quote pcsrb.mh.lucent.com$ echo 'a'b ab pcsrb.mh.lucent.com$ echo a'b' ab pcsrb.mh.lucent.com$
Shell Special Characters
Prompt
The shell uses a user prompt consisting of the system name as provided by /dev/sysname suffixed by "$"
Input/Output Re-directions
By default, standard input is the console keyboard and standard output the console display. Each command can arrange for standard input to be taken from a file and for standard output to be written to a file.Attempts to redirect standard input to a non-existing file will fail. Redirecting standard output to an non-existing file will cause the creation of that file. The destination file already exists, it will be overwritten. Any previous contents are lost.
In cases of competing re-direction mechanisms (re-direct to a file and to a pipe), the pipe has precedence.
Background Tasks
In general, the shell will wait for the termination of a command pipeline (including the limit case of a single command) before continuing execution (e.g., prompting the user for the next command). However, if the command pipeline is terminated by an ampersand (&) character, the wait stage is skipped and the shell continues execution immediately while the command pipeline executes as a background task.
Name Space Concerns
When started, the shell creates an independent file name space that is a copy of the file name space of the shell's creator.Command pipelines that are started synchronously by the shell are executed by threads that share the shell's name space. If those commands modify the file name space (and they have not mimicked the shell in creating their own independent name space), those modifications will be perceived by the shell when it continues execution. See bind and pctl .
Command pipelines that are started asynchronously by the shell (background tasks) are implicitly given an independent, duplicate file name space.
Files
/prog/n/wait See Also
Notes
This is a deliberately rudimentary shell designed for debugging applications. It is not intended to serve as a general-purpose programmable shell.
infernosupport@lucent.com Copyright © 1996,Lucent Technologies, Inc. All rights reserved.