1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Default to emacs upon invoking interactive shell

If the VISUAL or EDITOR environment variable is not set to a value
matching *[Vv][Ii]* or *macs* at initialisation time, then ksh does
not turn on any line editor.

This is user-hostile. New users on Unix-like systems typically have
a simple editor like nano preconfigured as their default, or may
not have the VISUAL or EDITOR variable set at all. So if they try
ksh, they find themselves without basic functionality such as arrow
keys and probably go straight back to bash.

The emacs line editor is by far the most widely used, especially
among new users, so ksh should default to that. Most other shells
already do this.

src/cmd/ksh93/sh/main.c: sh_main():
- On an interactive shell, if on editor was turned on based on
  $VISUAL or $EDITOR, turn on emacs before reading input.
This commit is contained in:
Martijn Dekker 2022-02-01 23:38:14 +00:00
parent d650c73e55
commit 1375cda934
5 changed files with 62 additions and 34 deletions

View file

@ -346,7 +346,18 @@ int sh_main(int ac, char *av[], Shinit_f userinit)
fixargs(sh.st.dolv,1);
}
if(sh_isoption(SH_INTERACTIVE))
{
sh_onstate(SH_INTERACTIVE);
#if SHOPT_ESH
/* do not leave users without a line editor */
if(!sh_isoption(SH_GMACS)
#if SHOPT_VSH
&& !sh_isoption(SH_VI)
#endif /* SHOPT_VSH */
)
sh_onoption(SH_EMACS);
#endif /* SHOPT_ESH */
}
nv_putval(IFSNOD,(char*)e_sptbnl,NV_RDONLY);
exfile(iop,fdin);
sh_done(0);