Adding some Lua documentation

Skip to first unread message

Cefan Daniel Rubin

Mar 13, 2021, 4:07:39 PMMar 13
to cosmopolitan cosmonauts
Dear all

I'm a very happy new cosmonaut. I've been converting a generic static-site text processor I wrote in Lua ages ago to benefit from living in the land of APE and it really works well! I wanted to get the following to work:
  1. Being able to extend the lua base with platform-specific functions (like luafilesystem)
  2. Pass along command-line arguments to an initial Lua file
  3. Enable Lua sripts to require other Lua files from within the zip archive
And I would like to share the simple steps with others.

Could something like this be helpful in the Documentation section of the site:

If so please shout if you suggest changes. Happy to mold it if needed. Thanks again justine and crew! :)

 - Cefan

Justine Tunney

Mar 14, 2021, 12:49:12 AMMar 14
to Cefan Daniel Rubin, cosmopolitan cosmonauts
package.path = 'zip:?.lua' is a brilliant insight. I had no idea it would be that simple.

Looking at the luafilesystem package I'd recommend caution. Those things likely weren't included in Lua for a reason. Cosmopolitan makes i/o primitives easier but that doesn't make them any less hairy. For example, there currently isn't a windows polyfill of readlink and posix advisory locks. Cosmopolitan should polyfill those things, but reading links isn't something I'd want to encourage people to do, since I'm not convinced it has a use case and it probably needs root on windows. Having readdir() would be good but please note it currently isn't polyfilled to support the zip file system.

You received this message because you are subscribed to the Google Groups "cosmopolitan cosmonauts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
For more options, visit

cd rubin

Mar 14, 2021, 8:56:52 AMMar 14
to Justine Tunney, cosmopolitan cosmonauts
Fanks for the feedback. I've removed the link related functions from
the morelua.c example - the directory iterator is really the function
I think is more important. I've also added a note to the
file not to expect directory iterators over the zip filesystem to work
quite yet. Cheers!
Reply all
Reply to author
0 new messages