Discussion:
[ast-developers] trap <number> vs trap <name>
gerald cato
2014-08-19 02:54:53 UTC
Permalink
Hi,

I've noticed inconsistent behavior between trap <number> vs trap <name>
when action is null. For example:

$ Version jM 93u 2011-02-08

$ trap '' 0
$ trap 0
$ trap '' exit
$ trap exit
ksh: trap: condition(s) required

$ trap '' 1
$ trap 1
$ trap '' HUP
$ trap HUP
ksh: trap: condition(s) required
$

$ Version M-11/16/88i
$ trap '' exit
$ trap '' 0
$ trap exit
$ trap 0

Not sure if this has been fixed in a later release.

Cheers, Gerald

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.research.att.com/pipermail/ast-developers/attachments/20140819/046685b0/attachment-0001.html>
clarkw
2014-08-19 08:35:11 UTC
Permalink
On Tue, Aug 19, 2014 at 10:54 AM, gerald cato <gerald.cato at oracle.com>
Post by gerald cato
Hi,
I've noticed inconsistent behavior between trap <number> vs trap <name>
$ Version jM 93u 2011-02-08
$ trap '' 0
$ trap 0
$ trap '' exit
$ trap exit
ksh: trap: condition(s) required
$ trap '' 1
$ trap 1
$ trap '' HUP
$ trap HUP
ksh: trap: condition(s) required
$
According to the ksh(1) manual (Version jM 93u 2011-02-08), "If *action* is
omitted and the first *sig* is a number, or if *action* is -, then the
trap(s) for each *sig* are reset to their original values". So both `trap
exit' and `trap HUP' are invalid commands as "exit" and "HUP" are not
numbers.

-clark
Post by gerald cato
$ Version M-11/16/88i
$ trap '' exit
$ trap '' 0
$ trap exit
$ trap 0
Not sure if this has been fixed in a later release.
Cheers, Gerald
_______________________________________________
ast-developers mailing list
ast-developers at lists.research.att.com
http://lists.research.att.com/mailman/listinfo/ast-developers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.research.att.com/pipermail/ast-developers/attachments/20140819/d07f4124/attachment.html>
gerald cato
2014-08-19 22:14:40 UTC
Permalink
Thanks Clark, that isclear. I hadn't thought to look at the ksh man page
for trap. However, the trap manual is not clear about this behaviour and
could do with updating. Currently (Version jM 93u 2011-02-08) it only
states: "If action is -, trap resets each condition to the default
value. If action is an empty string, the shell ignores each of the
conditions if they arise. "

Cheers, Gerald
Post by clarkw
On Tue, Aug 19, 2014 at 10:54 AM, gerald cato <gerald.cato at oracle.com
Hi,
I've noticed inconsistent behavior between trap <number> vs trap
$ Version jM 93u 2011-02-08
$ trap '' 0
$ trap 0
$ trap '' exit
$ trap exit
ksh: trap: condition(s) required
$ trap '' 1
$ trap 1
$ trap '' HUP
$ trap HUP
ksh: trap: condition(s) required
$
According to the ksh(1) manual (Version jM 93u 2011-02-08), "If
/action/ is omitted and the first /sig/ is a number, or if /action/ is
-, then the trap(s) for each /sig/ are reset to their original
values". So both `trap exit' and `trap HUP' are invalid commands as
"exit" and "HUP" are not numbers.
-clark
$ Version M-11/16/88i
$ trap '' exit
$ trap '' 0
$ trap exit
$ trap 0
Not sure if this has been fixed in a later release.
Cheers, Gerald
_______________________________________________
ast-developers mailing list
ast-developers at lists.research.att.com
<mailto:ast-developers at lists.research.att.com>
http://lists.research.att.com/mailman/listinfo/ast-developers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.research.att.com/pipermail/ast-developers/attachments/20140820/a711c5d4/attachment.html>
clarkw
2014-08-20 03:36:16 UTC
Permalink
Thanks Clark, that is clear. I hadn't thought to look at the ksh man
page for trap. However, the trap manual is not clear about this
behaviour and could do with updating.
That's true. The builtin --man manual is usually not consistent with the
ksh man page. Another good example is getopts.

-clark
Currently (Version jM 93u 2011-02-08) it only states: "If action is -,
trap resets each condition to the default value. If action is an empty
string, the shell ignores each of the conditions if they arise. "
Cheers, Gerald
On Tue, Aug 19, 2014 at 10:54 AM, gerald cato <gerald.cato at oracle.com>
Post by gerald cato
Hi,
I've noticed inconsistent behavior between trap <number> vs trap <name>
$ Version jM 93u 2011-02-08
$ trap '' 0
$ trap 0
$ trap '' exit
$ trap exit
ksh: trap: condition(s) required
$ trap '' 1
$ trap 1
$ trap '' HUP
$ trap HUP
ksh: trap: condition(s) required
$
According to the ksh(1) manual (Version jM 93u 2011-02-08), "If *action*
is omitted and the first *sig* is a number, or if *action* is -, then the
trap(s) for each *sig* are reset to their original values". So both `trap
exit' and `trap HUP' are invalid commands as "exit" and "HUP" are not
numbers.
-clark
Post by gerald cato
$ Version M-11/16/88i
$ trap '' exit
$ trap '' 0
$ trap exit
$ trap 0
Not sure if this has been fixed in a later release.
Cheers, Gerald
_______________________________________________
ast-developers mailing list
ast-developers at lists.research.att.com
http://lists.research.att.com/mailman/listinfo/ast-developers
_______________________________________________
ast-developers mailing list
ast-developers at lists.research.att.com
http://lists.research.att.com/mailman/listinfo/ast-developers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.research.att.com/pipermail/ast-developers/attachments/20140820/933d4cdb/attachment.html>
Loading...