I was writing a script to identify which outdated casks to upgrade, since brew cask upgrade
doesn't upgrade all casks with a numbered version, and brew cask upgrade --greedy
also upgrades those with auto-update.
But when I use brew cask outdated --greedy 2>&1 | grep -v '\(latest\)'
to filter out casks with auto-update, it doesn't work.
My output of brew cask outdated --greedy
is
google-drive-file-stream (latest) != latest
namechanger (3.4.2) != 3.4.3
quicklook-json (latest) != latest
timemachineeditor (latest) != latest
visual-studio-code (1.39.0) != 1.39.1
webpquicklook (latest) != latest
Whereas the output of brew cask outdated --greedy 2>&1 | grep -v '\(latest\)'
is
google-drive-file-stream
namechanger
quicklook-json
timemachineeditor
visual-studio-code
webpquicklook
The version numbers are missing.
With 2>&1
I thought everything should have been redirected to stdout
, but apparently version numbers are in neither stdout
nor stderr
.
I searched for similar problems and found one here, in which the command outputs directly to $(tty)
. But that's not what's happening in my case either. brew cask outdated --greedy &> /dev/null
does eliminate all output, the command does not directly output to $(tty)
.
Now I'm totally confused, where could those version numbers go?
I find that using script
as a workaround to capture the terminal output in a file works here, rather than attempting to redirect stdout
or stderr
.
tmp_file="$(mktemp)"
script -q "$tmp_file" brew cask outdated --greedy >/dev/null
grep -v "(latest)" "$tmp_file" | cut -d " " -f 1
rm "$tmp_file"