On Wed, Mar 14, 2012 at 22:44, David Korn <[email protected]> wrote:

> cc: [email protected]
> Subject: Re: [ast-users] [ksh93] `typeset -A arr' did not unset arr first
> --------
>
>
> > $ echo $KSH_VERSION
> > Version JMP 93u+ 2012-02-29
> > $ arr=( )
> > $ typeset -p arr
> > typeset -C arr=()
> > $ typeset -A arr    <-- explicitly change the attribute
> > $ typeset -p arr
> > typeset -A arr=([0]=())    <-- I would expect arr to be an empty
> > associative array here ??
> The typeset -A changed arr into an associative array and an value it had
> becomes the 0 element of this array.
> > $ unset arr
> > $ typeset -p arr
> > typeset -C arr=()    <-- It was not unset ??
> typeset -p arr only unsets the 0th element.  You need to use
>        typeset -p arr[@]
> to unset all the elements of an array.
>

1. Why `-A' is changed to `-C' after unset?

2. Normally, `unset arr' really can unset an associative array. You can try
like this:

$ typeset -A arr=( [0]=( ) )
$ typeset -p arr
typeset -A arr=([0]=())
$ unset arr
$ typeset -p arr
$


> Note that $arr is equivalent to ${arr[0]}
> > $ unset -v arr
> > $ typeset -p arr
> > typeset -C arr=()
> > $
> >
>
> David Korn
> [email protected]
>
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to