mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 03:32:24 +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:
parent
d650c73e55
commit
1375cda934
5 changed files with 62 additions and 34 deletions
6
NEWS
6
NEWS
|
@ -3,6 +3,12 @@ For full details, see the git log at: https://github.com/ksh93/ksh/tree/1.0
|
||||||
|
|
||||||
Any uppercase BUG_* names are modernish shell bug IDs.
|
Any uppercase BUG_* names are modernish shell bug IDs.
|
||||||
|
|
||||||
|
2022-02-01:
|
||||||
|
|
||||||
|
- Upon invocation, the interactive shell no longer leaves the user without
|
||||||
|
a line editor if the VISUAL or EDITOR variable does not indicate emacs,
|
||||||
|
gmacs or vi; instead, it now turns on the emacs option by default.
|
||||||
|
|
||||||
2022-01-31:
|
2022-01-31:
|
||||||
|
|
||||||
- Improved keyboard support for the vi and emacs built-in line editors:
|
- Improved keyboard support for the vi and emacs built-in line editors:
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */
|
#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */
|
||||||
#define SH_RELEASE_SVER "1.0.0-beta.2" /* semantic version number: https://semver.org */
|
#define SH_RELEASE_SVER "1.0.0-beta.2" /* semantic version number: https://semver.org */
|
||||||
#define SH_RELEASE_DATE "2022-01-31" /* must be in this format for $((.sh.version)) */
|
#define SH_RELEASE_DATE "2022-02-01" /* must be in this format for $((.sh.version)) */
|
||||||
#define SH_RELEASE_CPYR "(c) 2020-2022 Contributors to ksh " SH_RELEASE_FORK
|
#define SH_RELEASE_CPYR "(c) 2020-2022 Contributors to ksh " SH_RELEASE_FORK
|
||||||
|
|
||||||
/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */
|
/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */
|
||||||
|
|
|
@ -1848,15 +1848,11 @@ If the
|
||||||
.B
|
.B
|
||||||
.SM VISUAL
|
.SM VISUAL
|
||||||
variable is not set,
|
variable is not set,
|
||||||
the value of this variable will be checked for the patterns
|
the value of this variable will be checked for certain patterns
|
||||||
as described with
|
and the corresponding editing option will be turned on as described with
|
||||||
.B
|
.B
|
||||||
.SM VISUAL
|
.SM VISUAL
|
||||||
below and the corresponding editing option
|
below.
|
||||||
(see Special Command
|
|
||||||
.B set
|
|
||||||
below)
|
|
||||||
will be turned on.
|
|
||||||
.TP
|
.TP
|
||||||
.SM
|
.SM
|
||||||
.B ENV
|
.B ENV
|
||||||
|
@ -2274,26 +2270,34 @@ for this value which cannot be exceeded.)
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
.SM VISUAL
|
.SM VISUAL
|
||||||
If the value of this variable matches the pattern
|
The value of this variable is scanned when the shell is invoked
|
||||||
.IR *[Vv][Ii]* ,
|
and whenever its value is changed;
|
||||||
then the
|
if it is found to match certain patterns,
|
||||||
.B vi
|
the corresponding line editor
|
||||||
option
|
(see
|
||||||
(see Special Command
|
.I In-line Editing Options
|
||||||
.B set
|
|
||||||
below)
|
below)
|
||||||
is turned on.
|
is activated.
|
||||||
If the value matches the pattern
|
If it matches the pattern
|
||||||
.I *gmacs* ,
|
.IR *[Vv][Ii]* ,
|
||||||
|
the
|
||||||
|
.B vi
|
||||||
|
option is turned on;
|
||||||
|
else if it matches the pattern
|
||||||
|
.IR *gmacs* ,
|
||||||
the
|
the
|
||||||
.B gmacs
|
.B gmacs
|
||||||
option is turned on.
|
option is turned on;
|
||||||
If the value matches the pattern
|
else if it matches the pattern
|
||||||
.IR *macs* ,
|
.IR *macs* ,
|
||||||
then the
|
the
|
||||||
.B emacs
|
.B emacs
|
||||||
option
|
option is turned on.
|
||||||
will be turned on.
|
If none of the patterns match,
|
||||||
|
.B emacs
|
||||||
|
is turned on by default upon initializing an interactive shell.
|
||||||
|
If the value is changed by assignment and none of the patterns match,
|
||||||
|
no options are changed.
|
||||||
The value of
|
The value of
|
||||||
.B
|
.B
|
||||||
.SM VISUAL
|
.SM VISUAL
|
||||||
|
@ -4710,7 +4714,7 @@ If either the
|
||||||
or
|
or
|
||||||
.B vi
|
.B vi
|
||||||
option is active, the user can edit the command line.
|
option is active, the user can edit the command line.
|
||||||
To be in either of these edit modes
|
To be in either of these edit modes,
|
||||||
.B set
|
.B set
|
||||||
the corresponding
|
the corresponding
|
||||||
option.
|
option.
|
||||||
|
@ -4720,8 +4724,11 @@ An editing option is automatically selected each time the
|
||||||
or
|
or
|
||||||
.SM
|
.SM
|
||||||
.B EDITOR
|
.B EDITOR
|
||||||
variable is assigned a value ending in either of these
|
variable is assigned a value matching any of these editor names;
|
||||||
option names.
|
for details, see
|
||||||
|
.I Shell Variables
|
||||||
|
above under
|
||||||
|
.BR VISUAL .
|
||||||
.PP
|
.PP
|
||||||
The editing features require that the user's terminal
|
The editing features require that the user's terminal
|
||||||
accept `RETURN' as carriage return without line feed
|
accept `RETURN' as carriage return without line feed
|
||||||
|
@ -4742,8 +4749,8 @@ at least 8 columns to enter input, the prompt is truncated from the
|
||||||
left.
|
left.
|
||||||
If the line is longer than the window width minus two, a mark is
|
If the line is longer than the window width minus two, a mark is
|
||||||
displayed at the end of the window to notify the user.
|
displayed at the end of the window to notify the user.
|
||||||
As the cursor moves and reaches the window boundaries the window will be
|
As the cursor moves and reaches the window boundaries,
|
||||||
centered about the cursor.
|
the window will be centered about the cursor.
|
||||||
The mark is a
|
The mark is a
|
||||||
.BR > " (<" ,
|
.BR > " (<" ,
|
||||||
.BR * )
|
.BR * )
|
||||||
|
|
|
@ -346,7 +346,18 @@ int sh_main(int ac, char *av[], Shinit_f userinit)
|
||||||
fixargs(sh.st.dolv,1);
|
fixargs(sh.st.dolv,1);
|
||||||
}
|
}
|
||||||
if(sh_isoption(SH_INTERACTIVE))
|
if(sh_isoption(SH_INTERACTIVE))
|
||||||
|
{
|
||||||
sh_onstate(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);
|
nv_putval(IFSNOD,(char*)e_sptbnl,NV_RDONLY);
|
||||||
exfile(iop,fdin);
|
exfile(iop,fdin);
|
||||||
sh_done(0);
|
sh_done(0);
|
||||||
|
|
|
@ -471,9 +471,11 @@ L raw Bourne mode literal tab characters
|
||||||
# characters to spaces on the command line. See slowread() in io.c.
|
# characters to spaces on the command line. See slowread() in io.c.
|
||||||
|
|
||||||
p :test-1:
|
p :test-1:
|
||||||
w true /de\tv/nu\tl\tl
|
w set +o emacs 2>/dev/null
|
||||||
r ^:test-1: true (/de\tv/nu\tl\tl|/de v/nu l l)\r\n$
|
|
||||||
p :test-2:
|
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 <<"!"
|
VISUAL='' tst $LINENO <<"!"
|
||||||
|
@ -483,13 +485,15 @@ L raw Bourne mode backslash handling
|
||||||
# This is tested with both erase and kill characters.
|
# This is tested with both erase and kill characters.
|
||||||
|
|
||||||
p :test-1:
|
p :test-1:
|
||||||
w stty erase ^H kill ^X
|
w set +o emacs 2>/dev/null
|
||||||
p :test-2:
|
p :test-2:
|
||||||
w true string\\\\\cH\cH
|
w stty erase ^H kill ^X
|
||||||
r ^:test-2: true string\r\n$
|
|
||||||
p :test-3:
|
p :test-3:
|
||||||
|
w true string\\\\\cH\cH
|
||||||
|
r ^:test-3: true string\r\n$
|
||||||
|
p :test-4:
|
||||||
w true incorrect\\\cXtrue correct
|
w true incorrect\\\cXtrue correct
|
||||||
r ^:test-3: true correct\r\n$
|
r ^:test-4: true correct\r\n$
|
||||||
!
|
!
|
||||||
|
|
||||||
set --
|
set --
|
||||||
|
|
Loading…
Reference in a new issue