Merge pull request #19595 from gromgit/popen/fix-err-msg

popen: get correct cmd name on error
This commit is contained in:
Ruoyu Zhong 2025-03-25 06:03:13 +00:00 committed by GitHub
commit 358af263b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -51,13 +51,18 @@ module Utils
yield pipe
else
options[:err] ||= File::NULL unless ENV["HOMEBREW_STDERR"]
cmd = if args[0].is_a? Hash
args[1]
else
args[0]
end
begin
exec(*args, options)
rescue Errno::ENOENT
$stderr.puts "brew: command not found: #{args[0]}" if options[:err] != :close
$stderr.puts "brew: command not found: #{cmd}" if options[:err] != :close
exit! 127
rescue SystemCallError
$stderr.puts "brew: exec failed: #{args[0]}" if options[:err] != :close
$stderr.puts "brew: exec failed: #{cmd}" if options[:err] != :close
exit! 1
end
end