mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
21 lines
357 B
Ruby
21 lines
357 B
Ruby
![]() |
module Utils
|
||
|
def self.popen_read(*args, &block)
|
||
|
popen(args, "rb", &block)
|
||
|
end
|
||
|
|
||
|
def self.popen_write(*args, &block)
|
||
|
popen(args, "wb", &block)
|
||
|
end
|
||
|
|
||
|
def self.popen(args, mode)
|
||
|
IO.popen("-", mode) do |pipe|
|
||
|
if pipe
|
||
|
yield pipe
|
||
|
else
|
||
|
STDERR.reopen("/dev/null", "w")
|
||
|
exec(*args)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|