Easy way to add frozen_string_literal magic string to your ruby files

1
2
3
4
5
comm -23 \
<(git ls-files|sort) \
<(git grep -l 'frozen_string_literal'|sort) \
| grep -E '\.rb$' \
| xargs -n1 sed -i '1s/^/# frozen_string_literal: true\n\n/'

The code is pretty self explanatory, we get a list of all the files in our repo and then remove the ones which already have the magic string and then filter it to just the ruby files and finally adding the magic string to all the files.


I am currently working on LiveForm which makes setting up contact forms on your website a breeze.