From 38d54d33e44292c9a0955be1284fb875f3eebe35 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Sun, 29 Sep 1996 04:17:24 +0000 Subject: [PATCH] Now that we've already got "hexdump -C", make calling the command "hd" having the same effect, and install a link for this. There is historic precedence for the command hd(1) (with roughly that output format) in Xenix, SCO, and a few SysV's that tooks the idea. Also, added a couple of spaces to the -C format to make the output better readable. Ok'ed by: phk --- usr.bin/hexdump/Makefile | 2 ++ usr.bin/hexdump/hexdump.1 | 15 ++++++++++++++- usr.bin/hexdump/hexsyntax.c | 15 ++++++++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/usr.bin/hexdump/Makefile b/usr.bin/hexdump/Makefile index 1e0543bd363..24ad198b685 100644 --- a/usr.bin/hexdump/Makefile +++ b/usr.bin/hexdump/Makefile @@ -3,6 +3,8 @@ PROG= hexdump SRCS= conv.c display.c hexdump.c hexsyntax.c odsyntax.c parse.c MAN1= hexdump.1 od.1 +MLINKS= hexdump.1 hd.1 LINKS= ${BINDIR}/hexdump ${BINDIR}/od +LINKS+= ${BINDIR}/hexdump ${BINDIR}/hd .include diff --git a/usr.bin/hexdump/hexdump.1 b/usr.bin/hexdump/hexdump.1 index 563edac0fcd..a76d043fa29 100644 --- a/usr.bin/hexdump/hexdump.1 +++ b/usr.bin/hexdump/hexdump.1 @@ -35,7 +35,7 @@ .Dt HEXDUMP 1 .Os .Sh NAME -.Nm hexdump +.Nm hexdump, hd .Nd ascii, decimal, hexadecimal, octal dump .Sh SYNOPSIS .Nm hexdump @@ -47,6 +47,15 @@ .Op Fl s Ar skip .Ek .Ar file ... +.Nm hd +.Op Fl bcdovx +.Op Fl e Ar format_string +.Op Fl f Ar format_file +.Op Fl n Ar length +.Bk -words +.Op Fl s Ar skip +.Ek +.Ar file ... .Sh DESCRIPTION The hexdump utility is a filter which displays the specified files, or the standard input, if no files are specified, in a user specified @@ -69,6 +78,10 @@ data per line. Display the input offset in hexadecimal, followed by sixteen space-separated, two column, hexadecimal bytes, followed by the same sixteen bytes in %_p format enclosed in ``|'' characters. +.Pp +Calling the command +.Nm hd +implies this option. .It Fl d .Em Two-byte decimal display. Display the input offset in hexadecimal, followed by eight diff --git a/usr.bin/hexdump/hexsyntax.c b/usr.bin/hexdump/hexsyntax.c index 829a6303f24..e3bca0bc465 100644 --- a/usr.bin/hexdump/hexsyntax.c +++ b/usr.bin/hexdump/hexsyntax.c @@ -56,6 +56,14 @@ newsyntax(argc, argvp) char *p, **argv; argv = *argvp; + if ((p = rindex(argv[0], 'h')) != NULL && + strcmp(p, "hd") == 0) { + /* "Canonical" format, implies -C. */ + add("\"%08.8_Ax\n\""); + add("\"%08.8_ax \" 8/1 \"%02x \" \" \""); + add(" 8/1 \"%02x \" "); + add("\" |\" 16/1 \"%_p\" \"|\\n\""); + } while ((ch = getopt(argc, argv, "bcCde:f:n:os:vx")) != EOF) switch (ch) { case 'b': @@ -68,8 +76,9 @@ newsyntax(argc, argvp) break; case 'C': add("\"%08.8_Ax\n\""); - add("\"%08.8_ax \" 16/1 \"%02x \" "); - add("\" |\" 16/1 \"%_p\" \"|\\n\""); + add("\"%08.8_ax \" 8/1 \"%02x \" \" \""); + add(" 8/1 \"%02x \" "); + add("\" |\" 16/1 \"%_p\" \"|\\n\""); break; case 'd': add("\"%07.7_Ax\n\""); @@ -127,6 +136,6 @@ void usage() { (void)fprintf(stderr, -"hexdump: [-bcdovx] [-e fmt] [-f fmt_file] [-n length] [-s skip] [file ...]\n"); +"hexdump: [-bcCdovx] [-e fmt] [-f fmt_file] [-n length] [-s skip] [file ...]\n"); exit(1); }