cmd/list: list formulae only if one is installed

We need the `HOMEBREW_CELLAR.exist?` check to avoid errors in new
installations, which may not have a `Cellar` directory.
This commit is contained in:
Carlo Cabrera 2021-03-22 17:15:56 +00:00
parent a88d65acc7
commit 4dccc2ef7f
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -116,8 +116,10 @@ module Homebrew
ls_args << "-r" if args.r?
ls_args << "-t" if args.t?
ohai "Formulae" if $stdout.tty? && !args.formula?
safe_system "ls", *ls_args, HOMEBREW_CELLAR
if HOMEBREW_CELLAR.exist? && HOMEBREW_CELLAR.children.any?
ohai "Formulae" if $stdout.tty? && !args.formula?
safe_system "ls", *ls_args, HOMEBREW_CELLAR
end
if !args.formula? && Cask::Caskroom.casks.any?
if $stdout.tty?