[tcsh/f15] Fix status of pipelined/backquoted/list of commands

Vojtěch Vítek vvitek at fedoraproject.org
Sat Oct 29 19:43:11 UTC 2011


commit b0bc5bc5ac72dd7aa8a2de449266670a4f0918a7
Author: Vojtech Vitek (V-Teq) <vvitek at redhat.com>
Date:   Thu Oct 27 23:06:14 2011 +0200

    Fix status of pipelined/backquoted/list of commands

 ...00-status-pipeline-backquote-list-of-cmds.patch |  141 ++++++++++++++++++++
 tcsh.spec                                          |    4 +
 2 files changed, 145 insertions(+), 0 deletions(-)
---
diff --git a/tcsh-6.17.00-status-pipeline-backquote-list-of-cmds.patch b/tcsh-6.17.00-status-pipeline-backquote-list-of-cmds.patch
new file mode 100644
index 0000000..a9b4f92
--- /dev/null
+++ b/tcsh-6.17.00-status-pipeline-backquote-list-of-cmds.patch
@@ -0,0 +1,141 @@
+diff -u -r3.164 -r3.165
+--- tcsh-6.17.00/sh.h	5 Feb 2011 16:14:20 -0000	3.164
++++ tcsh-6.17.00/sh.h	14 Apr 2011 18:25:25 -0000	3.165
+@@ -578,6 +578,7 @@
+ EXTERN int    editing IZERO;	/* doing filename expansion and line editing */
+ EXTERN int    noediting IZERO;	/* initial $term defaulted to noedit */
+ EXTERN int    bslash_quote IZERO;/* PWP: tcsh-style quoting?  (in sh.c) */
++EXTERN int    anyerror IZERO;	/* propagate errors from pipelines/backq */
+ EXTERN int    compat_expr IZERO;/* csh-style expressions? */
+ EXTERN int    isoutatty IZERO;	/* is SHOUT a tty */
+ EXTERN int    isdiagatty IZERO;/* is SHDIAG a tty */
+diff -u -r3.118 -r3.119
+--- tcsh-6.17.00/sh.proc.c	24 Mar 2011 14:06:59 -0000	3.118
++++ tcsh-6.17.00/sh.proc.c	14 Apr 2011 18:25:25 -0000	3.119
+@@ -557,6 +557,11 @@
+     reason = 0;
+     fp = pp;
+     do {
++	/* In case of pipelines only the result of the last
++	 * command should be taken in account */
++	if (!anyerror && !(fp->p_flags & PBRACE)
++		&& ((fp->p_flags & PPOU) || (fp->p_flags & PBACKQ)))
++	    continue;
+ 	if (fp->p_reason)
+ 	    reason = fp->p_flags & (PSIGNALED | PINTERRUPTED) ?
+ 		fp->p_reason | META : fp->p_reason;
+@@ -734,6 +739,8 @@
+ 	pp->p_flags |= PBACKQ;
+     if (t->t_dflg & F_HUP)
+ 	pp->p_flags |= PHUP;
++    if (t->t_dcom && t->t_dcom[0] && (*t->t_dcom[0] == '{'))
++	pp->p_flags |= PBRACE;
+     if (cmdmax == 0)
+ 	morecommand(CMD_INIT);
+     cmdp = cmdstr;
+diff -u -r3.14 -r3.15
+--- tcsh-6.17.00/sh.proc.h	7 May 2010 18:16:07 -0000	3.14
++++ tcsh-6.17.00/sh.proc.h	14 Apr 2011 18:25:25 -0000	3.15
+@@ -103,6 +103,7 @@
+ #define	PNEEDNOTE	(1<<15)	/* notify as soon as practical */
+ #define PBACKQ		(1<<16)	/* Process is `` evaluation */
+ #define PHUP		(1<<17)	/* Process is marked for SIGHUP on exit */
++#define PBRACE		(1<<18)	/* Process is {} evaluation */
+ 
+ /* defines for arguments to pprint */
+ #define	NUMBER		01
+diff -u -r3.81 -r3.82
+--- tcsh-6.17.00/sh.set.c	4 Feb 2011 18:00:26 -0000	3.81
++++ tcsh-6.17.00/sh.set.c	14 Apr 2011 18:25:25 -0000	3.82
+@@ -106,6 +106,9 @@
+     else if (eq(vp, STRloginsh)) {
+ 	loginsh = 1;
+     }
++    else if (eq(vp, STRanyerror)) {
++	anyerror = 1;
++    }
+     else if (eq(vp, STRsymlinks)) {
+ 	Char *pn = varval(vp);
+ 
+@@ -763,6 +766,8 @@
+ 	HistLit = 0;
+     if (adrof(STRloginsh) == 0)
+ 	loginsh = 0;
++    if (adrof(STRanyerror) == 0)
++	anyerror = 0;
+     if (adrof(STRwordchars) == 0)
+ 	word_chars = STR_WORD_CHARS;
+     if (adrof(STRedit) == 0)
+diff -u -r3.97 -r3.98
+--- tcsh-6.17.00/tc.const.c	27 Feb 2011 00:14:38 -0000	3.97
++++ tcsh-6.17.00/tc.const.c	14 Apr 2011 18:25:26 -0000	3.98
+@@ -43,6 +43,7 @@
+ #endif
+ Char STRautomatic[]	= { 'a', 'u', 't', 'o', 'm', 'a', 't', 'i', 'c',
+ 			    '\0' };
++Char STRanyerror[]	= { 'a', 'n', 'y', 'e', 'r', 'r', 'o', 'r', '\0' };
+ Char STRhangup[]	= { 'h', 'a', 'n', 'g', 'u', 'p', '\0' };
+ Char STRaout[]		= { 'a', '.', 'o', 'u', 't', '\0' };
+ Char STRtty[]		= { 't', 't', 'y', '\0' };
+diff -u -r3.226 -r3.227
+--- tcsh-6.17.00/tcsh.man	1 Feb 2011 19:56:50 -0000	3.226
++++ tcsh-6.17.00/tcsh.man	14 Apr 2011 18:25:26 -0000	3.227
+@@ -4352,7 +4352,12 @@
+ See also \fBloginsh\fR.
+ .TP 8
+ .B status
+-The status returned by the last command.  If it terminated
++The status returned by the last command, unless the variable
++.B anyerror
++is set, and any error in a pipeline or a backquote expansion will be
++propagated (this was the default
++.B csh
++behavior). If it terminated
+ abnormally, then 0200 is added to the status.  Builtin commands
+ which fail return exit status `1', all other builtin commands
+ return status `0'.
+diff -u -r1.6 -r1.7
+--- tcsh-6.17.00/tests/lexical.at	6 May 2010 14:36:10 -0000	1.6
++++ tcsh-6.17.00/tests/lexical.at	14 Apr 2011 18:25:26 -0000	1.7
+@@ -57,7 +57,7 @@
+ set verbose
+ echo `&|;<>()&||<<>>space tab	end`
+ ]])
+-AT_CHECK([tcsh -f nosplit.csh], 1,
++AT_CHECK([tcsh -f nosplit.csh], 0,
+ [&|;<>()&||<<>>space tab	end
+ &|;<>()&||<<>>space tab	end
+ &|;<>()&||<<>>space tab	end
+@@ -132,7 +132,7 @@
+ AT_CHECK([tcsh -f -c 'echo "$OK"'], 1, , [OK: Undefined variable.
+ ])
+ 
+-AT_CHECK([tcsh -f -c 'echo "`OK`"'], 1, [
++AT_CHECK([tcsh -f -c 'echo "`OK`"'], 0, [
+ ],
+ [OK: Command not found.
+ ])
+diff -u -r1.2 -r1.3
+--- tcsh-6.17.00/tests/subst.at	16 Feb 2006 03:12:00 -0000	1.2
++++ tcsh-6.17.00/tests/subst.at	14 Apr 2011 18:25:26 -0000	1.3
+@@ -14,7 +14,7 @@
+ echo `echo 1; \\
+   echo 2`
+ ]])
+-AT_CHECK([tcsh -f backq.csh], 1,
++AT_CHECK([tcsh -f backq.csh], 0,
+ [4
+ 2
+ 1 2
+diff -u -r1.2 -r1.3
+--- tcsh-6.17.00/tests/syntax.at	16 Feb 2006 03:12:00 -0000	1.2
++++ tcsh-6.17.00/tests/syntax.at	14 Apr 2011 18:25:26 -0000	1.3
+@@ -156,7 +156,7 @@
+ [OK
+ ])
+ 
+-AT_CHECK([tcsh -f -c '(echo $this_does_not_exist) |& cat'], 1,
++AT_CHECK([tcsh -f -c '(echo $this_does_not_exist) |& cat'], 0,
+ [this_does_not_exist: Undefined variable.
+ ])
+ 
diff --git a/tcsh.spec b/tcsh.spec
index 962077c..294d9ae 100644
--- a/tcsh.spec
+++ b/tcsh.spec
@@ -36,6 +36,8 @@ Patch23: tcsh-6.17.00-extrafork.patch
 Patch24: tcsh-6.17.00-avoid-null-cwd.patch
 # Accepted by upstream (tcsh-6.17.03b http://bugs.gw.com/view.php?id=113):
 Patch26: tcsh-6.17.00-variable-names.patch
+# Accepted by upstream (tcsh-6.17.06b http://bugs.gw.com/view.php?id=110)
+Patch27: tcsh-6.17.00-status-pipeline-backquote-list-of-cmds.patch
 # Accepted by upstream (tcsh-6.17.05b http://mx.gw.com/pipermail/tcsh-bugs/2011-March/000727.html):
 Patch28: tcsh-6.17.00-avoid-infinite-loop-pendjob-xprintf.patch
 
@@ -78,6 +80,7 @@ like syntax.
 %patch23 -p1 -b .extrafork
 %patch24 -p1 -b .avoid-null-cwd
 %patch26 -p1 -b .variable-names
+%patch27 -p1 -b .status-pipeline-backquote-list-of-cmds
 %patch28 -p1 -b .avoid-infinite-loop-pendjob-xprintf
 
 for i in Fixes WishList; do
@@ -152,6 +155,7 @@ fi
 %{_mandir}/man1/*.1*
 
 %changelog
+- Fix status of pipelined/backquoted/list of commands (RHEL-6 #658190)
 - Do not dereference null pointer in cwd (RHEL-6 #700309)
 - Fix negative number of jobs with %%j formatting parameter in prompt
 - Clean-up patches numbers & order (prepare space for missing RHEL-6 patches)


More information about the scm-commits mailing list