From 85389705679ffa47b5fed4dc2667ca621d7499bf Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Mon, 22 Mar 2021 05:18:29 +0000 Subject: [PATCH 1/3] cmd/list: delineate formulae and casks Listing everything without qualifying which is which is confusing for some users. Fixes #10897. --- Library/Homebrew/cmd/list.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb index c9cb629aa6..a11b7f21fb 100644 --- a/Library/Homebrew/cmd/list.rb +++ b/Library/Homebrew/cmd/list.rb @@ -116,8 +116,16 @@ module Homebrew ls_args << "-r" if args.r? ls_args << "-t" if args.t? - safe_system "ls", *ls_args, HOMEBREW_CELLAR unless args.cask? - list_casks(args: args) unless args.formula? + ohai "Formulae" if $stdout.tty? && !args.formula? + safe_system "ls", *ls_args, HOMEBREW_CELLAR + + unless args.formula? + if $stdout.tty? + puts + ohai "Casks" + end + list_casks(args: args) + end elsif args.verbose? || !$stdout.tty? system_command! "find", args: args.named.to_kegs.map(&:to_s) + %w[-not -type d -print], print_stdout: true else From a88d65acc7e6500d9318d17e6f6d092bb58a0dd4 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Mon, 22 Mar 2021 14:12:42 +0000 Subject: [PATCH 2/3] cmd/list: list casks only if one is installed --- Library/Homebrew/cmd/list.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb index a11b7f21fb..52f853ea66 100644 --- a/Library/Homebrew/cmd/list.rb +++ b/Library/Homebrew/cmd/list.rb @@ -119,7 +119,7 @@ module Homebrew ohai "Formulae" if $stdout.tty? && !args.formula? safe_system "ls", *ls_args, HOMEBREW_CELLAR - unless args.formula? + if !args.formula? && Cask::Caskroom.casks.any? if $stdout.tty? puts ohai "Casks" From 4dccc2ef7f48e25a90a64701531bc88f2ffa31ef Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Mon, 22 Mar 2021 17:15:56 +0000 Subject: [PATCH 3/3] 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. --- Library/Homebrew/cmd/list.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb index 52f853ea66..6d05addb80 100644 --- a/Library/Homebrew/cmd/list.rb +++ b/Library/Homebrew/cmd/list.rb @@ -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?