From 2e1150c8e88cc69ac2f9dc659cfb732ece676994 Mon Sep 17 00:00:00 2001 From: tg Date: Sun, 15 Jul 2018 17:21:24 +0000 Subject: [PATCH] =?UTF-8?q?against=20better=20judgement,=20allow=20unsetti?= =?UTF-8?q?ng=20COLUMNS:=20=E2=80=A2=20GNU=20coreutils=E2=80=99=20test=20s?= =?UTF-8?q?uite=20insists=20on=20it,=20even=20despite=20it=20can=20run=20?= =?UTF-8?q?=20=20successfully=20without=20doing=20it=20(WTF=E2=80=BD)?= =?UTF-8?q?=E2=80=A6=20=E2=80=A2=20we=20already=20unspecial,=20explicitly?= =?UTF-8?q?=20commented=20as=20=E2=80=9Chands-off=E2=80=9D=20it,=20=20=20w?= =?UTF-8?q?hen=20imported=20from=20the=20environment=20=E2=80=A2=20it=20wa?= =?UTF-8?q?s=20already=20changeable=20(though=20that=20didn=E2=80=99t=20un?= =?UTF-8?q?special=20it=20on=20the=20=20=20command=20line)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mksh.1 | 12 ++++++------ sh.h | 4 ++-- var.c | 24 +++++++++++++++--------- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/mksh.1 b/mksh.1 index e00b600..0ba4afc 100644 --- a/mksh.1 +++ b/mksh.1 @@ -1,4 +1,4 @@ -.\" $MirOS: src/bin/mksh/mksh.1,v 1.457 2018/07/15 13:57:18 tg Exp $ +.\" $MirOS: src/bin/mksh/mksh.1,v 1.458 2018/07/15 17:21:22 tg Exp $ .\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $ .\"- .\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, @@ -1824,10 +1824,10 @@ built-in command will display the resulting directory when a match is found in any search path other than the empty path. .It Ev COLUMNS Set to the number of columns on the terminal or window. -Always set, defaults to 80, unless the -value as reported by +If never unset and not imported, always set dynamically; +unless the value as reported by .Xr stty 1 -is non-zero and sane enough (minimum is 12x3); similar for +is non-zero and sane enough (minimum is 12x3), defaults to 80; similar for .Ev LINES . This parameter is used by the interactive line editing modes and by the .Ic select , @@ -1996,7 +1996,7 @@ The line number of the function or shell script that is currently being executed. .It Ev LINES Set to the number of lines on the terminal or window. -Always set, defaults to 24. +Defaults to 24; always set, unless imported or unset. See .Ev COLUMNS . .It Ev OLDPWD @@ -6705,7 +6705,7 @@ for the in-memory portion of the history is slow, should use .Xr memmove 3 . .Pp This document attempts to describe -.Nm mksh\ R56 +.Nm mksh\ R57 and up, .\" with vendor patches from insert-your-name-here, compiled without any options impacting functionality, such as diff --git a/sh.h b/sh.h index d28a260..ab31694 100644 --- a/sh.h +++ b/sh.h @@ -182,9 +182,9 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.863 2018/06/26 21:22:24 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.864 2018/07/15 17:21:23 tg Exp $"); #endif -#define MKSH_VERSION "R56 2018/06/26" +#define MKSH_VERSION "R56 2018/07/15" /* arithmetic types: C implementation */ #if !HAVE_CAN_INTTYPES diff --git a/var.c b/var.c index 223e703..1263547 100644 --- a/var.c +++ b/var.c @@ -28,7 +28,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/var.c,v 1.225 2018/05/07 00:07:23 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/var.c,v 1.226 2018/07/15 17:21:24 tg Exp $"); /*- * Variables @@ -54,7 +54,7 @@ static int special(const char *); static void unspecial(const char *); static void getspec(struct tbl *); static void setspec(struct tbl *); -static void unsetspec(struct tbl *); +static void unsetspec(struct tbl *, bool); static int getint(struct tbl *, mksh_ari_u *, bool); static const char *array_index_calc(const char *, bool *, uint32_t *); @@ -105,7 +105,7 @@ popblock(void) if ((vq = global(vp->name))->flag & ISSET) setspec(vq); else - unsetspec(vq); + unsetspec(vq, false); } if (l->flags & BF_DOGETOPTS) user_opt = l->getopts_state; @@ -1054,7 +1054,7 @@ unset(struct tbl *vp, int flags) vp->flag &= SPECIAL | ((flags & 1) ? 0 : ARRAY|DEFINED); if (vp->flag & SPECIAL) /* responsible for 'unspecial'ing var */ - unsetspec(vp); + unsetspec(vp, true); } /* @@ -1441,7 +1441,7 @@ setspec(struct tbl *vp) } static void -unsetspec(struct tbl *vp) +unsetspec(struct tbl *vp, bool dounset) { /* * AT&T ksh man page says OPTIND, OPTARG and _ lose special @@ -1466,13 +1466,13 @@ unsetspec(struct tbl *vp) #endif case V_IFS: set_ifs(TC_IFSWS); - break; + return; case V_PATH: afree(path, APERM); strdupx(path, def_path, APERM); /* clear tracked aliases */ flushcom(true); - break; + return; #ifndef MKSH_NO_CMDLINE_EDITING case V_TERM: x_initterm(null); @@ -1484,14 +1484,14 @@ unsetspec(struct tbl *vp) afree(tmpdir, APERM); tmpdir = NULL; } - break; + return; case V_LINENO: case V_RANDOM: case V_SECONDS: case V_TMOUT: /* AT&T ksh leaves previous value in place */ unspecial(vp->name); - break; + return; #ifdef MKSH_EARLY_LOCALE_TRACKING case V_LANG: case V_LC_ALL: @@ -1499,6 +1499,12 @@ unsetspec(struct tbl *vp) recheck_ctype(); return; #endif + /* should not become unspecial, but allow unsetting */ + case V_COLUMNS: + case V_LINES: + if (dounset) + unspecial(vp->name); + return; } }