echo $(cygcheck...) oddity

Eric Blake eblake@redhat.com
Wed Feb 16 18:13:00 GMT 2011


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20110216/a4219828/attachment.sig>


More information about the Cygwin mailing list

AltStyle によって変換されたページ (->オリジナル) /