diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d02dbdcb1f9..9a1bf0c0cf8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ None at this time. ## Notable non-backward compatible changes +- Vi raw mode is now the default and cannot be disabled (issue #864). - Support for the `universe` command has been removed (issue #793). - Support for building on systems using EBCDIC has been removed (issue #742). - Support for the `LC_OPTIONS` env var has been removed (issue #579). diff --git a/src/cmd/ksh93/data/builtins.c b/src/cmd/ksh93/data/builtins.c index 7666beba86ab..7a0fc1c3175b 100644 --- a/src/cmd/ksh93/data/builtins.c +++ b/src/cmd/ksh93/data/builtins.c @@ -247,8 +247,7 @@ const char sh_set[] = "[+trackall?Equivalent to \b-h\b.]" "[+verbose?Equivalent to \b-v\b.]" "[+vi?Enables/disables \bvi\b editing mode.]" - "[+viraw?Does not use canonical input mode when using \bvi\b " - "edit mode.]" + "[+viraw?This option no longer does anything.]" "[+xtrace?Equivalent to \b-x\b.]" "}" "[p?Privileged mode. Disabling \b-p\b sets the effective user id to the " diff --git a/src/cmd/ksh93/data/options.c b/src/cmd/ksh93/data/options.c index c8074b50bfcb..33606faef42a 100644 --- a/src/cmd/ksh93/data/options.c +++ b/src/cmd/ksh93/data/options.c @@ -136,6 +136,8 @@ const Shtable_t shtab_options[] = {{"allexport", SH_ALLEXPORT}, {"nounset", SH_NOUNSET}, {"verbose", SH_VERBOSE}, {"vi", SH_VI}, + // This option is now always enabled and disabling it has no + // effect. {"viraw", SH_VIRAW}, #if SHOPT_BASH diff --git a/src/cmd/ksh93/edit/vi.c b/src/cmd/ksh93/edit/vi.c index 65c9c53e57db..694cc40647ae 100644 --- a/src/cmd/ksh93/edit/vi.c +++ b/src/cmd/ksh93/edit/vi.c @@ -166,7 +166,6 @@ static void vigetline(Vi_t *, int); static int getrchar(Vi_t *); static int mvcursor(Vi_t *, int); static void pr_string(Vi_t *, const char *); -static void putstring(Vi_t *, int, int); static void refresh(Vi_t *, int); static void replace(Vi_t *, int, int); static void restore_v(Vi_t *); @@ -183,7 +182,6 @@ static int textmod(Vi_t *, int, int); int ed_viread(void *context, int fd, char *shbuf, int nchar, int reedit) { Edit_t *ed = (Edit_t *)context; int i; // general variable - int term_char = 0; // read() termination character Vi_t *vp = ed->e_vi; char prompt[PRSIZE + 2]; // prompt genchar Physical[2 * MAXLINE]; // physical image @@ -191,9 +189,6 @@ int ed_viread(void *context, int fd, char *shbuf, int nchar, int reedit) { genchar ubuf[MAXLINE]; // used for u command genchar Window[MAXLINE]; // window image int Globals[9]; // local global variables - int esc_or_hang = 0; // or hangup - char cntl_char = 0; // TRUE if control character present -#define viraw 1 if (!vp) { ed->e_vi = vp = calloc(1, sizeof(Vi_t)); @@ -252,104 +247,6 @@ int ed_viread(void *context, int fd, char *shbuf, int nchar, int reedit) { if (nchar + plen > MAXCHAR) nchar = MAXCHAR - plen; max_col = nchar - 2; - if (!viraw) { - int kill_erase = 0; - for (i = (echoctl ? last_virt : 0); i < last_virt; ++i) { - // Change \r to \n, check for control characters, delete appropriate ^Vs, - // and estimate last physical column. - if (virtual[i] == '\r') virtual[i] = '\n'; - if (echoctl) continue; - int c = virtual[i]; - if (c <= usrerase) { - // User typed escaped erase or kill char. - cntl_char = 1; - if (is_print(c)) kill_erase++; - } else if (!is_print(c)) { - cntl_char = 1; - if (c == usrlnext) { - if (i == last_virt) { - // Eol/eof was escaped so replace ^V with it. - virtual[i] = term_char; - break; - } - - // Delete ^V. - gencpy((&virtual[i]), (&virtual[i + 1])); - --cur_virt; - --last_virt; - } - } - } - - // Copy virtual image to window. - if (last_virt > 0) last_phys = ed_virt_to_phys(vp->ed, virtual, physical, last_virt, 0, 0); - if (last_phys >= w_size) { - // Line longer than window. - vp->last_wind = w_size - 1; - } else { - vp->last_wind = last_phys; - } - genncpy(window, virtual, vp->last_wind + 1); - - if (term_char != ESC && (last_virt == INVALID || virtual[last_virt] != term_char)) { - // Line not terminated with ESC or escaped (^V) eol, so return after doing a total - // update. if( (speed is greater or equal to 1200 and something was typed) and (control - // character present or typeahead occurred). - tty_cooked(ERRIO); - if (editb.e_ttyspeed == FAST && last_virt != INVALID && (vp->typeahead || cntl_char)) { - refresh(vp, TRANSLATE); - pr_string(vp, Prompt); - putstring(vp, 0, last_phys + 1); - if (echoctl) { - ed_crlf(vp->ed); - } else { - while (kill_erase-- > 0) putchar(' '); - } - } - - if (term_char == '\n') { - if (!echoctl) ed_crlf(vp->ed); - virtual[++last_virt] = '\n'; - } - vp->last_cmd = 'i'; - save_last(vp); - virtual[last_virt + 1] = 0; - last_virt = ed_external(virtual, shbuf); - return (last_virt); - } - - // Line terminated with escape, or escaped eol/eof, so set raw mode. - if (tty_raw(ERRIO, 0) < 0) { - tty_cooked(ERRIO); - // The following prevents drivers that return 0 on causing an infinite loop. - if (esc_or_hang) return -1; - virtual[++last_virt] = '\n'; - virtual[last_virt + 1] = 0; - last_virt = ed_external(virtual, shbuf); - return last_virt; - } - - if (echoctl) { // for cntl-echo erase the ^[ - pr_string(vp, "\b\b\b\b \b\b"); - } - - if (crallowed) { - // Start over since there may be a control char, or cursor might not be at left margin - // (this lets us know where we are. - cur_phys = 0; - window[0] = '\0'; - pr_string(vp, Prompt); - if (term_char == ESC && (last_virt < 0 || virtual[last_virt] != ESC)) { - refresh(vp, CONTROL); - } else { - refresh(vp, INPUT); - } - } else { - // Just update everything internally. - refresh(vp, TRANSLATE); - } - } - // Handle usrintr, usrquit, or EOF. i = sigsetjmp(editb.e_env, 0); if (i != 0) { @@ -378,13 +275,7 @@ int ed_viread(void *context, int fd, char *shbuf, int nchar, int reedit) { vp->ofirst_wind = INVALID; refresh(vp, INPUT); } - if (viraw) { - vigetline(vp, APPEND); - } else if (last_virt >= 0 && virtual[last_virt] == term_char) { - vigetline(vp, APPEND); - } else { - vigetline(vp, ESC); - } + vigetline(vp, APPEND); if (vp->ed->e_multiline) cursor(vp, last_phys); // Add a new line if user typed unescaped \n to cause the shell to process the line. tty_cooked(ERRIO); @@ -1354,14 +1245,6 @@ static_fn void pr_string(Vi_t *vp, const char *sp) { return; } -// -// Put nchars starting at column of physical into the workspace to be printed. -// -static_fn void putstring(Vi_t *vp, int col, int nchars) { - while (nchars--) putchar(physical[col++]); - return; -} - // // This routine will refresh the crt so the physical image matches the virtual image and display the // proper window. diff --git a/src/cmd/ksh93/include/shell.h b/src/cmd/ksh93/include/shell.h index 71e6d7074eee..913cba7e8e07 100644 --- a/src/cmd/ksh93/include/shell.h +++ b/src/cmd/ksh93/include/shell.h @@ -85,6 +85,7 @@ typedef union Shnode_u Shnode_t; #define SH_MARKDIRS 15 #define SH_BGNICE 16 #define SH_VI 17 +// The "viraw" option no longer has any effect as its behavior is now always eanbled. #define SH_VIRAW 18 #define SH_TFLAG 19 #define SH_TRACKALL 20 diff --git a/src/cmd/ksh93/ksh.1 b/src/cmd/ksh93/ksh.1 index e9cdfcdd3b0d..45cd4a9c7d19 100644 --- a/src/cmd/ksh93/ksh.1 +++ b/src/cmd/ksh93/ksh.1 @@ -5230,8 +5230,6 @@ Delete previous character. .TP 10 .BI ^W Delete the previous blank separated word. -On some systems the \f3viraw\fP option -may be required for this to work. .TP 10 .I eof As the first character of the line causes @@ -5248,8 +5246,6 @@ or if not defined.) Removes the next character's editing features (if any). -On some systems the \f3viraw\fP option -may be required for this to work. .TP 10 .BI \e Escape the next @@ -7261,6 +7257,7 @@ Each character is processed as it is typed in .I vi\^ mode. +This is now always enabled. Disabling the option at run time has no effect. .TP 8 .B xtrace Same as diff --git a/src/cmd/ksh93/sh/args.c b/src/cmd/ksh93/sh/args.c index 55b106c6cf80..1517c17c6b30 100644 --- a/src/cmd/ksh93/sh/args.c +++ b/src/cmd/ksh93/sh/args.c @@ -812,7 +812,6 @@ void sh_printopts(Shell_t *shp, Shopt_t oflags, int mode, Shopt_t *mask) { return; } - on_option(&oflags, SH_VIRAW); if (!(mode & (PRINT_ALL | PRINT_VERBOSE))) { // only print set options if (mode & PRINT_SHOPT) { sfwrite(sfstdout, "shopt -s", 3); diff --git a/src/cmd/ksh93/sh/bash.c b/src/cmd/ksh93/sh/bash.c index 9b0bc50d3872..5bfb92d83341 100644 --- a/src/cmd/ksh93/sh/bash.c +++ b/src/cmd/ksh93/sh/bash.c @@ -205,7 +205,6 @@ int b_shopt(int argc, char *argv[], Shbltin_t *extra) { int setflag = 0, quietflag = 0, oflag = 0; memset(&opt, 0, sizeof(opt)); - on_option(&newflags, SH_VIRAW); while ((n = optget(argv, sh_optshopt))) { switch (n) { case 'p': { diff --git a/src/cmd/ksh93/sh/init.c b/src/cmd/ksh93/sh/init.c index 625f6060d449..8ae8df9fdf9a 100644 --- a/src/cmd/ksh93/sh/init.c +++ b/src/cmd/ksh93/sh/init.c @@ -1519,7 +1519,6 @@ int sh_reinit_20120720(Shell_t *shp, char *argv[]) { if (sh_isoption(shp, SH_EMACS)) on_option(&opt, SH_EMACS); if (sh_isoption(shp, SH_GMACS)) on_option(&opt, SH_GMACS); if (sh_isoption(shp, SH_VI)) on_option(&opt, SH_VI); - if (sh_isoption(shp, SH_VIRAW)) on_option(&opt, SH_VIRAW); shp->options = opt; // Set up new args. if (argv) shp->arglist = sh_argcreate(argv); diff --git a/src/cmd/ksh93/sh/jobs.c b/src/cmd/ksh93/sh/jobs.c index 1f4dd1d5ca80..c30ab307567e 100644 --- a/src/cmd/ksh93/sh/jobs.c +++ b/src/cmd/ksh93/sh/jobs.c @@ -615,7 +615,6 @@ void job_init(Shell_t *shp, int lflag) { #endif /* FIOLOOKLD */ if (job.linedisc != NTTYDISC && job.linedisc != OTTYDISC) { // No job control when running with MPX. - sh_onoption(shp, SH_VIRAW); return; } if (job.linedisc == NTTYDISC) job.linedisc = -1;