summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--v-editor.sh11
1 files changed, 6 insertions, 5 deletions
diff --git a/v-editor.sh b/v-editor.sh
index e6df2b3..2d0f52f 100644
--- a/v-editor.sh
+++ b/v-editor.sh
@@ -1,11 +1,12 @@
#!/bin/bash
run() {
- local editor=$1; shift
- local cmd
- eval "cmd=($(printf '%q ' "$editor"))"
- cmd+=("$@")
- "${cmd[@]}"
+ local prog="$1"; shift
+ local args=''
+ if [[ $# -gt 0 ]]; then
+ printf -v args -- ' %q' "$@"
+ fi
+ eval "${prog}${args}"
}
(if [ -n "$DISPLAY" ]; then run "${VISUAL:-$SELECTED_EDITOR}" "$@"