1 # Check for a working shell.
3 # Copyright (C) 2000-2001, 2007, 2009-2018 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3, or (at your option)
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 # Check for a working (i.e. POSIX-compatible) shell.
22 # Written by Paul Eggert <eggert@twinsun.com>,
23 # from an idea suggested by Albert Chin-A-Young <china@thewrittenword.com>.
24 AC_DEFUN([AC_PROG_SHELL],
25 [AC_MSG_CHECKING([for a POSIX-compliant shell])
26 AC_CACHE_VAL(ac_cv_path_shell,
28 # Test the noclobber option, using the portable POSIX.2 syntax.
34 # Test that $(...) works.
35 test "$(expr 3 + 4)" -eq 7 || exit
37 # Solaris 11 /bin/sh (AT&T Research) 93u 2011-02-08 has a file
38 # descriptor bug that breaks zgrep and is hard to test for
39 # directly. At some point $(...) is reading a pipe from the
40 # subshell, but the pipe is also open in the parent shell, so
41 # the read deadlocks. Prefer some other shell if available.
42 ac_maybe_solaris_sh_bug='test "${.sh.version}"'
49 if ("$SHELL" -c "$ac_command") 2>/dev/null; then
50 "$SHELL" -c "$ac_maybe_solaris_sh_bug" 2>/dev/null ||
51 ac_cv_path_shell=$SHELL
55 case $ac_cv_path_shell in
57 # Prefer shells that are more likely to be installed in the
58 # same place on all hosts of this platform. Therefore, prefer
59 # shells in /bin and /usr/bin to shells in the installer's
60 # PATH. Also, loop through PATH first and then through
61 # shells, since less-"nice" shells in /bin and /usr/bin are
62 # more likely to be installed than "nicer" shells elsewhere.
63 ac_break_if_good_shell=:
64 as_save_IFS=$IFS; IFS=:
65 for as_dir in /bin /usr/bin $PATH
70 for ac_base in sh bash ksh sh5; do
72 if ("$as_dir/$ac_base" -c "$ac_command") 2>/dev/null; then
73 if "$as_dir/$ac_base" -c "$ac_maybe_solaris_sh_bug" 2>/dev/null
75 test "$ac_cv_path_shell" = no
77 ac_break_if_good_shell=break
79 fi && ac_cv_path_shell=$as_dir/$ac_base
80 $ac_break_if_good_shell
83 $ac_break_if_good_shell
88 AC_MSG_RESULT($ac_cv_path_shell)
89 SHELL=$ac_cv_path_shell
90 if test "$SHELL" = no; then
92 AC_MSG_WARN([using $SHELL, even though it does not conform to POSIX])
94 if "$SHELL" -c "$ac_maybe_solaris_sh_bug" 2>/dev/null; then
95 AC_MSG_WARN([using $SHELL, even though it may have file descriptor bugs])