ExitCode

Normally, the `exit' command exits with a value of zero.

You can supply an optional numeric value to the `exit' command to make it exit with a value:

    if (whatever)
        exit 12;

If you have an END block, control first transfers there. Within the END block, an `exit' command exits immediately; if you had previously supplied a value, that value is used. But, if you give a new value to `exit' within the END block, the new value is used. This is documented in the GNU Awk User's Guide (gawk.texi).

If you have an END block you want to be able to skip sometimes, you may have to do something like this:

BEGIN \
{
  exitcode=0;
  ...
}

# normal rules processing...
{
  ...
  if (fatal)
  {
    exitcode=12;
    exit(exitcode);
  }
  ...
}

END {
  if (exitcode!=0)
    exit(exitcode);
  ...
}