diff --git a/Library/Homebrew/unpack_strategy/dmg.rb b/Library/Homebrew/unpack_strategy/dmg.rb index 55609e49a0..1df8292aa0 100644 --- a/Library/Homebrew/unpack_strategy/dmg.rb +++ b/Library/Homebrew/unpack_strategy/dmg.rb @@ -106,11 +106,8 @@ module UnpackStrategy end def self.can_extract?(path) - imageinfo = system_command("hdiutil", - args: ["imageinfo", path], - print_stderr: false).stdout - - !imageinfo.empty? + stdout, _, status = system_command("hdiutil", args: ["imageinfo", path], print_stderr: false) + status.success? && !stdout.empty? end private diff --git a/Library/Homebrew/unpack_strategy/tar.rb b/Library/Homebrew/unpack_strategy/tar.rb index 70c3198d34..17be99f406 100644 --- a/Library/Homebrew/unpack_strategy/tar.rb +++ b/Library/Homebrew/unpack_strategy/tar.rb @@ -22,9 +22,8 @@ module UnpackStrategy return false unless [Bzip2, Gzip, Lzip, Xz].any? { |s| s.can_extract?(path) } # Check if `tar` can list the contents, then it can also extract it. - IO.popen(["tar", "tf", path], err: File::NULL) do |stdout| - !stdout.read(1).nil? - end + stdout, _, status = system_command("tar", args: ["tf", path], print_stderr: false) + status.success? && !stdout.empty? end private