Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Applying a patch to files with spaces in names

Tags:

diff

patch

cygwin

Here's an output of diff -u "temp temp/docs 1.txt" "temp temp/docs 2.txt":

--- temp temp/docs 1.txt    Mon Apr  7 16:15:08 2014
+++ temp temp/docs 2.txt    Mon Apr  7 16:18:45 2014
@@ -2,6 +2,6 @@
 22
 333
 4444
-555555
+55555
 666666
 7777777 

However, feeding this diff to patch -u fails with following message:

can't find file to patch at input line 3
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|--- temp temp/docs 1.txt       Mon Apr  7 16:15:08 2014
|+++ temp temp/docs 2.txt       Mon Apr  7 16:18:45 2014
--------------------------

Apparently, the spaces are the problem; is there a way to make patch to work on files with spaces in names?

like image 249
Joker_vD Avatar asked Oct 13 '25 05:10

Joker_vD


2 Answers

No, GNU patch doesn't support this. Here's the official statement: http://www.gnu.org/software/diffutils/manual/html_node/Unusual-File-Names.html#Unusual%20File%20Names

like image 192
John Zwinck Avatar answered Oct 15 '25 14:10

John Zwinck


Gnu patch 2.6.1 (linux) seems to obey at least 1 space (not tried with more) if the filename is separated from the date with tab.

YYMV

like image 33
somloigaluska Avatar answered Oct 15 '25 13:10

somloigaluska



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!