hexdump elides a partial last line with asterisk
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
bsdmainutils (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Package bsdmainutils 8.2.3's hexdump(1) says
-v Cause hexdump to display all input data. Without the -v
option, any number of groups of output lines, which would be
identical to the immediately preceding group of output lines (except
for the input offsets), are replaced with a line comprised of a
single asterisk.
(Aside: "immediately preceding group of output lines" is misleading, the
"*" always indicates just the last printed line is repeated, not a group
of them.)
This suggests it's as coreutils's od's -v/--output-
behaves differently.
$ printf 0123456789abcdef0 | hd
00000000 30 31 32 33 34 35 36 37 38 39 61 62 63 64 65 66 |0123456789abcdef|
*
00000011
$
I have to subtract the address before the * from the one after to find
out the number of bytes that are the same as the previous fully-printed
line; in this case 1, the 0x30 byte.
Note, on some Ubuntus, e.g. 10.10, bsdmainutils 8.0.11ubuntu1, it's
worse as the final offset is incorrect.
$ printf 0123456789abcdef0 | hd
00000000 30 31 32 33 34 35 36 37 38 39 61 62 63 64 65 66 |0123456789abcdef|
*
00000010
$
I've no way of knowing how many bytes have been elided.
Here's coreutils's od.
$ s=0123456789abcdef
$ printf ${s}0 | od -tx1
0000000 30 31 32 33 34 35 36 37 38 39 61 62 63 64 65 66
0000020 30
0000021
$ printf $s$s${s}0 | od -tx1
0000000 30 31 32 33 34 35 36 37 38 39 61 62 63 64 65 66
*
0000060 30
0000061
$
Clearly, hexdump should print the trailing line of bytes in full if it's
an incomplete line just as coreutils's od does; I shouldn't have to do
arithmetic. However, if the current behaviour is deemed to be correct
then hexdump(1) needs correcting.