about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2007-12-09 23:53:33 +0000
committerBart Schaefer <barts@users.sourceforge.net>2007-12-09 23:53:33 +0000
commita124da3a4a4bf6e91a567033e1e03241d9d0faa9 (patch)
treef23fefa2ace89ded670c1ead15cc6195dac3cf71
parent6e58a1df8faab311a0479ef630b891ef50fd3f14 (diff)
downloadzsh-a124da3a4a4bf6e91a567033e1e03241d9d0faa9.tar.gz
zsh-a124da3a4a4bf6e91a567033e1e03241d9d0faa9.tar.xz
zsh-a124da3a4a4bf6e91a567033e1e03241d9d0faa9.zip
24150: Exit status of null command should be exit status of last cmdsubst.
-rw-r--r--ChangeLog10
-rw-r--r--Src/exec.c2
-rw-r--r--Test/D08cmdsubst.ztst8
3 files changed, 18 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 5086ca82b..09d34fa6c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,14 @@
+2007-12-09  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 24150 plus unposted: Src/exec.c, Test/D08cmdsubst.ztst:
+	Retain exit status of last non-assignment command substitution
+	across variable assignment processing so that, in the event of
+	no command word to execute, the exit status of the statement is
+	that of the last command substitution (per POSIX).
+
 2007-12-09  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
-	* 24197, Src/utils.c, Src/Modules/datetime.c: interface to
+	* 24197: Src/utils.c, Src/Modules/datetime.c: interface to
 	ztrftime() for insufficient memory was broken.
 
 2007-12-08  Clint Adams  <clint@zsh.org>
diff --git a/Src/exec.c b/Src/exec.c
index 3c13da476..438e30d0d 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2339,7 +2339,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		    lastval = 0;
 		    return;
 		} else {
-		    cmdoutval = 0;
+		    cmdoutval = lastval;
 		    if (varspc)
 			addvars(state, varspc, 0);
 		    if (errflag)
diff --git a/Test/D08cmdsubst.ztst b/Test/D08cmdsubst.ztst
index 6cbcbf929..015796ed6 100644
--- a/Test/D08cmdsubst.ztst
+++ b/Test/D08cmdsubst.ztst
@@ -81,3 +81,11 @@
 >third: file1.txt file2.txt
 >fourth: *
 >fifth: file1.txt file2.txt
+
+  $(exit 0) $(exit 3) || print $?
+0:empty command uses exit value of last substitution
+>3
+
+  X=$(exit 2) $(exit 0) || print $?
+0:variable assignments processed after other substitutions
+>2