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: echo $(cygcheck...) oddity


On 02/16/2011 11:07 AM, L Anderson wrote:
> Could the following signal a possible string buffering problem?

Nope.  Rather, it's an indication that cygcheck is a native windows
program...

> However,when I do
> 
> echo $(cygcheck /bin/sh.exe)       I get:
>  C:\WINDOWS\system32\GDI32.dlllll

and as such, it outputs \r\n line endings.

When echo is given only one argument, it outputs that argument
literally, so the \r are immediately followed by newline, and you don't
notice the difference.

But when echo is given multiple arguments, as is the case when you don't
use "" around $(), then each argument is separated by a space rather
than a newline.  And since word splitting ate the \n, that only leaves
you with \r, which rewinds to the beginning of the line for each line
printed.

> which clearly is unexpected.

Then your expectations are wrong.  Get in the habit of properly quoting
command substitution.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]