How to grep the progress bar?
A bit off topic perhaps, but I'll give it a shot:
I would like to run mas install in a shell script and report back when a download is finished and when it's successfully installed, but I cannot figure out how to do the former.
I thought I'd try a simple grep on the output, but only a mas install | grep "Installed" works (on the final output after the whole process is finished), while a mas install | grep "Installing" does not work.
It seems that the the output of the progress bar
################################################------------ 80.0% Installing
never gets piped to grep and only the final results ==> Downloading and ==> Installed actually get passed.
Throwing a | tee $somewhereelse in there does not work, either.
How can this be done?
Nevermind, I found a way to work around this by temporarily sending installd to sleep until the download is finished.
I leave this open in case it is of interest to anyone as an actual feature request.
The clearLine called in PurchaseDownloadObserver is probably what's fouling up that output. It's intended to rewrite the current line for an updating progress bar but messes up the final stdout that gets ends up in a command pipe.
Detection of stdout redirection and/or a way to force simpler, more reliable output would help.
Came looking for information about this while staring at Installing Xcode in the output of a script that I've written, which uses mas. I've been staring at it for quite some time now.