On Wed, Sep 20, 2000 at 04:37:43PM +0200, Akim Demaille wrote: > > #!/bin/sh > > test -f /bin/sh5 && test -z "$RUNNING_SH5" \ > && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ > && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } > unset RUNNING_SH5 > > test -f /bin/bsh && test -z "$RUNNING_BSH" \ > && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ > && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } > unset RUNNING_BSH > > Gary has a better method somewhere. Attached =)O| Cheers, Gary. -- ___ _ ___ __ _ mailto: [EMAIL PROTECTED] / __|__ _ _ ___ _| | / / | / /_ _ _ _ __ _| |_ __ _ ___ [EMAIL PROTECTED] | (_ / _` | '_|// / |/ /| |/ / _` | || / _` | ' \/ _` | _ \ \___\__,_|_|\_, /|___(_)___/\__,_|\_,_\__, |_||_\__,_|//_/ home page: /___/ /___/ gpg public key: http://www.oranda.demon.co.uk http://www.oranda.demon.co.uk/key.asc
#! /bin/sh # Zsh is not Bourne compatible without the following: if test -n "$ZSH_VERSION"; then emulate sh NULLCMD=: fi # Bash is not POSIX compliant without the following: test -n "$BASH_VERSION" && set -o posix SHELL="${SHELL-/bin/sh}" if test x"$1" = x--re-executed; then # Functional shell was found. Remove option and continue shift elif "$SHELL" -c 'foo () { exit 0; }; foo' 2>/dev/null; then # The current shell works already! : else # Try alternative shells that (sometimes) support functions for cmd in sh bash ash bsh ksh zsh sh5; do set `IFS=:; X="$PATH:/bin:/usr/bin:/usr/afsws/bin:/usr/ucb"; echo $X` for dir shell="$dir/$cmd" if (test -f "$shell" || test -f "$shell.exe") && "$shell" -c 'foo () { exit 0; }; foo' 2>/dev/null then # Re-execute with discovered functional shell SHELL="$shell" exec "$shell" "$0" --re-executed ${1+"$@"} fi done done echo "Unable to locate a shell interpreter with function support" >&2 exit 1 fi foo () { echo "$SHELL: ta da!" } foo exit 0