bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-09 Thread Paul Eggert
Jim Meyering wrote: I tried it, and found that this new function makes the multibyte-white-space test fail with GNU sed. Yes, and the more I look at it the less I like it. I'm afraid I'm now going back to the idea that we should just use octal. This outputting-hex business is more trouble t

bug#18987: Fwd: bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-09 Thread Jim Meyering
Forwarding to the bug tracking system: -- Forwarded message -- From: Jim Meyering Date: Sun, Nov 9, 2014 at 10:23 AM Subject: Re: bug#18987: the bourne shell printf-vs-\xHH portability trap To: Paul Eggert On Sun, Nov 9, 2014 at 9:36 AM, Jim Meyering wrote: > On Sat, No

bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-09 Thread Jim Meyering
On Sun, Nov 9, 2014 at 10:19 AM, Jim Meyering wrote: > 2014-11-08 20:19 GMT-08:00 Jim Meyering : >> On Sat, Nov 8, 2014 at 7:52 PM, Paul Eggert wrote: >>> hex_printf_() >>> { >>> hex_printf_format=$(printf '%s\n' "$1" | sed ' >>> s/^/_/ >>> s/$/_/ ... >> Do you have time to wr

bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-09 Thread Jim Meyering
2014-11-08 20:19 GMT-08:00 Jim Meyering : > On Sat, Nov 8, 2014 at 7:52 PM, Paul Eggert wrote: >> hex_printf_() >> { >> hex_printf_format=$(printf '%s\n' "$1" | sed ' >> s/^/_/ >> s/$/_/ >> s/\([^\\]\(\)*\\x\)\([0-9aAbBcCdDeEfF][^0-9aAbBcCdDeEfF]\)/\10\3/g >> s/

bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-08 Thread Norihiro Tanaka
On Sat, 8 Nov 2014 17:54:03 -0800 Jim Meyering wrote: > I pushed that, then tested more and found an error I'd introduced. > Here's the fix: Ah, I could not find it. Thanks.

bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-08 Thread Jim Meyering
On Sat, Nov 8, 2014 at 7:52 PM, Paul Eggert wrote: > hex_printf_() > { > hex_printf_format=$(printf '%s\n' "$1" | sed ' > s/^/_/ > s/$/_/ > s/\([^\\]\(\)*\\x\)\([0-9aAbBcCdDeEfF][^0-9aAbBcCdDeEfF]\)/\10\3/g > s/\([^\\]\(\)*\\x\)\([0-3]\)/\10\3/g > s/\(

bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-08 Thread Paul Eggert
I have some qualms about that patch. It assumes the C locale, and it's a bit safer to spell it out as in '0-9abcdefABCDEF'. Also, the temporary streams (i.e., the output of 'COMMAND inside '$(COMMAND)') are not text, and arguably this does not conform to POSIX (POSIX is murky here) and anyway

bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-08 Thread Jim Meyering
On Sat, Nov 8, 2014 at 5:02 PM, Jim Meyering wrote: > On Sat, Nov 8, 2014 at 3:38 PM, Norihiro Tanaka wrote: >> On Sat, 8 Nov 2014 07:56:48 -0800 >> Jim Meyering wrote: >>> Thank you for working on that. >>> I've improved your patch: update the now-shared hex_printf_ >>> rather than making a cop

bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-08 Thread Jim Meyering
On Sat, Nov 8, 2014 at 3:38 PM, Norihiro Tanaka wrote: > On Sat, 8 Nov 2014 07:56:48 -0800 > Jim Meyering wrote: >> Thank you for working on that. >> I've improved your patch: update the now-shared hex_printf_ >> rather than making a copy, use a better definition of that function >> (knowing that

bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-08 Thread Norihiro Tanaka
On Sat, 8 Nov 2014 07:56:48 -0800 Jim Meyering wrote: > Thank you for working on that. > I've improved your patch: update the now-shared hex_printf_ > rather than making a copy, use a better definition of that function > (knowing that "printf %s a b c d e" reuses the format string and > prints jus

bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-08 Thread Jim Meyering
On Sat, Nov 8, 2014 at 11:46 AM, wrote: > Norihiro Tanaka wrote: > >> Thanks, but it seem that it is also unportable. On Solaris 10 and AIX 7, >> below. Need Gawk for tests? >> >> $ awk 'BEGIN { printf "\x41" }' > \x41 > > If you use octal it should work with any awk. Thanks, but octal would

bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-08 Thread arnold
Norihiro Tanaka wrote: > Thanks, but it seem that it is also unportable. On Solaris 10 and AIX 7, > below. Need Gawk for tests? > > $ awk 'BEGIN { printf "\x41" }' \x41 If you use octal it should work with any awk. Arnold

bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-08 Thread Jim Meyering
On Fri, Nov 7, 2014 at 11:56 PM, Norihiro Tanaka wrote: > Jim Meyering wrote: >> Thank you for testing and reporting that! >> I have a marked preference for using hexadecimal (readability), >> but if I can't find a good, universally-portable converter that is >> sufficiently simple, I'll just rev

bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-07 Thread Norihiro Tanaka
Jim Meyering wrote: > Thank you for testing and reporting that! > I have a marked preference for using hexadecimal (readability), > but if I can't find a good, universally-portable converter that is > sufficiently simple, I'll just revert to using octal. Thanks, I fixed left multibyte-white-space

bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-07 Thread Jim Meyering
On Fri, Nov 7, 2014 at 2:30 PM, Norihiro Tanaka wrote: > Jim Meyering wrote: > >> I ran grep's tests on a debian system this morning and was >> surprised to see the word-multibyte test fail... >> Until I realized it was because that system was configured >> to use dash for /bin/sh, and this test

bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-07 Thread Jim Meyering
On Fri, Nov 7, 2014 at 2:30 PM, Norihiro Tanaka wrote: > Jim Meyering wrote: > >> I ran grep's tests on a debian system this morning and was >> surprised to see the word-multibyte test fail... >> Until I realized it was because that system was configured >> to use dash for /bin/sh, and this test

bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-07 Thread Norihiro Tanaka
Jim Meyering wrote: > I ran grep's tests on a debian system this morning and was > surprised to see the word-multibyte test fail... > Until I realized it was because that system was configured > to use dash for /bin/sh, and this test relied on the unportable > printf '\xc3\xa1\n' to print an a (A

bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-07 Thread Jim Meyering
I've pushed these, and will make a new snapshot soon. Holler if there's anything else you think should be included.

bug#18987: the bourne shell printf-vs-\xHH portability trap

2014-11-07 Thread Jim Meyering
I ran grep's tests on a debian system this morning and was surprised to see the word-multibyte test fail... Until I realized it was because that system was configured to use dash for /bin/sh, and this test relied on the unportable printf '\xc3\xa1\n' to print an à (A-grave). Using \xHH hexadecimal