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

Ksh emulation and function names



I hadn't put this particular set of ramifications together before, but
function names in ksh have to conform to parameter name syntax, which
means they can't begin with a "." unless referencing a namespace, and
if not referencing a namespace, they can't contain a "." unless what
follows it is a valid discipline function name for the variable.**
(If a function name both begins with and contains a dot, it refers to
a function inside a namespace, not a discipline, unless there are two
dots, in which case it's a discipline of a parameter in a namespace.
Urk.)

Ksh of course won't allow reference to namespaces that haven't been
declared, so that further limits function naming.  Zsh currently has
neither declared namespaces nor disciplines, so from that standpoint
it's not inconsistent that zsh allows function names that start with
and contain dots, but should this be mentioned somewhere?  (E.g., ksh
differences in the FAQ?)  Or not worth the effort?

The ksh93 "functions" builtin prints all functions that are in
namespaces, unlike "typeset" which defaults to skipping parameters in
namespaces (except see below).  So, also not inconsistent that zsh
"functions" includes names beginning with a dot.

Related curiosity:  In my (Ubuntu) install of ksh93, "typeset" output includes

readonly .sh

This is somewhat odd because it's the only "variable name" starting
with a dot that is included in this output, and also because there's
no restriction on (for example) creating new functions in the ".sh"
namespace, so except (I guess) that you can't "unset .sh" (whatever
that would mean), it doesn't behave as though it's read-only.

** Declaring a compound type allows creating additional disciplines.




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