]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hexdump: automatically use -C when called as hd
authorChris Hofstaedtler <zeha@debian.org>
Tue, 23 Jun 2020 00:14:30 +0000 (00:14 +0000)
committerKarel Zak <kzak@redhat.com>
Thu, 23 Jul 2020 10:23:56 +0000 (12:23 +0200)
When invoking hexdump as hd enable the "Canonical" format to by
default, implying the -C option.

This is historic behaviour on Debian and apparently also on FreeBSD.
Some Debian users have asked for this to be restored, after Debian
switched to util-linux' hexdump and hd.

Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
text-utils/hexdump.1
text-utils/hexdump.c

index eb7713ce61a29e39f93261dbc7edbcec5125b258..99b9d06361ed34032e4aef696934f1f30bf312f2 100644 (file)
@@ -67,6 +67,9 @@ by the same sixteen bytes in
 format enclosed in
 .RB ' | '
 characters.
+Invoking the program as
+.B hd
+implies this option.
 .TP
 \fB\-d\fR, \fB\-\-two\-bytes\-decimal\fR
 \fITwo-byte decimal display\fR.  Display the input offset in hexadecimal,
index d7a54be5bd6f8192ac2305b51aabc9d93f62fe51..4068fb8d10ae4603d140646724f6459e952d1409 100644 (file)
@@ -82,6 +82,13 @@ parse_args(int argc, char **argv, struct hexdump *hex)
                {NULL, no_argument, NULL, 0}
        };
 
+       if (!strcmp(program_invocation_short_name, "hd")) {
+               /* Canonical format */
+               add_fmt("\"%08.8_Ax\n\"", hex);
+               add_fmt("\"%08.8_ax  \" 8/1 \"%02x \" \"  \" 8/1 \"%02x \" ", hex);
+               add_fmt("\"  |\" 16/1 \"%_p\" \"|\\n\"", hex);
+       }
+
        while ((ch = getopt_long(argc, argv, "bcCde:f:L::n:os:vxhV", longopts, NULL)) != -1) {
                switch (ch) {
                case 'b':