This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: patch -e from stdin broken?


Corinna Vinschen wrote:
On Feb 21 15:35, pedro_alves@portugalmail.pt wrote:
Hi guys,

While looking at why 'quilt annotate' is broken in Cygwin, I found
something fishy on 'patch' in ed mode.  Looks like reading the patch
from stdin is broken.  Reading the patch from a file with -i works
ok.  Here is how to reproduce:

$ touch a.txt

$ cat << EOF > b.txt
a new line
EOF
$ diff -e a.txt b.txt > ab.diff

$ cat ab.diff
0a
a new line

The diff file also contains a third line with just a single dot. If I feed this to patch from stdin, everything's fine:

$ patch < ab.diff
can't find file to patch at input line 1
Perhaps you used the wrong -p or --strip option?
File to patch: a.txt
$ cat a.txt
a new line
$

Where's the problem exactly?



(Here is the original message I tried to send earlier, sorry for the mess.)


Hi guys,

While looking at why 'quilt annotate' is broken in Cygwin, I found
something fishy on 'patch' in ed mode.  Looks like reading the patch
from stdin is broken.  Reading the patch from a file with -i works
ok.  Here is how to reproduce:

$ touch a.txt

$ cat << EOF > b.txt

> a new line
> EOF

$ diff -e a.txt b.txt > ab.diff


$ cat ab.diff
0a
a new line
.

$ patch -e a.txt < ab.diff

$ /cygdrive/c/DOCUME~1/pt104167/LOCALS~1/Temp/poL0ERTu: No such file
or directory

#(a.txt should have the same contents as b.txt at this point)
$ cat a.txt

$ cat ab.diff | patch -e a.txt

$ /cygdrive/c/DOCUME~1/pt104167/LOCALS~1/Temp/po5so3lD: No such file
or directory

#(still wrong contents)
$ cat a.txt

$ patch -e a.txt -i ab.diff

#(ok now.)
$ cat a.txt
a new line


That 'No such file' error message comes from ed, or so it seems. It looks like something is going wrong with the pipe to ed (patch/pch.c:do_ed_script), but I can't see what. The filename passed to it is correct, but somehow, when the pipe is fflushed ed barks. If I put a _cexit before the pipe is flushed, ed doesn't complain. I also tested it on kubuntu 6.06, and on Solaris 10 with gnu patch, gnu diff and Sun ed, and it worked correctly, so it does look like a Cygwin specific problem.

Cygwin Package Information
Package              Version        Status
cygwin               1.5.24-2       OK
patch                2.5.8-9        OK
diffutils            2.8.7-1        OK
ed                   0.2-1          OK

(end original message)

As Corinna found out, not specifying the file to patch, but doing
it interactively works ok.  That should make it easier to debug.

$ patch -e < ab.diff
can't find file to patch at input line 1
Perhaps you used the wrong -p or --strip option?
File to patch: a.txt
$ cat a.txt
a new line
$

$ patch -e a.txt < ab.diff /cygdrive/c/DOCUME~1/ADMINI~1/DEFINI~1/Temp/poh0o0Rq: No such file or
directory


Cheers,
Pedro Alves




-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]