GithubHelp home page GithubHelp logo

luashell's Introduction

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

luashell's People

Contributors

amartos avatar

Watchers

 avatar

luashell's Issues

Signals are not handled

The shell should handle signals sent through keyboard, at least:

  • SIGINT (ctrl-c)
    • do not interrupt the shell itself
    • interrupt running commands
  • SIGSTOP (ctrl-z)
  • SIGCONT (jobs control)

Implement more unit tests

  • Globals
    • definition from environment
    • definition from script
    • definition from shell
    • no definition
    • wrong definition
  • Interactive mode
    • Lua interpreter launched
    • Lua errors handling (proper error messages printing?)
    • Signals handling (see #1)
  • Interpreter mode
    • Identification of shebangs (see #5)
    • Proper script execution
    • No printing of globals (PROMPT, BANNER, ...)
    • Printing of all CONFFILE loading result
    • No signal handling in interpreter mode (see #1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.