popen: get correct cmd name on error
Blindly using args[0] misleads users when an env is passed.
Before:
```
==> go build -ldflags=-s -w -X main.version=1.64.8 -X main.commit=8b37f14 -X main.date=2025-03-17T16:54:02Z ./cmd/golangci-lint
brew: command not found: {"SHELL"=>"bash"}
Error: Failure while executing; `\{\"SHELL\"=\>\"bash\"\} /opt/homebrew/Cellar/golangci-lint@1/1.64.8/bin/golangci-lint completion bash` exited with 127. Here's the output:
```
After:
```
==> go build -ldflags=-s -w -X main.version=1.64.8 -X main.commit=8b37f14 -X main.date=2025-03-17T16:54:02Z ./cmd/golangci-lint
brew: command not found: /opt/homebrew/Cellar/golangci-lint@1/1.64.8/bin/golangci-lint
Error: Failure while executing; `\{\"SHELL\"=\>\"bash\"\} /opt/homebrew/Cellar/golangci-lint@1/1.64.8/bin/golangci-lint completion bash` exited with 127. Here's the output:
```
This commit is contained in:
parent
a1df0c9dbe
commit
0efa6aab32
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user