trap 0 in /bin/sh

Walter Mecky walter at mecky.UUCP
Fri Mar 29 11:02:38 AEST 1991


In article <1991Mar27.153352.4421 at robobar.co.uk> ronald at robobar.co.uk (Ronald S H Khoo) writes:
< Can someone explain why these two commands give different output ?
< Is there some subtlety about the "trap" command that I don't understand ?
< 
< 	$ ( trap 'echo foo' 0 ; true )
< 	$ ( trap 'echo foo' 0 ; : )
< 	foo

Looks like a bug in sh, ksh executes echo with both commands.
I suppose, the subshell for the commands in ( ... ) looks to 
the last command bevor ) and, if it's not a builtin, does only exec(2),
instead of the usual fork(2)/exec(2). So sh cannot execute the trap
commands.
-- 
Walter Mecky	[ walter at mecky.uucp	or  ...uunet!unido!mecky!walter ]



More information about the Comp.unix.shell mailing list