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

Re: Some questions about Zsh internals (zmodules)

On Sun, 20 Apr 2008 01:04:01 +0000
"Johann \"Myrkraverk\" Oskarsson" <johann@xxxxxxxxxxxxxx> wrote:
> The Zsh developers guide mentions reading about the zmodload -F but
> that is not covered in my copy of the zshmodules man page.  Is that an
> oversight, or is the documentation somewhere else?

If you've found the zmodload documentation corresponding to the version
you're talking about you should see it, but it's in the zshbuiltins
manual page.  Note this is new in 4.3.5.

> More specifically,
> that's not in the online version of the manual either.

This doesn't always get updated and it looks like it's way out of date.
Ideally we should have separate manuals for the stable and development
branches.  Could somebody volunteer for this?  I have way, way, way too
much to do already.

> When I want to create a builtin that takes integers or floating point
> (double) arguments, do I really need to parse all that stuff myself,
> or does the shell have any support for that?  Is there a zsh specific
> API for it, or is there only the C library?

It has it, but at this level you'll just have to look at the shell's
internals to get it.    The usual way of getting it would be

  mnumber mn = matheval(*args);

Note this actually allows expressions, not just numbers.  There's a kind
of unwritten convention that the shell does this, but in a module
there's no reason why you should have to go to such lengths.  One good
reason for it, however, is that fully parsing the expression in this way
is the best way of getting the shell to decide whether the number is
integer or floating point.

mnumber is a discriminated unoin defined in zsh.h.

> Shouldn't it be documented somewhere that passing a NULL for the flags
> parameter in the builtin list disables flag handling by the shell?

Yes, probably.

Index: Etc/zsh-development-guide
RCS file: /cvsroot/zsh/zsh/Etc/zsh-development-guide,v
retrieving revision 1.18
diff -u -r1.18 zsh-development-guide
--- Etc/zsh-development-guide	3 Feb 2008 18:17:13 -0000	1.18
+++ Etc/zsh-development-guide	20 Apr 2008 16:33:56 -0000
@@ -391,7 +391,8 @@
     implement multiple builtins
   - the options the builtin accepts, given as a string containing the
     option characters (the above example makes the builtin accept the
-    options `f', `l', `a', `g', and `s')
+    options `f', `l', `a', `g', and `s').  Passing NULL here disables
+    all flag handling, i.e. even "--".
   - and finally a optional string containing option characters that
     will always be reported as set when calling the C-function (this,
     too, can be used when using one C-function to implement multiple
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/

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