[Chapter 4] 4.8 Invoking the Shell
Author: Daniel Gilly & the Staff of O'Reilly & Associates
Date: 1998-08-06T21:59:05Z

#

| Chapter 4 The Bourne Shell and Korn Shell |

## 4.8 Invoking the Shell

The command interpreter for the Bourne shell (sh) or the Korn shell (ksh) can be invoked as follows:

> sh [`options`] [`arguments`]

> ksh [`options`] [`arguments`]

ksh and sh can execute commands from a terminal (when -i is specified), from a file (when the first `argument` is an executable script), or from standard input (if no arguments remain or if -s is specified).

Arguments

  Arguments are assigned in order to the positional parameters $1, $2, etc. If array assignment is in effect (-A or +A), arguments are assigned as array elements. If the first argument is an executable script, commands are read from it, and remaining arguments are assigned to $1, $2, etc.

Options

  -c `str`

    Read commands from string `str`.

  -i

    Create an interactive shell (prompt for input).

  -p

    Start up as a privileged user (i.e., don't process $HOME/.profile).

  -r

    Create a restricted shell (same as rksh or rsh).

  -s

    Read commands from standard input; output from built-in commands goes to file descriptor 1; all other shell output goes to file descriptor 2.

The remaining options to sh and ksh are listed under the set built-in command.

4.7 Job Control |  | 4.9 Restricted Shells