我正在尝试修补一个文件。
修补程序文件位于要修补的文件列表的目录中。
当我运行表扬时
patch < file.patch
它提示我
File to patch:
如何避免这种情况?我应该在补丁文件中添加什么以自动检测它应该修补的文件名
GNU版本的补丁包括一个--batch
或-t
选项,它可以阻止所有提示。
-t or --batch
Suppress questions like -f, but make some different assumptions: skip patches
whose headers do not contain file names (the same as -f); skip patches for which
the file has the wrong version for the Prereq: line in the patch; and assume
that patches are reversed if they look like they are.
使用 diff
创建补丁时,默认情况下,输出格式不包括原始文件名的文件名。您可以使用-u
选项更改此设置,如下所示...
$ diff -u OriginalFile NewFile >NewFile.patch
然后,您可以简单地...
$ patch -u <NewFile.patch
有关更多信息,请阅读统一的 GNU diff
格式。