gpt4 book ai didi

linux - 补丁:以非交互模式运行

转载 作者:太空狗 更新时间:2023-10-29 12:00:52 30 4
gpt4 key购买 nike

我想自动测试一组仍然干净利落地适用于(更新的)代码库的补丁。为此,我打算运行

patch -p 1 < path/to/patch0.patch

对于所有补丁 patch*.patch,检查此命令的返回码,并将其存储在某处。不幸的是,patch 在某些情况下似乎可以交互工作。需要交互的典型输出是

can't find file to patch at input line 44
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|Index: foo/docs/faq.html
|===================================================================
|--- foo.orig/docs/faq.html
|+++ foo/docs/faq.html
--------------------------
File to patch:

有没有办法以非交互方式运行 patch? (也许 patch 不是完成这里任务的正确工具。)

最佳答案

使用-f(--force)选项:

echo a > a
echo b > b
diff -Nu a b > p
rm a b
patch -p 1 < p
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- a 2016-05-11 16:16:24.115481324 +0700
|+++ b 2016-05-11 16:16:24.115481324 +0700
--------------------------
File to patch:

(要求输入)。然而,

patch -f -p 1 < p
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- a 2016-05-11 16:16:24.115481324 +0700
|+++ b 2016-05-11 16:16:24.115481324 +0700
--------------------------
No file to patch. Skipping patch.
1 out of 1 hunk ignored

以退出状态 ($?) 1 退出:

echo $?
1

关于linux - 补丁:以非交互模式运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37157658/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com