sh [file]
If a file is named as a command line argument, that file is the source of input; otherwise, standard input is read.
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
|
to process a script file
|
another program
|
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.
Any input following a # on a line is discarded.
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. 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: expand, match - file pattern matching in Chapter 15.
This expansion is not applied to the filenames used for input/output redirection.
Quoting
The shell special characters can be stripped of their meaning and treated as literals by enclosing them in single quotes. Inside a quoted string, the special meaning of the single quote can be removed by immediately following it with another single quote. Command lines with un-terminated quoted strings are rejected and cause an error message. Examples
xxx$ echo '''' ' xxx$ echo 'don''t' don't xxx$ echo 'hello' 'world sh: unmatched quote xxx$ echo 'a'b ab xxx$ echo a'b' ab xxx$
Attempts to redirect standard input to a non-existing file will fail. Redirecting standard output to a non-existing file will cause that file to be created. If 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.
Command pipelines started 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, mount, unmount - change name space and pctl - process control in Chapter 8.
Files
/prog/n/wait Notes
This is a rudimentary shell designed for debugging applications. It is not intended to serve as a general-purpose programmable shell. Caveat
Inferno does not support an append mode. Therefore, the shell's approximation is not guaranteed if there are concurrent appending processes. See Also