always keep x_cols and x_lins valid; check once at start including tty init
if we find any, but not later; do not check on every read ⇒ allows changing COLUMNS and LINES (independent of each other, or both) for script shells by passing them in an environment setting, even if we get a tty; interactive shells still check before each line is read… reported by the PLD guys, thanks
This commit is contained in:
parent
69e1312265
commit
24e8a6996b
8
main.c
8
main.c
@ -34,7 +34,7 @@
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.207 2012/03/23 19:38:12 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.208 2012/03/23 21:58:21 tg Exp $");
|
||||
|
||||
extern char **environ;
|
||||
|
||||
@ -258,6 +258,12 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
|
||||
|
||||
init_histvec();
|
||||
|
||||
#ifdef TIOCGWINSZ
|
||||
/* try to initialise tty size before importing environment */
|
||||
tty_init(false, false);
|
||||
change_winsz();
|
||||
#endif
|
||||
|
||||
#ifdef _PATH_DEFPATH
|
||||
def_path = _PATH_DEFPATH;
|
||||
#else
|
||||
|
6
misc.c
6
misc.c
@ -30,7 +30,7 @@
|
||||
#include <grp.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.183 2012/03/23 20:07:11 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.184 2012/03/23 21:58:22 tg Exp $");
|
||||
|
||||
/* type bits for unsigned char */
|
||||
unsigned char chtypes[UCHAR_MAX + 1];
|
||||
@ -1174,10 +1174,6 @@ print_columns(struct shf *shf, int n,
|
||||
++max_oct;
|
||||
str = alloc(max_oct, ATEMP);
|
||||
|
||||
/* ensure x_cols is valid first */
|
||||
if (x_cols < MIN_COLS)
|
||||
change_winsz();
|
||||
|
||||
/*
|
||||
* We use (max_col + 1) to consider the space separator.
|
||||
* Note that no space is printed after the last column
|
||||
|
4
sh.h
4
sh.h
@ -152,7 +152,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef EXTERN
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.524 2012/03/23 20:07:11 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.525 2012/03/23 21:58:22 tg Exp $");
|
||||
#endif
|
||||
#define MKSH_VERSION "R40 2012/03/03"
|
||||
|
||||
@ -858,7 +858,7 @@ EXTERN char *current_wd;
|
||||
#define MIN_COLS (2 + MIN_EDIT_SPACE + 3)
|
||||
#define MIN_LINS 3
|
||||
EXTERN mksh_ari_t x_cols E_INIT(80); /* tty columns */
|
||||
EXTERN mksh_ari_t x_lins E_INIT(-1); /* tty lines */
|
||||
EXTERN mksh_ari_t x_lins E_INIT(24); /* tty lines */
|
||||
|
||||
/* These to avoid bracket matching problems */
|
||||
#define OPAREN '('
|
||||
|
13
var.c
13
var.c
@ -26,7 +26,7 @@
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.141 2012/03/03 21:30:59 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.142 2012/03/23 21:58:24 tg Exp $");
|
||||
|
||||
/*-
|
||||
* Variables
|
||||
@ -1132,7 +1132,6 @@ getspec(struct tbl *vp)
|
||||
* and the window is then resized, the app won't
|
||||
* see the change cause the environ doesn't change.
|
||||
*/
|
||||
change_winsz();
|
||||
i = st == V_COLUMNS ? x_cols : x_lins;
|
||||
break;
|
||||
default:
|
||||
@ -1458,16 +1457,6 @@ set_array(const char *var, bool reset, const char **vals)
|
||||
void
|
||||
change_winsz(void)
|
||||
{
|
||||
if (x_lins < 0) {
|
||||
/* first time initialisation */
|
||||
#ifdef TIOCGWINSZ
|
||||
if (tty_fd < 0)
|
||||
/* non-FTALKING, try to get an fd anyway */
|
||||
tty_init(true, false);
|
||||
#endif
|
||||
x_cols = -1;
|
||||
}
|
||||
|
||||
#ifdef TIOCGWINSZ
|
||||
/* check if window size has changed */
|
||||
if (tty_fd >= 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user