dnl CF_DEFAULT_SHELL version: 8 updated: 2024/04/01 20:13:36
dnl ----------------
dnl Look for a Bourne-shell compatible program from a list that we know about:
dnl	ash	Almquist Shell (sh based)
dnl	bash	Bourne Again Shell (sh, ksh based)
dnl	dash	Debian Almquist Shell (sh based)
dnl	jsh	Job Control Bourne Shell (sh based)
dnl	keysh	Key Shell (ksh based)
dnl	ksh	Korn Shell (sh based)
dnl	mksh	MirBSD Korn shell (pdksh based)
dnl	pdksh	Public-domain ksh
dnl	sh	Bourne Shell or POSIX Shell
dnl	zsh	Z Shell (sh, ksh based)
dnl On BSD systems look for a C Shell compatible program:
dnl	csh	C Shell
dnl	tcsh	TENEX C Shell (csh based)
AC_DEFUN([CF_DEFAULT_SHELL],
[
AC_MSG_CHECKING(for the default shell program)
cf_shell_progs="ifelse($1,,sh,[$1])"
if test -z "$cf_shell_progs" ; then
	cf_shell_progs="sh ksh bash zsh pdksh mksh jsh keysh ash dash"
	# TIN preferred default shell for BSD systems is csh. Others are sh.
	AC_TRY_COMPILE([
#include <sys/params.h>],[
#if (defined(BSD) && (BSD >= 199103))
#else
make an error
#endif
],[$cf_shell_progs="csh tcsh $cf_shell_progs"])
fi
CF_MSG_LOG(paths of shell programs: $cf_shell_progs)
if test -s /etc/shells && test `${EGREP-egrep}  -c -v '^(#| |    |$)' /etc/shells` -gt 0; then
	CF_MSG_LOG(/etc/shells)
	for cf_prog in $cf_shell_progs
	do
		case $cf_prog in
			/*)
				cf_pattern="^"$cf_prog"$"
				;;
			*/*)
				AC_MSG_ERROR(Program name must be absolute or filename: $cf_prog)
				;;
			*)
				cf_pattern="/"$cf_prog"$"
				;;
		esac
		cf_path=`${EGREP-egrep} $cf_pattern /etc/shells 2>/dev/null`
		if test -n "$cf_path"
		then
			for cf_shell in $cf_path
			do
				if test -f "$cf_shell"
				then
					DEFAULT_SHELL="$cf_shell"
					break
				fi
			done
		fi
		if test -n "$DEFAULT_SHELL"
		then
			break
		fi
	done
	AC_MSG_RESULT($DEFAULT_SHELL)
else
	CF_MSG_LOG($PATH)
AC_PATH_PROGS(DEFAULT_SHELL,
	$cf_shell_progs,,
	$PATH:/bin:/usr/bin:/usr/xpg4/bin:/bin/posix:/usr/bin/posix:/usr/old/bin:/usr/local/bin)
fi
if test -z "$DEFAULT_SHELL" ; then
	AC_MSG_WARN(
Cannot find the default shell you specified: $cf_shell_progs)
	if test -f /bin/false ; then
		AC_MSG_WARN(Using /bin/false instead)
		DEFAULT_SHELL=/bin/false
	else
		AC_MSG_ERROR(Cannot use /bin/false because it does not exist)
	fi
fi
AC_DEFINE_UNQUOTED(DEFAULT_SHELL,"$DEFAULT_SHELL",[Define this to the default shell-program])
])dnl
