7cc421e
diff -up tcsh-6.17.00/sh.glob.c_old tcsh-6.17.00/sh.glob.c
7cc421e
--- tcsh-6.17.00/sh.glob.c_old	2009-12-15 12:38:48.000000000 +0100
7cc421e
+++ tcsh-6.17.00/sh.glob.c	2009-12-15 12:40:52.000000000 +0100
7cc421e
@@ -882,6 +882,10 @@ backeval(struct blk_buf *bb, struct Strb
7cc421e
 	    alias(&paraml);
7cc421e
 	    t = syntax(paraml.next, &paraml, 0);
7cc421e
 	    cleanup_push(t, syntax_cleanup);
7cc421e
+	    /* The F_BACKQ flag must set so the job output is correct if
7cc421e
+	     * printexitvalue is set.  If it's not set, the job output
7cc421e
+	     * will have "Exit N" appended where N is the exit status. */
7cc421e
+	    t->t_dflg = F_BACKQ;
7cc421e
 	    if (seterr)
7cc421e
 		stderror(ERR_OLD);
7cc421e
 #ifdef SIGTSTP
7cc421e
diff -up tcsh-6.17.00/sh.sem.c_old tcsh-6.17.00/sh.sem.c
7cc421e
--- tcsh-6.17.00/sh.sem.c_old	2009-12-15 12:41:03.000000000 +0100
7cc421e
+++ tcsh-6.17.00/sh.sem.c	2009-12-15 12:57:49.000000000 +0100
7cc421e
@@ -664,31 +664,31 @@ execute(struct command *t, volatile int 
7cc421e
 #endif /* !CLOSE_ON_EXEC */
7cc421e
 	didfds = 0;
7cc421e
 	wanttty = -1;
7cc421e
-	t->t_dspr->t_dflg |= t->t_dflg & F_NOINTERRUPT;
7cc421e
+	t->t_dspr->t_dflg |= t->t_dflg & (F_NOINTERRUPT | F_BACKQ);
7cc421e
 	execute(t->t_dspr, wanttty, NULL, NULL, do_glob);
7cc421e
 	exitstat();
7cc421e
 
7cc421e
     case NODE_PIPE:
7cc421e
 #ifdef BACKPIPE
7cc421e
 	t->t_dcdr->t_dflg |= F_PIPEIN | (t->t_dflg &
7cc421e
-			(F_PIPEOUT | F_AMPERSAND | F_NOFORK | F_NOINTERRUPT));
7cc421e
+			(F_PIPEOUT | F_AMPERSAND | F_NOFORK | F_NOINTERRUPT | F_BACKQ));
7cc421e
 	execute(t->t_dcdr, wanttty, pv, pipeout, do_glob);
7cc421e
 	t->t_dcar->t_dflg |= F_PIPEOUT |
7cc421e
-	    (t->t_dflg & (F_PIPEIN | F_AMPERSAND | F_STDERR | F_NOINTERRUPT));
7cc421e
+	    (t->t_dflg & (F_PIPEIN | F_AMPERSAND | F_STDERR | F_NOINTERRUPT | F_BACKQ));
7cc421e
 	execute(t->t_dcar, wanttty, pipein, pv, do_glob);
7cc421e
 #else /* !BACKPIPE */
7cc421e
 	t->t_dcar->t_dflg |= F_PIPEOUT |
7cc421e
-	    (t->t_dflg & (F_PIPEIN | F_AMPERSAND | F_STDERR | F_NOINTERRUPT));
7cc421e
+	    (t->t_dflg & (F_PIPEIN | F_AMPERSAND | F_STDERR | F_NOINTERRUPT | F_BACKQ));
7cc421e
 	execute(t->t_dcar, wanttty, pipein, pv, do_glob);
7cc421e
 	t->t_dcdr->t_dflg |= F_PIPEIN | (t->t_dflg &
7cc421e
-			(F_PIPEOUT | F_AMPERSAND | F_NOFORK | F_NOINTERRUPT));
7cc421e
+			(F_PIPEOUT | F_AMPERSAND | F_NOFORK | F_NOINTERRUPT | F_BACKQ));
7cc421e
 	execute(t->t_dcdr, wanttty, pv, pipeout, do_glob);
7cc421e
 #endif /* BACKPIPE */
7cc421e
 	break;
7cc421e
 
7cc421e
     case NODE_LIST:
7cc421e
 	if (t->t_dcar) {
7cc421e
-	    t->t_dcar->t_dflg |= t->t_dflg & F_NOINTERRUPT;
7cc421e
+	    t->t_dcar->t_dflg |= t->t_dflg & (F_NOINTERRUPT | F_BACKQ);
7cc421e
 	    execute(t->t_dcar, wanttty, NULL, NULL, do_glob);
7cc421e
 	    /*
7cc421e
 	     * In strange case of A&B make a new job after A
7cc421e
@@ -699,7 +699,7 @@ execute(struct command *t, volatile int 
7cc421e
 	}
7cc421e
 	if (t->t_dcdr) {
7cc421e
 	    t->t_dcdr->t_dflg |= t->t_dflg &
7cc421e
-		(F_NOFORK | F_NOINTERRUPT);
7cc421e
+		(F_NOFORK | F_NOINTERRUPT | F_BACKQ);
7cc421e
 	    execute(t->t_dcdr, wanttty, NULL, NULL, do_glob);
7cc421e
 	}
7cc421e
 	break;
7cc421e
@@ -707,7 +707,7 @@ execute(struct command *t, volatile int 
7cc421e
     case NODE_OR:
7cc421e
     case NODE_AND:
7cc421e
 	if (t->t_dcar) {
7cc421e
-	    t->t_dcar->t_dflg |= t->t_dflg & F_NOINTERRUPT;
7cc421e
+	    t->t_dcar->t_dflg |= t->t_dflg & (F_NOINTERRUPT | F_BACKQ);
7cc421e
 	    execute(t->t_dcar, wanttty, NULL, NULL, do_glob);
7cc421e
 	    if ((getn(varval(STRstatus)) == 0) !=
7cc421e
 		(t->t_dtyp == NODE_AND)) {
7cc421e
@@ -716,7 +716,7 @@ execute(struct command *t, volatile int 
7cc421e
 	}
7cc421e
 	if (t->t_dcdr) {
7cc421e
 	    t->t_dcdr->t_dflg |= t->t_dflg &
7cc421e
-		(F_NOFORK | F_NOINTERRUPT);
7cc421e
+		(F_NOFORK | F_NOINTERRUPT | F_BACKQ);
7cc421e
 	    execute(t->t_dcdr, wanttty, NULL, NULL, do_glob);
7cc421e
 	}
7cc421e
 	break;