GNU bug report logs -
#7915
Possible off-by-1 in wc
Previous Next
Reported by: Sune Mølgaard <sune <at> molgaard.org>
Date: Wed, 26 Jan 2011 01:20:02 UTC
Severity: normal
Tags: notabug
Done: Jim Meyering <jim <at> meyering.net>
Bug is archived. No further changes may be made.
Full log
Message #11 received at 7915 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
[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 eblake <at> redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
[signature.asc (application/pgp-signature, attachment)]
This bug report was last modified 13 years and 292 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.