How can I highlight the warning and error lines in the make output?

前端 未结 7 2095
醉话见心
醉话见心 2021-01-30 11:19

Sometimes, make\'s output fills the screen. It\'s a little bit hard to identify all the warning and error message lines. I know may shell color output can help Can anyone can he

7条回答
  •  既然无缘
    2021-01-30 11:51

    On Mac, it worked by printing tput color codes around the error string.

    First export tput color codes as below:

    export red=`tput setaf 1`
    export reset=`tput sgr0`
    

    then, add a target to Makefile as below:

    ...
    check-env:
    ifndef ENV
        $(error ${red}ENV is undefined. Please export it using command [ export ENV=dev ]${reset})
    endif
    ...
    

    then, run it as make check-env

    Screen shot -

提交回复
热议问题