#! /bin/sh set -e editor=${MDW_EDITOR-ed} emacsclient=t [ -t 0 -a -t 1 ] || TERM=dumb case "$EDITOR,$VISUAL,$TERM" in mdw-editor,mdw-editor,dumb | \ mdw-editor,mdw-editor,emacs | \ mdw-editor,mdw-editor,eterm*) editor=emacsclient emacsclient=nil;; mdw-editor,mdw-editor,*);; mdw-editor,*,*) editor=$VISUAL;; *,*,*) editor=$EDITOR;; esac case "$emacsclient" in t) exec emacsclient -nw -a "$editor" "$@";; nil) exec $editor "$@";; esac