From b7c4caec669d18ac7c5a692c10da7ddcc0e1f2a5 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 28 Nov 2016 14:16:18 -0800 Subject: [PATCH] tests: use "returns_ N env VAR=val ..." rather than "VAR=val returns_ N ..." Some shells do not propagate envvar settings through our use of the "returns_" function, so set any envvar via use of "env". This was an issue at least on Ubuntu and Debian-based systems, presumably due to their common use of "dash" as /bin/sh. Reported by Assaf Gordon. * tests/char-class-multibyte: As above. * tests/euc-mb: Likewise. * tests/false-match-mb-non-utf8: Likewise. * tests/pcre-infloop: Likewise. * tests/pcre-jitstack: Likewise. * tests/sjis-mb: Likewise. * tests/warn-char-classes: Likewise. --- tests/char-class-multibyte | 2 +- tests/euc-mb | 2 +- tests/false-match-mb-non-utf8 | 8 ++++---- tests/pcre-infloop | 2 +- tests/pcre-jitstack | 2 +- tests/sjis-mb | 4 ++-- tests/warn-char-classes | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/char-class-multibyte b/tests/char-class-multibyte index 6bff4b3..b957518 100755 --- a/tests/char-class-multibyte +++ b/tests/char-class-multibyte @@ -24,7 +24,7 @@ done for LOC in en_US.UTF-8 $LOCALE_FR_UTF8; do out=out3-$LOC - printf '\303\n' | LC_ALL=$LOC returns_ 1 grep '[é]' > $out || fail=1 + printf '\303\n' | returns_ 1 env LC_ALL=$LOC grep '[é]' > $out || fail=1 done Exit $fail diff --git a/tests/euc-mb b/tests/euc-mb index 06e72cd..c639374 100755 --- a/tests/euc-mb +++ b/tests/euc-mb @@ -42,6 +42,6 @@ make_input BABABA |returns_ 1 euc_grep AB || fail=1 make_input BABABA |returns_ 1 euc_grep '^x\|AB' || fail=1 # -P supports only unibyte and UTF-8 locales. -LC_ALL=$locale returns_ 2 grep -P x /dev/null || fail=1 +returns_ 2 env LC_ALL=$locale grep -P x /dev/null || fail=1 Exit $fail diff --git a/tests/false-match-mb-non-utf8 b/tests/false-match-mb-non-utf8 index 6dfd10a..c772793 100755 --- a/tests/false-match-mb-non-utf8 +++ b/tests/false-match-mb-non-utf8 @@ -22,17 +22,17 @@ test "$(get-mb-cur-max $loc)" = 4 || skip_ "no support for the $loc locale" # of four bytes, the last of which is the digit, 7, and grep's DFA # matcher would mistakenly report that ".*7" matches that input line. printf '\2010\2077\n' > in || framework_failure_ -LC_ALL=$loc returns_ 1 grep -E '.*7' in || fail=1 +returns_ 1 env LC_ALL=$loc grep -E '.*7' in || fail=1 -LC_ALL=$loc returns_ 1 grep -E '.{0,1}7' in || fail=1 +returns_ 1 env LC_ALL=$loc grep -E '.{0,1}7' in || fail=1 -LC_ALL=$loc returns_ 1 grep -E '.?7' in || fail=1 +returns_ 1 env LC_ALL=$loc grep -E '.?7' in || fail=1 # Similar for the \ue9 code point, which ends in an "m" byte. loc=zh_HK.big5hkscs test "$(get-mb-cur-max $loc)" = 2 || skip_ "no support for the $loc locale" printf '\210m\n' > in || framework_failure_ -LC_ALL=$loc returns_ 1 grep '.*m' in || fail=1 +returns_ 1 env LC_ALL=$loc grep '.*m' in || fail=1 Exit $fail diff --git a/tests/pcre-infloop b/tests/pcre-infloop index ce6cd7a..fe97353 100755 --- a/tests/pcre-infloop +++ b/tests/pcre-infloop @@ -27,7 +27,7 @@ printf 'a\201b\r' > in || framework_failure_ fail=0 -LC_ALL=en_US.UTF-8 returns_ 1 timeout 10 grep -P 'a.?..b' in \ +returns_ 1 env LC_ALL=en_US.UTF-8 timeout 10 grep -P 'a.?..b' in \ || fail_ "libpcre's match function appears to infloop" Exit $fail diff --git a/tests/pcre-jitstack b/tests/pcre-jitstack index a7bca79..5bdb5a8 100755 --- a/tests/pcre-jitstack +++ b/tests/pcre-jitstack @@ -52,7 +52,7 @@ if test $? != 1; then # Rerun that same test, but now with no limit on stack size: (ulimit -s unlimited; - LC_ALL=C returns_ 1 grep -P -n '^([/](?!/)|[^/])*~/.*' pcrejit.txt) \ + returns_ 1 env LC_ALL=C grep -P -n '^([/](?!/)|[^/])*~/.*' pcrejit.txt) \ || fail=1 fi diff --git a/tests/sjis-mb b/tests/sjis-mb index fb6dcf7..abe2c0c 100755 --- a/tests/sjis-mb +++ b/tests/sjis-mb @@ -30,8 +30,8 @@ k=0 test_grep_reject() { k=$(expr $k + 1) encode "$2" > in || return 1 - LC_ALL=$locale \ - returns_ 1 timeout 10s grep $1 $(encode "$3") in >out$k 2>&1 \ + returns_ 1 env LC_ALL=$locale timeout 10s \ + grep $1 $(encode "$3") in >out$k 2>&1 \ && compare /dev/null out$k } diff --git a/tests/warn-char-classes b/tests/warn-char-classes index 1a64073..b1db240 100755 --- a/tests/warn-char-classes +++ b/tests/warn-char-classes @@ -18,7 +18,7 @@ returns_ 1 grep '[[:space:]]' x 2> err || fail=1 test -s err && fail=1 # disabled by POSIXLY_CORRECT -POSIXLY_CORRECT=yes returns_ 1 grep '[:space:]' x 2> err || fail=1 +returns_ 1 env POSIXLY_CORRECT=yes grep '[:space:]' x 2> err || fail=1 test -s err && fail=1 # patterns that are considered valid -- 2.9.3