Skip to content

Commit

Permalink
Set $*DIED-NATURALLY if exiting program without exception
Browse files Browse the repository at this point in the history
Inspired by https://stackoverflow.com/questions/73040525/how-to-know-in-a-end-block-if-the-programm-died

This minimal change allows an END block to do special actions if the
program exited because of an exception:

    END {
        unless $*DIED-NATURALLY {
            # do special cleanup actions
        }
    }
  • Loading branch information
lizmat committed Jul 19, 2022
1 parent 14fb6a5 commit 072d961
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/main.nqp
Expand Up @@ -69,6 +69,7 @@ sub MAIN(*@ARGS) {
$comp.command_line(@ARGS, :encoding('utf8'), :transcode('ascii iso-8859-1'), |%defaults);

# do all the necessary actions at the end, if any
my $*DIED-NATURALLY := 1;
if nqp::gethllsym('Raku', '&THE_END') -> $THE_END {
$THE_END()
}
Expand Down

0 comments on commit 072d961

Please sign in to comment.