new MKSH_NO_CMDLINE_EDITING to disable command line editing in its entirety

mainly for the Plan 9 port though it may also help the WinAPI variant,
other porting efforts, as well as a new project I cannot say yet
This commit is contained in:
tg 2012-05-04 20:49:08 +00:00
parent 7c4bf78446
commit 5780bc5eb7
9 changed files with 42 additions and 16 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.552 2012/04/27 16:16:19 tg Exp $'
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.553 2012/05/04 20:49:00 tg Exp $'
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012
@ -1398,7 +1398,7 @@ else
#define EXTERN
#define MKSH_INCLUDES_ONLY
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.552 2012/04/27 16:16:19 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.553 2012/05/04 20:49:00 tg Exp $");
int main(void) { printf("Hello, World!\n"); return (0); }
EOF
case $cm in
@ -2092,6 +2092,7 @@ MKSH_DONT_EMIT_IDSTRING omit RCS IDs from binary
MKSH_MIDNIGHTBSD01ASH_COMPAT set -o sh: additional compatibility quirk
MKSH_NOPROSPECTOFWORK disable jobs, co-processes, etc. (do not use)
MKSH_NOPWNAM skip PAM calls, for -static on eglibc, Solaris
MKSH_NO_CMDLINE_EDITING disable command line editing code entirely
MKSH_NO_DEPRECATED_WARNING omit warning when deprecated stuff is run
MKSH_NO_EXTERNAL_CAT omit hack to skip cat builtin when flags passed
MKSH_NO_LIMITS omit ulimit code

5
edit.c
View File

@ -26,7 +26,9 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.234 2012/04/06 15:06:42 tg Exp $");
#ifndef MKSH_NO_CMDLINE_EDITING
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.235 2012/05/04 20:49:01 tg Exp $");
/*
* in later versions we might use libtermcap for this, but since external
@ -5364,6 +5366,7 @@ vi_macro_reset(void)
}
}
#endif /* !MKSH_S_NOVI */
#endif /* !MKSH_NO_CMDLINE_EDITING */
void
x_mkraw(int fd, struct termios *ocb, bool forread)

View File

@ -38,7 +38,7 @@
#endif
#endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.213 2012/05/04 20:08:24 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.214 2012/05/04 20:49:03 tg Exp $");
#if HAVE_KILLPG
/*
@ -139,7 +139,9 @@ const struct builtin mkshbuiltins[] = {
{"+bg", c_fgbg},
{"+fg", c_fgbg},
#endif
#ifndef MKSH_NO_CMDLINE_EDITING
{"bind", c_bind},
#endif
{"cat", c_cat},
#if HAVE_MKNOD
{"mknod", c_mknod},
@ -1481,6 +1483,7 @@ c_getopts(const char **wp)
return (optc < 0 ? 1 : rv);
}
#ifndef MKSH_NO_CMDLINE_EDITING
int
c_bind(const char **wp)
{
@ -1539,6 +1542,7 @@ c_bind(const char **wp)
return (rv);
}
#endif
int
c_shift(const char **wp)

View File

@ -27,7 +27,7 @@
#include <sys/file.h>
#endif
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.123 2012/04/14 16:07:47 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.124 2012/05/04 20:49:04 tg Exp $");
Trap sigtraps[NSIG + 1];
static struct sigaction Sigact_ign;
@ -475,7 +475,7 @@ hist_get_oldest(void)
return (history);
}
#if !MKSH_S_NOVI
#if !defined(MKSH_NO_CMDLINE_EDITING) && !MKSH_S_NOVI
/* current position in history[] */
static char **current;

7
lex.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.161 2012/04/07 11:19:49 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.162 2012/05/04 20:49:04 tg Exp $");
/*
* states while lexing word
@ -1382,6 +1382,7 @@ getsc_line(Source *s)
}
if (interactive)
change_winsz();
#ifndef MKSH_NO_CMDLINE_EDITING
if (have_tty && (
#if !MKSH_S_NOVI
Flag(FVI) ||
@ -1395,7 +1396,9 @@ getsc_line(Source *s)
nread = 0;
xp[nread] = '\0';
xp += nread;
} else {
} else
#endif
{
if (interactive)
pprompt(prompt, 0);
else

6
main.c
View File

@ -34,7 +34,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.216 2012/04/14 16:07:47 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.217 2012/05/04 20:49:05 tg Exp $");
extern char **environ;
@ -327,6 +327,7 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
*/
Flag(FBRACEEXPAND) = 1;
#ifndef MKSH_NO_CMDLINE_EDITING
/*
* Set edit mode to emacs by default, may be overridden
* by the environment or the user. Also, we want tab completion
@ -335,6 +336,7 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
change_flag(FEMACS, OF_SPECIAL, 1);
#if !MKSH_S_NOVI
Flag(FVITABCOMPLETE) = 1;
#endif
#endif
/* import environment */
@ -517,7 +519,9 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
utf_flag = 0;
#endif
}
#ifndef MKSH_NO_CMDLINE_EDITING
x_init();
#endif
}
#ifdef SIGWINCH

7
misc.c
View File

@ -30,7 +30,7 @@
#include <grp.h>
#endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.188 2012/05/04 20:08:25 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.189 2012/05/04 20:49:06 tg Exp $");
/* type bits for unsigned char */
unsigned char chtypes[UCHAR_MAX + 1];
@ -226,6 +226,7 @@ change_flag(enum sh_flag f, int what, unsigned int newval)
j_change();
} else
#endif
#ifndef MKSH_NO_CMDLINE_EDITING
if ((
#if !MKSH_S_NOVI
f == FVI ||
@ -236,7 +237,9 @@ change_flag(enum sh_flag f, int what, unsigned int newval)
#endif
Flag(FEMACS) = Flag(FGMACS) = 0;
Flag(f) = (unsigned char)newval;
} else if (f == FPRIVILEGED && oldval && !newval) {
} else
#endif
if (f == FPRIVILEGED && oldval && !newval) {
/* Turning off -p? */
/*XXX this can probably be optimised */

10
sh.h
View File

@ -152,7 +152,7 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.552 2012/05/04 20:08:25 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.553 2012/05/04 20:49:07 tg Exp $");
#endif
#define MKSH_VERSION "R40 2012/04/27"
@ -1543,14 +1543,16 @@ void *aresize(void *, size_t, Area *);
void *aresize2(void *, size_t, size_t, Area *);
void afree(void *, Area *); /* can take NULL */
/* edit.c */
#ifndef MKSH_NO_CMDLINE_EDITING
#ifndef MKSH_SMALL
int x_bind(const char *, const char *, bool, bool);
#else
int x_bind(const char *, const char *, bool);
#endif
void x_init(void);
void x_mkraw(int, struct termios *, bool);
int x_read(char *, size_t);
#endif
void x_mkraw(int, struct termios *, bool);
/* eval.c */
char *substitute(const char *, int);
char **eval(const char **, int);
@ -1604,7 +1606,9 @@ int c_fgbg(const char **);
int c_kill(const char **);
void getopts_reset(int);
int c_getopts(const char **);
#ifndef MKSH_NO_CMDLINE_EDITING
int c_bind(const char **);
#endif
int c_shift(const char **);
int c_umask(const char **);
int c_dot(const char **);
@ -1646,7 +1650,7 @@ void sethistsize(mksh_ari_t);
#if HAVE_PERSISTENT_HISTORY
void sethistfile(const char *);
#endif
#if !MKSH_S_NOVI
#if !defined(MKSH_NO_CMDLINE_EDITING) && !MKSH_S_NOVI
char **histpos(void);
int histnum(int);
#endif

View File

@ -1,5 +1,5 @@
#if defined(SHFLAGS_DEFNS)
__RCSID("$MirOS: src/bin/mksh/sh_flags.h,v 1.9 2011/06/12 15:37:10 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh_flags.h,v 1.10 2012/05/04 20:49:08 tg Exp $");
#define FN(sname,cname,ochar,flags) /* nothing */
#elif defined(SHFLAGS_ENUMS)
#define FN(sname,cname,ochar,flags) cname,
@ -29,14 +29,18 @@ FN("bgnice", FBGNICE, 0, OF_ANY)
/* ./. enable {} globbing (non-standard) */
FN("braceexpand", FBRACEEXPAND, 0, OF_ANY)
#ifndef MKSH_NO_CMDLINE_EDITING
/* ./. Emacs command line editing mode */
FN("emacs", FEMACS, 0, OF_ANY)
#endif
/* -e quit on error */
FN("errexit", FERREXIT, 'e', OF_ANY)
#ifndef MKSH_NO_CMDLINE_EDITING
/* ./. Emacs command line editing mode, gmacs variant */
FN("gmacs", FGMACS, 0, OF_ANY)
#endif
/* ./. reading EOF does not exit */
FN("ignoreeof", FIGNOREEOF, 0, OF_ANY)
@ -108,7 +112,7 @@ FN("utf8-mode", FUNICODE, 'U', OF_ANY)
/* -v echo input */
FN("verbose", FVERBOSE, 'v', OF_ANY)
#if !MKSH_S_NOVI
#if !defined(MKSH_NO_CMDLINE_EDITING) && !MKSH_S_NOVI
/* ./. Vi command line editing mode */
FN("vi", FVI, 0, OF_ANY)