Chapter 12. Traps

Rather than waiting to hear through the grapevine about your teenager's latest hi-jinks and then ranting and raving long after the fact, wouldn't it be wonderful if every untoward action generated an “admonishment from parent,” which echoed in his head as if it were between two stereo speakers and you controlled the volume and content? Or how about a mechanism where every time he leaves the house there is an automatic litany of do's and dont's that bray into his mind? If either of these mechanisms sounds enticing, you will find the Korn Shell's capability to trap events to be of interest.

Consider two of the most common events that occur during the execution of a script: errors and exits. The errors referred to here are not ...

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.