16 Breaking-in

Sometimes you will realise you have made a mistake after starting a script, and therefore want to stop it to save time or damage. You can break-in using CTRL/C (hitting C while depressing the CTRL key), but doing this can leave unwanted intermediate files, graphics windows, and other mess. However, if you have

       onintr label
  
       <the main body of the script>
  
       label:
       <perform housekeeping>
  
       exit

near the head and tail of your script, whenever CTRL/C is detected, the script will go to the specified label. There you can close down the script in a controlled fashion, removing the garbage. If you want to prevent CTRL/C interrupts, you should include the line

       % onintr -

instead.