In the login shell, commands are read sequentially from the file /etc/profile and then, if the files exist, either from the .profile of the current directory or from $HOME/.profile. Following this, commands are also read from the file whose name is defined by the value of the shell variable ENV following parameter substitution.
Syntax
sh[ option...][ file][ argument]... |
No option specified A subshell with the option -s is called. The shell process which was already current becomes the parent of the new shell. Depending on which terminal you are using, you can terminate the subshell either with CTRL+D or @@d or with the exit command. option When called, sh interprets the options below as well as the options which are described under the POSIX shell built-in set command:
The commands are read from command_string.
If the option -s is specified or if file and argument are specified then the POSIX shell reads the commands from the standard input and writes output to the standard output. Only diagnostic messages are written to the standard error output.
If the option -i is specified or if the standard input and output are connected to a video display terminal then an interactive POSIX shell is called. In this case, TERM is ignored to prevent kill 0 from terminating an interactive shell and INTR is intercepted and ignored so that wait can be interrupted. In all cases, the POSIX shell ignores QUIT.
The -r option calls a restricted POSIX shell, in which the following restrictions apply:
To exit a restricted subshell you use CTRL+D or @@d or the exit command, depending on terminal type.
If option -s has not been specified but file has been, the shell procedure file is searched for at the location specified in the search path. The read permission must be set for the procedure. If the s-bit is set for the owner or group, then it is ignored. Commands are read as described below.
You may enter commands as arguments. The command name is passed as argument zero. The commands are described below. If the POSIX shell is called by means of the system call exec and if the first character of the zero argument is a hyphen |
Exit status
The POSIX shell normally returns the exit status of the last command executed (see exit). Errors detected by the POSIX shell (syntax errors for example) result in an exit status which is not equal to zero. If you are not using the POSIX shell interactively, processing of the script file is interrupted. If the POSIX shell detects runtime errors it reports these by outputting the command name and error conditions. If the line number of the line which contains the incorrect command is greater than one, the line number is output in square brackets [...] after the command or function name. |
File
/etc/profile /etc/suid_profile $HOME/.profile /tmp/sh* /dev/null |
Variable
The following variables affect sh: FCEDIT, HISTFILE, HISTSIZE, HOME, IFS, MAIL, MAIL, MAILCHECK, MAILPATH and PATH (description see the section “POSIX shell variables and parameter substitution”). |
Locale
The following environment variables affect the execution of sh: LANG Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_COLLATE Determine the locale for the behavior of ranges, equivalence classes and multicharacter collating elements within pattern matching. LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), which characters are defined as letters, and the behavior of character classes within pattern matching. LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES. |
See also
cat, cd, chmod, cut, echo, env, paste, stty, test, umask, vi dup(), exec(), fork(), getrlimit(), ioctl(), lseek(), pipe(), signal(), umask(), ulimit(), wait(), rand() [4] |