ソースコードの行末スペース
気になる。
どうしよう。でもsedとかIDEの補助を得るようにお願いするのも面倒だよな、という場合、
git stripspaceが使えるような気がする。
git stripspace
git stripspaceにファイルを標準入力に与えてやると
行末スペースを削除する。
before
test.txt
hello world
hoge
fuga
moge
テキストだとわかりづらいのかもしれんので、画像で。
after
git stripspace < test.txtを実行すると...
test.txt
hello world
hoge
fuga
moge
ファイルを上書き保存したい場合
git stripspaceは標準出力に変更内容を出す。
ファイルを上書きしたい場合、moreutilsにあるspongeを利用し、ファイルを上書きする。
Mac OS Xの場合
homebrewを使えばmoreutilsをインストール可能
> brew install moreutils
ファイルの行末スペースを削除しつつ保存
> git stripspace < test.txt | sponge test.txt
で。
行末スペースを削除して欲しい人に実行してもらうようにお願いしよう。