[Bug 11981] New: patch does not respect the posix filename determination

bugzilla at busybox.net bugzilla at busybox.net
Mon Jun 24 15:18:17 UTC 2019


https://bugs.busybox.net/show_bug.cgi?id=11981

            Bug ID: 11981
           Summary: patch does not respect the posix filename
                    determination
           Product: Busybox
           Version: unspecified
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Standard Compliance
          Assignee: unassigned at busybox.net
          Reporter: shuangistan at gmail.com
                CC: busybox-cvs at busybox.net
  Target Milestone: ---

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the busybox-cvs mailing list