against better judgement, allow unsetting COLUMNS:

• GNU coreutils’ test suite insists on it, even despite it can run
  successfully without doing it (WTF‽)…
• we already unspecial, explicitly commented as “hands-off” it,
  when imported from the environment
• it was already changeable (though that didn’t unspecial it on the
  command line)
This commit is contained in:
tg 2018-07-15 17:21:24 +00:00
parent 28a08dc7a0
commit 2e1150c8e8
3 changed files with 23 additions and 17 deletions

12
mksh.1
View File

@ -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

4
sh.h
View File

@ -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

24
var.c
View File

@ -28,7 +28,7 @@
#include <sys/sysctl.h>
#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;
}
}