formulary: improve style

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
Carlo Cabrera 2025-07-10 20:25:17 +08:00 committed by Carlo Cabrera
parent 6141c6a181
commit 69ce5edd14
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -139,11 +139,12 @@ module Formulary
raise new_exception, "", e.backtrace
end
ensure
printed_to_stdout = $stdout.string.strip
if printed_to_stdout.present?
# TODO: Make printing to stdout an error so that we can print a tap name.
# See discussion at https://github.com/Homebrew/brew/pull/20226#discussion_r2195886888
if (printed_to_stdout = $stdout.string.strip.presence)
opoo <<~WARNING
Formula #{name} attempted to print the following while being loaded:
#{$stdout.string.strip}
#{printed_to_stdout}
WARNING
end
$stdout = old_stdout