diff options
author | jaseg <git@jaseg.net> | 2018-12-02 13:31:09 +0900 |
---|---|---|
committer | jaseg <git@jaseg.net> | 2018-12-02 13:37:51 +0900 |
commit | 27768b78a4e6db74ae9f0b57581504adc25f2c82 (patch) | |
tree | 0364fdd6e97dde9c5728e7c84ab31343a8735357 /lolcat.c | |
parent | e913f914c463ac45f619ce90bdcc8b9555d31e87 (diff) | |
download | lolcat-27768b78a4e6db74ae9f0b57581504adc25f2c82.tar.gz lolcat-27768b78a4e6db74ae9f0b57581504adc25f2c82.tar.bz2 lolcat-27768b78a4e6db74ae9f0b57581504adc25f2c82.zip |
Fix TTY check for color output
Thanks @BourgeoisBear!
Diffstat (limited to 'lolcat.c')
-rw-r--r-- | lolcat.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -80,7 +80,7 @@ int main(int argc, char** argv) char* default_argv[] = { "-" }; int cc = -1, i, l = 0; wint_t c; - int colors = 1; + int colors = isatty(STDOUT_FILENO); double freq_h = 0.23, freq_v = 0.1; struct timeval tv; @@ -180,7 +180,10 @@ int main(int argc, char** argv) if (escape_state == 2) wprintf(L"\033[38;5;%hhum", codes[cc % ARRAY_SIZE(codes)]); } - printf("\n\033[0m"); + + if (colors) + wprintf(L"\n\033[0m"); + cc = -1; if (f) { |