Print disco to stderr instead of stdout.

This commit is contained in:
Jari Vetoniemi 2014-10-31 21:28:07 +02:00
parent 2386d44a99
commit a3e628f1c9

View File

@ -12,8 +12,8 @@ static void
disco_trap(int sig) disco_trap(int sig)
{ {
(void)sig; (void)sig;
printf("\e[?25h\n"); fprintf(stderr, "\e[?25h");
fflush(stdout); fflush(stderr);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -29,18 +29,18 @@ disco(void)
sigaction(SIGINT, &action, NULL); sigaction(SIGINT, &action, NULL);
uint32_t cc, c = 80; uint32_t cc, c = 80;
printf("\e[?25l"); fprintf(stderr, "\e[?25l");
while (1) { while (1) {
for (uint32_t i = 1; i < c - 1; ++i) { for (uint32_t i = 1; i < c - 1; ++i) {
printf("\r %*s%s %s %s ", (i > c / 2 ? c - i : i), " ", ((i % 2) ? "<o/" : "\\o>"), ((i % 4) ? "DISCO" : " "), ((i %2) ? "\\o>" : "<o/")); fprintf(stderr, "\r %*s%s %s %s ", (i > c / 2 ? c - i : i), " ", ((i % 2) ? "<o/" : "\\o>"), ((i % 4) ? "DISCO" : " "), ((i %2) ? "\\o>" : "<o/"));
for (cc = 0; cc < (i < c / 2 ? c / 2 - i : i - c / 2); ++cc) printf(((i % 2) ? "^" : "'")); for (cc = 0; cc < (i < c / 2 ? c / 2 - i : i - c / 2); ++cc) fprintf(stderr, ((i % 2) ? "^" : "'"));
printf("%s %s \r %s %s", ((i % 2) ? "*" : ""), ((i % 3) ? "\\o" : "<o"), ((i % 3) ? "o/" : "o>"), ((i % 2) ? "*" : "")); fprintf(stderr, "%s %s \r %s %s", ((i % 2) ? "*" : ""), ((i % 3) ? "\\o" : "<o"), ((i % 3) ? "o/" : "o>"), ((i % 2) ? "*" : ""));
for (cc = 2; cc < (i > c / 2 ? c - i : i); ++cc) printf(((i % 2) ? "^" : "'")); for (cc = 2; cc < (i > c / 2 ? c - i : i); ++cc) fprintf(stderr, ((i % 2) ? "^" : "'"));
fflush(stdout); fflush(stderr);
usleep(140 * 1000); usleep(140 * 1000);
} }
} }
printf("\e[?25h"); fprintf(stderr, "\e[?25h");
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }