Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: Docs out of sync



On Dec 9,  7:43pm, Phil Pennock wrote:
} Subject: PATCH: Docs out of sync
}
} Typing away merrily, Peter Stephenson produced the immortal words:
} > Phil Pennock wrote:
} > > * bash has arrays.  'declare', 'local' & 'readonly' each accept '-a' to
} > >   declare an array.  Is it reasonable to add '-a' to 'typeset'?  This
} > >   would automatically duplicate the bash-ism.
} > 
} > It's not exactly essential, since bash and zsh have rather different
} > extensions to sh in any case.  They're only similar in as much as they
} > both include sh.  It's hard enough keeping ksh emulation working.
} 
} Looking through the source for 3.1.5-patched, bin_typeset et al accept
} -a.  This is undocumented.  This functionality is not in 3.1.5.
} With no arguments beyond the options, "typeset -a" scans the parameter
} table for arrays.  "typeset -A" scans for hashes.  An added bonus!  ;^)

It was actually typeset -A that I was adding, and -a was the bonus.

} Except that "typeset -a foo" is silently ignored.  An unhandled case
} later on.

It's an unhandled case because the code (from prior to my patch) has an
explicit 	on &= ~PM_ARRAY;	in the loop that creates the
parameters when they don't already exist.  I think that's there because
the syntax	typeset array=(x y z)	doesn't make it through the
parser, but I don't know for sure so I didn't mess with it.

Anyway, it's not correct to say that `typeset -a foo` is ignored -- it
DOES create the parameter foo, but it creates it as a scalar, not as an
array, which is exactly what used to happen with `typeset foo=(x y z)`
before (x y z) started being interpreted as a glob modifier.  (Now it
says "unknown file attribute" and fails entirely.)

} Scanning back, Bart added this functionality in patch 4608 (Nov 12).
} It was documented in the article, but no docs patch.  The options to
} 'local' were also modified.

I didn't give a doc patch because none of this stuff is stable yet; the
syntax may change, etc.  (Though `typeset -A` is unlikely to change, as
it's ksh compatible.)

} Docs patch included at end of this article.

Thanks, but ...

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



Messages sorted by: Reverse Date, Date, Thread, Author