From 4736e253beca45aed88ef9a8d5225c7164208c45 Mon Sep 17 00:00:00 2001 From: Paul Ackersviller Date: Mon, 10 Dec 2007 03:16:53 +0000 Subject: Merge 24150: Exit status of null command should be exit status of last cmdsubst. --- ChangeLog | 8 ++++++++ Src/exec.c | 2 +- Test/D08cmdsubst.ztst | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e197f1e4a..e2d8aac60 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-12-09 Barton E. Schaefer + + * 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 * 24197, Src/utils.c, Src/Modules/datetime.c: interface to diff --git a/Src/exec.c b/Src/exec.c index 76bd8638a..fc45653e9 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -1963,7 +1963,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 -- cgit 1.4.1