ksh != sh on traps

Dave Burton daveb at i88.isc.com
Fri Feb 16 07:49:49 AEST 1990


The 88b version of ksh was changed in a way that, to my eyes, is broken.
Below, ksh = 11/16/88b, oksh = 06/03/86, and sh = SunOS 3.5 /bin/sh.

Script started on Thu Feb 15 14:18:59 1990
-------------------1$ cat x
:
trap "echo doing trap 0" 0
trap "echo doing trap 1" 1

die() {
        trap
        echo "function: die()"
        exit 1
}

echo "main body"
die
echo "end of main"
exit 2
-------------------2$ sh x
main body
0: echo doing trap 0
1: echo doing trap 1
function: die()
doing trap 0
-------------------3$ oksh x
main body
0:echo doing trap 0
1:echo doing trap 1
function: die()
doing trap 0
-------------------4$ ksh x
main body
function: die()
-------------------5$ ^D
script done on Thu Feb 15 14:19:23 1990

The KornShell book is self-contradictory on this point: cf ppg 150-151 & 204,
and I cannot find any good reason to fathom such a change. Perhaps someone
else has an answer (beyond "ksh is broken")? What about workarounds that are
compatible with both sh and ksh?
--
Dave Burton
uunet!ism780c!laidbak!daveb



More information about the Comp.unix.questions mailing list