Upgrade to latest version submitted to Autoconf-patches.
[debian/gzip] / m4 / shell.m4
1 #serial 3
2
3 # AC_PROG_SHELL
4 # -------------
5 # Check for a working (i.e. POSIX-compatible) shell.
6 # Written by Paul Eggert <eggert@twinsun.com>,
7 # from an idea suggested by Albert Chin-A-Young <china@thewrittenword.com>.
8 AC_DEFUN([AC_PROG_SHELL],
9   [AC_MSG_CHECKING([for a POSIX-compliant shell])
10    AC_CACHE_VAL(ac_cv_path_shell,
11      [ac_command='
12         # Test the noclobber option, using the portable POSIX.2 syntax.
13         set -C
14         rm -f conftest.c
15         >conftest.c || exit
16         >|conftest.c || exit
17         !>conftest.c || exit
18       '
19       ac_cv_path_shell=no
20
21       case $SHELL in
22       /*)
23         rm -f conftest.c
24         if ("$SHELL" -c "$ac_command") 2>/dev/null; then
25           ac_cv_path_shell=$SHELL
26         fi;;
27       esac
28
29       case $ac_cv_path_shell in
30       no)
31         # Prefer shells that are more likely to be installed in the
32         # same place on all hosts of this platform.  Therefore, prefer
33         # shells in /bin and /usr/bin to shells in the installer's
34         # PATH.  Also, loop through PATH first and then through
35         # shells, since less-"nice" shells in /bin and /usr/bin are
36         # more likely to be installed than "nicer" shells elsewhere.
37         _AS_PATH_WALK([/bin:/usr/bin:$PATH],
38           [for ac_base in sh bash ksh sh5; do
39              case $as_dir in
40              /*)
41                rm -f conftest.c
42                if ("$as_dir/$ac_base" -c "$ac_command") 2>/dev/null; then
43                  ac_cv_path_shell="$as_dir/$ac_base"
44                  break
45                fi;;
46              esac
47            done
48            case $ac_cv_path_shell in
49            no) ;;
50            *) break;;
51            esac])
52         rm -f conftest.c;;
53       esac])
54    AC_MSG_RESULT($ac_cv_path_shell)
55    SHELL=$ac_cv_path_shell
56    if test "$SHELL" = no; then
57      SHELL=/bin/sh
58      AC_MSG_WARN([using $SHELL, even though it does not conform to POSIX])
59    fi
60    AC_SUBST(SHELL)])