bug-coreutils
[Top][All Lists]
Advanced

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

bug#7915: Possible off-by-1 in wc


From: Eric Blake
Subject: bug#7915: Possible off-by-1 in wc
Date: Tue, 25 Jan 2011 19:08:15 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7

[Let's keep the list in the loop]

On 01/25/2011 07:04 PM, Sune Mølgaard wrote:
>> Thanks for the report.  However, this is not a bug - echo is outputting
>> a newline (which is a second character, and third byte given the
>> encoding of your chosen character).
>>
>> To see the difference, try:
>>
>> $ echo Å | od -tx1z
>> $ printf Å | od -tx1z
> 
> Thanks for the swift reply - I figured it might be something like that,
> but would it be possible to make an option to strip things like that, or
> is that a silly question?

An option to which program, echo or wc?

For wc, it's not possible.  How is wc supposed to know whether the input
has an extra trailing newline that should be ignored?  Fix the input
side of the equation, rather than adding complexity to wc.

For echo, the option is already (non-portably) there, in the form of
'echo -n' (won't work everywhere), or portably by using printf instead
of echo (as was the case in my example).

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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