From 493308abf91e146ca390148fe6d15b8830c485aa Mon Sep 17 00:00:00 2001 From: Andrew Naylor Date: Sat, 22 Aug 2015 02:11:36 +0800 Subject: [PATCH] Prevent progress bar if output is being piped --- mas-cli/DownloadQueueObserver.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mas-cli/DownloadQueueObserver.swift b/mas-cli/DownloadQueueObserver.swift index 96c98dd..6c43cc0 100644 --- a/mas-cli/DownloadQueueObserver.swift +++ b/mas-cli/DownloadQueueObserver.swift @@ -40,6 +40,11 @@ struct ProgressState { } func progress(state: ProgressState) { + // Don't display the progress bar if we're not on a terminal + if isatty(fileno(stdout)) == 0 { + return + } + let barLength = 60 let completeLength = Int(state.percentComplete * Float(barLength))