From 90e1d42a99178608ec22216f7f35dadcad5a8b3a Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Tue, 24 Mar 2015 20:32:42 -0400 Subject: Fix bug where exit with no argument was setting the exit status to zero. --- interpret.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'interpret.h') diff --git a/interpret.h b/interpret.h index b16dc126..372679df 100644 --- a/interpret.h +++ b/interpret.h @@ -1313,17 +1313,18 @@ match_re: fatal(_("`exit' cannot be called in the current context")); exiting = true; - t1 = POP_NUMBER(); - exit_val = (int) get_number_si(t1); - DEREF(t1); + if ((t1 = POP_NUMBER()) != Nnull_string) { + exit_val = (int) get_number_si(t1); #ifdef VMS - if (exit_val == 0) - exit_val = EXIT_SUCCESS; - else if (exit_val == 1) - exit_val = EXIT_FAILURE; - /* else - just pass anything else on through */ + if (exit_val == 0) + exit_val = EXIT_SUCCESS; + else if (exit_val == 1) + exit_val = EXIT_FAILURE; + /* else + just pass anything else on through */ #endif + } + DEREF(t1); if (currule == BEGINFILE || currule == ENDFILE) { -- cgit v1.2.3