Bug 200663

Summary: sed 'y': escape sequences in replacement text behave differently in different locales.
Product: Red Hat Enterprise Linux 3 Reporter: giuseppe bonacci <giuseppe.bonacci>
Component: sedAssignee: Petr Machata <pmachata>
Status: CLOSED ERRATA QA Contact: Ben Levenson <benl>
Severity: low Docs Contact:
Priority: medium    
Version: 3.0CC: jos, mnewsome
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: RHBA-2007-0472 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-06-11 18:37:10 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
fixed y command patch none

Description giuseppe bonacci 2006-07-30 08:26:19 UTC
Description of problem:

sed 'y': escape sequences in replacement text behave differently in different
locales.

Version-Release number of selected component (if applicable):
sed-4.0.7-8.EL3

How reproducible:
# echo aka | env LANG=en_US.UTF-8 sed 'y,k,\t,'
a       a
# echo aka | env LANG=en_US       sed 'y,k,\t,'
ata
# echo aka | env LANG=C           sed 'y,k,\t,'
ata

Comment 1 giuseppe bonacci 2006-07-30 08:27:46 UTC
please see https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=187574#c9

Comment 2 Petr Machata 2006-08-01 14:48:56 UTC
Created attachment 133402 [details]
fixed y command patch

My bad, I confused C locale with POSIXLY_CORRECT env variable. The problem was
different: I fogot to expand escape sequences in singlebyte modes when creating
patch.	With UTF-8 being so prevalent on devel boxes, the mistake went
unnoticed.  This updated patch fixes the problem.

Comment 3 Jos Vos 2006-08-29 08:20:10 UTC
In fact, the sed-4.0.7-8.EL3 does not rebuild on my system without tweaking,
because a test fails in the %check section:

1c1
< btxa
---
> b     xa
Test failed: sed doesn't handle escapes.
error: Bad exit status from /var/tmp/rpm-tmp.18907 (%check)

I guess that's due to the same problem?

Comment 4 Petr Machata 2006-08-29 08:48:30 UTC
Yes, probably.

Comment 5 Jos Vos 2006-08-29 10:44:02 UTC
How could that RPM (in RHEL3 U8) be built correctly at RH?

Comment 6 giuseppe bonacci 2006-08-29 11:01:19 UTC
the problem only shows in single-byte-charset locales, like e.g. C, POSIX, or
en_US.ISO-8859-1.  I guess most of RH building hosts run a en_US.UTF-8 default
locale, so the package builds smoothly.  

try yourself:
env LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 rpmbuild ...

of course, sed's behaviour will stay broken until you apply Petr's patch.

Comment 7 Jos Vos 2006-08-30 17:42:06 UTC
I'm also using a default en_US.UTF-8 locale, but then only LANG is set, LC_ALL
is empty.  When setting LC_ALL too, it indeed builds.

It also builds with Petr's patch, but I had to remove one chunk (that was
already in the code).

Comment 8 Petr Machata 2006-08-31 11:57:54 UTC
Yeah, the patch is meant to be replacement of current 'y' patch.

Comment 10 Frank Ch. Eigler 2007-03-08 12:31:51 UTC
Petr says patch is in hand.


Comment 16 Red Hat Bugzilla 2007-06-11 18:37:10 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2007-0472.html