Blob Blame History Raw
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.
 ])