diff options
-rw-r--r-- | v-editor.sh | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/v-editor.sh b/v-editor.sh index b1a32cc..09bccf5 100644 --- a/v-editor.sh +++ b/v-editor.sh @@ -1,5 +1,13 @@ -#!/bin/sh +#!/bin/bash -(if [ -n "$DISPLAY" ]; then eval ${VISUAL:-$SELECTED_EDITOR} "$@" - else eval ${EDITOR:-$SELECTED_EDITOR} "$@" -fi) || eval ${ALTERNATE_EDITOR:-false} "$@" +run() { + local editor=$1; shift + local cmd + IFS='|' cmd=($(eval printf '%s\|' "$editor")) + cmd+=("$@") + "${cmd[@]}" +} + +(if [ -n "$DISPLAY" ]; then run "${VISUAL:-$SELECTED_EDITOR}" "$@" + else run "${EDITOR:-$SELECTED_EDITOR}" "$@" +fi) || run "${ALTERNATE_EDITOR:-false}" "$@" |