Created
January 4, 2013 08:51
-
-
Save maeharin/4450996 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/ruby | |
if ARGV.count < 1 || ARGV.count >= 2 | |
raise '引数が不正です!第1引数に比較したいファイル名を指定してください' | |
end | |
file_name = ARGV[0] | |
full_path = {} | |
full_path[:a] = File::expand_path(file_name) | |
full_path[:b] = '' | |
case full_path[:a] | |
when %r!/xxx/(.+)! | |
puts <<-EOS | |
************************************************************* | |
あなたは今xxxにいます | |
+ はxxxで追加された部分 | |
- はxxxで削除された部分 | |
************************************************************* | |
EOS | |
full_path[:b] = "~/yyy/#{$~[1]}" | |
when %r!/yyy/(.+)! | |
puts <<-EOS | |
************************************************************* | |
あなたは今yyyにいます | |
+ はyyyで追加された部分 | |
- はyyyで削除された部分 | |
************************************************************* | |
EOS | |
full_path[:b] = "~/xxx/#{$~[1]}" | |
else | |
raise 'error!あなたのいる位置が不明です' | |
exit | |
end | |
begin | |
exec("diff -u #{full_path[:b]} #{full_path[:a]} | nkf -w8") | |
rescue | |
puts 'シェルスクリプトdiffが実行できませんでした' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment