[comp.unix.questions] Question about ksh "trap" and "select" statements

kamat@uceng.UC.EDU (Govind N. Kamat) (05/08/89)

I had a couple of questions about the Korn shell...

> trap "continue" INT TSTP
> select i in a b c; do
> 	prog
> done
> ...more statements...

This is supposed to display a menu consisting of a, b and c, and then
print a prompt asking the user to pick one.  Now, if a keyboard
interrupt is generated while "prog" is being executed, the trap causes
control to be returned to the prompt, as it should.  However, if
generated at the prompt itself, the menu gets printed out one more
time, and the program is aborted immediately after that.

I would have expected, that either:
a)  The menu is printed out once more, followed by the input prompt --
similar to the behavior when a new-line is entered, OR, less likely,
b)  The select is quit, but without printing of the menu.  But, the
program is not aborted, and control passes to the next instruction.

Would anyone have any idea as to why this behavior?

Secondly, there seem to be only two possible actions for SIGTSTP in
the trap: the default, or ignore.  Associating it with an action like
"continue" as shown above causes it to be ignored.  If there are any
non built-in commands in the script, of course it doesn't make much
sense to stop those and leave the shell blocked.  But even if all
commands in the script are internal to the shell, the "continue" is
never generated with a TSTP.

Are these related to any "features" of ksh?  
Thanks for any comments.

-- 
Govind N. Kamat				College of Engineering
kamat@uceng.UC.EDU			University of Cincinnati
					Cincinnati, OH 45221, USA