[bug #63429] Escape sequence in logs are lost with -O option

2022-11-27 Thread Paul D. Smith
Follow-up Comment #2, bug #63429 (project make):

I guess you could also do this in your makefile:

grep --color=$(if $(MAKE_TERMOUT),always,auto) foo $<

and that should also work.


___

Reply to this item at:

  

___
Message sent via Savannah
https://savannah.gnu.org/




[bug #63429] Escape sequence in logs are lost with -O option

2022-11-27 Thread Paul D. Smith
Update of bug #63429 (project make):

  Status:None => Not A Bug  
 Open/Closed:Open => Closed 

___

Follow-up Comment #1:

There is no way to avoid this.  In order for output sync to ensure output is
not jumbled, it has to save the output to a file and print it later.  Tools
like grep, etc. choose color or not color output by looking to see whether the
output device is a terminal or not.  This is so that if you use something like
*grep foo | sed ...* etc. you won't see all the control characters.

When make redirects the output of the command to a file, grep sees that it is
no longer writing to a terminal and so disables color mode.

GNU make will set the environment variable MAKE_TERMOUT if the command it's
running will _eventually_ be written to a terminal.  It would be possible for
tools like grep etc. to check that variable and, if it's set, behave the same
as if it was writing to a terminal.  But that would require enhancement to
grep.

The only possible way to solve this in GNU make would be to create a pty for
each command but that is extremely complicated and non-portable.


___

Reply to this item at:

  

___
Message sent via Savannah
https://savannah.gnu.org/




[bug #63429] Escape sequence in logs are lost with -O option

2022-11-26 Thread Masahiro Yamada
URL:
  

 Summary: Escape sequence in logs are lost with -O option
 Project: make
   Submitter: masahiroy
   Submitted: Sun 27 Nov 2022 02:32:02 AM UTC
Severity: 3 - Normal
  Item Group: None
  Status: None
 Privacy: Public
 Assigned to: None
 Open/Closed: Open
 Discussion Lock: Any
   Component Version: None
Operating System: None
   Fixed Release: None
   Triage Status: None


___

Follow-up Comments:


---
Date: Sun 27 Nov 2022 02:32:02 AM UTC By: Masahiro Yamada 
While the -O option buffering the logs, the escape sequences for colors are
lost.



[Sample Makefile]


all: test.txt
grep --color=auto foo $<

test.txt:
@echo foobar > $@




[Test without -O]

$ make
grep --color=auto foo test.txt
foobar


In my environment, the part "foo" is highlighted in color.




[Test with -O]
$ make -j2 -O
grep --color=auto foo test.txt
foobar


The part "foo" is not highlighted any more.




Recent compilers show warnings/errors in color, but they are lost with the -O
option.


Can we do this better?







___

Reply to this item at:

  

___
Message sent via Savannah
https://savannah.gnu.org/