bring back the 'version' editing command at "ESC ^V" like AT&T ksh93+r
This commit is contained in:
parent
711496f6fb
commit
db107a9b05
4
check.t
4
check.t
|
@ -1,4 +1,4 @@
|
||||||
# $MirOS: src/bin/mksh/check.t,v 1.47 2006/07/23 14:35:43 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.48 2006/08/01 12:44:16 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 $
|
||||||
|
@ -3784,5 +3784,5 @@ category: pdksh
|
||||||
stdin:
|
stdin:
|
||||||
echo $KSH_VERSION
|
echo $KSH_VERSION
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)MIRBSD KSH R27 2006/07/23
|
@(#)MIRBSD KSH R27 2006/08/01
|
||||||
---
|
---
|
||||||
|
|
83
edit.c
83
edit.c
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.23 2006/07/11 14:51:01 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.24 2006/08/01 12:44:16 tg Exp $");
|
||||||
|
|
||||||
/* tty driver characters we are interested in */
|
/* tty driver characters we are interested in */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -47,6 +47,10 @@ static void x_sigwinch(int);
|
||||||
static volatile sig_atomic_t got_sigwinch;
|
static volatile sig_atomic_t got_sigwinch;
|
||||||
static void check_sigwinch(void);
|
static void check_sigwinch(void);
|
||||||
|
|
||||||
|
static int path_order_cmp(const void *aa, const void *bb);
|
||||||
|
static char *add_glob(const char *, int);
|
||||||
|
static void glob_table(const char *, XPtrV *, struct table *);
|
||||||
|
static void glob_path(int flags, const char *, XPtrV *, const char *);
|
||||||
static int x_file_glob(int, const char *, int, char ***);
|
static int x_file_glob(int, const char *, int, char ***);
|
||||||
static int x_command_glob(int, const char *, int, char ***);
|
static int x_command_glob(int, const char *, int, char ***);
|
||||||
static int x_locate_word(const char *, int, int, int *, int *);
|
static int x_locate_word(const char *, int, int, int *, int *);
|
||||||
|
@ -316,10 +320,6 @@ x_do_comment(char *buf, int bsize, int *lenp)
|
||||||
/* Common file/command completion code for vi/emacs */
|
/* Common file/command completion code for vi/emacs */
|
||||||
|
|
||||||
|
|
||||||
static char *add_glob(const char *, int);
|
|
||||||
static void glob_table(const char *, XPtrV *, struct table *);
|
|
||||||
static void glob_path(int flags, const char *, XPtrV *, const char *);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
x_print_expansions(int nwords, char * const *words, int is_command)
|
x_print_expansions(int nwords, char * const *words, int is_command)
|
||||||
{
|
{
|
||||||
|
@ -455,8 +455,6 @@ struct path_order_info {
|
||||||
int path_order;
|
int path_order;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int path_order_cmp(const void *aa, const void *bb);
|
|
||||||
|
|
||||||
/* Compare routine used in x_command_glob() */
|
/* Compare routine used in x_command_glob() */
|
||||||
static int
|
static int
|
||||||
path_order_cmp(const void *aa, const void *bb)
|
path_order_cmp(const void *aa, const void *bb)
|
||||||
|
@ -995,6 +993,11 @@ static char *x_lastcp(void);
|
||||||
static void do_complete(int, Comp_type);
|
static void do_complete(int, Comp_type);
|
||||||
static int x_emacs_putbuf(const char *, size_t);
|
static int x_emacs_putbuf(const char *, size_t);
|
||||||
|
|
||||||
|
static int unget_char = -1;
|
||||||
|
|
||||||
|
static int x_do_ins(const char *, int);
|
||||||
|
static void bind_if_not_bound(int, int, int);
|
||||||
|
|
||||||
#define XFUNC_abort 0
|
#define XFUNC_abort 0
|
||||||
#define XFUNC_beg_hist 1
|
#define XFUNC_beg_hist 1
|
||||||
#define XFUNC_comp_comm 2
|
#define XFUNC_comp_comm 2
|
||||||
|
@ -1050,6 +1053,7 @@ static int x_emacs_putbuf(const char *, size_t);
|
||||||
#define XFUNC_fold_upper 52
|
#define XFUNC_fold_upper 52
|
||||||
#define XFUNC_set_arg 53
|
#define XFUNC_set_arg 53
|
||||||
#define XFUNC_comment 54
|
#define XFUNC_comment 54
|
||||||
|
#define XFUNC_version 55
|
||||||
|
|
||||||
static int x_abort (int);
|
static int x_abort (int);
|
||||||
static int x_beg_hist (int);
|
static int x_beg_hist (int);
|
||||||
|
@ -1106,6 +1110,7 @@ static int x_fold_lower (int);
|
||||||
static int x_fold_upper (int);
|
static int x_fold_upper (int);
|
||||||
static int x_set_arg (int);
|
static int x_set_arg (int);
|
||||||
static int x_comment (int);
|
static int x_comment (int);
|
||||||
|
static int x_version (int);
|
||||||
|
|
||||||
static const struct x_ftab x_ftab[] = {
|
static const struct x_ftab x_ftab[] = {
|
||||||
{ x_abort, "abort", 0 },
|
{ x_abort, "abort", 0 },
|
||||||
|
@ -1163,6 +1168,7 @@ static const struct x_ftab x_ftab[] = {
|
||||||
{ x_fold_upper, "upcase-word", XF_ARG },
|
{ x_fold_upper, "upcase-word", XF_ARG },
|
||||||
{ x_set_arg, "set-arg", XF_NOBIND },
|
{ x_set_arg, "set-arg", XF_NOBIND },
|
||||||
{ x_comment, "comment", 0 },
|
{ x_comment, "comment", 0 },
|
||||||
|
{ x_version, "version", 0 },
|
||||||
{ 0, NULL, 0 }
|
{ 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1219,6 +1225,7 @@ static struct x_defbindings const x_defbindings[] = {
|
||||||
{ XFUNC_kill_region, 0, MKCTRL('W') },
|
{ XFUNC_kill_region, 0, MKCTRL('W') },
|
||||||
{ XFUNC_xchg_point_mark, 2, MKCTRL('X') },
|
{ XFUNC_xchg_point_mark, 2, MKCTRL('X') },
|
||||||
{ XFUNC_literal, 0, MKCTRL('V') },
|
{ XFUNC_literal, 0, MKCTRL('V') },
|
||||||
|
{ XFUNC_version, 1, MKCTRL('V') },
|
||||||
{ XFUNC_prev_histword, 1, '.' },
|
{ XFUNC_prev_histword, 1, '.' },
|
||||||
{ XFUNC_prev_histword, 1, '_' },
|
{ XFUNC_prev_histword, 1, '_' },
|
||||||
{ XFUNC_set_arg, 1, '0' },
|
{ XFUNC_set_arg, 1, '0' },
|
||||||
|
@ -1351,8 +1358,6 @@ x_ins_string(int c)
|
||||||
return KSTD;
|
return KSTD;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int x_do_ins(const char *cp, int len);
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
x_do_ins(const char *cp, int len)
|
x_do_ins(const char *cp, int len)
|
||||||
{
|
{
|
||||||
|
@ -2349,8 +2354,6 @@ x_init_emacs(void)
|
||||||
Flag(FEMACSUSEMETA) = 0;
|
Flag(FEMACSUSEMETA) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bind_if_not_bound(int p, int k, int func);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
bind_if_not_bound(int p, int k, int func)
|
bind_if_not_bound(int p, int k, int func)
|
||||||
{
|
{
|
||||||
|
@ -2574,7 +2577,6 @@ do_complete(int flags, /* XCF_{COMMAND,FILE,COMMAND_FILE} */
|
||||||
* RETURN VALUE:
|
* RETURN VALUE:
|
||||||
* None
|
* None
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
x_adjust(void)
|
x_adjust(void)
|
||||||
{
|
{
|
||||||
|
@ -2589,8 +2591,6 @@ x_adjust(void)
|
||||||
x_flush();
|
x_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int unget_char = -1;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
x_e_ungetc(int c)
|
x_e_ungetc(int c)
|
||||||
{
|
{
|
||||||
|
@ -2660,7 +2660,6 @@ x_e_puts(const char *s)
|
||||||
* RETURN VALUE:
|
* RETURN VALUE:
|
||||||
* KSTD
|
* KSTD
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
x_set_arg(int c)
|
x_set_arg(int c)
|
||||||
{
|
{
|
||||||
|
@ -2682,7 +2681,6 @@ x_set_arg(int c)
|
||||||
return KSTD;
|
return KSTD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Comment or uncomment the current line. */
|
/* Comment or uncomment the current line. */
|
||||||
static int
|
static int
|
||||||
x_comment(int c __attribute__((unused)))
|
x_comment(int c __attribute__((unused)))
|
||||||
|
@ -2704,6 +2702,37 @@ x_comment(int c __attribute__((unused)))
|
||||||
return KSTD;
|
return KSTD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
x_version(int c __attribute__((unused)))
|
||||||
|
{
|
||||||
|
char *o_xbuf = xbuf, *o_xend = xend;
|
||||||
|
char *o_xbp = xbp, *o_xep = xep, *o_xcp = xcp;
|
||||||
|
int lim = x_lastcp() - xbp;
|
||||||
|
char *v = strdup(MKSH_VERSION + 4);
|
||||||
|
int vlen;
|
||||||
|
|
||||||
|
xbuf = xbp = xcp = v;
|
||||||
|
xend = xep = v + (vlen = strlen(v));
|
||||||
|
x_redraw(lim);
|
||||||
|
x_flush();
|
||||||
|
|
||||||
|
c = x_e_getc();
|
||||||
|
xbuf = o_xbuf;
|
||||||
|
xend = o_xend;
|
||||||
|
xbp = o_xbp;
|
||||||
|
xep = o_xep;
|
||||||
|
xcp = o_xcp;
|
||||||
|
x_redraw(vlen);
|
||||||
|
|
||||||
|
if (c < 0)
|
||||||
|
return KSTD;
|
||||||
|
/* This is what at&t ksh seems to do... Very bizarre */
|
||||||
|
if (c != ' ')
|
||||||
|
x_e_ungetc(c);
|
||||||
|
|
||||||
|
free(v);
|
||||||
|
return KSTD;
|
||||||
|
}
|
||||||
|
|
||||||
/* NAME:
|
/* NAME:
|
||||||
* x_prev_histword - recover word from prev command
|
* x_prev_histword - recover word from prev command
|
||||||
|
@ -2719,7 +2748,6 @@ x_comment(int c __attribute__((unused)))
|
||||||
* RETURN VALUE:
|
* RETURN VALUE:
|
||||||
* KSTD
|
* KSTD
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
x_prev_histword(int c __attribute__((unused)))
|
x_prev_histword(int c __attribute__((unused)))
|
||||||
{
|
{
|
||||||
|
@ -2798,7 +2826,6 @@ x_fold_capitalize(int c __attribute__((unused)))
|
||||||
* RETURN VALUE:
|
* RETURN VALUE:
|
||||||
* None
|
* None
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
x_fold_case(int c)
|
x_fold_case(int c)
|
||||||
{
|
{
|
||||||
|
@ -2865,7 +2892,6 @@ x_fold_case(int c)
|
||||||
* RETURN VALUE:
|
* RETURN VALUE:
|
||||||
* cp or NULL
|
* cp or NULL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
x_lastcp(void)
|
x_lastcp(void)
|
||||||
{
|
{
|
||||||
|
@ -3004,6 +3030,7 @@ const unsigned char classify[128] = {
|
||||||
#define VREDO 7 /* . */
|
#define VREDO 7 /* . */
|
||||||
#define VLIT 8 /* ^V */
|
#define VLIT 8 /* ^V */
|
||||||
#define VSEARCH 9 /* /, ? */
|
#define VSEARCH 9 /* /, ? */
|
||||||
|
#define VVERSION 10 /* <ESC> ^V */
|
||||||
|
|
||||||
static char undocbuf[LINE];
|
static char undocbuf[LINE];
|
||||||
|
|
||||||
|
@ -3088,7 +3115,7 @@ x_vi(char *buf, size_t len)
|
||||||
trapsig(c == edchars.intr ? SIGINT : SIGQUIT);
|
trapsig(c == edchars.intr ? SIGINT : SIGQUIT);
|
||||||
x_mode(false);
|
x_mode(false);
|
||||||
unwind(LSHELL);
|
unwind(LSHELL);
|
||||||
} else if (c == edchars.eof) {
|
} else if (c == edchars.eof && state != VVERSION) {
|
||||||
if (es->linelen == 0) {
|
if (es->linelen == 0) {
|
||||||
x_vi_zotc(edchars.eof);
|
x_vi_zotc(edchars.eof);
|
||||||
c = -1;
|
c = -1;
|
||||||
|
@ -3168,6 +3195,14 @@ vi_hook(int ch)
|
||||||
return -1;
|
return -1;
|
||||||
refresh(0);
|
refresh(0);
|
||||||
}
|
}
|
||||||
|
if (state == VVERSION) {
|
||||||
|
save_cbuf();
|
||||||
|
es->cursor = 0;
|
||||||
|
es->linelen = 0;
|
||||||
|
putbuf(MKSH_VERSION + 4,
|
||||||
|
strlen(MKSH_VERSION + 4), 0);
|
||||||
|
refresh(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -3182,6 +3217,12 @@ vi_hook(int ch)
|
||||||
state = VNORMAL;
|
state = VNORMAL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VVERSION:
|
||||||
|
restore_cbuf();
|
||||||
|
state = VNORMAL;
|
||||||
|
refresh(0);
|
||||||
|
break;
|
||||||
|
|
||||||
case VARG1:
|
case VARG1:
|
||||||
if (isdigit((unsigned char)ch))
|
if (isdigit((unsigned char)ch))
|
||||||
argc1 = argc1 * 10 + ch - '0';
|
argc1 = argc1 * 10 + ch - '0';
|
||||||
|
@ -3398,6 +3439,8 @@ nextstate(int ch)
|
||||||
return VXCH;
|
return VXCH;
|
||||||
else if (ch == '.')
|
else if (ch == '.')
|
||||||
return VREDO;
|
return VREDO;
|
||||||
|
else if (ch == Ctrl('v'))
|
||||||
|
return VVERSION;
|
||||||
else if (is_cmd(ch))
|
else if (is_cmd(ch))
|
||||||
return VCMD;
|
return VCMD;
|
||||||
else
|
else
|
||||||
|
|
23
mksh.1
23
mksh.1
|
@ -1,8 +1,8 @@
|
||||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.41 2006/07/27 14:45:30 tg Exp $
|
.\" $MirOS: src/bin/mksh/mksh.1,v 1.42 2006/08/01 12:44:17 tg Exp $
|
||||||
.\" $OpenBSD: ksh.1,v 1.112 2006/04/22 14:10:36 jmc Exp $
|
.\" $OpenBSD: ksh.1,v 1.112 2006/04/22 14:10:36 jmc Exp $
|
||||||
.\" $OpenBSD: sh.1tbl,v 1.53 2004/12/10 01:56:56 jaredy Exp $
|
.\" $OpenBSD: sh.1tbl,v 1.53 2004/12/10 01:56:56 jaredy Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd June 27, 2006
|
.Dd August 1, 2006
|
||||||
.Dt MKSH 1
|
.Dt MKSH 1
|
||||||
.Os MirBSD
|
.Os MirBSD
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -1409,6 +1409,11 @@ This parameter is not imported from the environment when the shell is
|
||||||
started.
|
started.
|
||||||
.It Ev KSH_VERSION
|
.It Ev KSH_VERSION
|
||||||
The name and version of the shell (read-only).
|
The name and version of the shell (read-only).
|
||||||
|
See also the version commands in
|
||||||
|
.Sx Emacs editing mode
|
||||||
|
and
|
||||||
|
.Sx Vi editing mode
|
||||||
|
sections, below.
|
||||||
.It Ev LINENO
|
.It Ev LINENO
|
||||||
The line number of the function or shell script that is currently being
|
The line number of the function or shell script that is currently being
|
||||||
executed.
|
executed.
|
||||||
|
@ -4521,7 +4526,7 @@ Introduces a 2-character command sequence.
|
||||||
The last
|
The last
|
||||||
.Pq Ar n Ns th
|
.Pq Ar n Ns th
|
||||||
word of the previous command is inserted at the cursor.
|
word of the previous command is inserted at the cursor.
|
||||||
.It quote: ^^
|
.It quote: ^^ , ^V
|
||||||
The following character is taken literally rather than as an editing command.
|
The following character is taken literally rather than as an editing command.
|
||||||
.It redraw: ^L
|
.It redraw: ^L
|
||||||
Reprints the prompt string and the current input line.
|
Reprints the prompt string and the current input line.
|
||||||
|
@ -4584,8 +4589,11 @@ lines (earlier).
|
||||||
Uppercase the next
|
Uppercase the next
|
||||||
.Ar n
|
.Ar n
|
||||||
words.
|
words.
|
||||||
.It quote: ^V
|
.It version: ^[^V
|
||||||
Synonym for ^^.
|
Display the version of
|
||||||
|
.Nm .
|
||||||
|
The current edit buffer is restored as soon as a key is pressed.
|
||||||
|
The restoring keypress is processed, unless it is a space.
|
||||||
.It yank: ^Y
|
.It yank: ^Y
|
||||||
Inserts the most recently killed text string at the current cursor position.
|
Inserts the most recently killed text string at the current cursor position.
|
||||||
.It yank-pop: ^[y
|
.It yank-pop: ^[y
|
||||||
|
@ -4800,6 +4808,11 @@ enumeration command).
|
||||||
.It = and ^E
|
.It = and ^E
|
||||||
Command/file name enumeration.
|
Command/file name enumeration.
|
||||||
List all the commands or files that match the current big-word.
|
List all the commands or files that match the current big-word.
|
||||||
|
.It ^V
|
||||||
|
Display the version of
|
||||||
|
.Nm .
|
||||||
|
The current edit buffer is restored as soon as a key is pressed.
|
||||||
|
The restoring keypress is ignored.
|
||||||
.It @ Ns Ar c
|
.It @ Ns Ar c
|
||||||
Macro expansion.
|
Macro expansion.
|
||||||
Execute the commands found in the alias
|
Execute the commands found in the alias
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
/* $MirOS: src/bin/mksh/version.h,v 1.1 2006/08/01 12:22:26 tg Exp $ */
|
/* $MirOS: src/bin/mksh/version.h,v 1.2 2006/08/01 12:44:17 tg Exp $ */
|
||||||
|
|
||||||
EXTERN const char MKSH_VERSION[] I__("@(#)MIRBSD KSH R27 2006/07/23");
|
EXTERN const char MKSH_VERSION[] I__("@(#)MIRBSD KSH R27 2006/08/01");
|
||||||
|
|
Loading…
Reference in New Issue