cc: [email protected]
Subject: Re: Re: Re: [ast-users] ksh93 returns "()" for "${a[@]}" if I clear an
array with a=( )
--------
> >> (Slightly) offtopic: How can I clear a plain string array (e.g. $
> >> typeset -a ar #) via the C API (without having to resort to
> >> |sh_trap()| to do it...) ?
> >
> > You can do
> > nv_putsub(np,0,0,ARRAY_UNDEF);
> > before calling
> > _nv_unset(np,NV_RDONLY);
>
> Ok... so a function to clear an associative/indexed array would look like
> this:
> -- snip --
> void nv_clear_array(Namval_t* np)
> {
> nv_putsub(np,0,0,ARRAY_UNDEF);
> _nv_unset(np,NV_RDONLY);
> }
> -- snip --
> ... right ?
>
> Next question: How do I clear a compound variable using the libshell C API ?
>
Use
_nv_unset(np,NV_RDONLY);
just as you do for a simple variable.
By the way, use 0 instead of NV_RDONLY if you don't want to remove a readonly
variable.
David Korn
[email protected]
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers