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 end
relocation.add_replacement_pair(:library, HOMEBREW_LIBRARY.to_s, LIBRARY_PLACEHOLDER) relocation.add_replacement_pair(:library, HOMEBREW_LIBRARY.to_s, LIBRARY_PLACEHOLDER)
relocation.add_replacement_pair(:perl, relocation.add_replacement_pair(:perl,
%r{\A#!(/usr/bin/perl\d\.\d+|#{HOMEBREW_PREFIX}/opt/perl/bin/perl)$}o, %r{\A#!(?:/usr/bin/perl\d\.\d+|#{HOMEBREW_PREFIX}/opt/perl/bin/perl)( |$)}o,
"#!#{PERL_PLACEHOLDER}") "#!#{PERL_PLACEHOLDER}\\1")
relocation relocation
end end
alias generic_prepare_relocation_to_placeholders prepare_relocation_to_placeholders alias generic_prepare_relocation_to_placeholders prepare_relocation_to_placeholders

View File

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

View File

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