[PATCH] hexdump: automatically use -C when called as hd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 text-utils/hexdump.1 | 3 +++
 text-utils/hexdump.c | 7 +++++++
 2 files changed, 10 insertions(+)

diff --git a/text-utils/hexdump.1 b/text-utils/hexdump.1
index eb508f6d4..80a7c0f0d 100644
--- a/text-utils/hexdump.1
+++ b/text-utils/hexdump.1
@@ -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,
diff --git a/text-utils/hexdump.c b/text-utils/hexdump.c
index cbd593e5f..ce83c9d83 100644
--- a/text-utils/hexdump.c
+++ b/text-utils/hexdump.c
@@ -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':
-- 
2.27.0




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux