summaryrefslogtreecommitdiff
path: root/bin/ksh
diff options
context:
space:
mode:
authorChristian Weisgerber <naddy@cvs.openbsd.org>2003-09-01 15:47:41 +0000
committerChristian Weisgerber <naddy@cvs.openbsd.org>2003-09-01 15:47:41 +0000
commit02de0a76104fd5d7d72eba532f459d3379e9603f (patch)
tree3e71879eb4f55ace7faef2b1dca1a399334a14e4 /bin/ksh
parent60ed2c841bf7d745690289837c45a85fdac0ce62 (diff)
In emacs editing mode, ksh by default interprets a set 8th bit as
meta prefix, i.e. all characters with the top bit set (>= 0x80) are taken as commands and cannot be entered literally. Introduce a new shell option, emacs-usemeta, that allows to toggle this behavior. The default is the traditional behavior; to enter 8-bit characters use "set +o emacs-usemeta". ok fgsch@, henning@
Diffstat (limited to 'bin/ksh')
-rw-r--r--bin/ksh/emacs.c7
-rw-r--r--bin/ksh/ksh.18
-rw-r--r--bin/ksh/ksh.1tbl8
-rw-r--r--bin/ksh/misc.c3
-rw-r--r--bin/ksh/sh.h3
5 files changed, 17 insertions, 12 deletions
diff --git a/bin/ksh/emacs.c b/bin/ksh/emacs.c
index 02097c86659..9f042779465 100644
--- a/bin/ksh/emacs.c
+++ b/bin/ksh/emacs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: emacs.c,v 1.26 2003/08/27 14:56:11 fgsch Exp $ */
+/* $OpenBSD: emacs.c,v 1.27 2003/09/01 15:47:40 naddy Exp $ */
/*
* Emacs-like command line editing and history
@@ -25,7 +25,7 @@ static Area aedit;
#define CTRL(x) ((x) == '?' ? 0x7F : (x) & 0x1F) /* ASCII */
#define UNCTRL(x) ((x) == 0x7F ? '?' : (x) | 0x40) /* ASCII */
#define META(x) ((x) & 0x7f)
-#define ISMETA(x) (x_usemeta && ((x) & 0x80))
+#define ISMETA(x) (Flag(FEMACSUSEMETA) && ((x) & 0x80))
/* values returned by keyboard functions */
@@ -101,7 +101,6 @@ static int x_col;
static int x_displen;
static int x_arg; /* general purpose arg */
static int x_arg_defaulted;/* x_arg not explicitly set; defaulted to 1 */
-static int x_usemeta; /* no 8-bit ascii, meta = ESC */
static int xlp_valid;
/* end from 4.9 edit.h } */
@@ -1534,7 +1533,7 @@ x_init_emacs()
*/
locale = setlocale(LC_CTYPE, NULL);
if (locale == NULL || !strcmp(locale, "C") || !strcmp(locale, "POSIX"))
- x_usemeta = 1;
+ Flag(FEMACSUSEMETA) = 1;
}
static void bind_if_not_bound(int p, int k, int func);
diff --git a/bin/ksh/ksh.1 b/bin/ksh/ksh.1
index 7969f9e1a80..f497434e228 100644
--- a/bin/ksh/ksh.1
+++ b/bin/ksh/ksh.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ksh.1,v 1.55 2003/07/19 08:07:35 jmc Exp $
+.\" $OpenBSD: ksh.1,v 1.56 2003/09/01 15:47:40 naddy Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -3348,6 +3348,9 @@ Enable brace expansion (a.k.a., alternation).
.It Ic emacs
Enable BRL emacs-like command-line editing (interactive shells only); see
.Sx Emacs editing mode .
+.It Ic emacs-usemeta
+In emacs command-line editing, use the 8th bit as meta (^[) prefix.
+This is the default.
.It Ic gmacs
Enable gmacs-like command-line editing (interactive shells only).
Currently identical to emacs editing except that transpose (^T) acts slightly
@@ -4303,8 +4306,7 @@ When the
.Ic emacs
option is set, interactive input line editing is enabled.
Warning: This mode is
-slightly different from the emacs mode in the original Korn shell and the 8th
-bit is stripped in emacs mode.
+slightly different from the emacs mode in the original Korn shell.
In this mode, various editing commands
(typically bound to one or more control characters) cause immediate actions
without waiting for a newline.
diff --git a/bin/ksh/ksh.1tbl b/bin/ksh/ksh.1tbl
index 2515609d0ad..c710728bef7 100644
--- a/bin/ksh/ksh.1tbl
+++ b/bin/ksh/ksh.1tbl
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ksh.1tbl,v 1.55 2003/07/19 08:07:35 jmc Exp $
+.\" $OpenBSD: ksh.1tbl,v 1.56 2003/09/01 15:47:40 naddy Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -3348,6 +3348,9 @@ Enable brace expansion (a.k.a., alternation).
.It Ic emacs
Enable BRL emacs-like command-line editing (interactive shells only); see
.Sx Emacs editing mode .
+.It Ic emacs-usemeta
+In emacs command-line editing, use the 8th bit as meta (^[) prefix.
+This is the default.
.It Ic gmacs
Enable gmacs-like command-line editing (interactive shells only).
Currently identical to emacs editing except that transpose (^T) acts slightly
@@ -4303,8 +4306,7 @@ When the
.Ic emacs
option is set, interactive input line editing is enabled.
Warning: This mode is
-slightly different from the emacs mode in the original Korn shell and the 8th
-bit is stripped in emacs mode.
+slightly different from the emacs mode in the original Korn shell.
In this mode, various editing commands
(typically bound to one or more control characters) cause immediate actions
without waiting for a newline.
diff --git a/bin/ksh/misc.c b/bin/ksh/misc.c
index 832ad7ffbc7..30347e673c5 100644
--- a/bin/ksh/misc.c
+++ b/bin/ksh/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.18 2003/08/06 21:08:05 millert Exp $ */
+/* $OpenBSD: misc.c,v 1.19 2003/09/01 15:47:40 naddy Exp $ */
/*
* Miscellaneous functions
@@ -141,6 +141,7 @@ const struct option options[] = {
{ (char *) 0, 'c', OF_CMDLINE },
#ifdef EMACS
{ "emacs", 0, OF_ANY },
+ { "emacs-usemeta", 0, OF_ANY }, /* non-standard */
#endif
{ "errexit", 'e', OF_ANY },
#ifdef EMACS
diff --git a/bin/ksh/sh.h b/bin/ksh/sh.h
index 83975878773..48ce14570ea 100644
--- a/bin/ksh/sh.h
+++ b/bin/ksh/sh.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sh.h,v 1.13 2003/05/16 19:58:57 jsyn Exp $ */
+/* $OpenBSD: sh.h,v 1.14 2003/09/01 15:47:40 naddy Exp $ */
/*
* Public Domain Bourne/Korn shell
@@ -474,6 +474,7 @@ enum sh_flag {
FCOMMAND, /* -c: (invocation) execute specified command */
#ifdef EMACS
FEMACS, /* emacs command editing */
+ FEMACSUSEMETA, /* use 8th bit as meta */
#endif
FERREXIT, /* -e: quit on error */
#ifdef EMACS