oksh-noxz

[fork] Portable OpenBSD ksh, based on the Public Domain Korn Shell (pdksh).
git clone https://noxz.tech/git/oksh-noxz.git
oksh-noxz

commit: 97322363ca0d06efdcd7af8b42e93f885a3acec1
parent: 27efeb20ba7f7ae11d0f94215bc3bf36f04cc080
author: Brian Callahan <bcallah@openbsd.org>
date:   Wed, 10 Mar 2021 16:27:08 -0500
Chase two commits made earlier today.
They fix an issue first reported here.

CVSROOT:	/cvs
Module name:	src
Changes by:	millert@cvs.openbsd.org	2021/03/10 13:06:04

Modified files:
	bin/ksh        : vi.c

Log message:
Fix redrawing of a multiline PS1 prompt in vi mode.
From gotroyb127 OK tb@

---

CVSROOT:	/cvs
Module name:	src
Changes by:	millert@cvs.openbsd.org	2021/03/10 13:17:34

Modified files:
	bin/ksh        : ksh.1 vi.c

Log message:
Add support for ^R (redraw) in insert mode too.
From gotroyb127, OK tb@

---

Fix #54
MCVS/Entries8++++----
Mksh.121++++++++++++++++++--
Moksh.121++++++++++++++++++--
Mvi.c17++++++++--------
4 files changed, 51 insertions(+), 16 deletions(-)
diff --git a/CVS/Entries b/CVS/Entries
@@ -11,13 +11,10 @@
 /sh.h/1.76/Result of merge//
 /eval.c/1.66/Result of merge//
 /misc.c/1.76/Result of merge//
-/vi.c/1.57/Sat Oct 31 00:41:35 2020//
 /CONTRIBUTORS/1.11/Sat Mar  6 16:35:13 2021//
 /LEGAL/1.2/Sat Mar  6 16:35:13 2021//
-/Makefile/1.39/Sat Mar  6 16:35:19 2021//
 /NOTES/1.16/Sat Mar  6 16:35:13 2021//
 /PROJECTS/1.9/Sat Mar  6 16:35:13 2021//
-/README/1.16/Sat Mar  6 16:35:19 2021//
 /alloc.c/1.19/Sat Mar  6 16:35:13 2021//
 /c_ksh.c/1.62/Sat Mar  6 16:35:13 2021//
 /c_sh.c/1.64/Sat Mar  6 16:35:13 2021//
@@ -27,7 +24,6 @@
 /expand.h/1.15/Sat Mar  6 16:35:13 2021//
 /expr.c/1.34/Sat Mar  6 16:35:13 2021//
 /jobs.c/1.62/Sat Mar  6 16:35:13 2021//
-/ksh.1/1.210/Sat Mar  6 16:35:13 2021//
 /lex.c/1.78/Sat Mar  6 16:35:13 2021//
 /lex.h/1.21/Sat Mar  6 16:35:13 2021//
 /mail.c/1.27/Sat Mar  6 16:35:13 2021//
@@ -43,4 +39,8 @@
 /tty.h/1.6/Sat Mar  6 16:35:13 2021//
 /var.c/1.72/Result of merge//
 /version.c/1.12/Sat Mar  6 16:35:13 2021//
+/Makefile/1.39/Wed Mar 10 21:24:19 2021//
+/README/1.16/Wed Mar 10 21:24:19 2021//
+/ksh.1/1.212/Wed Mar 10 21:24:19 2021//
+/vi.c/1.58/Result of merge//
 D
diff --git a/ksh.1 b/ksh.1
@@ -1,8 +1,8 @@
-.\"	$OpenBSD: ksh.1,v 1.210 2020/09/20 14:40:45 millert Exp $
+.\"	$OpenBSD: ksh.1,v 1.212 2021/03/08 06:20:50 jsg Exp $
 .\"
 .\"	Public Domain
 .\"
-.Dd $Mdocdate: September 20 2020 $
+.Dd $Mdocdate: March 8 2021 $
 .Dt KSH 1
 .Os
 .Sh NAME
@@ -5560,6 +5560,23 @@ Privileged shell profile.
 .Xr environ 7 ,
 .Xr script 7
 .Rs
+.%A S. R. Bourne
+.%T The UNIX Shell
+.%J Bell System Technical Journal
+.%V 57:6
+.%P pp. 1971-1990
+.%D 1978
+.Re
+.Rs
+.\" 4.4BSD USD:3
+.%A S. R. Bourne
+.%T An Introduction to the UNIX Shell
+.%I AT&T Bell Laboratories
+.%R Computing Science Technical Report
+.%N 70
+.%D 1978
+.Re
+.Rs
 .%A Morris Bolsky
 .%A David Korn
 .%B The KornShell Command and Programming Language
diff --git a/oksh.1 b/oksh.1
@@ -1,8 +1,8 @@
-.\"	$OpenBSD: ksh.1,v 1.210 2020/09/20 14:40:45 millert Exp $
+.\"	$OpenBSD: ksh.1,v 1.212 2021/03/08 06:20:50 jsg Exp $
 .\"
 .\"	Public Domain
 .\"
-.Dd $Mdocdate: September 20 2020 $
+.Dd $Mdocdate: March 8 2021 $
 .Dt OKSH 1
 .Os
 .Sh NAME
@@ -5560,6 +5560,23 @@ Privileged shell profile.
 .Xr environ 7 ,
 .Xr script 7
 .Rs
+.%A S. R. Bourne
+.%T The UNIX Shell
+.%J Bell System Technical Journal
+.%V 57:6
+.%P pp. 1971-1990
+.%D 1978
+.Re
+.Rs
+.\" 4.4BSD USD:3
+.%A S. R. Bourne
+.%T An Introduction to the UNIX Shell
+.%I AT&T Bell Laboratories
+.%R Computing Science Technical Report
+.%N 70
+.%D 1978
+.Re
+.Rs
 .%A Morris Bolsky
 .%A David Korn
 .%B The KornShell Command and Programming Language
diff --git a/vi.c b/vi.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: vi.c,v 1.57 2020/09/20 14:40:45 millert Exp $	*/
+/*	$OpenBSD: vi.c,v 1.58 2021/03/10 20:06:04 millert Exp $	*/
 
 /*
  *	vi command editing
@@ -62,7 +62,7 @@ static int	Endword(int);
 static int	grabhist(int, int);
 static int	grabsearch(int, int, int, char *);
 static void	do_clear_screen(void);
-static void	redraw_line(int);
+static void	redraw_line(int, int);
 static void	refresh_line(int);
 static int	outofwin(void);
 static void	rewindow(void);
@@ -726,7 +726,7 @@ vi_cmd(int argcnt, const char *cmd)
 			break;
 
 		case CTRL('r'):
-			redraw_line(1);
+			redraw_line(1, 0);
 			break;
 
 		case '@':
@@ -1744,18 +1744,19 @@ do_clear_screen(void)
 			neednl = 0;
 	}
 #endif
-	redraw_line(neednl);
+	/* Only print the full prompt if we cleared the screen. */
+	redraw_line(neednl, !neednl);
 }
 
 static void
-redraw_line(int neednl)
+redraw_line(int neednl, int full)
 {
 	(void) memset(wbuf[win], ' ', wbuf_len);
 	if (neednl) {
 		x_putc('\r');
 		x_putc('\n');
 	}
-	vi_pprompt(0);
+	vi_pprompt(full);
 	cur_col = pwidth;
 	morec = ' ';
 }
@@ -2116,7 +2117,7 @@ complete_word(int command, int count)
 			vi_error();
 			x_print_expansions(nwords, words, is_command);
 			x_free_words(nwords, words);
-			redraw_line(0);
+			redraw_line(0, 0);
 			return -1;
 		}
 		/*
@@ -2190,7 +2191,7 @@ print_expansions(struct edstate *e)
 	}
 	x_print_expansions(nwords, words, is_command);
 	x_free_words(nwords, words);
-	redraw_line(0);
+	redraw_line(0, 0);
 	return 0;
 }