fix ${!foo} for when foo is unset
This commit is contained in:
parent
0c3c44a6a7
commit
d8461d400f
20
check.t
20
check.t
@ -1,4 +1,4 @@
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.644 2014/04/29 07:43:38 tg Exp $
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.645 2014/05/27 13:00:31 tg Exp $
|
||||
# OpenBSD src/regress/bin/ksh updated: 2013/12/02 20:39:44
|
||||
#-
|
||||
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
@ -7147,15 +7147,15 @@ stdin:
|
||||
echo !arz[0]: ${!arz[0]}
|
||||
echo !arz[1]: ${!arz[1]}
|
||||
expected-stdout:
|
||||
!arz: 0
|
||||
!arz[0]:
|
||||
!arz[1]:
|
||||
!arz: arz
|
||||
!arz[0]: 0
|
||||
!arz[1]:
|
||||
!arz: 0
|
||||
!arz[0]:
|
||||
!arz[1]:
|
||||
!arz[0]: arz[0]
|
||||
!arz[1]: arz[1]
|
||||
!arz: arz
|
||||
!arz[0]: arz[0]
|
||||
!arz[1]: arz[1]
|
||||
!arz: arz
|
||||
!arz[0]: arz[0]
|
||||
!arz[1]: arz[1]
|
||||
---
|
||||
name: arrays-8
|
||||
description:
|
||||
@ -10564,7 +10564,7 @@ expected-stdout:
|
||||
ir2: ir2
|
||||
s1: ir2=ind
|
||||
s2: typeset -n ir2
|
||||
!ind[1]: 1
|
||||
!ind[1]: blub[1]
|
||||
!ir2: ir2
|
||||
ind[1]: e2
|
||||
ir2: e3
|
||||
|
17
eval.c
17
eval.c
@ -23,7 +23,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.147 2014/01/11 18:09:39 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.148 2014/05/27 13:00:30 tg Exp $");
|
||||
|
||||
/*
|
||||
* string expansion
|
||||
@ -1252,17 +1252,12 @@ varsub(Expand *xp, const char *sp, const char *word,
|
||||
if (*sp == '!' && sp[1]) {
|
||||
++sp;
|
||||
xp->var = global(sp);
|
||||
if (vstrchr(sp, '[')) {
|
||||
if (xp->var->flag & ISSET)
|
||||
xp->str = shf_smprintf("%lu",
|
||||
arrayindex(xp->var));
|
||||
else
|
||||
xp->str = null;
|
||||
} else if (xp->var->flag & ISSET)
|
||||
xp->str = xp->var->name;
|
||||
if (vstrchr(sp, '['))
|
||||
xp->str = shf_smprintf("%s[%lu]",
|
||||
xp->var->name,
|
||||
arrayindex(xp->var));
|
||||
else
|
||||
/* ksh93 compat */
|
||||
xp->str = "0";
|
||||
xp->str = xp->var->name;
|
||||
} else {
|
||||
xp->var = global(sp);
|
||||
xp->str = str_val(xp->var);
|
||||
|
Loading…
Reference in New Issue
Block a user