.Dd November 9, 2022 .Dt SH 1 .Os .Sh NAME .Nm sh .Nd shell command interpreter .Sh SYNOPSIS .Nm sh .Op Fl ceils .Op Ar script Oo argument ... Oc .Nm sortix-sh .Op Fl ceils .Op Ar script Oo argument ... Oc .Sh DESCRIPTION .Nm is the command line interpreter for the shell language. It reads and executes commands from the standard input or the .Ar script file if specified. .Nm is interactive if the standard input is a terminal and no .Ar script file was specified. .Pp The standard shell .Nm sortix-sh is currently primitive and cannot execute most scripts. .Nm sh is currently a thin wrapper that detects non-interactive use and invokes a better shell instead, named in the .Ev SORTIX_SH_BACKEND environment variable if set, or named in .Xr proper-sh 5 if it exists, and otherwise .Xr dash 1 is invoked. .Pp The options can be unset by prefixing them with a plus .Sq + instead of a dash .Sq - . .Pp The options are as follows: .Bl -tag -width "12345678" .It Fl c The .Ar script argument contains the script's text instead of a path to the script file. .It Fl e Exit if any command exit non-zero. .It Fl i Interactively read and execute commands. .It Fl l The shell is a login shell. Interactive shells run the .Xr profile 5 script on startup instead of the .Xr shrc script. This option is set if the shell is invoked by a name starting with a dash .Sq - . .It Fl s Read commands from the standard input (the default). This option can be combined with the .Fl c option to execute the script text in the .Ar script argument before reading normally from the standard input .El .Sh ENVIRONMENT .Nm uses environment these variables: .Bl -tag -width "HISTFILE" .It Ev ENV File to execute on non-login interactive startup instead of .Pa ~/.shrc per .Xr shrc 5 . This variable is subject to path expansion. .It Ev HISTFILE Save the shell history in this file. The default is .Pa ~/.sh_history . .It Ev HISTSIZE Maximum number of commands in the saved shell history. The default is 500. .It Ev HOME The user's home directory .Sq ( ~ ) . .It Ev PATH The colon-separated list of directory paths to search for programs. .It Ev PWD Set to the current working directory. .It Ev SHELL Set to .Nm . .It Ev 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 .Pa /dev/tty1 terminal to avoid accidentally powering off the machine. .It Ev SORTIX_SH_BACKEND Name of a better shell to use for non-interactive use per .Xr proper-sh 5 . This variable takes precedence over .Pa /etc/proper-sh . .El .Sh FILES .Bl -tag -width "/etc/proper-sh" -compact .It Pa ~/.profile , /etc/profile , /etc/default/profile .Xr profile 5 script whose commands are run on non-login interactive shell startup. .It Pa /etc/proper-sh Name of a better shell to use for non-interactive use per .Xr proper-sh 5 . The .Ev SORTIX_SH_BACKEND environment variable takes precedence over this file if set. .Xr dash 1 is used by default if it is installed. .It Pa ~/.sh_history The saved shell history. This location is controlled by the .Ev HISTFILE environment variable. .It Pa ~/.shrc , /etc/shrc , /etc/default/shrc .Xr shrc 5 script whose commands are run on login interactive shell startup. The .Ev ENV environment variable overrides the search for the script if set. .El .Sh EXIT STATUS .Nm exits with the same exit status as the last run command, or 0 if no command has been run. .Sh SEE ALSO .Xr dash 1 , .Xr profile 5 , .Xr proper-sh 5 , .Xr session 5 , .Xr shrc 5 , .Xr login 8