mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
language/*: fix *_SHEBANG_REGEX
anchors
We should use `\A` to pick up shebangs at the start of files instead of just anywhere in a given script. See Homebrew/homebrew-core#227654 for an example where this can cause problems.
This commit is contained in:
parent
cfede01ea9
commit
6a7416c296
@ -96,7 +96,7 @@ module Language
|
||||
module_function
|
||||
|
||||
# A regex to match potential shebang permutations.
|
||||
NODE_SHEBANG_REGEX = %r{^#! ?(?:/usr/bin/(?:env )?)?node( |$)}
|
||||
NODE_SHEBANG_REGEX = %r{\A#! ?(?:/usr/bin/(?:env )?)?node( |$)}
|
||||
|
||||
# The length of the longest shebang matching `SHEBANG_REGEX`.
|
||||
NODE_SHEBANG_MAX_LENGTH = T.let("#! /usr/bin/env node ".length, Integer)
|
||||
|
@ -15,7 +15,7 @@ module Language
|
||||
module_function
|
||||
|
||||
# A regex to match potential shebang permutations.
|
||||
PERL_SHEBANG_REGEX = %r{^#! ?(?:/usr/bin/(?:env )?)?perl( |$)}
|
||||
PERL_SHEBANG_REGEX = %r{\A#! ?(?:/usr/bin/(?:env )?)?perl( |$)}
|
||||
|
||||
# The length of the longest shebang matching `SHEBANG_REGEX`.
|
||||
PERL_SHEBANG_MAX_LENGTH = T.let("#! /usr/bin/env perl ".length, Integer)
|
||||
|
@ -15,7 +15,7 @@ module Language
|
||||
module_function
|
||||
|
||||
# A regex to match potential shebang permutations.
|
||||
PHP_SHEBANG_REGEX = %r{^#! ?(?:/usr/bin/(?:env )?)?php( |$)}
|
||||
PHP_SHEBANG_REGEX = %r{\A#! ?(?:/usr/bin/(?:env )?)?php( |$)}
|
||||
|
||||
# The length of the longest shebang matching `SHEBANG_REGEX`.
|
||||
PHP_SHEBANG_MAX_LENGTH = T.let("#! /usr/bin/env php ".length, Integer)
|
||||
|
@ -112,7 +112,7 @@ module Language
|
||||
module_function
|
||||
|
||||
# A regex to match potential shebang permutations.
|
||||
PYTHON_SHEBANG_REGEX = %r{^#! ?(?:/usr/bin/(?:env )?)?python(?:[23](?:\.\d{1,2})?)?( |$)}
|
||||
PYTHON_SHEBANG_REGEX = %r{\A#! ?(?:/usr/bin/(?:env )?)?python(?:[23](?:\.\d{1,2})?)?( |$)}
|
||||
|
||||
# The length of the longest shebang matching `SHEBANG_REGEX`.
|
||||
PYTHON_SHEBANG_MAX_LENGTH = T.let("#! /usr/bin/env pythonx.yyy ".length, Integer)
|
||||
|
Loading…
x
Reference in New Issue
Block a user