aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/container/executable.rb
blob: af3b36fd10871caf1bba8f69c1b41dde5051e5dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
require "hbc/container/naked"
require "vendor/macho/macho"

module Hbc
  class Container
    class Executable < Naked
      def self.me?(criteria)
        return true if criteria.magic_number(/^#!\s*\S+/)

        begin
          criteria.path.file? && MachO.open(criteria.path).header.executable?
        rescue MachO::MagicError
          false
        end
      end
    end
  end
end