Hi David,
I’m having a slight problem (shbot runs ksh93 when asked “k#”):
19:06⎜mirabilos:#ksh k# nameref x=y; y=z; echo $x,$y; unset x; echo $x,$y
19:06⎜«shbot:#ksh» mirabilos: z,z
19:06⎜«shbot:#ksh» mirabilos: ,
19:06⎜mirabilos:#ksh k# nameref x=y; y=z; echo $x,$y; nameref x=; echo $x,$y
19:06⎜«shbot:#ksh» mirabilos: z,z
19:06⎜«shbot:#ksh» mirabilos: ksh: typeset: : invalid variable name
19:06⎜mirabilos:#ksh ok, ksh93 behaves the same… how does one “un-nameref” an
identifier?
This is mksh:
19:06⎜mirabilos:#ksh m# nameref x=y; y=z; echo $x,$y; nameref x=; echo $x,$y
19:06⎜«shbot:#ksh» mirabilos: z,z
19:06⎜«shbot:#ksh» mirabilos: mksh: x=: empty nameref target
19:07⎜mirabilos:#ksh pre-R50 mksh showed ',z' on the second line
For reference, the versions installed on shbot right now are:
19:17⎜mirabilos:#ksh k# echo ${.sh.version}
19:17⎜«shbot:#ksh» mirabilos: Version AJM 93u+ 2012-08-01
19:17⎜mirabilos:#ksh m# echo $KSH_VERSION
19:17⎜«shbot:#ksh» mirabilos: @(#)MIRBSD KSH R50 2014/07/28
Basically, I need something so that $x is no longer a nameref;
changing it to another target is of course possible, or leaving
a function in which it was a local variable, but what about the
main program in which I also want to occasionally use namerefs,
e.g. in sourced libraries?
I cannot let it refer to itself in either shell, either:
19:15⎜mirabilos:#ksh k# nameref x=y; y=z; echo $x,$y; nameref x=x; echo $x,$y
19:15⎜«shbot:#ksh» mirabilos: z,z
19:15⎜«shbot:#ksh» mirabilos: ksh: typeset: x: invalid self reference
mksh has: mksh: x: expression recurses on parameter
Right now, I believe using 'nameref x=' to un-nameref it
is the way to go, and would restore that for mksh, but since
it’s your feature, I thought I’d rather ask you first.
(You don’t sit in IRC on Freenode, do you?)
Thanks in advance,
//mirabilos
--
„Cool, /usr/share/doc/mksh/examples/uhr.gz ist ja ein Grund,
mksh auf jedem System zu installieren.“
-- XTaran auf der OpenRheinRuhr, ganz begeistert
(EN: “[…]uhr.gz is a reason to install mksh on every system.”)