pretty tricky thing, IBM’s curses library does nameref foo=foo…
This commit is contained in:
parent
c57f8ede17
commit
43c8d8765f
21
check.t
21
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.467 2011/06/12 14:58:43 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.468 2011/06/21 21:50:23 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/06/12
|
@(#)MIRBSD KSH R40 2011/06/21
|
||||||
description:
|
description:
|
||||||
Check version of shell.
|
Check version of shell.
|
||||||
stdin:
|
stdin:
|
||||||
@ -8755,6 +8755,23 @@ expected-stdout:
|
|||||||
2 a .
|
2 a .
|
||||||
3 .
|
3 .
|
||||||
---
|
---
|
||||||
|
name: nameref-4
|
||||||
|
description:
|
||||||
|
Ensure we don't run in an infinite loop
|
||||||
|
time-limit: 3
|
||||||
|
stdin:
|
||||||
|
baz() {
|
||||||
|
typeset -n foo=foo
|
||||||
|
foo[0]=bar
|
||||||
|
}
|
||||||
|
set -A foo bad
|
||||||
|
echo sind $foo .
|
||||||
|
baz
|
||||||
|
echo blah $foo .
|
||||||
|
expected-stdout:
|
||||||
|
sind bad .
|
||||||
|
blah bar .
|
||||||
|
---
|
||||||
name: better-parens-1a
|
name: better-parens-1a
|
||||||
description:
|
description:
|
||||||
Check support for ((…)) and $((…)) vs (…) and $(…)
|
Check support for ((…)) and $((…)) vs (…) and $(…)
|
||||||
|
4
sh.h
4
sh.h
@ -151,9 +151,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.478 2011/06/21 21:11:20 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.479 2011/06/21 21:50:25 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R40 2011/06/12"
|
#define MKSH_VERSION "R40 2011/06/21"
|
||||||
|
|
||||||
#ifndef MKSH_INCLUDES_ONLY
|
#ifndef MKSH_INCLUDES_ONLY
|
||||||
|
|
||||||
|
21
var.c
21
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.125 2011/06/21 21:11:21 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.126 2011/06/21 21:50:26 tg Exp $");
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Variables
|
* Variables
|
||||||
@ -751,6 +751,25 @@ typeset(const char *var, Tflag set, Tflag clr, int field, int base)
|
|||||||
tvar[len-3] = '\0';
|
tvar[len-3] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (set_refflag == SRF_ENABLE) {
|
||||||
|
const char *qval;
|
||||||
|
|
||||||
|
/* bail out on 'nameref foo+=bar' */
|
||||||
|
if (vappend)
|
||||||
|
errorfz();
|
||||||
|
/* find value if variable already exists */
|
||||||
|
if ((qval = val) == NULL) {
|
||||||
|
varsearch(e->loc, &vp, tvar, hash(tvar));
|
||||||
|
if (vp != NULL)
|
||||||
|
qval = str_val(vp);
|
||||||
|
}
|
||||||
|
/* silently ignore 'nameref foo=foo' */
|
||||||
|
if (qval != NULL && !strcmp(qval, tvar)) {
|
||||||
|
afree(tvar, ATEMP);
|
||||||
|
return (&vtemp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* prevent typeset from creating a local PATH/ENV/SHELL */
|
/* prevent typeset from creating a local PATH/ENV/SHELL */
|
||||||
if (Flag(FRESTRICTED) && (strcmp(tvar, "PATH") == 0 ||
|
if (Flag(FRESTRICTED) && (strcmp(tvar, "PATH") == 0 ||
|
||||||
strcmp(tvar, "ENV") == 0 || strcmp(tvar, "SHELL") == 0))
|
strcmp(tvar, "ENV") == 0 || strcmp(tvar, "SHELL") == 0))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user