]> git.cworth.org Git - gzip/blob - m4/shell.m4
Imported Debian patch 1.3.12-1
[gzip] / m4 / shell.m4
1 # Check for a working shell.
2
3 # Copyright (C) 2000, 2001, 2007 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 2, or (at your option)
7 # any later version.
8
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.
13
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
17 # 02111-1307, USA.
18
19 # AC_PROG_SHELL
20 # -------------
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,
27      [ac_command='
28         # Test the noclobber option, using the portable POSIX.2 syntax.
29         set -C
30         rm -f conftest.c
31         >conftest.c || exit
32         >|conftest.c || exit
33         !>conftest.c || exit
34         # Test that $(...) works.
35         test "$(expr 3 + 4)" -eq 7 || exit
36       '
37       ac_cv_path_shell=no
38
39       case $SHELL in
40       /*)
41         rm -f conftest.c
42         if ("$SHELL" -c "$ac_command") 2>/dev/null; then
43           ac_cv_path_shell=$SHELL
44         fi;;
45       esac
46
47       case $ac_cv_path_shell in
48       no)
49         # Prefer shells that are more likely to be installed in the
50         # same place on all hosts of this platform.  Therefore, prefer
51         # shells in /bin and /usr/bin to shells in the installer's
52         # PATH.  Also, loop through PATH first and then through
53         # shells, since less-"nice" shells in /bin and /usr/bin are
54         # more likely to be installed than "nicer" shells elsewhere.
55         as_save_IFS=$IFS; IFS=:
56         for as_dir in /bin /usr/bin $PATH
57         do
58           IFS=$as_save_IFS
59           case $as_dir in
60           /*)
61             for ac_base in sh bash ksh sh5; do
62               rm -f conftest.c
63               if ("$as_dir/$ac_base" -c "$ac_command") 2>/dev/null; then
64                 ac_cv_path_shell=$as_dir/$ac_base
65                 break
66               fi
67             done
68             case $ac_cv_path_shell in
69             /*) break;;
70             esac;;
71           esac
72         done
73         rm -f conftest.c;;
74       esac])
75    AC_MSG_RESULT($ac_cv_path_shell)
76    SHELL=$ac_cv_path_shell
77    if test "$SHELL" = no; then
78      SHELL=/bin/sh
79      AC_MSG_WARN([using $SHELL, even though it does not conform to POSIX])
80    fi
81    AC_SUBST(SHELL)])