WEB+DB PRESS Vol.46で取り上げたGNU diff(1)のラッパー、「di」をGitHubに置いた。GNU diffには多彩なオプションが用意されているが、POSIXなどの規格の縛りもありデフォルト設定が日常利用には不便なものになっている。いちいちdiff -Nrpu dir1 dir2
なんて面倒くさい。以下の特長を持つラッパーdiで楽をしよう。
-U3 -N -p -d
がデフォルト。- 出力が色付き。ページャが起動される。(Gitのまね)
- バックアップファイルやオブジェクトファイル、
.git
,.hg
,.svn
,CVS
などのディレクトリを無視する。 - RCS/CVSキーワードタグの違いを無視する。
- ディレクトリを与えれば自動で再帰比較。
- 上記を含むデフォルトのオプション設定は環境変数で変更可能。
- GNU diffがサポートしないオプションの組み合わせもサポート。
「alias di="diff -ru"
でいいんじゃないの?」という人は、理不尽におこられた経験がないのかもしれない。context diffがほしくなってdi -c FILE1 FILE2
とすると、展開されてこうなる。
1 2 3 4 |
% diff -ru -c FILE1 FILE2 diff: conflicting output style options diff: Try `diff --help' for more information. |
黙って後から指定した方を採用してくれればいいのに、まったく余計なお世話だ。(FreeBSDではこのエラーは抑止されている)
そして、diff FILE1 DIR
は動くのになぜかdiff FILE1 FILE2 DIR
はエラーになるのも不便だ。
1 2 3 4 |
% diff FILE1 FILE2 DIR diff: extra operand `DIR' diff: Try `diff --help' for more information. |
diだとちゃんと動く。ほかにも、-r
と-D NAME
が組み合わせられない問題も自力でディレクトリを辿ることで回避している。
インストールは、単にbin/di
をパスの通ったところに置くか、またはgem install di
でOK。動作にはRubyが必要。
弱点は大きなツリーの比較が遅いこと。GNU diffは-x/--exclude
を使ってもファイル名でしか除外できず、二つのファイルリストを渡して比較するということもサポートしていないため、自力でディレクトリ探索を行う場合はディレクトリごとにdiff(1)
を複数回起動しなければならない。しかし、並列起動で高速化する余地はあるので今後の課題。
もう一つ、--ignore-file-name-case
をサポートしていないが、これは面倒な割には使いたいと思ったことがないため。それだけなので、気が向けば実装するかも。あるいは切実にほしいあなたが実装するかも。
Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.
Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.
I truly appreciate your technique of writing a blog. I added it to my bookmark site list and will
I am truly thankful to the owner of this web site who has shared this fantastic piece of writing at at this place.
Good post! We will be linking to this particularly great post on our site. Keep up the great writing
I like the efforts you have put in this, regards for all the great content.
I appreciate you sharing this blog post. Thanks Again. Cool.
I truly appreciate your technique of writing a blog. I added it to my bookmark site list and will
I’m often to blogging and i really appreciate your content. The article has actually peaks my interest. I’m going to bookmark your web site and maintain checking for brand spanking new information.
Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.
I just like the helpful information you provide in your articles
I really like reading through a post that can make men and women think. Also, thank you for allowing me to comment!
Great information shared.. really enjoyed reading this post thank you author for sharing this post .. appreciated
Great information shared.. really enjoyed reading this post thank you author for sharing this post .. appreciated
I do not even understand how I ended up here, but I assumed this publish used to be great
Awesome! Its genuinely remarkable post, I have got much clear idea regarding from this post
This was beautiful Admin. Thank you for your reflections.
For the reason that the admin of this site is working, no uncertainty very quickly it will be renowned, due to its quality contents.
Good post! We will be linking to this particularly great post on our site. Keep up the great writing
I’m often to blogging and i really appreciate your content. The article has actually peaks my interest. I’m going to bookmark your web site and maintain checking for brand spanking new information.
I’m often to blogging and i really appreciate your content. The article has actually peaks my interest. I’m going to bookmark your web site and maintain checking for brand spanking new information.
You’re so awesome! I don’t believe I have read a single thing like that before. So great to find someone with some original thoughts on this topic. Really.. thank you for starting this up. This website is something that is needed on the internet, someone with a little originality!
This is my first time pay a quick visit at here and i am really happy to read everthing at one place
You’re so awesome! I don’t believe I have read a single thing like that before. So great to find someone with some original thoughts on this topic. Really.. thank you for starting this up. This website is something that is needed on the internet, someone with a little originality!
I truly appreciate your technique of writing a blog. I added it to my bookmark site list and will
This is really interesting, You’re a very skilled blogger. I’ve joined your feed and look forward to seeking more of your magnificent post. Also, I’ve shared your site in my social networks!
This is really interesting, You’re a very skilled blogger. I’ve joined your feed and look forward to seeking more of your magnificent post. Also, I’ve shared your site in my social networks!
Awesome! Its genuinely remarkable post, I have got much clear idea regarding from this post
Pretty! This has been a really wonderful post. Many thanks for providing these details.
Nice post. I learn something totally new and challenging on websites
For the reason that the admin of this site is working, no uncertainty very quickly it will be renowned, due to its quality contents.