bin/172862: sed improperly deals with escape chars
Garrett Cooper
yanegomi at gmail.com
Thu Oct 18 21:10:01 UTC 2012
>Number: 172862
>Category: bin
>Synopsis: sed improperly deals with escape chars
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Thu Oct 18 21:10:00 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator: Garrett Cooper
>Release: 9.1-STABLE
>Organization:
EMC Isilon
>Environment:
FreeBSD bayonetta.local 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #0 r240836M: Sat Sep 22 12:30:11 PDT 2012 gcooper at bayonetta.local:/usr/obj/store/freebsd/stable/9/sys/BAYONETTA amd64
>Description:
sed doesn't appear to be doing the right thing with escape chars (in this case '\t'); it's not properly reinterpreting '\t' as \011, but is instead interpreting it was 't':
$ echo "foot " | sed -e 's/[\\t ]*$//' | hexdump -C
00000000 66 6f 6f 0a |foo.|
00000004
$ echo "foot " | sed -E -e 's/[\\t ]*$//' | hexdump -C
00000000 66 6f 6f 0a |foo.|
00000004
GNU sed does do the right thing with escape chars (verified on Fedora 17):
# cat /etc/redhat-release
Fedora release 17 (Beefy Miracle)
# echo foot | sed -e 's/[\t ]*$//' | hexdump -C
00000000 66 6f 6f 74 0a |foot.|
00000005
# echo "foot " | sed -e 's/[\t ]*$//' | hexdump -C
00000000 66 6f 6f 74 0a |foot.|
00000005
>How-To-Repeat:
echo foot | sed -e 's/[\t ]*$//'
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list