GNU bug report logs - #17961
"od -c" producing numbers greater than 255 ?

Previous Next

Package: coreutils;

Reported by: Sebastian Pipping <sebastian <at> pipping.org>

Date: Sun, 6 Jul 2014 22:58:04 UTC

Severity: normal

Tags: notabug

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 17961 in the body.
You can then email your comments to 17961 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#17961; Package coreutils. (Sun, 06 Jul 2014 22:58:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sebastian Pipping <sebastian <at> pipping.org>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sun, 06 Jul 2014 22:58:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Sebastian Pipping <sebastian <at> pipping.org>
To: bug-coreutils <at> gnu.org
Subject: "od -c" producing numbers greater than 255 ?
Date: Sun, 06 Jul 2014 20:54:40 +0200
Hello!


I have observed od printing byte values greater than 255 (e.g 302 and
303) and wonder if that's a bug and if not what's the idea behind it.

I'm running coreutils version 8.22.

My command to re-produce is

  python3 -c 'for i in range(256): print("%c" % i, end="")' | od -c

Please note that Python is producing UTF-8 here.

This is the output I get:


# python3 -c 'for i in range(256): print("%c" % i, end="")' | od -c
0000000  \0 001 002 003 004 005 006  \a  \b  \t  \n  \v  \f  \r 016 017
0000020 020 021 022 023 024 025 026 027 030 031 032 033 034 035 036 037
0000040       !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /
0000060   0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?
0000100   @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O
0000120   P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _
0000140   `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o
0000160   p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~ 177
0000200 302 200 302 201 302 202 302 203 302 204 302 205 302 206 302 207
0000220 302 210 302 211 302 212 302 213 302 214 302 215 302 216 302 217
0000240 302 220 302 221 302 222 302 223 302 224 302 225 302 226 302 227
0000260 302 230 302 231 302 232 302 233 302 234 302 235 302 236 302 237
0000300 302 240 302 241 302 242 302 243 302 244 302 245 302 246 302 247
0000320 302 250 302 251 302 252 302 253 302 254 302 255 302 256 302 257
0000340 302 260 302 261 302 262 302 263 302 264 302 265 302 266 302 267
0000360 302 270 302 271 302 272 302 273 302 274 302 275 302 276 302 277
0000400 303 200 303 201 303 202 303 203 303 204 303 205 303 206 303 207
0000420 303 210 303 211 303 212 303 213 303 214 303 215 303 216 303 217
0000440 303 220 303 221 303 222 303 223 303 224 303 225 303 226 303 227
0000460 303 230 303 231 303 232 303 233 303 234 303 235 303 236 303 237
0000500 303 240 303 241 303 242 303 243 303 244 303 245 303 246 303 247
0000520 303 250 303 251 303 252 303 253 303 254 303 255 303 256 303 257
0000540 303 260 303 261 303 262 303 263 303 264 303 265 303 266 303 267
0000560 303 270 303 271 303 272 303 273 303 274 303 275 303 276 303 277
0000600


I'm looking forward to your reply.  Please keep me in CC for now.

Best,



Sebastian




Information forwarded to bug-coreutils <at> gnu.org:
bug#17961; Package coreutils. (Sun, 06 Jul 2014 23:56:02 GMT) Full text and rfc822 format available.

Message #8 received at 17961 <at> debbugs.gnu.org (full text, mbox):

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: Sebastian Pipping <sebastian <at> pipping.org>, 17961 <at> debbugs.gnu.org
Subject: Re: bug#17961: "od -c" producing numbers greater than 255 ?
Date: Mon, 07 Jul 2014 01:55:07 +0200
tag 17961 notabug
close 17961
stop

On 07/06/2014 08:54 PM, Sebastian Pipping wrote:
> I have observed od printing byte values greater than 255 (e.g 302 and
> 303) and wonder if that's a bug and if not what's the idea behind it.
> 
> I'm running coreutils version 8.22.
> 
> My command to re-produce is
> 
>   python3 -c 'for i in range(256): print("%c" % i, end="")' | od -c

Thanks for the bug report.  However, there seems to be some
misunderstanding on your side about what 'od -c' does:
the default output format is to use octal number, which you can
already see in the first line from the printed numbers:

  $ python3 -c 'for i in range(256): print("%c" % i, end="")' | od -c | head -n1
  0000000  \0 001 002 003 004 005 006  \a  \b  \t  \n  \v  \f  \r 016 017

Therefore, od(1) prints up to 377 (octal) in your case - which is 255 decimal:

  $ python3 -c 'print("%o" % 255)'
  377

Have a nice day,
Berny




Information forwarded to bug-coreutils <at> gnu.org:
bug#17961; Package coreutils. (Mon, 07 Jul 2014 00:28:01 GMT) Full text and rfc822 format available.

Message #11 received at 17961 <at> debbugs.gnu.org (full text, mbox):

From: Sebastian Pipping <sebastian <at> pipping.org>
To: Bernhard Voelker <mail <at> bernhard-voelker.de>, 17961 <at> debbugs.gnu.org
Subject: Re: bug#17961: "od -c" producing numbers greater than 255 ?
Date: Mon, 07 Jul 2014 02:27:43 +0200
Hello!


Intersting, thanks for your reply.  For "-c" the man page reads

  "printable character or backslash escape"

I don't really see any mention of octal fallback in there :)
Personally, I would expect (and prefer) \x?? output for any
non-printable bytes from that description.  My vote too add that or at
least making the man page more precise about "-c", that would be cool.

I guess "od -t u1" is what I'll use in the meantime.

Best,



Sebastian





Information forwarded to bug-coreutils <at> gnu.org:
bug#17961; Package coreutils. (Mon, 07 Jul 2014 06:19:02 GMT) Full text and rfc822 format available.

Message #14 received at 17961 <at> debbugs.gnu.org (full text, mbox):

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: Sebastian Pipping <sebastian <at> pipping.org>, 17961 <at> debbugs.gnu.org
Subject: Re: bug#17961: "od -c" producing numbers greater than 255 ?
Date: Mon, 07 Jul 2014 08:18:12 +0200
On 07/07/2014 02:27 AM, Sebastian Pipping wrote:
> I don't really see any mention of octal fallback in there

It is already there ... in the first sentence:

  NAME
         od - dump files in octal and other formats

  SYNOPSIS
         od [OPTION]... [FILE]...
         od [-abcdfilosx]... [FILE] [[+]OFFSET[.][b]]
         od --traditional [OPTION]... [FILE] [[+]OFFSET[.][b] [+][LABEL][.][b]]

  DESCRIPTION
         Write  an  unambiguous  representation,  octal bytes
         by default, of FILE to standard output.
         ...

BTW: the man pages of the coreutils programs are not much more
than the output from "PROG --help".  Instead, the more detailed
documentation goes into the Texinfo manual - as mentioned at
the end of the man page:

  SEE ALSO
     ...
     info coreutils 'od invocation'

Alternatively you can choose the online version:

  http://www.gnu.org/software/coreutils/manual/html_node/od-invocation.html#od-invocation

> My vote too add that or at
> least making the man page more precise about "-c", that would be cool.

The output of --help and therefore 'man od' is already quite
large.  Please read the info manual.  If you still think that
there's something missing or unclear, please tell us ... maybe
with a suggestion for the wording, or even better as a patch.

Thanks & have a nice day,
Berny




Information forwarded to bug-coreutils <at> gnu.org:
bug#17961; Package coreutils. (Mon, 07 Jul 2014 12:58:02 GMT) Full text and rfc822 format available.

Message #17 received at 17961 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Sebastian Pipping <sebastian <at> pipping.org>,
 Bernhard Voelker <mail <at> bernhard-voelker.de>, 17961 <at> debbugs.gnu.org
Subject: Re: bug#17961: "od -c" producing numbers greater than 255 ?
Date: Mon, 07 Jul 2014 06:56:52 -0600
[Message part 1 (text/plain, inline)]
On 07/06/2014 06:27 PM, Sebastian Pipping wrote:
> Hello!
> 
> 
> Intersting, thanks for your reply.  For "-c" the man page reads
> 
>   "printable character or backslash escape"
> 
> I don't really see any mention of octal fallback in there :)
> Personally, I would expect (and prefer) \x?? output for any
> non-printable bytes from that description.  My vote too add that or at
> least making the man page more precise about "-c", that would be cool.

Alas, we can't change the behavior; it is mandated by POSIX:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/od.html

-c
    [XSI] [Option Start] Interpret bytes as characters specified by the
current setting of the LC_CTYPE category. Certain non-graphic characters
appear as C escapes: "NUL=\0", "BS=\b", "FF=\f", "NL=\n", "CR=\r",
"HT=\t"; others appear as 3-digit octal numbers. [Option End]

> 
> I guess "od -t u1" is what I'll use in the meantime.

Yes, that is a reasonable action.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Added tag(s) notabug. Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 20 Oct 2018 03:37:01 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 17961 <at> debbugs.gnu.org and Sebastian Pipping <sebastian <at> pipping.org> Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 20 Oct 2018 03:37:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 17 Nov 2018 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 274 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.