Re: bug with built-in commands in bash when redirecting output

2007-01-24 Thread Sjoerd Mullender
On 2007-01-27 21:33:08, Eric Blake wrote:
> Meanwhile, have you considered using the cygwin-specific igncr shellopt?

No, I haven't, and it's not really an option in real life.  I found the
problem with a libtool-generated script and I'd have to change that
script in order to pass the option.

I'm looking forward to your fix.

-- 
Sjoerd Mullender

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



bug with built-in commands in bash when redirecting output

2007-01-23 Thread Sjoerd Mullender
The following one liner illustrates a bug in sh:
$ /bin/bash -c '/bin/bash -cx '\''x=`echo hello`'\''' > @x
++ echo hello
+ x=$'hello\r'
$

The problem is as follows.  When a built-in shell command (such as pwd
or echo) is executed within back quotes (or within $(...)) when the
shell's output is redirected to a file, the command produces \r\n at the
end of the line of which only the final \n is removed.

Normally when a command is executed within back quotes, the final line
ending is removed before the result is substituted.  That happens here
also, but the difference is that there is still a \r at the end.

When the echo command in the above example is replace by /bin/echo, the
result is correct (i.e. no \r in the assignment to x):

$ /bin/bash -c '/bin/bash -cx '\''x=`/bin/echo hello`'\''' > @x
++ /bin/echo hello
+ x=hello
$

The bug, it seems to me, is that the shell checks that its output is
redirected to a file and that it therefore has to write \r\n at the end
of each line.  So far so good.  However, when it executes a built-in
command within back quotes, it still uses this knowledge and still
writes \r\n.

It may be relevant that I have Cygwin configured to use DOS line
endings.  Also, my Cygwin installation is up-to-date (except for pending
updates to readline).  My bash version is 3.2.9-10.

-- 
Sjoerd Mullender



signature.asc
Description: OpenPGP digital signature


rsync text mode problem with fix

2004-09-21 Thread Sjoerd Mullender
Since my last update of my Cygwin installation I noticed that binary 
files copied from a Linux box were corrupted.  The problem appeared to 
be text mode vs. binary mode.  After some investigation I found the 
problem and I have a fix.

The diff is against the unpacked and prepared rsync-2.6.2-2 release (the 
latest, as far as I know).

--
Sjoerd Mullender <[EMAIL PROTECTED]>
--- syscall.c~  2004-02-18 23:33:21.0 +0100
+++ syscall.c   2004-09-21 10:33:50.442132800 +0200
@@ -164,6 +164,7 @@
errno = errno_save;
return -1;
}
+   setmode(fd, O_BINARY);
return fd;
}
 #else


smime.p7s
Description: S/MIME Cryptographic Signature