Module: Language::Perl::Shebang

Defined in:
brew/Library/Homebrew/language/perl.rb

Class Method Summary collapse

Class Method Details

.detected_perl_shebang(formula = self) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'brew/Library/Homebrew/language/perl.rb', line 8

def detected_perl_shebang(formula = self)
  perl_path = if formula.uses_from_macos_elements&.include? "perl"
    "/usr/bin/perl"
  elsif formula.deps.map(&:name).include? "perl"
    Formula["perl"].opt_bin/"perl"
  else
    raise "Cannot detect Perl shebang: formula does not depend on Perl."
  end

  Utils::Shebang::RewriteInfo.new(
    %r{^#! ?/usr/bin/(env )?perl$},
    20, # the length of "#! /usr/bin/env perl"
    perl_path,
  )
end