Method: #shebang?

Defined in:
lib/vagrant-subutai/packer/subutai_hooks.rb

#shebang?(bash_hook) ⇒ Boolean

True if script starts with #!/bin/bash


Returns:

  • (Boolean)


5
6
7
8
9
10
11
# File 'lib/vagrant-subutai/packer/subutai_hooks.rb', line 5

def shebang?(bash_hook)
  text = File.open(bash_hook).read
  text.gsub!(/\r\n?/, "\n")
  line = text.next
  return true if line.start_with? '#!/bin/bash'
  true if line.start_with? '#!/usr/bin/env bash'
end