aboutsummaryrefslogtreecommitdiffstats
path: root/bin/editor
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2013-03-02 23:55:48 +0000
committerNicolas Vigier <boklm@mageia.org>2013-03-02 23:55:48 +0000
commitbe94d560412611b59270c6832dea3ed16c034cac (patch)
tree5be4f7410b10c9c56d666be8fc4fd1147de2264c /bin/editor
parent2630ebc4621f1808af0350c3b5e09e26eb26e9f5 (diff)
downloadcommon-data-be94d560412611b59270c6832dea3ed16c034cac.tar
common-data-be94d560412611b59270c6832dea3ed16c034cac.tar.gz
common-data-be94d560412611b59270c6832dea3ed16c034cac.tar.bz2
common-data-be94d560412611b59270c6832dea3ed16c034cac.tar.xz
common-data-be94d560412611b59270c6832dea3ed16c034cac.zip
bin/editor: revert to buggy version as requested by David Walser
http://www.mageia.org/pipermail/mageia-dev/2013-March/023248.html
Diffstat (limited to 'bin/editor')
-rwxr-xr-xbin/editor73
1 files changed, 55 insertions, 18 deletions
diff --git a/bin/editor b/bin/editor
index 145fffb..2d64dea 100755
--- a/bin/editor
+++ b/bin/editor
@@ -1,24 +1,61 @@
#!/bin/sh
-# launch a text editor
+#---------------------------------------------------------------
+# Project : Mageia
+# Module : bin
+# File : editor
+# Author : David Walser
+# Created On : Thu Apr 3 16:26:54 2012
+# Purpose : launch a text editor
+#---------------------------------------------------------------
-exec_editor() {
- if [ -n "$1" ] && [ $(basename "$1") != "editor" ] \
- && which "$1" > /dev/null 2>&1
- then
- exec "$@"
+strip_texteditor_var() {
+ if [[ -n "$TEXTEDITOR" ]]; then
+ if [[ `basename "$TEXTEDITOR"` == "editor" ]]; then
+ unset TEXTEDITOR
+ elif ! which $TEXTEDITOR > /dev/null 2>&1; then
+ unset TEXTEDITOR
+ fi
fi
}
-exec_editor "$TEXTEDITOR" "$@"
-exec_editor "$VISUAL" "$@"
-exec_editor "$EDITOR" "$@"
-[ -n "$GNOME_DESKTOP_SESSION_ID" ] && exec_editor gedit "$@"
-[ -n "$KDE_FULL_SESSION" ] && exec_editor kwrite "$@"
-exec_editor kwrite "$@"
-exec_editor gedit "$@"
-exec_editor emacs "$@"
-exec_editor vim "$@"
-exec_editor nano "$@"
+strip_texteditor_var
+if [[ -z "$TEXTEDITOR" ]]; then
+
+ # using GNOME
+ if [[ -n "$GNOME_DESKTOP_SESSION_ID" ]]; then
+ TEXTEDITOR="gedit"
+ fi
+
+ #using KDE
+ if [[ -n "$KDE_FULL_SESSION" ]]; then
+ TEXTEDITOR="kwrite"
+ fi
+
+
+ strip_texteditor_var
+
+ [[ -z "$TEXTEDITOR" ]] && TEXTEDITOR=`which kwrite 2> /dev/null`
+ [[ -z "$TEXTEDITOR" ]] && TEXTEDITOR=`which gedit 2> /dev/null`
+
+ if [[ -z "$TEXTEDITOR" ]]; then
+ EMACS=`/usr/sbin/update-alternatives --list emacs`
+ if [[ -n "$EMACS" ]]; then
+ if [[ `basename "$EMACS"` = "emacs-nox" ]]; then
+ TEXTEDITOR="xvt -e emacs"
+ else
+ TEXTEDITOR="emacs"
+ fi
+ fi
+ fi
+
+ [[ -z "$TEXTEDITOR" ]] && which vim > /dev/null 2>&1 && TEXTEDITOR="xvt -e vim"
+ [[ -z "$TEXTEDITOR" ]] && which nano > /dev/null 2>&1 && TEXTEDITOR="xvt -e nano"
+fi
+
+if [[ -n "$TEXTEDITOR" ]]; then
+ exec $TEXTEDITOR $@
+else
+ echo "no text editor detected"
+fi
-echo "no text editor detected" >&2
-exit 1
+# editor ends here