bug-coreutils
[Top][All Lists]
Advanced

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

RE: Bug in cat


From: Cutler, David
Subject: RE: Bug in cat
Date: Wed, 24 Oct 2007 00:53:12 +0000

More works for me as a replacement for cat but I like your idea better.

I will talk to the Cygwin folks.

Thanks,

-Dave

-----Original Message-----
From: Micah Cowan [mailto:address@hidden
Sent: Tuesday, October 23, 2007 5:49 PM
To: Cutler, David
Cc: address@hidden
Subject: Re: Bug in cat

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Cutler, David wrote:
> Hello,
>
> My execution environment is
>    CYGWIN_NT-5.1 DCUTLER 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin
>    (dual core, 2.0 GHz cpu with 2GB ram Compaq NW8440 Laptop)
>
> 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.
>
> It's common to place a set of names into a file (one name per line) and then 
> use a for loop to walk through the list.
>
> For example:
>
> If a file named list contains
> a001s2
> a002s2
> a003s2
> a004s2
> a005s2
> a006s2
>
> And you execute the command:
>    for I in `cat list` ; do echo \"${i}\" ; done
>
> The output is
> "a001s2
> "a002s2
> "a003s2
> "a004s2
> "a005s2
> "a006s2

Echo is printing literal "\r"s from the DOS-style CR LF line terminators. Your 
terminal is interpreting "\r" (rightly) as "move to the beginning of the 
current line."

Cat is just spitting out the file's contents. It's not going to read them as 
"lines", just as data to spit out. If there's a bug, it's not with cat. Talk to 
the Cygwin folks to find out what's going on. I don't know, but it's possible 
something like

  cat list | while read -r I; do echo \"$I\" ; done

(which is more "line oriented") will work better for you. Either way, there's 
not much we can do for you here. Cat is just doing its job.

- --
HTH,
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHHpYC7M8hyUobTrERCH7PAJ4tDY/OHHvk9moHoXR2PXb7LV9IKgCfaXXq
uxGKS1kY7f1YTGyh9kjXj+g=
=3pQ2
-----END PGP SIGNATURE-----




reply via email to

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