]> granicus.if.org Git - sudo/commitdiff
add SUDO_EDITOR variable that sudoedit uses in preference to VISUAL or EDITOR
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 8 Oct 2008 20:56:17 +0000 (20:56 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 8 Oct 2008 20:56:17 +0000 (20:56 +0000)
sudo.pod
sudo_edit.c

index 1bf5c2e207e25bab971bd7e4e25c5abfcb6d83de..4a1764787acac3a5c7ee5c6278080034930222ee 100644 (file)
--- a/sudo.pod
+++ b/sudo.pod
@@ -172,10 +172,10 @@ set to the invoking user.
 
 =item 2.
 
-The editor specified by the C<VISUAL> or C<EDITOR> environment
-variables is run to edit the temporary files.  If neither C<VISUAL>
-nor C<EDITOR> are set, the program listed in the I<editor> I<sudoers>
-variable is used.
+The editor specified by the C<SUDO_EDITOR>, C<VISUAL> or C<EDITOR>
+environment variables is run to edit the temporary files.  If none
+of C<SUDO_EDITOR>, C<VISUAL> or C<EDITOR> are set, the first program
+listed in the I<editor> I<sudoers> variable is used.
 
 =item 3.
 
@@ -484,7 +484,8 @@ B<sudo> utilizes the following environment variables:
 
 =item C<EDITOR>
 
-Default editor to use in B<-e> (sudoedit) mode if C<VISUAL> is not set
+Default editor to use in B<-e> (sudoedit) mode if neither C<SUDO_EDITOR>
+nor C<VISUAL> is set
 
 =item C<HOME>
 
@@ -528,13 +529,18 @@ Set to the gid of the user who invoked sudo
 
 If set, C<PS1> will be set to its value
 
+=item C<SUDO_EDITOR>
+
+Default editor to use in B<-e> (sudoedit) mode
+
 =item C<USER>
 
 Set to the target user (root unless the B<-u> option is specified)
 
 =item C<VISUAL>
 
-Default editor to use in B<-e> (sudoedit) mode
+Default editor to use in B<-e> (sudoedit) mode if C<SUDO_EDITOR>
+is not set
 
 =back
 
index 29bc4cf29dbb63130a88d82d97c43238e89883d6..23669d8c08f52348e40cb6063f2277b1d8d76f74 100644 (file)
@@ -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)