mas icon indicating copy to clipboard operation
mas copied to clipboard

How to grep the progress bar?

Open shoopdawoop opened this issue 5 years ago • 8 comments

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?

shoopdawoop avatar Nov 14 '20 23:11 shoopdawoop

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.

shoopdawoop avatar Nov 15 '20 13:11 shoopdawoop

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.

phatblat avatar Nov 16 '20 13:11 phatblat

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.

philsherry avatar Mar 19 '22 16:03 philsherry