diff --git a/NEWS b/NEWS index b52cc56d3..2e06fe309 100644 --- a/NEWS +++ b/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. +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: - Improved keyboard support for the vi and emacs built-in line editors: diff --git a/src/cmd/ksh93/include/version.h b/src/cmd/ksh93/include/version.h index 2dd38c2bc..c66fb0022 100644 --- a/src/cmd/ksh93/include/version.h +++ b/src/cmd/ksh93/include/version.h @@ -21,7 +21,7 @@ #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_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 /* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */ diff --git a/src/cmd/ksh93/sh.1 b/src/cmd/ksh93/sh.1 index 537b7b706..8ec08e19c 100644 --- a/src/cmd/ksh93/sh.1 +++ b/src/cmd/ksh93/sh.1 @@ -1848,15 +1848,11 @@ If the .B .SM VISUAL variable is not set, -the value of this variable will be checked for the patterns -as described with +the value of this variable will be checked for certain patterns +and the corresponding editing option will be turned on as described with .B .SM VISUAL -below and the corresponding editing option -(see Special Command -.B set -below) -will be turned on. +below. .TP .SM .B ENV @@ -2274,26 +2270,34 @@ for this value which cannot be exceeded.) .TP .B .SM VISUAL -If the value of this variable matches the pattern -.IR *[Vv][Ii]* , -then the -.B vi -option -(see Special Command -.B set +The value of this variable is scanned when the shell is invoked +and whenever its value is changed; +if it is found to match certain patterns, +the corresponding line editor +(see +.I In-line Editing Options below) -is turned on. -If the value matches the pattern -.I *gmacs* , +is activated. +If it matches the pattern +.IR *[Vv][Ii]* , +the +.B vi +option is turned on; +else if it matches the pattern +.IR *gmacs* , the .B gmacs -option is turned on. -If the value matches the pattern +option is turned on; +else if it matches the pattern .IR *macs* , -then the +the .B emacs -option -will be turned on. +option is 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 .B .SM VISUAL @@ -4710,7 +4714,7 @@ If either the or .B vi 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 the corresponding option. @@ -4720,8 +4724,11 @@ An editing option is automatically selected each time the or .SM .B EDITOR -variable is assigned a value ending in either of these -option names. +variable is assigned a value matching any of these editor names; +for details, see +.I Shell Variables +above under +.BR VISUAL . .PP The editing features require that the user's terminal 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. 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. -As the cursor moves and reaches the window boundaries the window will be -centered about the cursor. +As the cursor moves and reaches the window boundaries, +the window will be centered about the cursor. The mark is a .BR > " (<" , .BR * ) diff --git a/src/cmd/ksh93/sh/main.c b/src/cmd/ksh93/sh/main.c index 00622c3f8..4da08a3d1 100644 --- a/src/cmd/ksh93/sh/main.c +++ b/src/cmd/ksh93/sh/main.c @@ -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); diff --git a/src/cmd/ksh93/tests/pty.sh b/src/cmd/ksh93/tests/pty.sh index 5f8a91442..211d1c836 100755 --- a/src/cmd/ksh93/tests/pty.sh +++ b/src/cmd/ksh93/tests/pty.sh @@ -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 --