Skip to content

Latest commit

 

History

History
61 lines (45 loc) · 2.55 KB

README.org

File metadata and controls

61 lines (45 loc) · 2.55 KB

Luashell

A very simple Lua interpreter + shell implementation in C++, as a demo. It currently depends on Lua version 5.4 and GNU’s readline library.

Configuration

The interpreter loads the file located at $LUASHELL_CONFFILE if defined, or $XDG_CONFIG_HOME/luashell/config.lua, if it exists, before execution of any script or the shell’s prompt.

Environment

The interpreter globals are:

namedefault valuedescriptiontypes
CONFFILE$XDG_CONFIG_HOME/luashell/config.luaconfig file path
HISTFILE$XDG_DATA_HOME/luashell/historyhistory file pathstr, str f()
PROMPT>>>prompt stringstr, str f()
BANNERbanner stringstr, str f()

Definition priorities

Each of these globals are first fetched from the environment, where their name is prefixed with LUASHELL_ (example: LUASHELL_CONFFILE). The default values are used if they are not defined or empty.

The configuration file is loaded after fetching the environment values, thus they can be redefined in it using the name listed in the table above. Note redefinition of globals with an empty types value in the table do not matter at this stage (see the next section).

Finally, they can be redefined in the shell or the script itself, using the names in the table, but the given values won’t persist between sessions.

Globals’ values types

The types column contains a comma-separated list of types that the shell expects to find in the variable. If the type is of the form returnType f(argType, argType, ...), the value may be a Lua function of the described prototype (the name f does not matter).

If no types are defined, the variable expects a string and its redefinition is only considered if it is done in the environment. The value is still accessible and modifiable from the shell/script/config file, but this won’t affect the interpreter at all.

For a list of available types (applicable to returnType and argType), see the types used by Lua. Their name may be shortened in the table, for example str for string. The following types are additional to this list:

typeLua typedescription
intnumbera number that will be truncated