1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

typeset -T shouldn't list types created with enum (#340)

Listing types with 'typeset -T' will list not only types created with
typeset, but also types created with enum. However, the types created
by enum are not displayed correctly in the resulting output:

$ enum Foo_t=(foo bar)
$ typeset -T
typeset -T Foo_t
typeset -T Foo_t=fo)

The fix for this bug was backported from ksh93v- 2013-10-08.

src/cmd/ksh93/sh/nvtype.c:
- sh_outtype(): Skip over enums when listing types with 'typeset -T'.
This commit is contained in:
Johnothan King 2021-11-20 00:41:49 -08:00 committed by Martijn Dekker
parent cb961788a8
commit e554a07c56
4 changed files with 16 additions and 2 deletions

View file

@ -1580,13 +1580,16 @@ int sh_outtype(Shell_t *shp,Sfio_t *out)
if(indent==0)
for(tp = (Namval_t*)dtfirst(dp); tp; tp = (Namval_t*)dtnext(dp,tp))
{
/* skip over enums */
if(tp->nvfun && !nv_isvtree(tp))
continue;
if(!nv_search(tp->nvname,shp->bltin_tree,0))
continue;
sfprintf(out,"typeset -T %s\n",tp->nvname);
}
for(tp = (Namval_t*)dtfirst(dp); tp; tp = (Namval_t*)dtnext(dp,tp))
{
if(nv_isnull(tp))
if(nv_isnull(tp) || !nv_isvtree(tp))
continue;
if(indent && (memcmp(tp->nvname,shp->prefix,n-1) || tp->nvname[n-1]!='.' || strchr(tp->nvname+n,'.')))
continue;