SH(1)

NAME
sh - shell command interpreter

SYNOPSIS
sh [-ceils] [script [argument ...]]
sortix-sh [-ceils] [script [argument ...]]

DESCRIPTION
sh is the command line interpreter for the shell language. It reads and executes commands from the standard input or the script file if specified. sh is interactive if the standard input is a terminal and no script file was specified.

The standard shell sortix-sh is currently primitive and cannot execute most scripts. sh is currently a thin wrapper that detects non-interactive use and invokes a better shell instead, named in the SORTIX_SH_BACKEND environment variable if set, or named in proper-sh(5) if it exists, and otherwise dash(1) is invoked.

The options can be unset by prefixing them with a plus ‘+’ instead of a dash ‘-’.

The options are as follows:

-c  The script argument contains the script's text instead of a path to the script file.

-e  Exit if any command exit non-zero.

-i  Interactively read and execute commands.

-l  The shell is a login shell. Interactive shells run the profile(5) script on startup instead of the shrc script. This option is set if the shell is invoked by a name starting with a dash ‘-’.

-s  Read commands from the standard input (the default). This option can be combined with the -c option to execute the script text in the script argument before reading normally from the standard input

ENVIRONMENT
sh uses environment these variables:

ENV File to execute on non-login interactive startup instead of ~/.shrc per shrc(5). This variable is subject to path expansion.

HISTFILE
    Save the shell history in this file. The default is ~/.sh_history.

HISTSIZE
    Maximum number of commands in the saved shell history. The default is 500.

HOME
    The user's home directory ‘(~’).

PATH
    The colon-separated list of directory paths to search for programs.

PS1 Interactive shell prompt when expecting a new command.

PS2 Interactive shell prompt when the current command continues onto another line.

PWD Set to the current working directory.

SHELL
    Set to sh.

SHLVL
    Depth of recursive shell sessions. The outermost interactive shell (depth 1) will currently refuse to exit on an end-of-file condition (^D) when on the /dev/tty1 terminal to avoid accidentally powering off the machine.

SORTIX_SH_BACKEND
    Name of a better shell to use for non-interactive use per proper-sh(5). This variable takes precedence over /etc/proper-sh.

FILES
~/.profile, /etc/profile, /etc/default/profile
    profile(5) script whose commands are run on non-login interactive shell startup.
/etc/proper-sh
    Name of a better shell to use for non-interactive use per proper-sh(5). The SORTIX_SH_BACKEND environment variable takes precedence over this file if set. dash(1) is used by default if it is installed.
~/.sh_history
    The saved shell history. This location is controlled by the HISTFILE environment variable.
~/.shrc, /etc/shrc, /etc/default/shrc
    shrc(5) script whose commands are run on login interactive shell startup. The ENV environment variable overrides the search for the script if set.

EXIT STATUS
sh exits with the same exit status as the last run command, or 0 if no command has been run.

SEE ALSO
dash(1), profile(5), proper-sh(5), session(5), shrc(5), login(8)