diff --git a/src/bin/pkgman/PackageManager.cpp b/src/bin/pkgman/PackageManager.cpp index d2cb0a9f2d..35bd011415 100644 --- a/src/bin/pkgman/PackageManager.cpp +++ b/src/bin/pkgman/PackageManager.cpp @@ -173,10 +173,13 @@ PackageManager::Warn(status_t error, const char* format, ...) void PackageManager::ProgressPackageDownloadStarted(const char* packageName) { + fShowProgress = isatty(STDOUT_FILENO); fLastBytes = 0; fLastRateCalcTime = system_time(); fDownloadRate = 0; - printf(" 0%%"); + + if (fShowProgress) + printf(" 0%%"); } @@ -186,7 +189,7 @@ PackageManager::ProgressPackageDownloadActive(const char* packageName, { if (bytes == totalBytes) fLastBytes = totalBytes; - if (!fInteractive) + if (!fShowProgress) return; // Do not update if nothing changed in the last 500ms @@ -258,7 +261,7 @@ PackageManager::ProgressPackageDownloadActive(const char* packageName, void PackageManager::ProgressPackageDownloadComplete(const char* packageName) { - if (fInteractive) { + if (fShowProgress) { // Erase the line, return to the start, and reset colors printf("\r\33[2K\r\x1B[0m"); } diff --git a/src/bin/pkgman/PackageManager.h b/src/bin/pkgman/PackageManager.h index efc6cb4ac5..3359b07cb5 100644 --- a/src/bin/pkgman/PackageManager.h +++ b/src/bin/pkgman/PackageManager.h @@ -72,6 +72,7 @@ private: fClientInstallationInterface; bool fInteractive; + bool fShowProgress; off_t fLastBytes; bigtime_t fLastRateCalcTime; float fDownloadRate;