patchmake - Patches: patch #6911, Ability to detect interactive...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #6911: Ability to detect interactive shell (isatty())

Submitter:  Mark <mtrinh>
Submitted:  Tue 08 Sep 2009 04:46:16 PM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Fixed Release:  4.1

Sat 04 Jan 2020 12:24:18 PM UTC, comment #4: 

As of GNU make 4.1, there's a make variable MAKE_TERMOUT which will be empty if stdout is NOT a terminal, or non-empty if stdout IS a terminal.

Paul D. Smith <psmith>
Group administrator
Sun 13 Sep 2009 07:02:55 PM UTC, comment #3: 

sorry, it should be like this:

ifeq "$(MAKE_ISSATTY)" "1"

all:
@echo "\033[33mHi\033[0m"

else

all:
@echo "Hi"

endif

Mark <mtrinh>
Sun 13 Sep 2009 05:00:23 PM UTC, comment #2: 

It's useful when we are outputting colors in the terminal during a build.  For example, the below code would only output colors when it is in an interactive terminal.  If you redirect the output to a file, then it wont output the escape characters in your file. (not sure if the "ifeq" statement is written correctly. :) Hope this helps.

gmake vs gmake > out.txt

ifeq "$(MAKE_ISSATTY)" "1"

all:
      @echo "\033[33mHi\033[0m"

else

all:
      @echo "\033[33mHi\033[0m"

endif

Mark <mtrinh>
Sat 12 Sep 2009 10:35:59 PM UTC, comment #1: 

Can you give me some idea of why this is useful information / what it's useful for?  Thanks!

Paul D. Smith <psmith>
Group administrator
Tue 08 Sep 2009 04:46:16 PM UTC, original submission:  

There are times where I need to figure out if the current shell is interactive or not.  This patch introduces an environment macro called MAKE_ISATTY, which returns either a 1 or 0.

This calls isatty on stdout to figure out if you are redirecting make to a file (ie. make > foo) or not.

This patch is off of the version from CVS.

Mark <mtrinh>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #18689:  tty.patch added by mtrinh (600B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by mtrinh (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-01-04 psmith StatusNone Done
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Fixed ReleaseNone 4.1
    2009-09-08 mtrinh Attached File- Added tty.patch, #18689

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code