HP-UX Reference (11i v2 04/09) - 1 User Commands N-Z (vol 2)
s
sh-posix(1) sh-posix(1)
% trap [arg][sig]...
Set arg as a command that is read and executed when the shell receives a sig signal. (Note that arg
is scanned once when the trap is set and once when the trap is taken.) Each sig can be given as the
number or name of a signal. Letter case is ignored. For example,
3, QUIT, quit, and SIGQUIT
all specify the same signal. Use kill -l
to get a list of signals.
Trap commands are executed in signal number order. Any attempt to set a trap on a signal that was
ignored upon entering the current shell is ineffective. Traps remain in effect for a given shell until
explicitly changed with another
trap command; that is, a trap set within a function will remain in
effect even after the function returns.
If arg is
- (or if arg is omitted and the first sig is numeric), reset all traps for each sig to their origi-
nal values.
If arg is the null string (
’’
or ""), each sig is ignored by the shell and by the commands it invokes.
If sig is
DEBUG, then arg is executed after each command. If sig is
ERR, arg is executed whenever a
command has a nonzero exit code. If sig is
0 or EXIT, the command arg is executed on exit from
the shell.
With no arguments, print a list of commands associated with each signal name.
&
typeset [{-+}LRZfilrtux[n]] [name[=value] ]... name
=value [name=value]...
Assign types and a value to a local named parameter name. See also the
export special command.
Parameter assignments remain in effect after the command completes. When invoked inside a func-
tion, create a new instance of the parameter name. The parameter value and type are restored
when the function completes.
The following list of attributes can be specified. Use
+ instead of - to turn the options off.
-L Left justify and remove leading blanks from value.Ifn is nonzero, it defines the width of the
field; otherwise, it is determined by the width of the value of first assignment. When name is
assigned, the value is filled on the right with blanks or truncated, if necessary, to fit into the
field. Leading zeros are removed if the
-Z option is also set. The -R
option is turned off.
Flagged as
leftjust n.
-R Right justify and fill with leading blanks. If n is nonzero, it defines the width of the field; oth-
erwise, it is determined by the width of the value of first assignment. The field is left-filled
with blanks or truncated from the end if the parameter is reassigned. The -L option is turned
off. Flagged as rightjust n.
-Z Right justify and fill with leading zeros if the first nonblank character is a digit and the
-L
option has not been set. If n is nonzero it defines the width of the field; otherwise, it is deter-
mined by the width of the value of first assignment. Flagged as zerofill n plus the flag for
-L or -R.
-f Cause name to refer to function names rather than parameter names. No assignments can be
made to the name declared with the typeset statement. The only other valid options are -t
(which turns on execution tracing for this function) and -x (which allows the function to
remain in effect across shell procedures executed in the same process environment). Flagged
as function.
-i Parameter is an integer. This makes arithmetic faster. If n is nonzero it defines the output
arithmetic base; otherwise, the first assignment determines the output base. Flagged as
integer [base n].
-l Convert all uppercase characters to lowercase. The uppercase -u option is turned off. Flagged
as lowercase.
-r Mark any given name as "read only". The name cannot be changed by subsequent assignment.
Flagged as readonly.
-t Tag the named parameters. Tags are user-definable and have no special meaning to the shell.
Flagged as tagged.
-u Convert all lowercase characters to uppercase characters. The lowercase -l option is turned
off. Flagged as uppercase.
-x Mark any given name for automatic export to the environment of subsequently executed com-
mands. Flagged as export.
Section 1−−854 Hewlett-Packard Company − 10 − HP-UX 11i Version 2: September 2004