Unable to apply Unified diff patch for Solaris

For example, if I have two files:

file1:

This is file 1

and file2:

This is file 2

and create a patch using the following command:

diff -u file1 file2 > files.patch

result:

--- file1       Fri Aug 13 17:53:28 2010
+++ file2       Fri Aug 13 17:53:38 2010
@@ -1,1 +1,1 @@
-This is file 1
+This is file 2

Then, if I try to apply this patch to Solaris using the patch command:

patch -u -i files.patch

it freezes:

 Looks like a unified context diff.
File to patch:

1. Is there a way to use the native patch command for Solaris with uniform differences?

2. What diff format is considered the most portable if it is impossible to apply a unified format?

Update: I found the answer in the first part of my question. patchOn Solaris , it seems to freeze if the second file (file2 in this case) exists in the same folder as the first (file1). For example, the following pretty common diff:

--- a/src/file.src       Sat Aug 14 23:07:29 2010
+++ b/src/file.src       Sat Aug 14 23:07:37 2010
@@ -1,2 +1,1 @@
-1
-
+2

will not work with a fairly general fix command:

patch -p1 -u -d a < file.patch

diff ( ):

--- a/src/file.src       Sat Aug 14 23:07:29 2010
+++ b/src/file_new.src       Sat Aug 14 23:07:37 2010
@@ -1,2 +1,1 @@
-1
-
+2

.

. .

+5
3

Single Unix v2 v3 , , diffs (-c diff patch).

Solaris ( 10, ) , /usr/xpg4/bin /usr/bin $PATH, .

0

Solaris /usr/bin/patch , . GNU /usr/bin/gpatch Solaris 8 .

+6
diff -cr old.new new.txt > patch.txt

gpatch -p0 < patch.txt

Works fine for me (using gpatch)

+2
source

All Articles