Skip to content

Instantly share code, notes, and snippets.

@brainopia
Created March 27, 2012 11:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brainopia/2215241 to your computer and use it in GitHub Desktop.
Save brainopia/2215241 to your computer and use it in GitHub Desktop.
Set bom recursively to ruby files
#!/usr/bin/env ruby
require 'epath'
bom = "\xEF\xBB\xBF".force_encoding('binary')
Path.glob('**/*.rb') do |file|
next if file.binread(3) == bom
previous = file.binread
file.write bom + previous
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment