fix allexport for arrays; add testcase that also catches exporting arrays

This commit is contained in:
tg 2018-04-28 07:07:39 +00:00
parent 1c24f0dbc7
commit 09c8df8058
3 changed files with 24 additions and 6 deletions

21
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.802 2018/03/09 01:29:08 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.803 2018/04/28 07:07:35 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 R56 2018/03/09
@(#)MIRBSD KSH R56 2018/04/28
description:
Check base version of full shell
stdin:
@ -39,7 +39,7 @@ name: KSH_VERSION
category: !shell:legacy-yes
---
expected-stdout:
@(#)LEGACY KSH R56 2018/03/09
@(#)LEGACY KSH R56 2018/04/28
description:
Check base version of legacy shell
stdin:
@ -6854,6 +6854,21 @@ expected-stdout:
3 10 .
4 -2147483646 .
---
name: export-1
description:
Check allexport works, basic
stdin:
qa=1
set -A qb 2 3
set -a
qc=4
set -A qd 5 6
export -p | grep '^export q'
expected-stdout:
export qc=4
export qd[0]=5
export qd[1]=6
---
name: readonly-0
description:
Ensure readonly is honoured for assignments and unset

4
sh.h
View File

@ -182,9 +182,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.859 2018/03/09 01:29:11 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.860 2018/04/28 07:07:37 tg Exp $");
#endif
#define MKSH_VERSION "R56 2018/03/09"
#define MKSH_VERSION "R56 2018/04/28"
/* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES

5
var.c
View File

@ -28,7 +28,7 @@
#include <sys/sysctl.h>
#endif
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.223 2018/01/13 23:55:15 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.224 2018/04/28 07:07:39 tg Exp $");
/*-
* Variables
@ -1617,6 +1617,9 @@ set_array(const char *var, bool reset, const char **vals)
unset(vp, 1);
/* allocate-by-access the [0] element to keep in scope */
arraysearch(vp, 0);
/* honour set -o allexport */
if (Flag(FEXPORT))
typeset(ccp, EXPORT, 0, 0, 0);
}
/*
* TODO: would be nice for assignment to completely succeed or