From nobody@FreeBSD.org  Sun May  1 18:01:57 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id BF3AB106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  1 May 2011 18:01:57 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id AFFAD8FC16
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  1 May 2011 18:01:57 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p41I1v3i067478
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 1 May 2011 18:01:57 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p41I1vB5067476;
	Sun, 1 May 2011 18:01:57 GMT
	(envelope-from nobody)
Message-Id: <201105011801.p41I1vB5067476@red.freebsd.org>
Date: Sun, 1 May 2011 18:01:57 GMT
From: Federico <esepecesito@esepecesito.com.ar>
To: freebsd-gnats-submit@FreeBSD.org
Subject: sed utility extrange behavior with s/../& /g command on a .hex file
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         156758
>Category:       bin
>Synopsis:       sed(1) utility extrange behavior with s/../& /g command on a .hex file
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 01 18:10:11 UTC 2011
>Closed-Date:    Mon May 02 05:44:17 UTC 2011
>Last-Modified:  Mon May 02 05:44:17 UTC 2011
>Originator:     Federico
>Release:        8.2-RELEASE
>Organization:
Kybernan
>Environment:
FreeBSD marte.esepecesito.com.ar 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Thu Feb 17 02:41:51 UTC 2011     root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64

>Description:
I was trying to split a hex file into groups of 2 chars to do some procesing, the relevant part of the file is:

:1000000018F09FE518F09FE518F09FE518F09FE5C0
:1000100018F09FE50000A0E1F0FF1FE514F09FE558

When I run it through sed 's/../& /g' I expect to get:

:1 00 00 etc...
:1 00 01 etc...

But I get:

 1 00 00 00 01 8F 09 FE 51 8F 09 FE 51 8F 09 FE 51 8F 09 FE 5C 0
 1 00 01 00 01 8F 09 FE 50 00 0A 0E 1F 0F F1 FE 51 4F 09 FE 55 8

I did sed -e 's/../_& /g' 
And I got:

_:1 _00 _00 _00 _01 _8F _09 etc...
_:1 _00 _01 _00 _01 _8F _09 etc...

which makes sense... but when I try to do just with a space, it fails.
>How-To-Repeat:
Make a file with this content:

:1000000018F09FE518F09FE518F09FE518F09FE5C0
:1000100018F09FE50000A0E1F0FF1FE514F09FE558

or take any intel .hex file, and run " sed 's/../& /' " on it.
>Fix:
I could not find the problem

>Release-Note:
>Audit-Trail:

From: Yuri Pankov <yuri.pankov@gmail.com>
To: Federico <esepecesito@esepecesito.com.ar>
Cc: bug-followup@freebsd.org
Subject: Re: misc/156758: sed utility extrange behavior with s/../& /g
 command on a .hex file
Date: Sun, 1 May 2011 22:41:25 +0400

 Can't reproduce it on 8.2 with either sed or gsed:
 
 $ /usr/bin/sed -e 's/../& /g' test
 :1 00 00 00 01 8F 09 FE 51 8F 09 FE 51 8F 09 FE 51 8F 09 FE 5C 0
 :1 00 01 00 01 8F 09 FE 50 00 0A 0E 1F 0F F1 FE 51 4F 09 FE 55 8
 $ /usr/local/bin/gsed -e 's/../& /g' test
 :1 00 00 00 01 8F 09 FE 51 8F 09 FE 51 8F 09 FE 51 8F 09 FE 5C 0
 :1 00 01 00 01 8F 09 FE 50 00 0A 0E 1F 0F F1 FE 51 4F 09 FE 55 8
 
 Probably something is stripping : at the start of the line in your
 environment?
 
 
 Yuri

From: Jason Hellenthal <jhell@DataIX.net>
To: Federico <esepecesito@esepecesito.com.ar>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: misc/156758: sed utility extrange behavior with s/../& /g
 command on a .hex file
Date: Sun, 1 May 2011 23:27:16 -0400

 Federico,
 
 sed -e 's/^://' -e 's/../& /' file |awk '{print ":"$0}'
 
 Will that work for you ?
 
 
 I am not entirely convinced this is a problem with sed(1)
 
 -- 
 
  Regards, (jhell)
  Jason Hellenthal
 

From: Federico Sanchez Pinzon <esepecesito@esepecesito.com.ar>
To: Yuri Pankov <yuri.pankov@gmail.com>
Cc: bug-followup@freebsd.org
Subject: Re: misc/156758: sed utility extrange behavior with s/../& /g command
 on a .hex file
Date: Mon, 2 May 2011 00:52:32 -0300

 --20cf303f6a5600eb5f04a242f4b2
 Content-Type: text/plain; charset=ISO-8859-1
 
 SORRY!
 I think it was my mistake :( there was a \r that I was not expecting in the
 output of a GNU utility (obj-dump)
 Striping the \r with 'tr' solved the issue. Thks anyway, and sorry for
 wasting your time.
 
 2011/5/1 Yuri Pankov <yuri.pankov@gmail.com>
 
 > Can't reproduce it on 8.2 with either sed or gsed:
 >
 > $ /usr/bin/sed -e 's/../& /g' test
 > :1 00 00 00 01 8F 09 FE 51 8F 09 FE 51 8F 09 FE 51 8F 09 FE 5C 0
 > :1 00 01 00 01 8F 09 FE 50 00 0A 0E 1F 0F F1 FE 51 4F 09 FE 55 8
 > $ /usr/local/bin/gsed -e 's/../& /g' test
 > :1 00 00 00 01 8F 09 FE 51 8F 09 FE 51 8F 09 FE 51 8F 09 FE 5C 0
 > :1 00 01 00 01 8F 09 FE 50 00 0A 0E 1F 0F F1 FE 51 4F 09 FE 55 8
 >
 > Probably something is stripping : at the start of the line in your
 > environment?
 >
 >
 > Yuri
 >
 
 --20cf303f6a5600eb5f04a242f4b2
 Content-Type: text/html; charset=ISO-8859-1
 Content-Transfer-Encoding: quoted-printable
 
 SORRY!<br>I think it was my mistake :( there was a \r that I was not expect=
 ing in the output of a GNU utility (obj-dump) <br>Striping the \r with &#39=
 ;tr&#39; solved the issue. Thks anyway, and sorry for wasting your time.<br=
 >
 <br><div class=3D"gmail_quote">2011/5/1 Yuri Pankov <span dir=3D"ltr">&lt;<=
 a href=3D"mailto:yuri.pankov@gmail.com">yuri.pankov@gmail.com</a>&gt;</span=
 ><br><blockquote class=3D"gmail_quote" style=3D"margin: 0pt 0pt 0pt 0.8ex; =
 border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
 Can&#39;t reproduce it on 8.2 with either sed or gsed:<br>
 <br>
 $ /usr/bin/sed -e &#39;s/../&amp; /g&#39; test<br>
 :1 00 00 00 01 8F 09 FE 51 8F 09 FE 51 8F 09 FE 51 8F 09 FE 5C 0<br>
 :1 00 01 00 01 8F 09 FE 50 00 0A 0E 1F 0F F1 FE 51 4F 09 FE 55 8<br>
 $ /usr/local/bin/gsed -e &#39;s/../&amp; /g&#39; test<br>
 :1 00 00 00 01 8F 09 FE 51 8F 09 FE 51 8F 09 FE 51 8F 09 FE 5C 0<br>
 :1 00 01 00 01 8F 09 FE 50 00 0A 0E 1F 0F F1 FE 51 4F 09 FE 55 8<br>
 <br>
 Probably something is stripping : at the start of the line in your<br>
 environment?<br>
 <font color=3D"#888888"><br>
 <br>
 Yuri<br>
 </font></blockquote></div><br>
 
 --20cf303f6a5600eb5f04a242f4b2--
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Mon May 2 05:44:04 UTC 2011 
State-Changed-Why:  
apparently acting as designed. 

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