可以在Linux中使用Ant任务“修补程序”来使用DOS换行符来修补文件吗?

问题描述

我们怎么能...

  1. 使用Linux中的Ant任务patch通过DOS换行符修补文件吗?
  2. 将命令行选项--binary应用于Ant任务patch

请参阅下面的详细信息。

文件

命令行patch失败

补丁文件中的

DOS换行符转换为Unix换行符并进行修补 失败:

[0] mypc<u0>:~/src/test/ant_patch_crlf>patch -i test.patch
(Stripping trailing CRs from patch; use --binary to disable.)
patching file test.txt
Hunk #1 Failed at 1 (different line endings).
1 out of 1 hunk Failed -- saving rejects to file test.txt.rej

命令行patch --binary正常工作

如上所述。

use --binary to disable

添加选项--binary有帮助:

[0] mypc<u0>:~/src/test/ant_patch_crlf>patch --binary -i test.patch
patching file test.txt

蚂蚁任务patch失败

蚂蚁任务patch失败,错误与命令行相同,但没有 选项--binary

[0] mypc<u0>:~/src/test/ant_patch_crlf>ant                              
Buildfile: /home/u0/src/test/ant_patch_crlf/build.xml

patch:
    [patch] (Stripping trailing CRs from patch; use --binary to disable.)
    [patch] patching file test.txt
    [patch] Hunk #1 Failed at 1 (different line endings).
    [patch] 1 out of 1 hunk Failed -- saving rejects to file test.txt.rej
    [patch] 'patch' Failed with exit code 1

BUILD SUCCESSFUL
Total time: 0 seconds

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)