bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in cat


From: Brian Dessent
Subject: Re: Bug in cat
Date: Tue, 23 Oct 2007 17:53:43 -0700

"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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]