Read if no block is passed to Utils.popen_read
This commit is contained in:
		
							parent
							
								
									677cd51977
								
							
						
					
					
						commit
						5c24b7330b
					
				@ -231,13 +231,13 @@ module OS
 | 
			
		||||
    def mdfind(*ids)
 | 
			
		||||
      return [] unless OS.mac?
 | 
			
		||||
      (@mdfind ||= {}).fetch(ids) do
 | 
			
		||||
        @mdfind[ids] = Utils.popen_read("/usr/bin/mdfind", mdfind_query(*ids), &:read).split("\n")
 | 
			
		||||
        @mdfind[ids] = Utils.popen_read("/usr/bin/mdfind", mdfind_query(*ids)).split("\n")
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def pkgutil_info(id)
 | 
			
		||||
      (@pkginfo ||= {}).fetch(id) do |key|
 | 
			
		||||
        @pkginfo[key] = Utils.popen_read("/usr/sbin/pkgutil", "--pkg-info", key, &:read).strip
 | 
			
		||||
        @pkginfo[key] = Utils.popen_read("/usr/sbin/pkgutil", "--pkg-info", key).strip
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -57,7 +57,7 @@ module OS
 | 
			
		||||
 | 
			
		||||
      def version_from_mdls(path)
 | 
			
		||||
        version = Utils.popen_read(
 | 
			
		||||
          "/usr/bin/mdls", "-raw", "-nullMarker", "", "-name", "kMDItemVersion", path.to_s, &:read
 | 
			
		||||
          "/usr/bin/mdls", "-raw", "-nullMarker", "", "-name", "kMDItemVersion", path.to_s
 | 
			
		||||
        ).strip
 | 
			
		||||
        version unless version.empty?
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@ -10,7 +10,11 @@ module Utils
 | 
			
		||||
  def self.popen(args, mode)
 | 
			
		||||
    IO.popen("-", mode) do |pipe|
 | 
			
		||||
      if pipe
 | 
			
		||||
        yield pipe
 | 
			
		||||
        if block_given?
 | 
			
		||||
          yield pipe
 | 
			
		||||
        else
 | 
			
		||||
          return pipe.read
 | 
			
		||||
        end
 | 
			
		||||
      else
 | 
			
		||||
        STDERR.reopen("/dev/null", "w")
 | 
			
		||||
        exec(*args)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user