summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSören Tempel <soeren+git@soeren-tempel.net>2021-07-23 14:54:04 +0300
committerTimo Teräs <timo.teras@iki.fi>2021-07-23 15:22:00 +0300
commit9bdde453b721fe2c9dd53de189fd5fd9aa4ab937 (patch)
tree7aef0ef3f849d5d687344f19dbf3fc6eff366404 /src
parent03844f5dbe8535aa532ff2c1c4bdbc18ed6b8453 (diff)
downloadapk-tools-9bdde453b721fe2c9dd53de189fd5fd9aa4ab937.tar.gz
apk-tools-9bdde453b721fe2c9dd53de189fd5fd9aa4ab937.tar.bz2
apk-tools-9bdde453b721fe2c9dd53de189fd5fd9aa4ab937.tar.xz
apk-tools-9bdde453b721fe2c9dd53de189fd5fd9aa4ab937.zip
Disable progress bar on dumb terminals by default
The progress bar requires the terminal emulator to support ANSI escape sequences. Normally, TERM is set to dumb to indicate that the terminal emulator doesn't support any ANSI escape sequences. Attempting to use ANSI escape sequences on dumb terminals will lead to weird output. In order to make apk work by default, even on dumb terminals, this commit introduces an additional check which consults $TERM and disables the progress bar if it is set to "dumb". [TT: backported to 2.12]
Diffstat (limited to 'src')
-rw-r--r--src/apk.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/apk.c b/src/apk.c
index baa2b94..ad48916 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -489,11 +489,16 @@ static void setup_terminal(void)
static void setup_automatic_flags(void)
{
+ const char *tmp;
+
if (!isatty(STDOUT_FILENO) || !isatty(STDERR_FILENO) ||
!isatty(STDIN_FILENO))
return;
- apk_flags |= APK_PROGRESS;
+ /* Enable progress bar by default, except on dumb terminals. */
+ if (!(tmp = getenv("TERM")) || strcmp(tmp, "dumb") != 0)
+ apk_flags |= APK_PROGRESS;
+
if (!(apk_flags & APK_SIMULATE) &&
access("/etc/apk/interactive", F_OK) == 0)
apk_flags |= APK_INTERACTIVE;