#!/bin/sh # $Id: mzscheme-version.in 5550 2009-02-19 18:14:43Z cher $ # Copyright (c) 2005-2008 Alexander Chernov LANG_CONFIG_DIR="/home/judges/compile/conf/lang.d" common_config() { echo 'long_name="MzScheme"' echo 'src_sfx=".scm"' echo 'arch="linux-shared"' } failure() { rm -f conftest* echo 'version=' echo 'arg="'"${arg}"'"' common_config echo 'MZSCHEMEPATH=/bin/false' [ "${verbose}" = 1 ] && echo "no" >&2 exit 1 } unset LANG unset LC_ALL unset LC_MESSAGES unset LANGUAGE if [ x"$1" = x-v ] then verbose=1 shift fi # recheck the language if [ x"$1" = x-r ] then arg="$2" [ x"$2" != x ] && mzscheme="$2" [ "${mzscheme}" = "" ] && mzscheme="mzscheme" [ "${verbose}" = 1 ] && echo -n "checking whether MzScheme is available..." >&2 "${mzscheme}" --version >/dev/null 2>&1 || failure version=`"${mzscheme}" --version 2>&1 | grep "MzScheme" | gawk -v FS="[ ,]" '{ if ($4 == "version") v=$5; else v=$4; gsub("v", "", v); print v; }'` [ "${version}" != "" ] || failure MZSCHEMEPATH=`which "${mzscheme}"` || failure [ "${MZSCHEMEPATH}" != "" ] || failure echo "#! ${MZSCHEMEPATH} -qr" > conftest.scm echo '(display "OK")' >> conftest.scm chmod +x ./conftest.scm || failure ./conftest.scm >/dev/null 2>&1 || failure rm -f ./conftest* echo 'version="'"${version}"'"' echo 'arg="'"${arg}"'"' common_config echo 'MZSCHEMEPATH="'"${MZSCHEMEPATH}"'"' [ "${verbose}" = 1 ] && echo "yes, ${MZSCHEMEPATH}, ${version}" >&2 exit 0 fi if [ x"$1" = x-l ] then echo "MzScheme interpreter [http://www.drscheme.org]" exit 0 fi [ "${EJUDGE_LANG_CONFIG}" = "" ] && EJUDGE_LANG_CONFIG="${LANG_CONFIG_DIR}/mzscheme.cfg" if [ -f "${EJUDGE_LANG_CONFIG}" ] then . "${EJUDGE_LANG_CONFIG}" else MZSCHEMEPATH="/usr/bin/mzscheme" fi if [ x"${MZSCHEMEPATH}" = x -o x"${MZSCHEMEPATH}" = x/bin/false ] then echo "This language is not supported." >&2 exit 1 fi if [ x"$1" = x-p ] then echo "${MZSCHEMEPATH}" exit 0 fi "${MZSCHEMEPATH}" --version 2>/dev/null >/dev/null || exit 1 [ x"$1" = x-f ] && echo -n "MzScheme " "${MZSCHEMEPATH}" --version 2>&1 | grep "MzScheme" | gawk -v FS="[ ,]" '{ if ($4 == "version") v=$5; else v=$4; gsub("v", "", v); print v; }'