cid 1004E0F5C27271F5B00 broke integer-base handling of built-in parameters
mksh -c 'echo a=$RANDOM; RANDOM=0x12; echo b=$RANDOM' # behaviour changed
This commit is contained in:
parent
f92108dccc
commit
c620f865c1
4
check.t
4
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.486 2011/11/05 23:39:02 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.487 2011/11/08 22:07:11 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 $
|
||||||
@ -25,7 +25,7 @@
|
|||||||
# http://www.research.att.com/~gsf/public/ifs.sh
|
# http://www.research.att.com/~gsf/public/ifs.sh
|
||||||
|
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)MIRBSD KSH R40 2011/10/26
|
@(#)MIRBSD KSH R40 2011/11/07
|
||||||
description:
|
description:
|
||||||
Check version of shell.
|
Check version of shell.
|
||||||
stdin:
|
stdin:
|
||||||
|
24
main.c
24
main.c
@ -33,7 +33,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.200 2011/10/07 19:51:28 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.201 2011/11/08 22:07:14 tg Exp $");
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
@ -330,9 +330,9 @@ main(int argc, const char *argv[])
|
|||||||
while (*wp != NULL)
|
while (*wp != NULL)
|
||||||
wp++;
|
wp++;
|
||||||
}
|
}
|
||||||
setint_n(global("COLUMNS"), 0);
|
setint_n(global("COLUMNS"), 0, 10);
|
||||||
setint_n(global("LINES"), 0);
|
setint_n(global("LINES"), 0, 10);
|
||||||
setint_n(global("OPTIND"), 1);
|
setint_n(global("OPTIND"), 1, 10);
|
||||||
|
|
||||||
kshuid = getuid();
|
kshuid = getuid();
|
||||||
kshgid = getgid();
|
kshgid = getgid();
|
||||||
@ -345,21 +345,21 @@ main(int argc, const char *argv[])
|
|||||||
(!ksheuid && !strchr(str_val(vp), '#')))
|
(!ksheuid && !strchr(str_val(vp), '#')))
|
||||||
/* setstr can't fail here */
|
/* setstr can't fail here */
|
||||||
setstr(vp, safe_prompt, KSH_RETURN_ERROR);
|
setstr(vp, safe_prompt, KSH_RETURN_ERROR);
|
||||||
setint_n((vp = global("PGRP")), (mksh_uari_t)kshpgrp);
|
setint_n((vp = global("PGRP")), (mksh_uari_t)kshpgrp, 10);
|
||||||
vp->flag |= INT_U;
|
vp->flag |= INT_U;
|
||||||
setint_n((vp = global("PPID")), (mksh_uari_t)kshppid);
|
setint_n((vp = global("PPID")), (mksh_uari_t)kshppid, 10);
|
||||||
vp->flag |= INT_U;
|
vp->flag |= INT_U;
|
||||||
setint_n((vp = global("USER_ID")), (mksh_uari_t)ksheuid);
|
setint_n((vp = global("USER_ID")), (mksh_uari_t)ksheuid, 10);
|
||||||
vp->flag |= INT_U;
|
vp->flag |= INT_U;
|
||||||
setint_n((vp = global("KSHUID")), (mksh_uari_t)kshuid);
|
setint_n((vp = global("KSHUID")), (mksh_uari_t)kshuid, 10);
|
||||||
vp->flag |= INT_U;
|
vp->flag |= INT_U;
|
||||||
setint_n((vp = global("KSHEGID")), (mksh_uari_t)kshegid);
|
setint_n((vp = global("KSHEGID")), (mksh_uari_t)kshegid, 10);
|
||||||
vp->flag |= INT_U;
|
vp->flag |= INT_U;
|
||||||
setint_n((vp = global("KSHGID")), (mksh_uari_t)kshgid);
|
setint_n((vp = global("KSHGID")), (mksh_uari_t)kshgid, 10);
|
||||||
vp->flag |= INT_U;
|
vp->flag |= INT_U;
|
||||||
setint_n((vp = global("RANDOM")), rndsetup());
|
setint_n((vp = global("RANDOM")), rndsetup(), 10);
|
||||||
vp->flag |= INT_U;
|
vp->flag |= INT_U;
|
||||||
setint_n((vp_pipest = global("PIPESTATUS")), 0);
|
setint_n((vp_pipest = global("PIPESTATUS")), 0, 10);
|
||||||
|
|
||||||
/* Set this before parsing arguments */
|
/* Set this before parsing arguments */
|
||||||
Flag(FPRIVILEGED) = kshuid != ksheuid || kshgid != kshegid;
|
Flag(FPRIVILEGED) = kshuid != ksheuid || kshgid != kshegid;
|
||||||
|
6
sh.h
6
sh.h
@ -151,9 +151,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.499 2011/10/26 20:46:16 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.500 2011/11/08 22:07:14 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R40 2011/10/26"
|
#define MKSH_VERSION "R40 2011/11/07"
|
||||||
|
|
||||||
#ifndef MKSH_INCLUDES_ONLY
|
#ifndef MKSH_INCLUDES_ONLY
|
||||||
|
|
||||||
@ -1840,7 +1840,7 @@ char *str_val(struct tbl *);
|
|||||||
int setstr(struct tbl *, const char *, int);
|
int setstr(struct tbl *, const char *, int);
|
||||||
struct tbl *setint_v(struct tbl *, struct tbl *, bool);
|
struct tbl *setint_v(struct tbl *, struct tbl *, bool);
|
||||||
void setint(struct tbl *, mksh_ari_t);
|
void setint(struct tbl *, mksh_ari_t);
|
||||||
void setint_n(struct tbl *, mksh_ari_t);
|
void setint_n(struct tbl *, mksh_ari_t, int);
|
||||||
struct tbl *typeset(const char *, uint32_t, uint32_t, int, int)
|
struct tbl *typeset(const char *, uint32_t, uint32_t, int, int)
|
||||||
MKSH_A_NONNULL((__nonnull__ (1)));
|
MKSH_A_NONNULL((__nonnull__ (1)));
|
||||||
void unset(struct tbl *, int);
|
void unset(struct tbl *, int);
|
||||||
|
10
var.c
10
var.c
@ -26,7 +26,7 @@
|
|||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.133 2011/10/16 00:18:56 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.134 2011/11/08 22:07:15 tg Exp $");
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Variables
|
* Variables
|
||||||
@ -556,7 +556,7 @@ setint_v(struct tbl *vq, struct tbl *vp, bool arith)
|
|||||||
|
|
||||||
if ((base = getint(vp, &num, arith)) == -1)
|
if ((base = getint(vp, &num, arith)) == -1)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
setint_n(vq, num);
|
setint_n(vq, num, 0);
|
||||||
if (vq->type == 0)
|
if (vq->type == 0)
|
||||||
/* default base */
|
/* default base */
|
||||||
vq->type = base;
|
vq->type = base;
|
||||||
@ -565,7 +565,7 @@ setint_v(struct tbl *vq, struct tbl *vp, bool arith)
|
|||||||
|
|
||||||
/* convert variable vq to integer variable, setting its value to num */
|
/* convert variable vq to integer variable, setting its value to num */
|
||||||
void
|
void
|
||||||
setint_n(struct tbl *vq, mksh_ari_t num)
|
setint_n(struct tbl *vq, mksh_ari_t num, int newbase)
|
||||||
{
|
{
|
||||||
if (!(vq->flag & INTEGER) && (vq->flag & ALLOC)) {
|
if (!(vq->flag & INTEGER) && (vq->flag & ALLOC)) {
|
||||||
vq->flag &= ~ALLOC;
|
vq->flag &= ~ALLOC;
|
||||||
@ -573,6 +573,8 @@ setint_n(struct tbl *vq, mksh_ari_t num)
|
|||||||
afree(vq->val.s, vq->areap);
|
afree(vq->val.s, vq->areap);
|
||||||
}
|
}
|
||||||
vq->val.i = num;
|
vq->val.i = num;
|
||||||
|
if (newbase != 0)
|
||||||
|
vq->type = newbase;
|
||||||
vq->flag |= ISSET|INTEGER;
|
vq->flag |= ISSET|INTEGER;
|
||||||
if (vq->flag&SPECIAL)
|
if (vq->flag&SPECIAL)
|
||||||
setspec(vq);
|
setspec(vq);
|
||||||
@ -1133,7 +1135,7 @@ getspec(struct tbl *vp)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vp->flag &= ~SPECIAL;
|
vp->flag &= ~SPECIAL;
|
||||||
setint_n(vp, i);
|
setint_n(vp, i, 0);
|
||||||
vp->flag |= SPECIAL;
|
vp->flag |= SPECIAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user