From 8145d516e22bd6e7b928009af35d6db166cf8230 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 1 Nov 2022 13:51:13 +0000 Subject: [PATCH] cmd/search: better handle non-TTY output. When `stdout` is not a TTY then using `ohai` is a bit unpleasant as it prevents using pipes to do cool things with the output. --- Library/Homebrew/cmd/search.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index 962a33ea12..6fa72a11df 100644 --- a/Library/Homebrew/cmd/search.rb +++ b/Library/Homebrew/cmd/search.rb @@ -146,9 +146,21 @@ module Homebrew print_formulae &&= all_formulae.any? print_casks &&= all_casks.any? - ohai "Formulae", Formatter.columns(all_formulae) if print_formulae + if print_formulae + if $stdout.tty? + ohai "Formulae", Formatter.columns(all_formulae) + else + puts all_formulae + end + end puts if print_formulae && print_casks - ohai "Casks", Formatter.columns(all_casks) if print_casks + if print_casks + if $stdout.tty? + ohai "Casks", Formatter.columns(all_casks) + else + puts all_casks + end + end count = all_formulae.count + all_casks.count