msb@lsuc.UUCP (Mark Brader) (02/26/85)
The shell scripts Pnews and Rnmail, which are part of rn, both allow you to temporarily escape to your favorite editor, then they take over control again. If your editor is one that catches interrupts and does something useful with them (such as ed or qed, I don't know about vi), then you want to be able to issue interrupts while you're inside Pnews. But as distributed, Pnews says: trap "" 2 ${VISUAL-${EDITOR-$defeditor}} $tmpart $oldart In other words, all interrupts are ignored while the editor is running. This was obviously done to protect Pnews itself from being interrupted. But, as sh(1) explains, if interrupts are turned off this way, the effect is propagated to anything called from sh (including another sh where you might try turning them back on; doesn't work). In fact there is another way to turn off interrupts, which is NOT propagated to children. It's not mentioned in sh(1), and I think it should be; it's sufficiently non-obvious that I think it's worth posting. Ta-da.... trap : 2 In other words, call a no-op upon interrupt. *EMPHASIS* This is what should be used by sh scripts that call programs that catch interrupts. (Also sh scripts that want to allow the user to interrupt some command without the script losing control.) *END EMPHASIS* I have patched our local copies of Rnmail and Pnews so that they work this way now (and they do the same thing with quits... no reason to assume what the editor will do with them). Since I can't depend on other sh scripts being written this way, I have also patched our local copy of the qed editor so that it does not ignore interrupts if stdin is a tty, even if they were being ignored when it was invoked. Mark Brader P.S. utzoo!henry, who told me about this, thinks it's true for all Bourne shell versions. We run V7 locally, and my references to sh(1) are for V7.