Pet*_*ner 3 patch here-document
我正在尝试在 bash 中修补这样的文件:
cat << ''EOF | patch --dry-run
> --- urancid 2017-12-06 09:56:33.000000000 -0600 patch --dry-run
> +++ /tmp/urancid 2017-12-06 15:06:57.000000000 -0600
> @@ -393,7 +393,7 @@
> last if (/^$prompt/);
> next if (/-ac\.\s*/);
> next if (/-fs\.\s*/);
> - next if (/set date\s*/)
> + next if (/set date\s*/);
> next if (/^(\s*|\s*$cmd\s*)$/);
> if ( ! /^$prompt/) {
> if ( ! $skipprocess ) {
> EOF
Run Code Online (Sandbox Code Playgroud)
但我得到的只是
patching file urancid
Hunk #1 FAILED at 393.
1 out of 1 hunk FAILED -- saving rejects to file urancid.rej
Run Code Online (Sandbox Code Playgroud)
似乎应该是可能的,如果我找到我正在粘贴的补丁文件,它就可以工作。
我想这样做,以便我可以制作补丁脚本而不包含多个文件。
到目前为止,我对“补丁”关心的内容不太熟悉,猜测有一些空白问题?
修复示例中的空格以便补丁可以应用表明该概念是可以接受的(尽管我不明白为什么cat需要)。
另一方面,如果您有一个空白对齐严重的补丁,我建议您使用该--ignore-whitespace参数。(您可以在补丁的手册页中找到它,man patch。)
patch --dry-run --ignore-whitespace << 'EOF'
...
...
EOF
Run Code Online (Sandbox Code Playgroud)