From 7bb5160394a73cfdb3910cf8e433b53d6b8d9677 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 8 Oct 2008 20:56:17 +0000 Subject: [PATCH] add SUDO_EDITOR variable that sudoedit uses in preference to VISUAL or EDITOR --- sudo.pod | 18 ++++++++++++------ sudo_edit.c | 9 +++++---- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/sudo.pod b/sudo.pod index 1bf5c2e20..4a1764787 100644 --- a/sudo.pod +++ b/sudo.pod @@ -172,10 +172,10 @@ set to the invoking user. =item 2. -The editor specified by the C or C environment -variables is run to edit the temporary files. If neither C -nor C are set, the program listed in the I I -variable is used. +The editor specified by the C, C or C +environment variables is run to edit the temporary files. If none +of C, C or C are set, the first program +listed in the I I variable is used. =item 3. @@ -484,7 +484,8 @@ B utilizes the following environment variables: =item C -Default editor to use in B<-e> (sudoedit) mode if C is not set +Default editor to use in B<-e> (sudoedit) mode if neither C +nor C is set =item C @@ -528,13 +529,18 @@ Set to the gid of the user who invoked sudo If set, C will be set to its value +=item C + +Default editor to use in B<-e> (sudoedit) mode + =item C Set to the target user (root unless the B<-u> option is specified) =item C -Default editor to use in B<-e> (sudoedit) mode +Default editor to use in B<-e> (sudoedit) mode if C +is not set =back diff --git a/sudo_edit.c b/sudo_edit.c index 29bc4cf29..23669d8c0 100644 --- a/sudo_edit.c +++ b/sudo_edit.c @@ -358,11 +358,12 @@ cleanup: static char * find_editor() { - char *cp, *editor = NULL, **ev, *ev0[3]; + char *cp, *editor = NULL, **ev, *ev0[4]; - ev0[0] = "VISUAL"; - ev0[1] = "EDITOR"; - ev0[2] = NULL; + ev0[0] = "SUDO_EDITOR"; + ev0[1] = "VISUAL"; + ev0[2] = "EDITOR"; + ev0[3] = NULL; for (ev = ev0; *ev != NULL; ev++) { if ((editor = getenv(*ev)) != NULL && *editor != '\0') { if ((cp = strrchr(editor, '/')) != NULL) -- 2.40.0