civix: unix system library for Civstack

Civix contains standard unix functions that exist in most language's "sys" library such as sleep, epoch etc. It also contains a powerful Sh{} type and convieience sh() function for executing system shell commands, either synchronously or asynchronously using the LAP protocol (see lap.html.

TODO: better docs to come once the ele shell is finished

Mod civix

civix: unix-like OS utilities.

Types: Walk Sh ShFin

Functions

Record Walk

Walk the directory tree as a iterator of path, ftype. Can walk either a single path Walk'path/' or a list of paths Walk{'a/', 'b.txt'}.

Usage:

local ix = require'civix'
local w = ix.Walk{'path/', 'path2/', 'file.txt'}
for path, pathTy in w do
  if pathTy == 'dir' and path:match'skipMe' do
    w:skip() -- skips the rest in this directory.
  end
  -- ... do something with each path.
end

Fields:

Methods

Record Sh

Start args on the shell
Suggestion: use civix.sh instead.

Sh:start() kicks off a subprocess which start the shell using the fds you pass in or creating them if you set them to true. Created file descriptors will be stored in the associated name.

Why? This means that :close() will only close filedescriptors created by the shell itself, and you won't accidentially close io.stdout/etc.

Examples (see civix.sh for more examples):

Lua Bash
Sh({'ls', 'foo/bar'}, {stdout=io.stdout}):start() ls foo/bar
v = Sh{'ls foo/bar', stdout=true}:start():read'a' v=$(ls foo/bar)

Fields:

Methods

Record ShFin

Argument for #civix.Sh.finish.

Fields:

Mod civix.testing

test runners and helpers for civix

Functions