Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!samsung!caen!hellgate.utah.edu!csn!convex!usenet From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.unix.shell Subject: Re: error processing in borne Message-ID: <1991Apr25.160235.12663@convex.com> Date: 25 Apr 91 16:02:35 GMT References: <1991Apr25.150529.29406@cid.aes.doe.CA> Sender: usenet@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Distribution: na Organization: CONVEX Software Development, Richardson, TX Lines: 33 Nntp-Posting-Host: pixel.convex.com From the keyboard of afsihrs@cidsv01.cid.aes.doe.CA (): : : WE ARE IN THE PROCESS OF CONVERTING TO UNIX AND HAVE COME UP :AGAINST A PROBLEM WITH ERROR PROCESSING. THE FOLLOWING IS AN :EXAMPLE OF OUR OLD JCL: : : COMMAND : COMMAND : COMMAND : EXIT : ERROR-COMMAND : ERROR-COMMAND : IN THE ABOVE IF THE JOB WORKED PROPERLY IT ENDED AT EXIT,WHILE :IF ANY COMMAND ABORTED, IT WOULD IMMEDIATELY GO TO THE EXIT AND :PROCESS THE ERROR-COMMANDS. IS THERE SOME METHOD EQUIVALENT TO :TRAP THAT WE CAN USE TO EXIT ON ANY ERRORS? WE ALSO DON'T WANT :TO HAVE TO CHECK AFTER EVERY COMMAND. well, the first problem you need to solve is to get your caps lock keys fixed. :-) you can use something like this: #!/bin/sh -e trap 'special error commands' 0 some commands that might fail triggering the exit due to -e, and then trigger the onexit trap trap 0 # clear on exit trap exit 0 # and leave --tom