From af2a9f95b2c0a536bdac8093b62219e19de3f3a2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 2 Nov 2013 22:58:11 -0400 Subject: v-editor: this is the version I've been running --- v-editor.sh | 16 ++++++++++++---- 1 file 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}" "$@" -- cgit v1.2.3