Mail Archives: cygwin/2011/02/16/15:07:01
X-Recipient: | archive-cygwin AT delorie DOT com
|
X-SWARE-Spam-Status: | No, hits=-4.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,TW_PD,TW_YG,T_RP_MATCHES_RCVD
|
X-Spam-Check-By: | sourceware.org
|
In-Reply-To: | <4D5C13D1.8010105@redhat.com>
|
References: | <4D5C127D DOT 40401 AT member DOT fsf DOT org> <4D5C13D1 DOT 8010105 AT redhat DOT com>
|
To: | cygwin AT cygwin DOT com
|
MIME-Version: | 1.0
|
Subject: | Re: echo $(cygcheck...) oddity
|
X-KeepSent: | E564C01B:7208557E-85257839:006C8E0A; type=4; name=$KeepSent
|
Message-ID: | <OFE564C01B.7208557E-ON85257839.006C8E0A-85257839.006E7974@lnotes-gw.ent.nwie.net>
|
From: | RISINGP1 AT nationwide DOT com
|
Date: | Wed, 16 Feb 2011 15:06:39 -0500
|
X-IsSubscribed: | yes
|
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm
|
List-Id: | <cygwin.cygwin.com>
|
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
|
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com>
|
List-Archive: | <http://sourceware.org/ml/cygwin/>
|
List-Post: | <mailto:cygwin AT cygwin DOT com>
|
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
|
Sender: | cygwin-owner AT cygwin DOT com
|
Mail-Followup-To: | cygwin AT cygwin DOT com
|
Delivered-To: | mailing list cygwin AT cygwin DOT com
|
cygwin-owner wrote on 02/16/2011 01:13:37 PM:
> 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 at redhat.com +1-801-349-2682
> Libvirt virtualization library http://libvirt.org
>
This is an informational note - I wasn't sure where to bring this up.
I suspected a problem with \r, so I tried it. However, I am using pdksh,
and ended up with something that really was unexpected... Take careful
note the first three lines of the output for the second command. It turns
out this is the result of the behavior of the internal echo command that
pdksh uses. If "echo" is replaced with "echo -E" or "/bin/echo", the
output looks like that found when executing the commands in bash.
For what it is worth, the output of the third command piped into "od -c"
(see below) shows why you get the reduced number of displayed lines - as
Eric pointed out, the \r is not paired with a \n.
$ cygcheck /bin/sh.exe
C:\cygwin\bin\sh.exe
C:\cygwin\bin\cyggcc_s-1.dll
C:\cygwin\bin\cygwin1.dll
C:\WINXP\system32\ADVAPI32.DLL
C:\WINXP\system32\KERNEL32.dll
C:\WINXP\system32\ntdll.dll
C:\WINXP\system32\RPCRT4.dll
C:\WINXP\system32\Secur32.dll
C:\cygwin\bin\cygintl-8.dll
C:\cygwin\bin\cygiconv-2.dll
C:\cygwin\bin\cygreadline7.dll
C:\cygwin\bin\cygncurses-9.dll
C:\WINXP\system32\USER32.dll
C:\WINXP\system32\GDI32.dll
$ echo "$(cygcheck /bin/sh.exe)"
C:ygwiin\sh.exe
C:ygwiinyggcc_s-1.dll
C:ygwiinygwin1.dll
C:\WINXP\system32\ADVAPI32.DLL
C:\WINXP\system32\KERNEL32.dll
C:\WINXP\system32
tdll.dll
C:\WINXP\system32\RPCRT4.dll
C:\WINXP\system32\Secur32.dll
C:ygwiinygintl-8.dll
C:ygwiinygiconv-2.dll
C:ygwiinygreadline7.dll
C:ygwiinygncurses-9.dll
C:\WINXP\system32\USER32.dll
C:\WINXP\system32\GDI32.dll
$ echo $(cygcheck /bin/sh.exe)
C:\WINXP\system32\KERNEL32.dll
C:\WINXP\system32\GDI32.dllll
$ cygcheck /bin/sh.exe | od -c
0000000 C : \ c y g w i n \ b i n \ s h
0000020 . e x e \r \n C : \ c y g w i
0000040 n \ b i n \ c y g g c c _ s - 1
0000060 . d l l \r \n C : \ c y g
0000100 w i n \ b i n \ c y g w i n 1 .
0000120 d l l \r \n C : \ W I
0000140 N X P \ s y s t e m 3 2 \ A D V
0000160 A P I 3 2 . D L L \r \n
0000200 C : \ W I N X P \ s y s t
0000220 e m 3 2 \ K E R N E L 3 2 . d l
0000240 l \r \n C : \
0000260 W I N X P \ s y s t e m 3 2 \ n
0000300 t d l l . d l l \r \n
0000320 C : \ W I N X P \ s y s t e
0000340 m 3 2 \ R P C R T 4 . d l l \r \n
0000360 C : \ W I N
0000400 X P \ s y s t e m 3 2 \ S e c u
0000420 r 3 2 . d l l \r \n C : \ c y
0000440 g w i n \ b i n \ c y g i n t l
0000460 - 8 . d l l \r \n C : \ c
0000500 y g w i n \ b i n \ c y g i c o
0000520 n v - 2 . d l l \r \n C : \ c
0000540 y g w i n \ b i n \ c y g r e a
0000560 d l i n e 7 . d l l \r \n
0000600 C : \ c y g w i n \ b i n \ c y
0000620 g n c u r s e s - 9 . d l l \r \n
0000640 C : \ W I N X P \ s y s
0000660 t e m 3 2 \ U S E R 3 2 . d l l
0000700 \r \n C : \ W I N X P
0000720 \ s y s t e m 3 2 \ G D I 3 2 .
0000740 d l l \r \n
0000745
$ echo "$(cygcheck /bin/sh.exe)" | od -c
0000000 C : y g w i n \b i n \ s h . e x
0000020 e \r \n C : y g w i n \b i n y
0000040 g g c c _ s - 1 . d l l \r \n
0000060 C : y g w i n \b i n y g w i
0000100 n 1 . d l l \r \n C :
0000120 \ W I N X P \ s y s t e m 3 2 \
0000140 A D V A P I 3 2 . D L L \r \n
0000160 C : \ W I N X P \ s
0000200 y s t e m 3 2 \ K E R N E L 3 2
0000220 . d l l \r \n
0000240 C : \ W I N X P \ s y s t e m 3
0000260 2 \n t d l l . d l l \r \n
0000300 C : \ W I N X P \ s y s
0000320 t e m 3 2 \ R P C R T 4 . d l l
0000340 \r \n C : \ W
0000360 I N X P \ s y s t e m 3 2 \ S e
0000400 c u r 3 2 . d l l \r \n C : y
0000420 g w i n \b i n y g i n t l - 8 .
0000440 d l l \r \n C : y g w i n
0000460 \b i n y g i c o n v - 2 . d l l
0000500 \r \n C : y g w i n \b i n y g
0000520 r e a d l i n e 7 . d l l \r \n
0000540 C : y g w i n \b i n y g n
0000560 c u r s e s - 9 . d l l \r \n
0000600 C : \ W I N X P \ s y s t e
0000620 m 3 2 \ U S E R 3 2 . d l l \r \n
0000640 C : \ W I N X P \ s
0000660 y s t e m 3 2 \ G D I 3 2 . d l
0000700 l \r
0000702
$ echo $(cygcheck /bin/sh.exe) | od -c
0000000 C : y g w i n \b i n \ s h . e x
0000020 e \r C : y g w i n \b i n y g g
0000040 c c _ s - 1 . d l l \r C : y g
0000060 w i n \b i n y g w i n 1 . d l l
0000100 \r C : \ W I N X P \ s y s t e
0000120 m 3 2 \ A D V A P I 3 2 . D L L
0000140 \r C : \ W I N X P \ s y s t e
0000160 m 3 2 \ K E R N E L 3 2 . d l l
0000200 \r C : \ W I N X P \ s y s t e
0000220 m 3 2 \n t d l l . d l l \r C :
0000240 \ W I N X P \ s y s t e m 3 2 \
0000260 R P C R T 4 . d l l \r C : \ W
0000300 I N X P \ s y s t e m 3 2 \ S e
0000320 c u r 3 2 . d l l \r C : y g w
0000340 i n \b i n y g i n t l - 8 . d l
0000360 l \r C : y g w i n \b i n y g i
0000400 c o n v - 2 . d l l \r C : y g
0000420 w i n \b i n y g r e a d l i n e
0000440 7 . d l l \r C : y g w i n \b i
0000460 n y g n c u r s e s - 9 . d l l
0000500 \r C : \ W I N X P \ s y s t e
0000520 m 3 2 \ U S E R 3 2 . d l l \r
0000540 C : \ W I N X P \ s y s t e m 3
0000560 2 \ G D I 3 2 . d l l \r
0000574
- Phil
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -