I pushed that patch, then tested on a Debian system with /bin/sh == dash.
That exposed at least one more failure (pcre-utf8) due to use of
printf with \xHH, so here's another patch to deal with that and the
few others I found. There is also a tiny clean-up patch.
From 3dd2c253bd1ab9975243a496947b9e9ca778ce97 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Mon, 21 Oct 2013 07:39:00 -0700
Subject: [PATCH 1/2] maint: clean up an ugly 'while' condition
* src/main.c (get_nondigit_option): Separate a slightly baroque
"while" expression into two separate statements, both inside the loop.
---
src/main.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/main.c b/src/main.c
index 974cf91..d9c7759 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1746,16 +1746,20 @@ static int
get_nondigit_option (int argc, char *const *argv, intmax_t *default_context)
{
static int prev_digit_optind = -1;
- int opt, this_digit_optind, was_digit;
+ int this_digit_optind, was_digit;
char buf[INT_BUFSIZE_BOUND (intmax_t) + 4];
char *p = buf;
+ int opt;
was_digit = 0;
this_digit_optind = optind;
- while (opt = getopt_long (argc, (char **) argv, short_options, long_options,
- NULL),
- '0' <= opt && opt <= '9')
+ while (1)
{
+ opt = getopt_long (argc, (char **) argv, short_options,
+ long_options, NULL);
+ if ( ! ('0' <= opt && opt <= '9'))
+ break;
+
if (prev_digit_optind != this_digit_optind || !was_digit)
{
/* Reset to start another context length argument. */
--
1.8.0.1.350.gee26a6e
From 8ddecd8045887f48633d326216389eb3d30c6567 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Thu, 24 Oct 2013 11:21:03 -0700
Subject: [PATCH 2/2] tests: port more tests to bourne shells with
hex-challenged printf
* tests/pcre-utf8: Convert the hex \xHH literals for the euro symbol
to octal \OOO.
* tests/turkish-I: Likewise for "I with dot".
* tests/turkish-I-without-dot: Likewise for another Turkish I: U+0131.
---
tests/pcre-utf8 | 2 +-
tests/turkish-I | 2 +-
tests/turkish-I-without-dot | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/pcre-utf8 b/tests/pcre-utf8
index 612b702..b8228d5 100755
--- a/tests/pcre-utf8
+++ b/tests/pcre-utf8
@@ -16,7 +16,7 @@ fail=0
echo '$' | LC_ALL=en_US.UTF-8 grep -qP '\p{S}' \
|| skip_ 'PCRE support is compiled out, or it does not support properties'
-euro='\xe2\x82\xac euro'
+euro='\342\202\254 euro'
printf "$euro\\n" > in || framework_failure_
LC_ALL=en_US.UTF-8 grep -P '^\p{S}' in > out || fail=1
diff --git a/tests/turkish-I b/tests/turkish-I
index 2decc46..d32cfa6 100755
--- a/tests/turkish-I
+++ b/tests/turkish-I
@@ -23,7 +23,7 @@ require_compiled_in_MB_support
fail=0
-i='\xC4\xB0'
+i='I\304\260'
printf "$i$i$i$i$i$i$i\n" > in || framework_failure_
LC_ALL=en_US.UTF-8 grep -i .... in > out || fail=1
diff --git a/tests/turkish-I-without-dot b/tests/turkish-I-without-dot
index 2b4e9cc..daf0b75 100755
--- a/tests/turkish-I-without-dot
+++ b/tests/turkish-I-without-dot
@@ -47,7 +47,7 @@ compare out in || fail=1
# buffer have precisely the same length (22 bytes here), yet internal
# offsets do differ. Lengths are the same because while some bytes shrink
# when converted to lower case, others grow, and here they balance out.
-i='I\xC4\xB0'
+i='I\304\260'
printf "$i$i$i$i$i$i$i\n" > in || framework_failure_
LC_ALL=tr_TR.utf8 grep -i .... in > out || fail=1
compare out in || fail=1
--
1.8.0.1.350.gee26a6e