Blob Blame History Raw
diff -upr tcsh-6.17.00_orig/sh.c tcsh-6.17.00_work/sh.c
--- tcsh-6.17.00_orig/sh.c	2013-04-04 09:52:20.180008940 +0200
+++ tcsh-6.17.00_work/sh.c	2013-04-04 09:52:54.015137195 +0200
@@ -273,6 +273,8 @@ main(int argc, char **argv)
     PRCHROOT = '#';
     word_chars = STR_WORD_CHARS;
     bslash_quote = 0;		/* PWP: do tcsh-style backslash quoting? */
+    anyerror = 1;    /* for compatibility */
+    setcopy(STRanyerror, STRNULL, VAR_READWRITE);
 
     /* Default history size to 100 */
     setcopy(STRhistory, str2short("100"), VAR_READWRITE);
diff -upr tcsh-6.17.00_orig/sh.h tcsh-6.17.00_work/sh.h
--- tcsh-6.17.00_orig/sh.h	2013-04-04 09:52:20.260009235 +0200
+++ tcsh-6.17.00_work/sh.h	2013-04-04 09:50:52.104708055 +0200
@@ -558,6 +558,7 @@ EXTERN int    havhash IZERO;	/* path has
 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 -upr tcsh-6.17.00_orig/sh.proc.c tcsh-6.17.00_work/sh.proc.c
--- tcsh-6.17.00_orig/sh.proc.c	2013-04-04 09:52:20.262009242 +0200
+++ tcsh-6.17.00_work/sh.proc.c	2013-04-04 09:50:52.105708059 +0200
@@ -551,6 +551,11 @@ pjwait(struct process *pp)
     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;
@@ -730,6 +735,8 @@ palloc(pid_t pid, struct command *t)
 	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 -upr tcsh-6.17.00_orig/sh.proc.h tcsh-6.17.00_work/sh.proc.h
--- tcsh-6.17.00_orig/sh.proc.h	2013-04-04 09:52:20.185008957 +0200
+++ tcsh-6.17.00_work/sh.proc.h	2013-04-04 09:50:52.081708001 +0200
@@ -102,6 +102,7 @@ struct process {
 #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 -upr tcsh-6.17.00_orig/sh.set.c tcsh-6.17.00_work/sh.set.c
--- tcsh-6.17.00_orig/sh.set.c	2013-04-04 09:52:20.178008937 +0200
+++ tcsh-6.17.00_work/sh.set.c	2013-04-04 09:50:52.073707890 +0200
@@ -100,6 +100,9 @@ update_vars(Char *vp)
     else if (eq(vp, STRloginsh)) {
 	loginsh = 1;
     }
+    else if (eq(vp, STRanyerror)) {
+	anyerror = 1;
+    }
     else if (eq(vp, STRsymlinks)) {
 	Char *pn = varval(vp);
 
@@ -757,6 +760,8 @@ unset(Char **v, struct command *c)
 	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 -upr tcsh-6.17.00_orig/tc.const.c tcsh-6.17.00_work/tc.const.c
--- tcsh-6.17.00_orig/tc.const.c	2013-04-04 09:52:20.183008948 +0200
+++ tcsh-6.17.00_work/tc.const.c	2013-04-04 09:50:52.079707993 +0200
@@ -43,6 +43,7 @@ Char STRrootdefautologout[] = { '1', '5'
 #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 -upr tcsh-6.17.00_orig/tests/lexical.at tcsh-6.17.00_work/tests/lexical.at
--- tcsh-6.17.00_orig/tests/lexical.at	2013-04-04 09:52:20.178008937 +0200
+++ tcsh-6.17.00_work/tests/lexical.at	2013-04-04 09:50:52.074707910 +0200
@@ -57,7 +57,7 @@ echo "&|;<>()&||<<>>space tab	end"
 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, ,
 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 -upr tcsh-6.17.00_orig/tests/subst.at tcsh-6.17.00_work/tests/subst.at
--- tcsh-6.17.00_orig/tests/subst.at	2013-04-04 09:52:20.179008939 +0200
+++ tcsh-6.17.00_work/tests/subst.at	2013-04-04 09:50:52.074707910 +0200
@@ -14,7 +14,7 @@ set csubstnonl
 echo `echo 1; \\
   echo 2`
 ]])
-AT_CHECK([tcsh -f backq.csh], 1,
+AT_CHECK([tcsh -f backq.csh], 0,
 [4
 2
 1 2
diff -upr tcsh-6.17.00_orig/tests/syntax.at tcsh-6.17.00_work/tests/syntax.at
--- tcsh-6.17.00_orig/tests/syntax.at	2013-04-04 09:52:20.179008939 +0200
+++ tcsh-6.17.00_work/tests/syntax.at	2013-04-04 09:50:52.074707910 +0200
@@ -156,7 +156,7 @@ AT_CHECK([cat output], ,
 [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.
 ])