David Korn wrote:
> cc:  shell-discuss at opensolaris.org  don.cragun at sun.com pkchris at 
> users.sourceforge.ne
> Subject: Re: Re: [ksh93-integration-discuss] CR 6791838 Created P3 
> shell/korn93  *ksh93* unset of a variablewhich is not set should return 0
> --------
> > Doesn't [[ ${x+y} ]] expand variable x?
> > x= ; x.get() { print "hello" ; } [[ ${x+y} ]] ; print $?
> > prints
> > hello
> > 0
> > ${x+y} will be a big performance regression if compared to if (unset -e x)
> 
> It currently does expand x, but I don't think that this is necessary
> and I could change this.  I could detect that x is followed by a + and just
> check for not set.

My concern with using ${x+y} is that if "x" is a compound variable which
contains many child nodes (for example complex variable tree with 50000
nodes and 200MB of data) then the expansion of such a variable to a
string would be slow as molasses compared to the current use of $ if !
(unset compoundvar) ; then print "compound variable 'compoundvar' exists
; fi #

Beyond that... what about getting _both_  "[[ ${x+y} ]]" _and_ "unset -e
x" (see my other email to you) - the first form would be useable in [[
]]-tests while "unset -e" covers "legacy scripts" (via Chris's alias
unset='unset -e') and testing for namerefs+functions (see Jenny's
comments in
http://mail.opensolaris.org/pipermail/ksh93-integration-discuss/2009-January/006777.html)
...

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) roland.mainz at nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)

Reply via email to