OpenWrt/LEDE Project

  • Status Unconfirmed
  • Percent Complete
  • Task Type Bug Report
  • Category Base system
  • Assigned To No-one
  • Operating System All
  • Severity Low
  • Priority Very Low
  • Reported Version Trunk
  • Due in Version Undecided
  • Due Date Undecided
  • Private
Attached to Project: OpenWrt/LEDE Project
Opened by R. Diez - 27.01.2019

FS#2086 - IS_TTY in the makefile is broken

File include/ tries to find out whether the build is running in an interactive console like this:

export IS_TTY=$(shell tty -s && echo 1 || echo 0)

That is the wrong way to do it. The code above is testing stdin, and not stdout. As a result, piping to a log file with a tool like ‘tee’ yields a log file that still contains the same \r codes etc. as when running on an interactive console.

Other tools like systemd’s systemctl do it right by checking stdout. On an interactive console, run these 2 commands to see the difference:

systemctl –help
systemctl –help | tee test.txt

It turns out that checking stdout is not so easy to do inside a makefile. In the shell, you would normally check with “-t 1”, but a $(shell ...) construct inside a makefile won’t work, because $(shell) always redirects stdout in order to capture the command’s output.

See here for the gory details:

While there are workarounds for makefiles, I wouldn’t go that far. I would just stop trying. and let the user decide with some variable. Maybe some day there will be a wrapper shell script, instead of using the makefile directly. In such a wrapper script it would be trivial to check for things like interactive terminal and/or terminal color support.


Available keyboard shortcuts


Task Details

Task Editing