Author: jilles
Date: Sat Sep 11 15:07:40 2010
New Revision: 212475
URL: http://svn.freebsd.org/changeset/base/212475

Log:
  sh: Fix exit status if return is used within a loop condition.

Added:
  head/tools/regression/bin/sh/builtins/return6.4   (contents, props changed)
  head/tools/regression/bin/sh/builtins/return7.4   (contents, props changed)
Modified:
  head/bin/sh/eval.c

Modified: head/bin/sh/eval.c
==============================================================================
--- head/bin/sh/eval.c  Sat Sep 11 14:46:19 2010        (r212474)
+++ head/bin/sh/eval.c  Sat Sep 11 15:07:40 2010        (r212475)
@@ -305,6 +305,8 @@ skipping:     if (evalskip == SKIPCONT && 
                        }
                        if (evalskip == SKIPBREAK && --skipcount <= 0)
                                evalskip = 0;
+                       if (evalskip == SKIPFUNC || evalskip == SKIPFILE)
+                               status = exitstatus;
                        break;
                }
                if (n->type == NWHILE) {

Added: head/tools/regression/bin/sh/builtins/return6.4
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/bin/sh/builtins/return6.4     Sat Sep 11 15:07:40 
2010        (r212475)
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+while return 4; do exit 3; done

Added: head/tools/regression/bin/sh/builtins/return7.4
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/regression/bin/sh/builtins/return7.4     Sat Sep 11 15:07:40 
2010        (r212475)
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+f() {
+       while return 4; do exit 3; done
+}
+f
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to