bin/81495: hexdump(1) format option does not allow literal '%' in output

Hirohisa Yamaguchi umq at
Thu May 26 11:20:07 GMT 2005

>Number:         81495
>Category:       bin
>Synopsis:       hexdump(1) format option does not allow literal '%' in output
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 26 11:20:01 GMT 2005
>Originator:     Hirohisa Yamaguchi
>Release:        6.0-CURRENT
I cannot get literal '%' in hexdump(1) output with any format_string.
Though the man page mentions exceptions in fprintf-style format,
there's no explanation why '%' cannot be printed.
exec hexdump(1) with format_string which contains '%%' to get literal '%' in output.
 $ echo foo | hexdump -e '"" /1 "%%%02x" "\n"'

I got:
 hexdump: %%: bad conversion character
a) If there's any historical reasons to be so, update the man page; to mention that literal '%' cannot be included in output.


b) fix it.
I wrote a patch, not thoroughly tested. And flag name is, perhaps, not appropriate.

--- src/usr.bin/hexdump/parse.c.orig	Thu Jul 22 22:14:42 2004
+++ src/usr.bin/hexdump/parse.c	Thu May 26 19:22:28 2005
@@ -383,6 +383,10 @@ isint2:					switch(fu->bcnt) {
+			case '%':
+				/* skip over '%' */
+				pr->flags = F_ADDRESS;
+				break;
 				p1[1] = '\0';


More information about the freebsd-bugs mailing list