 8486f6e04d
			
		
	
	
		8486f6e04d
		
	
	
	
	
		
			
			Prior to this change there were only 3 instances of `STD(IN|OUT|ERR)` versus 74 instances of `$std(in|out|err)` in the Homebrew code base. The latter variant is also strongly suggested by bbatsov's Ruby Style Guide.
		
			
				
	
	
		
			29 lines
		
	
	
		
			514 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			514 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| module Utils
 | |
|   def self.popen_read(*args, &block)
 | |
|     popen(args, "rb", &block)
 | |
|   end
 | |
| 
 | |
|   def self.popen_read_text(*args, &block)
 | |
|     popen(args, "r", &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
 | |
|         if block_given?
 | |
|           yield pipe
 | |
|         else
 | |
|           return pipe.read
 | |
|         end
 | |
|       else
 | |
|         $stderr.reopen("/dev/null", "w")
 | |
|         exec(*args)
 | |
|       end
 | |
|     end
 | |
|   end
 | |
| end
 |