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: Bug in cat


Hi Brian,

It makes sense to me.   I like your recommended replacement too.

Thanks,

-Dave

-----Original Message-----
From: Brian Dessent [mailto:brian@dessent.net]
Sent: Tuesday, October 23, 2007 5:54 PM
To: Cutler, David
Cc: bug-coreutils@gnu.org
Subject: Re: Bug in cat

"Cutler, David" wrote:

> When I downloaded Cygwin, I specified the use of DOS line terminators.
>
> I found a bug in what I suspect is cat when used with a simple bash shell script.

Since you're using Cygwin, the Cygwin mailing list is a better place to post this because most coreutils developers don't use Cygwin.

This is not technically a bug however, because cat always works in binary mode by design regardless of mount mode.  This is required by POSIX I believe.  Eric has mentioned in the past adding a Cygwin-specific --text option to cat but any time you start to maintain special patches it makes maintainer burden go up.  Even then, you would have to give the option explicitly.

And besides, there are much better ways to deal with this:

> And you execute the command:
>    for I in `cat list` ; do echo \"${i}\" ; done

Inefficient.  Instead you can simply:

while read i; do echo \"${i}\"; done <list

This has the following advantages:

- no need to spawn a subshell process plus a cat subprocess (this is very slow on Cygwin)
- since the file is opened by bash it obeys the mount table settings

If you must use backticks, pipe the output through d2u.  You can also set the 'nobinmode' parameter of $CYGWIN which effects the mode of pipes (which are used with the backtick operator), turning them into text by default.  However this is quite dangerous as it breaks commands that expect to pass binary files through pipes, such as tar/gzip/bzip2.

Brian

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