tools/pw-dump: fix parentheses around isatty() call

Previously,

  isatty(fileno(data.out) && getenv("NO_COLOR") == NULL))

would call `isatty()` with

  fileno(data.out) && getenv("NO_COLOR") == NULL

as its argument. This meant that, for example,

  NO_COLOR=1 pw-dump

would still produce colored output when run with
a TTY as its standard input.

Fix that by moving the parenthesis.

Fixes: af63d08453 ("tools/pw-dump: only print colors if we're connected to a terminal")
This commit is contained in:
Barnabás Pőcze 2021-05-08 03:35:17 +02:00
parent 02decd9fba
commit 68f75bbd57

View file

@ -1429,7 +1429,7 @@ int main(int argc, char *argv[])
pw_init(&argc, &argv);
data.out = stdout;
if (isatty(fileno(data.out) && getenv("NO_COLOR") == NULL))
if (isatty(fileno(data.out)) && getenv("NO_COLOR") == NULL)
colors = true;
while ((c = getopt_long(argc, argv, "hVr:mN", long_options, NULL)) != -1) {