HP-UX Reference (11i v1 05/09) - 1 User Commands N-Z (vol 2)

s
sh-bourne(1) sh-bourne(1)
0 Success.
1 Built-in command failure (see Special Commands).
2 Syntax error.
3 Signal received that is not trapped.
If the shell is non-interactive, it terminates and passes one of the above as its exit status. If it is interac-
tive, it does not terminate, but $? is set to one of the above values.
Whenever a child process of the shell dies due to a signal, the shell returns an exit status of 80 hexadecimal
plus the number of the signal.
WARNINGS
If a command is executed and a command having the same name is installed in a directory in the search
path before the directory where the original command was found, the shell continues to
exec the original
command. Use the
hash command to correct this situation.
When the shell encounters >>, it does not open the file in append mode. Instead, it opens the file for writ-
ing and seeks to the end.
If you move the current directory or one above it, pwd cannot give the correct response. Use the
cd com-
mand with a full path name to correct this situation.
The command
readonly (without arguments) produces the same output as the command export.
Failure (non-zero exit status) of a special command preceding a ||
symbol prevents the list following ||
from executing.
In an international environment, character ordering is determined by the setting of
LC_COLLATE ,rather
than by the binary ordering of character values in the machine collating sequence. This brings with it cer-
tain attendant dangers, particularly when using range expressions in file-name-generation patterns. For
example, the command,
rm [a-z]*
might be expected to match all file names beginning with a lowercase alphabetic character. However, if
dictionary ordering is specified by
LC_COLLATE , it also matches file names beginning with an uppercase
character (as well as those beginning with accented letters). Conversely, it fails to match letters collated
after z in languages such as Norwegian.
The correct (and safe) way to match specific character classes in an international environment is to use a
pattern of the form:
rm [[:lower:]]*
This uses LC_CTYPE to determine character classes and works predictably for all supported languages and
codesets. For shell scripts produced on non-internationalized systems (or without consideration for the
above dangers), it is recommended that they be executed in a non-NLS environment. This requires that
LANG, LC_COLLATE, etc., be set to "C" or not set at all.
sh implements command substitution by creating a pipe between itself and the command. If the root file
system is full, the substituted command cannot write to the pipe. As a result, the shell receives no input
from the command, and the result of the substitution is null. In particular, using command substitution for
variable assignment under such circumstances results in the variable being silently assigned a NULL value.
The signal SIGSEGV should not be blocked when executing sh.
sh reserves file descriptor 59 for internal use. Reducing the number of available file descriptors below 60
causes sh to fail.
Each time a function is executed in a shell script, any arguments given to the function overwrite the values
of the positional parameters for the entire script. If the values of the positional parameters must be
preserved, they must be explicitly saved before each function call.
AUTHOR
sh was developed by AT&T and HP.
FILES
$HOME/.profile
/dev/null
/etc/profile
Section 1890 Hewlett-Packard Company 9 HP-UX 11i Version 1: September 2005