HP-UX Reference (11i v1 05/09) - 1 User Commands A-M (vol 1)

k
ksh(1) ksh(1)
KSH_QUOTEMC switches the processing of quoted metacharacters in "
[[ string
= pattern ]]" con-
structs. If
KSH_QUOTEMC=true
is defined in the environment, then any part of pattern can be quoted to
cause it to be matched as a string. This usage follows the conventions of dtksh(1). If
KSH_QUOTEMC is
not defined in the environment, then processing follows the traditional Korn shell conventions.
International Code Set Support
Single-byte character code sets are supported.
RETURN VALUE
Errors detected by the shell, such as syntax errors, cause the shell to return a non-zero exit status. Other-
wise, the shell returns the exit status of the last command executed (also see the
exit command above).
If the shell is being used non-interactively, 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
File descriptors 10 and 54 through 60 are used internally by the Korn Shell. Applications using these and
forking a subshell should not depend upon them surviving in the subshell or its descendants.
If a command which 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 contin-
ues 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
command with a full path name to correct this situation.
Some very old shell scripts contain a caret (ˆ) as a synonym for the pipe character (
|). Note however,
ksh 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 causes the entire command to disappear
from the history file.
The built-in command . file reads the entire file before any commands are executed. Therefore,
alias
and unalias commands in the file do 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
CHLD is not exe-
cuted until the foreground job terminates.
The
export built-in command does not handle arrays properly. Only the first element of an array is
exported to the environment.
Background processes started from a non-interactive shell cannot be accessed by using job control com-
mands.
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 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 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.
HP-UX 11i Version 1: September 2005 22 Hewlett-Packard Company Section 1431