2025-09-21 Paul Eggert <eggert@cs.ucla.edu>
+ tests: avoid grep in init.sh
+ * tests/init.sh (warn_, gl_shell_test_script_):
+ Avoid the use of grep, as that introduces an unwanted dependency.
+ On older systems like Solaris there can be many greps and they
+ can be buggy, so it’s better to not rely on them in a central
+ part of the test harness.
+
tests: avoid test failure due to rmdir race
* tests/init.sh (remove_tmp_): If the rm -rf fails, wait a second
and try again. This works around a problem I observed on Solaris
case $IFS in
' '*) printf '%s\n' "$*" >&2
test $stderr_fileno_ = 2 \
- || { printf '%s\n' "$*" | sed 1q >&$stderr_fileno_ ; } ;;
+ || { local args=$*
+ local firstline=${args%%"$gl_init_sh_nl_"*}
+ printf '%s\n' "$firstline" >&$stderr_fileno_
+ }
+ ;;
*) (IFS=' '; warn_ "$@");;
esac
}
# ? - not ok
gl_shell_test_script_='
test $(echo y) = y || exit 1
-LC_ALL=en_US.UTF-8 printf "\\351" 2>/dev/null \
- | LC_ALL=C tr "\\351" x | LC_ALL=C grep "^x$" > /dev/null \
- || exit 1
-printf "\\351" 2>/dev/null \
- | LC_ALL=C tr "\\351" x | LC_ALL=C grep "^x$" > /dev/null \
- || exit 1
+case $({ LC_ALL=en_US.UTF-8 printf "\\351"
+ printf "\\351\\n"
+ } 2>/dev/null | LC_ALL=C tr "\\351" x) in
+ xx) ;;
+ *) exit 1;;
+esac
f_local_() { local v=1; }; f_local_ || exit 1
f_dash_local_fail_() { local t=$(printf " 1"); }; f_dash_local_fail_
score_=10