diff options
| author | Jack Nagel | 2014-07-05 13:50:54 -0500 |
|---|---|---|
| committer | Jack Nagel | 2014-07-05 13:50:54 -0500 |
| commit | ad27b21cd11a4e28f4174ebb54df357d6b6221a0 (patch) | |
| tree | 3fceb4dcca1e378778bcce33737a68320d3b4596 /Library/Homebrew/utils | |
| parent | 84372e570eb211af82d486b9b9dea5f6ed4ba78e (diff) | |
| download | brew-ad27b21cd11a4e28f4174ebb54df357d6b6221a0.tar.bz2 | |
Add popen wrapper that does not invoke the shell
Diffstat (limited to 'Library/Homebrew/utils')
| -rw-r--r-- | Library/Homebrew/utils/popen.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Library/Homebrew/utils/popen.rb b/Library/Homebrew/utils/popen.rb new file mode 100644 index 000000000..83f140163 --- /dev/null +++ b/Library/Homebrew/utils/popen.rb @@ -0,0 +1,20 @@ +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 |
