From b903a5e66a79d6de6a54de07e323d54290264fdf Mon Sep 17 00:00:00 2001 From: tg Date: Wed, 26 Jul 2017 23:02:28 +0000 Subject: [PATCH] make readonly idempotent; spotted by selk from Dragora --- check.t | 13 ++++++++++--- sh.h | 4 ++-- var.c | 10 +++++----- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/check.t b/check.t index e0c8d5e..8ff54a4 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.793 2017/05/14 19:05:44 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.794 2017/07/26 23:02:23 tg Exp $ # -*- mode: sh -*- #- # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, @@ -30,7 +30,7 @@ # (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date expected-stdout: - @(#)MIRBSD KSH R55 2017/05/05 + @(#)MIRBSD KSH R55 2017/07/26 description: Check base version of full shell stdin: @@ -39,7 +39,7 @@ name: KSH_VERSION category: !shell:legacy-yes --- expected-stdout: - @(#)LEGACY KSH R55 2017/05/01 + @(#)LEGACY KSH R55 2017/07/26 description: Check base version of legacy shell stdin: @@ -6906,6 +6906,13 @@ expected-exit: e != 0 expected-stderr-pattern: /read[ -]?only/ --- +name: readonly-5 +description: + Ensure readonly is idempotent +stdin: + readonly x=1 + readonly x +--- name: syntax-1 description: Check that lone ampersand is a syntax error diff --git a/sh.h b/sh.h index 73dacdb..a3ebe52 100644 --- a/sh.h +++ b/sh.h @@ -175,9 +175,9 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.836 2017/05/05 22:53:30 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.837 2017/07/26 23:02:27 tg Exp $"); #endif -#define MKSH_VERSION "R55 2017/05/05" +#define MKSH_VERSION "R55 2017/07/26" /* arithmetic types: C implementation */ #if !HAVE_CAN_INTTYPES diff --git a/var.c b/var.c index a27928b..a53fae8 100644 --- a/var.c +++ b/var.c @@ -28,7 +28,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/var.c,v 1.219 2017/05/05 22:53:32 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/var.c,v 1.220 2017/07/26 23:02:28 tg Exp $"); /*- * Variables @@ -917,12 +917,12 @@ typeset(const char *var, uint32_t set, uint32_t clr, int field, int base) vpbase = (vp->flag & ARRAY) ? global(arrayname(tvar)) : vp; /* - * only allow export flag to be set; AT&T ksh allows any - * attribute to be changed which means it can be truncated or - * modified (-L/-R/-Z/-i) + * only allow export and readonly flag to be set; AT&T ksh + * allows any attribute to be changed which means it can be + * truncated or modified (-L/-R/-Z/-i) */ if ((vpbase->flag & RDONLY) && - (val || clr || (set & ~EXPORT))) + (val || clr || (set & ~(EXPORT | RDONLY)))) /* XXX check calls - is error here ok by POSIX? */ errorfx(2, Tf_ro, tvar); afree(tvar, ATEMP);