From nobody@FreeBSD.org  Fri Aug 23 08:49:47 2002
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 67FCD37B400
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 23 Aug 2002 08:49:47 -0700 (PDT)
Received: from www.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 38CA543E75
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 23 Aug 2002 08:47:54 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.4/8.12.4) with ESMTP id g7NFjDOT023042
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 23 Aug 2002 08:45:13 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.4/8.12.4/Submit) id g7NFjDDl023041;
	Fri, 23 Aug 2002 08:45:13 -0700 (PDT)
Message-Id: <200208231545.g7NFjDDl023041@www.freebsd.org>
Date: Fri, 23 Aug 2002 08:45:13 -0700 (PDT)
From: Elliott Hughes <elliotth@bluearc.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: hexdump(1) unprintable ASCII enhancement [PATCH]
X-Send-Pr-Version: www-1.0

>Number:         41947
>Category:       bin
>Synopsis:       [patch] hexdump(1) unprintable ASCII enhancement
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          analyzed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 23 08:50:01 PDT 2002
>Closed-Date:    
>Last-Modified:  Mon Jul 02 20:45:44 UTC 2012
>Originator:     Elliott Hughes
>Release:        Mac OS X
>Organization:
>Environment:
Darwin 5.5 powerpc
(also Linux 2.4.18 #4 i686)

>Description:
[Forgive me if this is the wrong place to submit this, but as far as I can work out, the hexdump on Mac OS X and Linux is the one from FreeBSD.]

I'm trying to convert myself away from home-grown stuff to using things
I can rely on to be around on both Mac OS X at home and Linux at work.
The one thing I don't like about BSD hexdump(1) -- available on both --
is that I can't ask it to show me the ASCII part of the hex dump in two
colors. This would (a) enable me to distinguish an actual '.' from a
pseudo-'.' used to represent an unprintable character and (b) makes it
far easier to read control codes out of the ASCII part while still
seeing the text.

I've used the same command-line options as GNU grep(1), not least
because both -c and -C are already taken! I also emulate grep's
behavior with regard to not coloring output not going to a tty or
going to a tty calling itself "dumb". I've also used HEXDUMP_COLOR
analagous to GREP_COLOR.

The only thing I'm not sure about is my use of getopt_long. I don't
know what the appropriate change to a BSD makefile would be, or
whether I actually need to include getopt.h and getopt.c as part of
hexdump; does BSD have GNU getopt?

[On a not unrelated note, it might be worth a page somewhere explaining
how Mac OS X users can join in. We're pseudo-BSD users: enough to
benefit from improvements to BSD but not enough to be using an actual
BSD release or have the BSD sources/build system around.]

>How-To-Repeat:
Apply the patch, and try stuff like:

hexdump -C --color `which hexdump`               # color hexdump
hexdump -C --color `which hexdump` | head        # no color in a pipe
hexdump -C --color=always `which hexdump` | head # unless you force it

>Fix:
uuencoded diff -u:

begin 644 hexdump-patch.txt
M9&EF9B`M=2!H97AD=6UP+6]R:6=I;F%L+V1I<W!L87DN8R!H97AD=6UP+V1I
M<W!L87DN8PHM+2T@:&5X9'5M<"UO<FEG:6YA;"]D:7-P;&%Y+F,)5&AU($%U
M9R`Q-2`Q,SHT-#HU-B`R,#`R"BLK*R!H97AD=6UP+V1I<W!L87DN8PE&<FD@
M075G(#(S(#$V.C$W.C4W(#(P,#(*0$`@+34U+#8@*S4U+#$Q($!`"B!S=&%T
M:6,@;V9F7W0@861D<F5S<SL)"0DO*B!A9&1R97-S+V]F9G-E="!I;B!S=')E
M86T@*B\*('-T871I8R!O9F9?="!E861D<F5S<SL)"0DO*B!E;F0@861D<F5S
M<R`J+PH@"BLO*B!4:&4@8V]L;W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-Trail:

From: Elliott Hughes <ehughes@bluearc.com>
To: "'freebsd-gnats-submit@FreeBSD.org'" <freebsd-gnats-submit@FreeBSD.org>
Cc:  
Subject: Re: misc/41947: hexdump(1) unprintable ASCII enhancement [PATCH]
Date: Fri, 30 Aug 2002 15:01:18 +0100

 Thinking about it, display.c:197 should read:
 
         if (color_option == 1 && iscntrl(*bp) && *bp != 0x7f) {
 
 because we shouldn't print the character (0x7f + '@') in all fonts, so it's
 best avoided.
 
  --elliott
 
 
 
 *********************************************************************
 This e-mail and any attachment is confidential. It may only be read, copied and used by the intended recipient(s). If you are not the intended recipient(s), you may not copy, use, distribute, forward, store or disclose this e-mail or any attachment. If you are not the intended recipient(s) or have otherwise received this e-mail in error, you should destroy it and any attachment and notify the sender by reply e-mail or send a message to sysadmin@bluearc.com
 *********************************************************************
 
Responsible-Changed-From-To: freebsd-bugs->gcooper 
Responsible-Changed-By: gavin 
Responsible-Changed-When: Mon Jun 23 17:52:43 UTC 2008 
Responsible-Changed-Why:  
Give to gcooper, he's looking at hexdump 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41947 

From: "Garrett Cooper" <yanegomi@gmail.com>
To: bug-followup@FreeBSD.org, elliotth@bluearc.com
Cc:  
Subject: Re: bin/41947: [patch] hexdump(1) unprintable ASCII enhancement
Date: Sat, 11 Oct 2008 16:28:50 -0700

 Elliot,
      Forgive me if I'm wrong, but that doesn't actually do anything
 color-wise with the text... All it does is gives the user the option
 to print in color, which falsifies the claim of being able to print in
 color.
 -Garrett
State-Changed-From-To: open->suspended 
State-Changed-By: gavin 
State-Changed-When: Sun Oct 12 13:55:09 UTC 2008 
State-Changed-Why:  
Mark as suspended, submitter's email bounces 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41947 

From: "Garrett Cooper" <yanegomi@gmail.com>
To: bug-followup <bug-followup@freebsd.org>
Cc:  
Subject: Re: bin/41947: [patch] hexdump(1) unprintable ASCII enhancement
Date: Tue, 23 Dec 2008 01:53:18 -0800

     I need to stop jumping to conclusions sometimes. Yes, this patch
 does deliver to expectations (at least for the submitter). Need to
 validate that it does do as expected though under a series of
 testcases.
     I'll take ownership of this until it's committed.
 Thanks,
 -Garrett

From: Garrett Cooper <yanegomi@gmail.com>
To: bug-followup@FreeBSD.org, elliotth@bluearc.com
Cc:  
Subject: Re: bin/41947: [patch] hexdump(1) unprintable ASCII enhancement
Date: Mon, 3 May 2010 04:09:22 -0700

     There's already equivalent functionality available via %_c, %_p,
 and %_u, which clarifies which characters are printable or not; the
 only potential item that this patch may resolve is that the
 differentiation between a standard `.' (ascii char 46) and an
 unprintable character is indistinguishable today via %_p. That in and
 of itself is a pain more than anything else, so I understand why the
 OP is requesting this feature enhancement.
     Rather than clutter up one's screen with color codes by default in
 special cases (like the above patch does) though, I need to take it
 and style(9)-ize it, remove the auto-defaults code, and then proceed
 from there. I hate it when utilities do colorization by default [like
 gnu grep(1) or ls(1)], and I know I'm not alone in this regard.
     Please mark this bug analyzed and I'll be sure to finish off a
 functional patch in a few weeks or so.
 Thanks,
 -Garrett
State-Changed-From-To: suspended->analyzed 
State-Changed-By: gavin 
State-Changed-When: Mon May 3 11:29:05 UTC 2010 
State-Changed-Why:  
Looks like we know what's happenin g with this PR now 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41947 
Responsible-Changed-From-To: gcooper->freebsd-bugs 
Responsible-Changed-By: crees 
Responsible-Changed-When: Mon Jul 2 20:45:34 UTC 2012 
Responsible-Changed-Why:  
gcooper is not a developer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41947 
>Unformatted:
