patch -e from stdin broken?

2007-02-21 Thread pedro_alves
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

--
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/



patch -e from stdin broken?

2007-02-21 Thread pedro_alves
Damn, sorry for the noise, webmail client severelly broken, and 
behind proxy without SMTP access... Will repost later.

Cheers,
Pedro Alves

__
Email gratuito com 2 000 MB
Espaço para guardar as memórias de uma vida
http://www.portugalmail.pt/2000mb

--
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/



Re: patch -e from stdin broken?

2007-02-21 Thread Corinna Vinschen
On Feb 21 15:35, [EMAIL PROTECTED] 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?


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  cygwin AT cygwin DOT com
Red Hat

--
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/



Re: patch -e from stdin broken?

2007-02-21 Thread Pedro Alves

Corinna Vinschen wrote:

On Feb 21 15:35, [EMAIL PROTECTED] 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  VersionStatus
cygwin   1.5.24-2   OK
patch2.5.8-9OK
diffutils2.8.7-1OK
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/



Re: patch -e from stdin broken?

2007-02-21 Thread Igor Peshansky
On Wed, 21 Feb 2007, Pedro Alves wrote:

 (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



Looks like your $TMP is set to something Cygwin doesn't like...  Try
setting it to, say, /tmp, and see if that makes patch -e happier...

 [snip]
 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.

You could also try playing with the binmode setting in the Cygwin
environment variable, which controls line endings in pipes.

 (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

Hmm, you also forgot to mention the directory where a.txt resides...
Try first doing this on a binary mount in some directory under Cygwin root
(e.g., /tmp).  If that works, look into directories and environment
variable settings.
HTH,
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_Igor Peshansky, Ph.D. (name changed!)
 |,4-  ) )-,_. ,\ (  `'-'   old name: Igor Pechtchanski
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Freedom is just another word for nothing left to lose...  -- Janis Joplin

--
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/



Re: patch -e from stdin broken?

2007-02-21 Thread Pedro Alves

Hi Igor,

Igor Peshansky wrote:

On Wed, 21 Feb 2007, Pedro Alves wrote:


(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




Looks like your $TMP is set to something Cygwin doesn't like...  Try
setting it to, say, /tmp, and see if that makes patch -e happier...



Thanks for the hints.  Sorry I didn't say earlier, but I had
already tried that.  Cygwin does understand that path, just checked
(notice the /cygdrive/c/ prefix).  Actually patch honors $TMPDIR first,
so I had tried setting it to /tmp, and the same thing happens:

export TMPDIR=/tmp
patch -e a.txt  ab.diff
/tmp/posrjz1q: No such file or directory

(yes, /tmp does exist)

(
Just found out another thing:

export TMPDIR=/
patch -e a.txt  ab.diff
#looks like it is hanging, but about 20 seconds later:
patch:  Can't create file //ppMxHRaO : No such host or network path

The double slash should have been filtered before trying to open the
file.  Humm, easy to solve on patch side, but setting TMPDIR=/ breaks
a lot of stuff, even gcc and make, so I guess it is one of those
don't do it - FAQ thingies, that I missed somewhere.
)



[snip]
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.


You could also try playing with the binmode setting in the Cygwin
environment variable, which controls line endings in pipes.



I don't have any textmode mounts.


(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


Hmm, you also forgot to mention the directory where a.txt resides...
Try first doing this on a binary mount in some directory under Cygwin root
(e.g., /tmp).  If that works, look into directories and environment
variable settings.



Doesn't work anywhere:  ~, /tmp, /cygdrive/d, etc.  Did it work for you,
when you followed the recipe I sent?  If you didn't try, could you, please?

mount
d:\cygwin\bin on /usr/bin type system (binmode)
d:\cygwin\lib on /usr/lib type system (binmode)
d:\cygwin on / type system (binmode)
d:\MinGW on /mingw type system (binmode)
c: on /cygdrive/c type system (binmode,noumount)
d: on /cygdrive/d type system (binmode,noumount)
e: on /cygdrive/e type system (binmode,noumount)
f: on /cygdrive/f type system (binmode,noumount)
l: on /cygdrive/l type system (binmode,noumount)
m: on /cygdrive/m type system (binmode,noumount)
x: on /cygdrive/x type system (binmode,noumount)

set | grep CYG
CYGWIN=ntsec
CYGWIN_ROOT='\cygwin'

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/



Re: patch -e from stdin broken?

2007-02-21 Thread Igor Peshansky
On Wed, 21 Feb 2007, Pedro Alves wrote:

 Hi Igor,

 Igor Peshansky wrote:
  On Wed, 21 Feb 2007, Pedro Alves wrote:
 
   (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
 
  
 
  Looks like your $TMP is set to something Cygwin doesn't like...  Try
  setting it to, say, /tmp, and see if that makes patch -e happier...
 

 Thanks for the hints.  Sorry I didn't say earlier, but I had
 already tried that.  Cygwin does understand that path, just checked
 (notice the /cygdrive/c/ prefix).  Actually patch honors $TMPDIR first,
 so I had tried setting it to /tmp, and the same thing happens:

 export TMPDIR=/tmp
 patch -e a.txt  ab.diff
 /tmp/posrjz1q: No such file or directory

 (yes, /tmp does exist)

 (
 Just found out another thing:

 export TMPDIR=/
 patch -e a.txt  ab.diff
 #looks like it is hanging, but about 20 seconds later:
 patch:  Can't create file //ppMxHRaO : No such host or network path

 The double slash should have been filtered before trying to open the
 file.  Humm, easy to solve on patch side, but setting TMPDIR=/ breaks
 a lot of stuff, even gcc and make, so I guess it is one of those
 don't do it - FAQ thingies, that I missed somewhere.
 )

This is a long-standing bug (in many apps, as you noticed)...

   [snip]
   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.
 
  You could also try playing with the binmode setting in the Cygwin
  environment variable, which controls line endings in pipes.

 I don't have any textmode mounts.

   (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
 
  Hmm, you also forgot to mention the directory where a.txt resides...
  Try first doing this on a binary mount in some directory under Cygwin root
  (e.g., /tmp).  If that works, look into directories and environment
  variable settings.

 Doesn't work anywhere:  ~, /tmp, /cygdrive/d, etc.  Did it work for you,
 when you followed the recipe I sent?  If you didn't try, could you,
 please?

You're right, I didn't try it.  When I did, I was able to reproduce your
error.

Patch is supposed to copy the source file to the temporary location, and
then feed it to ed.  Looking at the strace, it seems that the file is
copied properly, with no errors, but then, for some reason, the patch
process unlinks the file during the invocation of sh, before it invokes
ed.  This unlink does not happen if the name of the file to patch is
supplied interactively.

I don't have the time for a more in-depth analysis at the moment, but
patch built from source OOTB, so you should be able to debug it locally.
HTH,
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_Igor Peshansky, Ph.D. (name changed!)
 |,4-  ) )-,_. ,\ (  `'-'   old name: Igor Pechtchanski
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Freedom is just another word for nothing left to lose...  -- Janis Joplin

--
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/