#! /bin/bash
(set -o igncr) 2>/dev/null && set -o igncr; # this comment is required

function report { echo "$@"; exit 0; }

System="$(uname)"
Darwin1=/Applications/Emacs.app/Contents/MacOS/Emacs
Darwin2=/Applications/MacPorts/Emacs.app

if [ ! -z "${EMACS}" ]; then report "${EMACS}"; fi

if [ ${System} == "Darwin" ]; then
  if [ -f ${Darwin1} ]; then report "${Darwin1}"; fi
  if [ -f ${Darwin2} ]; then report "${Darwin2}"; fi
fi

report "emacs"
