patch does not respect the posix filename determination
Liu, Shuang (ADITG/ESM)
sliu at de.adit-jv.com
Wed Jun 26 14:52:01 UTC 2019
Hi,
We created a ticket as https://bugs.busybox.net/show_bug.cgi?id=11981
If a filename is not given, busybox patch uses the newname in the line +++.
This does not align with the posix filename determination rule.
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/patch.html
The posix filename determination said:
If the type of diff is context, the patch utility shall delete the pathname components (as specified by the -p option) from the filename on the line beginning with "---" (if copied context) or "+++" (if unified context), then test for the existence of this file relative to the current directory (or the directory specified with the -d option). If the file exists, the patch utility shall use this filename.
Steps to Reproduce:
$ echo test > test.txt
$ echo updated_test > utest.txt
$ diff -u test.txt utest.txt
--- test.txt
+++ utest.txt
@@ -1 +1 @@
-test
+updated_test
$ diff -u test.txt utest.txt > test.patch
$ busybox patch < test.patch
patching file utest.txt
Hunk 1 FAILED 1/1.
-test
+updated_test
Expected behavior with GNU patch --posix:
$ patch --posix < test.patch
patching file test.txt
Best regards
Shuang Liu
Engineering Software Multimedia (ADITG/ESM)
More information about the busybox
mailing list