On Mon, Mar 12, 2012 at 10:09:13AM +0000, Stuart Henderson wrote:
>
> I've wasted countless time because of this "feature", it's probably
> my no.1 annoyance with the OS. It used to be possible to set this
> in a file sourced via ENV so it could be applied automatically,
> but sudo now (rightly) prohibits passing this variable.
>
> After using stupid things like EDITOR=/usr/bin/emacs-not-really
> symlinked to vi for a while on some machines, I came up with this
> approach instead. Does anyone else think this is worth the extra
> bytes?
>
> Index: bin/ksh/ksh.1
> ===================================================================
> RCS file: /cvs/src/bin/ksh/ksh.1,v
> retrieving revision 1.141
> diff -u -p -r1.141 ksh.1
> --- bin/ksh/ksh.1 3 Sep 2011 22:59:08 -0000 1.141
> +++ bin/ksh/ksh.1 12 Mar 2012 09:37:28 -0000
> @@ -1362,14 +1362,36 @@ This parameter is used by the interactiv
> and
> .Ic kill -l
> commands to format information columns.
> +.It Ev EDITMODE
> +If set, this parameter controls the command-line editing mode for interactive
> +shells.
> +If the last component of the path specified in this parameter contains
> +the string
> +.Dq vi ,
> +.Dq emacs ,
> +or
> +.Dq gmacs ,
> +the
> +.Xr vi ,
> +.Xr emacs ,
> +or
> +.Xr gmacs
> +(Gosling emacs) editing mode is enabled, respectively.
> +Also see the
> +.Ev EDITOR
> +and
> +.Ev VISUAL
> +parameters below.
> .It Ev EDITOR
> If the
> .Ev VISUAL
> -parameter is not set, this parameter controls the command-line editing mode
> for
> -interactive shells.
> +and
> +.Ev EDITMODE
> +parameters are not set, this parameter controls the command-line editing mode
> +for interactive shells.
> See the
> -.Ev VISUAL
> -parameter below for how this works.
> +.Ev EDITMODE
> +parameter above for how this works.
> .Pp
> Note:
> traditionally,
> @@ -1381,8 +1403,9 @@ and
> was used to specify a (new-style) screen editor, such as
> .Xr vi 1 .
> Hence if
> -.Ev VISUAL
> -is set, it overrides
> +.Ev VISUAL or
> +.Ev EDITMODE
> +are set, they override
> .Ev EDITOR .
> .It Ev ENV
> If this parameter is found to be set after any profile files are executed,
> the
> @@ -1745,23 +1768,13 @@ set, or does not contain the absolute pa
> files are created in
> .Pa /tmp .
> .It Ev VISUAL
> -If set, this parameter controls the command-line editing mode for interactive
> -shells.
> -If the last component of the path specified in this parameter contains
> -the string
> -.Dq vi ,
> -.Dq emacs ,
> -or
> -.Dq gmacs ,
> -the
> -.Xr vi ,
> -.Xr emacs ,
> -or
> -.Xr gmacs
> -(Gosling emacs) editing mode is enabled, respectively.
> -See also the
> -.Ev EDITOR
> -parameter, above.
> +If the
> +.Ev EDITMODE
> +parameter is not set, this parameter controls the command-line editing mode
> +for interactive shells.
> +See the
> +.Ev EDITMODE
> +parameter above for how this works.
> .El
> .Ss Tilde expansion
> Tilde expansion, which is done in parallel with parameter substitution, is
> done
> Index: bin/ksh/table.h
> ===================================================================
> RCS file: /cvs/src/bin/ksh/table.h,v
> retrieving revision 1.8
> diff -u -p -r1.8 table.h
> --- bin/ksh/table.h 19 Feb 2012 07:52:30 -0000 1.8
> +++ bin/ksh/table.h 12 Mar 2012 09:37:28 -0000
> @@ -170,6 +170,7 @@ extern const struct builtin shbuiltins [
> #define V_TMOUT 15
> #define V_TMPDIR 16
> #define V_LINENO 17
> +#define V_EDITMODE 18
>
> /* values for set_prompt() */
> #define PS1 0 /* command */
> Index: bin/ksh/var.c
> ===================================================================
> RCS file: /cvs/src/bin/ksh/var.c,v
> retrieving revision 1.34
> diff -u -p -r1.34 var.c
> --- bin/ksh/var.c 15 Oct 2007 02:16:35 -0000 1.34
> +++ bin/ksh/var.c 12 Mar 2012 09:37:28 -0000
> @@ -96,6 +96,7 @@ initvar(void)
> { "HISTSIZE", V_HISTSIZE },
> #endif /* HISTORY */
> #ifdef EDIT
> + { "EDITMODE", V_EDITMODE },
> { "EDITOR", V_EDITOR },
> { "VISUAL", V_VISUAL },
> #endif /* EDIT */
> @@ -1004,11 +1005,16 @@ setspec(struct tbl *vp)
> break;
> #endif /* HISTORY */
> #ifdef EDIT
> - case V_VISUAL:
> + case V_EDITMODE:
> set_editmode(str_val(vp));
> break;
> + case V_VISUAL:
> + if (!(global("EDITMODE")->flag & ISSET))
> + set_editmode(str_val(vp));
> + break;
> case V_EDITOR:
> - if (!(global("VISUAL")->flag & ISSET))
> + if ((!(global("EDITMODE")->flag & ISSET)) &&
> + (!(global("VISUAL")->flag & ISSET)))
> set_editmode(str_val(vp));
> break;
> case V_COLUMNS:
> Index: usr.bin/sudo/sudoers
> ===================================================================
> RCS file: /cvs/src/usr.bin/sudo/sudoers,v
> retrieving revision 1.25
> diff -u -p -r1.25 sudoers
> --- usr.bin/sudo/sudoers 26 Oct 2009 19:28:26 -0000 1.25
> +++ usr.bin/sudo/sudoers 12 Mar 2012 09:37:28 -0000
> @@ -16,11 +16,11 @@
> # Cmnd alias specification
>
> # Defaults specification
> -Defaults env_keep +="DESTDIR DISTDIR EDITOR FETCH_CMD FLAVOR FTPMODE GROUP
> MAKE"
> -Defaults env_keep +="MAKECONF MULTI_PACKAGES NOMAN OKAY_FILES OWNER
> PKG_CACHE"
> -Defaults env_keep +="PKG_DBDIR PKG_DESTDIR PKG_PATH PKG_TMPDIR PORTSDIR"
> -Defaults env_keep +="RELEASEDIR SHARED_ONLY SSH_AUTH_SOCK SUBPACKAGE VISUAL"
> -Defaults env_keep +="WRKOBJDIR"
> +Defaults env_keep +="DESTDIR DISTDIR EDITOR EDITMODE FETCH_CMD FLAVOR
> FTPMODE"
> +Defaults env_keep +="GROUP MAKE MAKECONF MULTI_PACKAGES NOMAN OKAY_FILES
> OWNER"
> +Defaults env_keep +="PKG_CACHE PKG_DBDIR PKG_DESTDIR PKG_PATH PKG_TMPDIR"
> +Defaults env_keep +="PORTSDIR RELEASEDIR SHARED_ONLY SSH_AUTH_SOCK"
> +Defaults env_keep +="SUBPACKAGE VISUAL WRKOBJDIR"
>
> # Uncomment to disable the lecture the first time you run sudo
> #Defaults !lecture
>
+1
I had the joy with this "Feature" of showing some newbies how to use ssh
to access on the server, only to have to say "Well this should be
working, Hmm, not sure why."
I looked like an idiot.
Leaving everything the same without using new variable is perfect.