diff --git a/configure.ac b/configure.ac index 7ebd1d05..f74c3179 100644 --- a/configure.ac +++ b/configure.ac @@ -57,7 +57,8 @@ LT_INIT # A real bash, for "make deb" and the test harness. Not searched into BASH: bash presets # that to its own path, and macOS /bin/sh is a bash, so the macro never searches (#895). -AS_UNSET([BASH_SHELL]) +# BASH_SHELL isn't preset the way BASH is, so AC_ARG_VAR needs no guard. +AC_ARG_VAR([BASH_SHELL], [path to a real (non-POSIX-mode) bash]) AC_PATH_PROGS([BASH_SHELL], [bash], [/bin/bash]) # Export LD_LIBRARY_PATH name or equivalent. diff --git a/tests/146_bash-shell.test b/tests/146_bash-shell.test index a753533e..4d83062d 100644 --- a/tests/146_bash-shell.test +++ b/tests/146_bash-shell.test @@ -43,4 +43,48 @@ test "$out" = procsub || { exit 1 } +# Whatever configure picks, an absolute BASH_SHELL from the user must win over the search. +configure="${abs_top_srcdir:-}/configure" +test -r "$configure" || { + echo "no configure script at $configure; tests/Makefile.am must export abs_top_srcdir" >&2 + exit 1 +} + +help=$(bash "$configure" --help) +grep -q '^ *BASH_SHELL ' <<<"$help" || { + echo "configure --help does not advertise BASH_SHELL (AC_ARG_VAR missing)" >&2 + exit 1 +} + +tmp=$(mktemp -d) +trap 'set +e; rm -rf "$tmp"' EXIT +mkdir "$tmp/src" "$tmp/bld" +ln -s "$sh" "$tmp/mybash" + +# Symlink farm, not the real srcdir: an in-tree config.status makes autoconf refuse it. +for f in "$abs_top_srcdir"/*; do + case "${f##*/}" in + config.status | config.log | config.h | stamp-h1 | Makefile) continue ;; + esac + ln -s "$f" "$tmp/src/" +done + +# Prefer the Makefile: it proves the value that reaches $(BASH_SHELL), not just the macro's +# decision. configure may die on a library check before writing one, so fall back to the +# trace it printed earlier. +(cd "$tmp/bld" && BASH_SHELL="$tmp/mybash" bash "$tmp/src/configure" --disable-https >conf.log 2>&1) || true +if test -f "$tmp/bld/Makefile"; then + got=$(sed -n 's/^BASH_SHELL = //p' "$tmp/bld/Makefile") + from="Makefile" +else + got=$(sed -n 's/^checking for bash\.\.\. //p' "$tmp/bld/conf.log") + got=${got#"(cached) "} + from="trace" +fi +test "$got" = "$tmp/mybash" || { + echo "configure discarded BASH_SHELL=$tmp/mybash, $from has: ${got:-}" >&2 + tail -20 "$tmp/bld/conf.log" >&2 + exit 1 +} + echo "configured bash is $sh ($version)" diff --git a/tests/Makefile.am b/tests/Makefile.am index ec2385a7..983e3e2b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -27,6 +27,7 @@ TESTS_ENVIRONMENT += V6_SUPPORT=$(V6_SUPPORT) # Asserted by 146_bash-shell.test. TESTS_ENVIRONMENT += BASH_SHELL=$(BASH_SHELL) TESTS_ENVIRONMENT += top_srcdir=$(top_srcdir) +TESTS_ENVIRONMENT += abs_top_srcdir=$(abs_top_srcdir) TESTS_ENVIRONMENT += abs_top_builddir=$(abs_top_builddir) TESTS_ENVIRONMENT += CONFIGURED_DATADIR=$(datadir) TESTS_ENVIRONMENT += RENAMEFAIL_LA=$(abs_builddir)/librenamefail.la