#!/bin/sh GNUCLIENT=gnuclient GNUCLIENTPINGOPTIONS="-batch -eval t" EMACS=/Applications/Emacs.app TIMEOUT=20 # this will either bring Emacs to the foreground or launch it. open ${EMACS} # Try for TIMEOUT seconds to talk to the Emacs process. count=0 until ${GNUCLIENT} ${GNUCLIENTPINGOPTIONS} >/dev/null 2>&1 ; do if [ ${count} -gt ${TIMEOUT} ] ; then echo "gc: error starting Emacs" 1>&2 exit 1 fi sleep 1 count=`expr ${count} + 1` done exec ${GNUCLIENT} -q ${1+"$@"}