Zbigniew Jędrzejewski-Szmek 436654
From 1e534b8a0da393c90b6dedeb5fdd1abd08293ae7 Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek 436654
From: Michael Biebl <biebl@debian.org>
Zbigniew Jędrzejewski-Szmek 436654
Date: Wed, 3 Jun 2015 14:00:59 +0200
Zbigniew Jędrzejewski-Szmek 436654
Subject: [PATCH] systemctl: Use /usr/bin/editor if available
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
If the EDITOR environment variable is not set, the Debian policy
Zbigniew Jędrzejewski-Szmek 436654
recommends to use the /usr/bin/editor program as default editor.
Zbigniew Jędrzejewski-Szmek 436654
This file is managed via the dpkg alternatives mechanism and typically
Zbigniew Jędrzejewski-Szmek 436654
used in Debian/Ubuntu and derivatives to configure the default editor.
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
See section 11.4 of the Debian policy [1].
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
Therefor prefer /usr/bin/editor over specific editors if available.
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
[1] https://www.debian.org/doc/debian-policy/ch-customized-programs.html
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
(cherry picked from commit 9391a1c3d6c94c478b0016a81df3f874fd99260e)
Zbigniew Jędrzejewski-Szmek 436654
---
Zbigniew Jędrzejewski-Szmek 436654
 man/systemctl.xml         | 1 +
Zbigniew Jędrzejewski-Szmek 436654
 src/systemctl/systemctl.c | 2 +-
Zbigniew Jędrzejewski-Szmek 436654
 2 files changed, 2 insertions(+), 1 deletion(-)
Zbigniew Jędrzejewski-Szmek 436654
Zbigniew Jędrzejewski-Szmek 436654
diff --git a/man/systemctl.xml b/man/systemctl.xml
Zbigniew Jędrzejewski-Szmek 436654
index 94a77bce0c..9b79c2df0f 100644
Zbigniew Jędrzejewski-Szmek 436654
--- a/man/systemctl.xml
Zbigniew Jędrzejewski-Szmek 436654
+++ b/man/systemctl.xml
Zbigniew Jędrzejewski-Szmek 436654
@@ -1730,6 +1730,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
Zbigniew Jędrzejewski-Szmek 436654
         <varname>$VISUAL</varname> are present or if it is set to an empty
Zbigniew Jędrzejewski-Szmek 436654
         string or if their execution failed, systemctl will try to execute well
Zbigniew Jędrzejewski-Szmek 436654
         known editors in this order:
Zbigniew Jędrzejewski-Szmek 436654
+        <citerefentry project='die-net'><refentrytitle>editor</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
Zbigniew Jędrzejewski-Szmek 436654
         <citerefentry project='die-net'><refentrytitle>nano</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
Zbigniew Jędrzejewski-Szmek 436654
         <citerefentry project='die-net'><refentrytitle>vim</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
Zbigniew Jędrzejewski-Szmek 436654
         <citerefentry project='die-net'><refentrytitle>vi</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
Zbigniew Jędrzejewski-Szmek 436654
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
Zbigniew Jędrzejewski-Szmek 436654
index f8e10a4710..cf5aa07ac6 100644
Zbigniew Jędrzejewski-Szmek 436654
--- a/src/systemctl/systemctl.c
Zbigniew Jędrzejewski-Szmek 436654
+++ b/src/systemctl/systemctl.c
Zbigniew Jędrzejewski-Szmek 436654
@@ -5870,7 +5870,7 @@ static int run_editor(char **paths) {
Zbigniew Jędrzejewski-Szmek 436654
                         execvp(editor, (char* const*) args);
Zbigniew Jędrzejewski-Szmek 436654
                 }
Zbigniew Jędrzejewski-Szmek 436654
 
Zbigniew Jędrzejewski-Szmek 436654
-                FOREACH_STRING(p, "nano", "vim", "vi") {
Zbigniew Jędrzejewski-Szmek 436654
+                FOREACH_STRING(p, "editor", "nano", "vim", "vi") {
Zbigniew Jędrzejewski-Szmek 436654
                         args[0] = p;
Zbigniew Jędrzejewski-Szmek 436654
                         execvp(p, (char* const*) args);
Zbigniew Jędrzejewski-Szmek 436654
                         /* We do not fail if the editor doesn't exist