Support handling of rewriting shebangs with flags

Fixes #11108.
This commit is contained in:
Bo Anderson 2021-05-04 15:59:53 +01:00
parent ae49b06600
commit 5f41016267
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
3 changed files with 8 additions and 8 deletions

View File

@ -79,8 +79,8 @@ class Keg
end
relocation.add_replacement_pair(:library, HOMEBREW_LIBRARY.to_s, LIBRARY_PLACEHOLDER)
relocation.add_replacement_pair(:perl,
%r{\A#!(/usr/bin/perl\d\.\d+|#{HOMEBREW_PREFIX}/opt/perl/bin/perl)$}o,
"#!#{PERL_PLACEHOLDER}")
%r{\A#!(?:/usr/bin/perl\d\.\d+|#{HOMEBREW_PREFIX}/opt/perl/bin/perl)( |$)}o,
"#!#{PERL_PLACEHOLDER}\\1")
relocation
end
alias generic_prepare_relocation_to_placeholders prepare_relocation_to_placeholders

View File

@ -20,9 +20,9 @@ module Language
end
Utils::Shebang::RewriteInfo.new(
%r{^#! ?/usr/bin/(env )?perl$},
20, # the length of "#! /usr/bin/env perl"
perl_path,
%r{^#! ?/usr/bin/(?:env )?perl( |$)},
21, # the length of "#! /usr/bin/env perl "
"#{perl_path}\\1",
)
end
end

View File

@ -96,9 +96,9 @@ module Language
# @private
def python_shebang_rewrite_info(python_path)
Utils::Shebang::RewriteInfo.new(
%r{^#! ?/usr/bin/(env )?python([23](\.\d{1,2})?)?$},
28, # the length of "#! /usr/bin/env pythonx.yyy$"
python_path,
%r{^#! ?/usr/bin/(?:env )?python(?:[23](?:\.\d{1,2})?)?( |$)},
28, # the length of "#! /usr/bin/env pythonx.yyy "
"#{python_path}\\1",
)
end