Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): extract ShellWriter_ErrOn from JobPrin...



details:   https://anonhg.NetBSD.org/src/rev/c3dee1e7abee
branches:  trunk
changeset: 947154:c3dee1e7abee
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Dec 12 12:54:58 2020 +0000

description:
make(1): extract ShellWriter_ErrOn from JobPrintCommand

It had been conceptually wrong to modify cmdFlags.echo just to suppress
echoing while enabling error checking.

Now the code in JobPrintCommand speaks for itself and no longer needs
any comments.  The few lines at the end have the sole purpose of
restoring the default state (echo + errChk) in the shell file.

diffstat:

 usr.bin/make/job.c |  44 +++++++++++++++++++-------------------------
 1 files changed, 19 insertions(+), 25 deletions(-)

diffs (77 lines):

diff -r 1f3ba231c8db -r c3dee1e7abee usr.bin/make/job.c
--- a/usr.bin/make/job.c        Sat Dec 12 12:28:06 2020 +0000
+++ b/usr.bin/make/job.c        Sat Dec 12 12:54:58 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.381 2020/12/12 12:28:06 rillig Exp $ */
+/*     $NetBSD: job.c,v 1.382 2020/12/12 12:54:58 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -143,7 +143,7 @@
 #include "trace.h"
 
 /*     "@(#)job.c      8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.381 2020/12/12 12:28:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.382 2020/12/12 12:54:58 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -798,22 +798,24 @@
        }
 }
 
-/*
- * We don't want the error-control commands showing up either, so we turn
- * off echoing while executing them. We could put another field in the shell
- * structure to tell JobDoOutput to look for this string too, but why make
- * it any more complex than it already is?
- */
 static void
 ShellWriter_ErrOff(ShellWriter *wr, Boolean echo)
 {
-       if (echo && shell->hasEchoCtl) {
+       if (echo)
                ShellWriter_EchoOff(wr);
-               ShellWriter_Println(wr, shell->errOff);
+       ShellWriter_Println(wr, shell->errOff);
+       if (echo)
                ShellWriter_EchoOn(wr);
-       } else {
-               ShellWriter_Println(wr, shell->errOff);
-       }
+}
+
+static void
+ShellWriter_ErrOn(ShellWriter *wr, Boolean echo)
+{
+       if (echo)
+               ShellWriter_EchoOff(wr);
+       ShellWriter_Println(wr, shell->errOn);
+       if (echo)
+               ShellWriter_EchoOn(wr);
 }
 
 /*
@@ -962,18 +964,10 @@
        ShellWriter_PrintFmt(wr, cmdTemplate, xcmd);
        free(xcmdStart);
        free(escCmd);
-       if (cmdFlags.ignerr) {
-               /*
-                * If echoing is already off, there's no point in issuing the
-                * echoOff command. Otherwise we issue it and pretend it was on
-                * for the whole command...
-                */
-               if (cmdFlags.echo && job->echo && shell->hasEchoCtl) {
-                       ShellWriter_EchoOff(wr);
-                       cmdFlags.echo = FALSE;
-               }
-               ShellWriter_Println(wr, shell->errOn);
-       }
+
+       if (cmdFlags.ignerr)
+               ShellWriter_ErrOn(wr, cmdFlags.echo && job->echo);
+
        if (!cmdFlags.echo)
                ShellWriter_EchoOn(wr);
 }



Home | Main Index | Thread Index | Old Index