-
I was disturbed at first with static scoping, I abused bash dynamic scoping (while forced to move to bash) and struggled to get passing args by ref (typeset -n, nameref) because of circular name reference. Now I reunite with ksh93 and enjoy the safety of static scoping, I was wondering about nameref circular ref, thinking it should be impossible to do in ksh93, still I tried this
Though completely useless example, let say it could be a programing error, I was kinda expecting the 1st error message, then after What does it mean ? Is that expected? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
IMHO, it's a bug. The Try this patch: diff --git a/src/cmd/ksh93/sh/name.c b/src/cmd/ksh93/sh/name.c
index 3c78d2686..a797f68fc 100644
--- a/src/cmd/ksh93/sh/name.c
+++ b/src/cmd/ksh93/sh/name.c
@@ -1246,7 +1246,8 @@ void nv_delete(Namval_t* np, Dt_t *root, int flags)
free(rp->sub);
rp->sub = 0;
rp = dtdelete(Refdict,(void*)rp);
- rp->np = &NullNode;
+ if(!(flags&NV_REF))
+ rp->np = &NullNode;
}
}
}
@@ -3369,7 +3370,7 @@ void nv_setref(register Namval_t *np, Dt_t *hp, int flags)
sh.instance = 0;
sh.last_root = root;
_nv_unset(np,0);
- nv_delete(np,(Dt_t*)0,0);
+ nv_delete(np,(Dt_t*)0,NV_REF);
np->nvalue.nrp = sh_newof(0,struct Namref,1,sizeof(Dtlink_t));
np->nvalue.nrp->np = nq;
np->nvalue.nrp->root = hp; |
Beta Was this translation helpful? Give feedback.
-
I tested the ksh93-history versions with |
Beta Was this translation helpful? Give feedback.
-
@McDutchie Whew, well done :) |
Beta Was this translation helpful? Give feedback.
Fixed in 72d895d (dev), d9d9c50 (1.0)