summaryrefslogtreecommitdiff
path: root/v-editor.sh
blob: 568f8f14399f73d709e117260af9109d699a7031 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/bash
# Copyright (C) 2011-2015 Luke Shumaker <lukeshu@sbcglobal.net>

run() {
	local prog="$1"; shift
	local args=''
	if [[ $# -gt 0 ]]; then
		printf -v args -- ' %q' "$@"
	fi
	eval exec -- "${prog}${args}"
}

{ if [ -n "$DISPLAY" ]; then run "${VISUAL:-$SELECTED_EDITOR}" "$@"
  else                       run "${EDITOR:-$SELECTED_EDITOR}" "$@"
  fi } ||                    run "${ALTERNATE_EDITOR:-false}"  "$@"