Module: Utils::Shebang

Included in:
Formula
Defined in:
brew/Library/Homebrew/utils/shebang.rb

Defined Under Namespace

Classes: RewriteInfo

Class Method Summary collapse

Class Method Details

.rewrite_shebang(rewrite_info, *paths) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'brew/Library/Homebrew/utils/shebang.rb', line 17

def rewrite_shebang(rewrite_info, *paths)
  paths.each do |f|
    f = Pathname(f)
    next unless f.file?
    next unless rewrite_info.regex.match?(f.read(rewrite_info.max_length))

    Utils::Inreplace.inreplace f.to_s, rewrite_info.regex, "#!#{rewrite_info.replacement}"
  end
end