Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/cmd/ksh93/sh/macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,7 @@ static int varsub(Mac_t *mp)
char *idx = 0;
int var=1,addsub=0,oldpat=mp->pattern,idnum=0,flag=0,d;
Stk_t *stkp = sh.stk;
char have_dot=0; /* bug-875: Phi: */
mp->wasexpan = 1;
retry1:
idbuff[0] = 0;
Expand Down Expand Up @@ -1292,7 +1293,11 @@ static int varsub(Mac_t *mp)
do
{
if(LEN==1)
{
if(c=='.')
have_dot=1;
sfputc(stkp,c);
}
else
sfwrite(stkp,fcseek(0)-LEN,LEN);
}
Expand Down Expand Up @@ -1609,7 +1614,8 @@ static int varsub(Mac_t *mp)
dolg = -1;
nextname(mp,id,0);
/* Check if the prefix (id) itself exists. If so, start with that. */
if(nv_open(id,sh.var_tree,NV_NOREF|NV_NOADD|NV_VARNAME|NV_NOFAIL))
/* bug-875: Phi: Don't do that for namespaced var*/
if( !have_dot && nv_open(id,sh.var_tree,NV_NOREF|NV_NOADD|NV_VARNAME|NV_NOFAIL))
v = id;
else
v = nextname(mp,id,dolmax);
Expand Down
7 changes: 7 additions & 0 deletions src/cmd/ksh93/tests/variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1769,5 +1769,12 @@ got=$(./issue861.sh 2>&1)
"(got status $e, $(printf %q "$got"))"
unset i

# ======
# https://github.com/ksh93/ksh/issues/861
a=1 a.a=2 a.b=3 a.c=4 a.aa=5 a.ac=6
got=$(echo ${!a.a*})
exp="a.a a.aa a.ac"
[[ $got == "$exp" ]] || err_exit "\${!a.*} not workig. expected '$exp' got '$got'"

# ======
exit $((Errors<125?Errors:125))