-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
/
perl.rb
30 lines (27 loc) 路 819 Bytes
/
perl.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# typed: true
# frozen_string_literal: true
module Language
# Helper functions for Perl formulae.
#
# @api public
module Perl
# Helper module for replacing `perl` shebangs.
module Shebang
module_function
def detected_perl_shebang(formula = self)
perl_path = if formula.deps.map(&:name).include? "perl"
Formula["perl"].opt_bin/"perl"
elsif formula.uses_from_macos_names.include? "perl"
"/usr/bin/perl#{MacOS.preferred_perl_version}"
else
raise ShebangDetectionError.new("Perl", "formula does not depend on Perl")
end
Utils::Shebang::RewriteInfo.new(
%r{^#! ?/usr/bin/(?:env )?perl( |$)},
21, # the length of "#! /usr/bin/env perl "
"#{perl_path}\\1",
)
end
end
end
end