Thank you @ron2138 !
The first idea I had earlier (to check if output goes to a tty or not), was a bit too quick. It wouldn't prevent colored lines in the log, because makepkg
redirects the data stream to the log file outside of the PKGBUILD's functions, and thus after that condition would be tested.
I figured it would make much more sense anyways, to let the user switch off color explicitely via the -m
/--nocolor
flag which you mentioned. The only (sensible) way to check if that flag is set or not, that I could come up with, is querying a variable that depends on it.
You're correct in that USE_COLOR
is a variable defined by makepkg
itself. That doesn't offend the recommendation in the packaging etiquette though, in my opinion, since it's not a subroutine.
As I understand that wiki clause, internal makepkg
functions should not be used because the build script could break when those functions are changed at some point. This is not the case when a variable is queried though. Building would still work after a change.
In case that I'm getting something completely wrong please let me know. Also @yochananmarqos and/or @DuckSoft, do you have any strong opinions about this ? Would it make more sense to just remove the color codes ?
Pinned Comments