HP-UX Reference (11i v2 07/12) - 1 User Commands N-Z (vol 2)

s
sh-posix(1) sh-posix(1)
If the shell is being used noninteractively, the execution of the shell file is abandoned. Runtime errors
detected by the shell are reported by printing the command or function name and the error condition. If
the line number on which the error occurred is greater than one, the line number is also printed in brackets
([]) after the command or function name.
WARNINGS
Some file descriptors are used internally by the POSIX shell. For HP-UX releases 10.10 and beyond, file
descriptors 24 through 30 are reserved. HP-UX releases 10.00 and 10.01 reserve descriptors 54 through 60.
Applications using these and forking a subshell should not depend upon them surviving in the subshell or
its descendants.
If a command that is a tracked alias is executed, and a command with the same name is installed in a
directory in the search path before the directory where the original command was found, the shell will con-
tinue to load and execute the original command. Use the
-t option of the alias command to correct this
situation.
If you move the current directory or one above it,
pwd may not give the correct response. Use the cd com-
mand with a full path name to correct this situation.
Some very old shell scripts use a caret (
ˆ) as a synonym for the pipe character (
|). sh does not recognize
the caret as a pipe character.
If a command is piped into a shell command, all variables set in the shell command are lost when the com-
mand completes.
Using the
fc built-in command within a compound command will cause the entire command to disappear
from the history file.
The dot (.) special command, as in . file, reads the entire file before any commands are executed. There-
fore, alias and unalias commands in the file will not apply to any functions defined in the file.
Traps are not processed while the shell is waiting for a foreground job. Thus, a trap on
SIGCHLD is not
executed until the foreground job terminates.
The
export special command does not handle arrays properly. Only the first element of an array is
exported to the environment.
Background processes started from a noninteractive shell cannot be accessed with job control commands.
The value of the IFS variable in the user’s environment affects the behavior of scripts.
Collating Order
In an international environment, character ordering is determined by the value 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 would also match file names beginning with an upper-
case character (as well as those beginning with accented letters). Conversely, it would fail to match letters
collated after z in languages such as Danish or Norwegian.
The correct (and safe) way to match specific character classes in an international environment is to use a
pattern (see regexp(5)) 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 noninternationalized 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, and so on, be set to C or not set at all.
History File and Locales
The history file does not support mixing of locales in the same file. For users of multiple locales, you can
assign a unique history file for each locale by setting HISTFILE as:
HISTFILE=$HOME/.sh_hist_${LANG}
290 Hewlett-Packard Company 26 HP-UX 11i Version 2: December 2007 Update