when doing a history search (^R), restore old input line on

abortion (^G – ^C is SIGINT and doesn’t work like this, but
that’s actually good IMO)

prompted by enquiry about the Emacs editing mode by <smultron:#MidnightBSD>
This commit is contained in:
tg 2008-10-19 20:15:45 +00:00
parent 9be489ea90
commit 2fc9fb99d7
4 changed files with 14 additions and 7 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.231 2008/10/15 10:24:59 tg Exp $ # $MirOS: src/bin/mksh/check.t,v 1.232 2008/10/19 20:15:42 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $ # $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -7,7 +7,7 @@
# http://www.research.att.com/~gsf/public/ifs.sh # http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout: expected-stdout:
@(#)MIRBSD KSH R35 2008/10/15 @(#)MIRBSD KSH R35 2008/10/19
description: description:
Check version of shell. Check version of shell.
stdin: stdin:

6
edit.c
View File

@ -5,7 +5,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.138 2008/10/13 23:06:02 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/edit.c,v 1.139 2008/10/19 20:15:43 tg Exp $");
/* tty driver characters we are interested in */ /* tty driver characters we are interested in */
typedef struct { typedef struct {
@ -2202,6 +2202,10 @@ x_search_hist(int c)
} }
} }
offset = x_search(pat, 0, offset); offset = x_search(pat, 0, offset);
} else if (f == XFUNC_abort) {
if (offset >= 0)
x_load_hist(histptr + 1);
break;
} else { /* other command */ } else { /* other command */
x_e_ungetc(c); x_e_ungetc(c);
break; break;

7
mksh.1
View File

@ -1,4 +1,4 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.140 2008/10/04 23:22:13 tg Exp $ .\" $MirOS: src/bin/mksh/mksh.1,v 1.141 2008/10/19 20:15:44 tg Exp $
.\" $OpenBSD: ksh.1,v 1.122 2008/05/17 23:31:52 sobrado Exp $ .\" $OpenBSD: ksh.1,v 1.122 2008/05/17 23:31:52 sobrado Exp $
.\"- .\"-
.\" Try to make GNU groff and AT&T nroff more compatible .\" Try to make GNU groff and AT&T nroff more compatible
@ -30,7 +30,7 @@
.el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 .el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8
.. ..
.\"- .\"-
.Dd $Mdocdate: October 4 2008 $ .Dd $Mdocdate: October 19 2008 $
.Dt MKSH 1 .Dt MKSH 1
.Os MirBSD .Os MirBSD
.Sh NAME .Sh NAME
@ -4840,6 +4840,9 @@ followed by a
or or
.Ic prefix\-2 .Ic prefix\-2
key will be executed after leaving search mode. key will be executed after leaving search mode.
The
.Ic abort Pq \*(haG
command will restore the input line before search started.
Successive Successive
.Ic search\-history .Ic search\-history
commands continue searching backward to the next previous occurrence of the commands continue searching backward to the next previous occurrence of the

4
sh.h
View File

@ -100,9 +100,9 @@
#define __SCCSID(x) __IDSTRING(sccsid,x) #define __SCCSID(x) __IDSTRING(sccsid,x)
#ifdef EXTERN #ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.241 2008/10/15 10:25:01 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.242 2008/10/19 20:15:45 tg Exp $");
#endif #endif
#define MKSH_VERSION "R35 2008/10/15" #define MKSH_VERSION "R35 2008/10/19"
#ifndef MKSH_INCLUDES_ONLY #ifndef MKSH_INCLUDES_ONLY