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

@ -471,9 +471,11 @@ L raw Bourne mode literal tab characters
# characters to spaces on the command line. See slowread() in io.c.
p :test-1:
w true /de\tv/nu\tl\tl
r ^:test-1: true (/de\tv/nu\tl\tl|/de v/nu l l)\r\n$
w set +o emacs 2>/dev/null
p :test-2:
w true /de\tv/nu\tl\tl
r ^:test-2: true (/de\tv/nu\tl\tl|/de v/nu l l)\r\n$
p :test-3:
!
VISUAL='' tst $LINENO <<"!"
@ -483,13 +485,15 @@ L raw Bourne mode backslash handling
# This is tested with both erase and kill characters.
p :test-1:
w stty erase ^H kill ^X
w set +o emacs 2>/dev/null
p :test-2:
w true string\\\\\cH\cH
r ^:test-2: true string\r\n$
w stty erase ^H kill ^X
p :test-3:
w true string\\\\\cH\cH
r ^:test-3: true string\r\n$
p :test-4:
w true incorrect\\\cXtrue correct
r ^:test-3: true correct\r\n$
r ^:test-4: true correct\r\n$
!
set --