Wall 表示,patch 改變了計算文化。Eric Raymond 認為,patch 是 Wall 對開放源碼文化最重要的貢獻。他說,Wall 實際上催生了,或至少是激發了 Linux 展現的高度分散式開發的現代模式。
摘自
有了如上的两个人,我们还有什么话说?理解之、发扬之、然后扭头、摇头、低头,最后手舞足蹈之。
patch允许软件的开发者只发行定义两个版本之间区别的文件,这样无论是谁,只要他拥有某个文件的一个版本和这个版本与下一个版本之间的区别(diff的输出)的文件,他就可以用patch命令将此版本变成下一个版本,而无须拥有完整的下一个版本。
社区法则:如果在某个程序中发现了漏洞并进行了修补,给程序的作者发送一个补丁比仅仅给出对修补的描述要更容易、更准确、也更有礼貌。
废话就不多说了,下面我给出一个简单的操作实例,来具体的体验它一次:
现在我建立了两个文件,new.txt和new1.txt.内容分别如下:
lee@lee-laptop:~$ cat new.txt
this is just test diff and patch program.
so you must don't edit it.
just use patch
o,no,
you must use diff first.
goodbye!
thank you.
lee@lee-laptop:~$ cat new1.txt
hello everyone!
this is just test diff and patch program.
(如果你觉得别扭的话,可以将内容互换。)
现在我们用diff比较它们的不同之处,并且输出到一个文件new_diff.
lee@lee-laptop:~$ diff new.txt new1.txt > new_diff
然后我们再来看new_diff
lee@lee-laptop:~$ cat new_diff
1d0
< hello everyone!
2a2,7
> so you must don't edit it.
> just use patch
> o,no,
> you must use diff first.
> goodbye!
> thank you.
真正的主角就要出场了:我们现在将new1.txt的内容变成和new.txt的内容一致.
lee@lee-laptop:~$ patch new1.txt new_diff1
patching file new1.txt
lee@lee-laptop:~$ cat new1.txt
this is just test diff and patch program.
so you must don't edit it.
just use patch
o,no,
you must use diff first.
goodbye!
thank you.
new1.txt和new.txt的内容变得一模一样了。那么当然patch还支持回滚的。
lee@lee-laptop:~$ patch -R new1.txt new_diff1
patching file new1.txt
lee@lee-laptop:~$ cat new1.txt
hello everyone!
this is just test diff and patch program.
(-R,递归或回滚,Recursive or Rollback ,unix cmdline Skills ......)
阅读(2000) | 评论(0) | 转发(0) |