fix ${!foo} for when foo is unset
This commit is contained in:
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
|
# OpenBSD src/regress/bin/ksh updated: 2013/12/02 20:39:44
|
||||||
#-
|
#-
|
||||||
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||||
@ -7147,15 +7147,15 @@ stdin:
|
|||||||
echo !arz[0]: ${!arz[0]}
|
echo !arz[0]: ${!arz[0]}
|
||||||
echo !arz[1]: ${!arz[1]}
|
echo !arz[1]: ${!arz[1]}
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
!arz: 0
|
|
||||||
!arz[0]:
|
|
||||||
!arz[1]:
|
|
||||||
!arz: arz
|
!arz: arz
|
||||||
!arz[0]: 0
|
!arz[0]: arz[0]
|
||||||
!arz[1]:
|
!arz[1]: arz[1]
|
||||||
!arz: 0
|
!arz: arz
|
||||||
!arz[0]:
|
!arz[0]: arz[0]
|
||||||
!arz[1]:
|
!arz[1]: arz[1]
|
||||||
|
!arz: arz
|
||||||
|
!arz[0]: arz[0]
|
||||||
|
!arz[1]: arz[1]
|
||||||
---
|
---
|
||||||
name: arrays-8
|
name: arrays-8
|
||||||
description:
|
description:
|
||||||
@ -10564,7 +10564,7 @@ expected-stdout:
|
|||||||
ind: global
|
ind: global
|
||||||
!ir2: bar
|
!ir2: bar
|
||||||
ir2: global
|
ir2: global
|
||||||
!ind: ind
|
!ind: ind
|
||||||
ind: ir2
|
ind: ir2
|
||||||
!ir2: ind
|
!ir2: ind
|
||||||
ir2: ir2
|
ir2: ir2
|
||||||
|
13
eval.c
13
eval.c
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#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
|
* string expansion
|
||||||
@ -1252,17 +1252,12 @@ varsub(Expand *xp, const char *sp, const char *word,
|
|||||||
if (*sp == '!' && sp[1]) {
|
if (*sp == '!' && sp[1]) {
|
||||||
++sp;
|
++sp;
|
||||||
xp->var = global(sp);
|
xp->var = global(sp);
|
||||||
if (vstrchr(sp, '[')) {
|
if (vstrchr(sp, '['))
|
||||||
if (xp->var->flag & ISSET)
|
xp->str = shf_smprintf("%s[%lu]",
|
||||||
xp->str = shf_smprintf("%lu",
|
xp->var->name,
|
||||||
arrayindex(xp->var));
|
arrayindex(xp->var));
|
||||||
else
|
else
|
||||||
xp->str = null;
|
|
||||||
} else if (xp->var->flag & ISSET)
|
|
||||||
xp->str = xp->var->name;
|
xp->str = xp->var->name;
|
||||||
else
|
|
||||||
/* ksh93 compat */
|
|
||||||
xp->str = "0";
|
|
||||||
} else {
|
} else {
|
||||||
xp->var = global(sp);
|
xp->var = global(sp);
|
||||||
xp->str = str_val(xp->var);
|
xp->str = str_val(xp->var);
|
||||||
|
Reference in New Issue
Block a user