summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2015-03-24 20:32:42 -0400
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2015-03-24 20:32:42 -0400
commit90e1d42a99178608ec22216f7f35dadcad5a8b3a (patch)
treeaaf1e18dfbdd1b73c03010798b55fa529e539409
parent981e106b111672aac520fbb397ee82c64f3c4f2a (diff)
downloadgawk-90e1d42a99178608ec22216f7f35dadcad5a8b3a.tar.gz
Fix bug where exit with no argument was setting the exit status to zero.
-rw-r--r--ChangeLog5
-rw-r--r--interpret.h19
-rw-r--r--test/ChangeLog6
-rw-r--r--test/Makefile.am4
-rw-r--r--test/Makefile.in9
-rw-r--r--test/Maketests5
-rw-r--r--test/exitval3.awk2
-rw-r--r--test/exitval3.ok1
8 files changed, 40 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index b8b3ee9a..a3496ddb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-24 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * interpret.h (r_interpret): When Op_K_exit has an argument of
+ Nnull_string, do not update exit_val, since no value was supplied.
+
2015-03-18 Arnold D. Robbins <arnold@skeeve.com>
* config.guess, config.sub: Updated, from libtool 2.4.6.
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) {
diff --git a/test/ChangeLog b/test/ChangeLog
index c33ac108..862b8491 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,9 @@
+2015-03-24 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * Makefile.am (EXTRA_DIST): Add exitval3.awk and exitval3.ok.
+ (BASIC_TESTS): Add new test exitval3.
+ * exitval3.awk, exitval3.ok: New files.
+
2015-03-17 Andrew J. Schorr <aschorr@telemetry-investments.com>
* inplace1.ok, inplace2.ok, inplace3.ok: Update error message line
diff --git a/test/Makefile.am b/test/Makefile.am
index f1a0a275..1b5a2a50 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -221,6 +221,8 @@ EXTRA_DIST = \
exitval2.awk \
exitval2.ok \
exitval2.w32 \
+ exitval3.awk \
+ exitval3.ok \
fcall_exit.awk \
fcall_exit.ok \
fcall_exit2.awk \
@@ -1001,7 +1003,7 @@ BASIC_TESTS = \
callparam childin clobber closebad clsflnam compare compare2 concat1 concat2 \
concat3 concat4 convfmt \
datanonl defref delargv delarpm2 delarprm delfunc dfamb1 dfastress dynlj \
- eofsplit exit2 exitval1 exitval2 \
+ eofsplit exit2 exitval1 exitval2 exitval3 \
fcall_exit fcall_exit2 fldchg fldchgnf fnamedat fnarray fnarray2 \
fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fsrs fsspcoln \
fstabplus funsemnl funsmnam funstack \
diff --git a/test/Makefile.in b/test/Makefile.in
index b794e04e..d5f39447 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -478,6 +478,8 @@ EXTRA_DIST = \
exitval2.awk \
exitval2.ok \
exitval2.w32 \
+ exitval3.awk \
+ exitval3.ok \
fcall_exit.awk \
fcall_exit.ok \
fcall_exit2.awk \
@@ -1257,7 +1259,7 @@ BASIC_TESTS = \
callparam childin clobber closebad clsflnam compare compare2 concat1 concat2 \
concat3 concat4 convfmt \
datanonl defref delargv delarpm2 delarprm delfunc dfamb1 dfastress dynlj \
- eofsplit exit2 exitval1 exitval2 \
+ eofsplit exit2 exitval1 exitval2 exitval3 \
fcall_exit fcall_exit2 fldchg fldchgnf fnamedat fnarray fnarray2 \
fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fsrs fsspcoln \
fstabplus funsemnl funsmnam funstack \
@@ -2709,6 +2711,11 @@ exitval2:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+exitval3:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
fcall_exit:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 8c270869..58a1d670 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -230,6 +230,11 @@ exitval2:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+exitval3:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
fcall_exit:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/exitval3.awk b/test/exitval3.awk
new file mode 100644
index 00000000..33e8c433
--- /dev/null
+++ b/test/exitval3.awk
@@ -0,0 +1,2 @@
+BEGIN { exit 42 }
+END { exit }
diff --git a/test/exitval3.ok b/test/exitval3.ok
new file mode 100644
index 00000000..20f64b8c
--- /dev/null
+++ b/test/exitval3.ok
@@ -0,0 +1 @@
+EXIT CODE: 42