diff options
author | Timo Teräs <timo.teras@iki.fi> | 2011-03-16 15:22:05 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2011-03-16 15:22:05 +0200 |
commit | 20775276b934418ba451f76c9c8a24418201fa66 (patch) | |
tree | bf5551aded838ae3a8c739e7d990a29dfb012d1d /src/apk.c | |
parent | 5d64bc5d8c7cdd2759e970f848e948fac9cc9577 (diff) | |
download | apk-tools-20775276b934418ba451f76c9c8a24418201fa66.tar.gz apk-tools-20775276b934418ba451f76c9c8a24418201fa66.tar.bz2 apk-tools-20775276b934418ba451f76c9c8a24418201fa66.tar.xz apk-tools-20775276b934418ba451f76c9c8a24418201fa66.zip |
apk: show progress bar by default for tty controlled runs
and make the progress bar disappear on regular runs too.
Diffstat (limited to 'src/apk.c')
-rw-r--r-- | src/apk.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -17,6 +17,7 @@ #include <stdlib.h> #include <string.h> #include <getopt.h> +#include <unistd.h> #include <sys/stat.h> #include <openssl/crypto.h> @@ -45,6 +46,7 @@ static struct apk_option generic_options[] = { { 'f', "force", "Do what was asked even if it looks dangerous" }, { 'U', "update-cache", "Update the repository cache" }, { 0x101, "progress", "Show a progress bar" }, + { 0x110, "no-progress", "Disable progress bar even for TTYs" }, { 0x102, "clean-protected", "Do not create .apk-new files to " "configuration dirs" }, { 0x106, "purge", "Delete also modified configuration files on " @@ -256,6 +258,9 @@ int main(int argc, char **argv) apk_atom_init(); umask(0); + if (isatty(STDOUT_FILENO) && isatty(STDERR_FILENO) && isatty(STDIN_FILENO)) + apk_flags |= APK_PROGRESS; + applet = deduce_applet(argc, argv); num_options = ARRAY_SIZE(generic_options) + 1; if (applet != NULL) @@ -326,6 +331,9 @@ int main(int argc, char **argv) case 0x101: apk_flags |= APK_PROGRESS; break; + case 0x110: + apk_flags &= ~APK_PROGRESS; + break; case 0x102: apk_flags |= APK_CLEAN_PROTECTED; break; |