From: Pádraig Brady Date: Wed, 25 Mar 2026 17:33:47 +0000 (+0000) Subject: od: suppress address output on read error X-Git-Tag: v9.11~147 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=0ec2340c08719d6f342780b4669ea05c3559d9a3;p=thirdparty%2Fcoreutils.git od: suppress address output on read error We don't output an address for `od missing` or `od --strings .`, so be consistent and suppress the address for `od .`. * src/od.c (dump): Only output an address if no errors or the offset is non zero. --- diff --git a/src/od.c b/src/od.c index e749a6b086..265e3d2ee8 100644 --- a/src/od.c +++ b/src/od.c @@ -1561,7 +1561,8 @@ dump (void) current_offset += n_bytes_read; } - format_address (current_offset, '\n'); + if (ok || current_offset) + format_address (current_offset, '\n'); if (0 <= end_offset && end_offset <= current_offset) ok &= check_and_close (0); diff --git a/tests/od/od-N.sh b/tests/od/od-N.sh index 40d3d914e3..97c1a8f466 100755 --- a/tests/od/od-N.sh +++ b/tests/od/od-N.sh @@ -54,4 +54,11 @@ printf '\001%10s\000%10s\000' | od -S10 > out || fail=1 printf '%07o %10s\n' 1 '' 12 '' > exp || framework_failure_ compare exp out || fail=1 +# Ensure no address output for read error +# (Users may use -N0 -j... to do base conversion) +if ! cat . >/dev/null 2>&1; then + returns_ 1 od -N1 . > out || fail=1 + compare /dev/null out || fail=1 +fi + Exit $fail