diff options
author | Sören Tempel <soeren+git@soeren-tempel.net> | 2021-07-23 14:54:04 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2021-07-23 14:54:04 +0300 |
commit | 0acfe394a10f21ce3d252a8e0b3c79d480566458 (patch) | |
tree | dee9b57124330835cb48f15ee0cb9845f15a2afb /src | |
parent | 3cce27e83d068d274235995c03fed1e0f8a808fb (diff) | |
download | apk-tools-0acfe394a10f21ce3d252a8e0b3c79d480566458.tar.gz apk-tools-0acfe394a10f21ce3d252a8e0b3c79d480566458.tar.bz2 apk-tools-0acfe394a10f21ce3d252a8e0b3c79d480566458.tar.xz apk-tools-0acfe394a10f21ce3d252a8e0b3c79d480566458.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.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -417,11 +417,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; |