Skip to content
/ clsh Public

CLSH is a lightweight, experimental Lua scripting host written in C. The goal of this project is to learn and explore the possibilities with C and Lua.

License

Notifications You must be signed in to change notification settings

Skryvvara/clsh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


CLSH Logo

CLSH - A Lua scripting host written in C

Description

! This is a very early proof of concept

CLSH is a Lua scripting host written in C.

Build

You can build clsh using cmake, first verify that cmake and a c++ compiler is installed. The Lua sources are included in the lib/lua directory, therefore no external packages or an internet connection is required.

cmake --version

#cmake version 3.30.0
#
#CMake suite maintained and supported by Kitware (kitware.com/cmake).

clang --version

#Apple clang version 15.0.0 (clang-1500.3.9.4)
#Target: arm64-apple-darwin23.5.0
#Thread model: posix
#InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

now run the steps below to compile and run the code

mkdir build
cd build

cmake ..
make

./clsh
# usage: ./clsh [file]

Usage

Currently the only supported usage is by providing a lua file as the first argument to CLSH.

Example:

./clsh

./clsh
# usage: ./clsh [file]

./clsh ../scripts/test.lua
# Hi from test.lua

Alternatively you can use the shebang notation to run the lua scripts directly, to do this some preperation is necessary.

  1. Copy the clsh binary to a directory in your path
echo $PATH
cp ./clsh /dir/in/path/clsh

# example:
# I have a directory called $HOME/bin containing the clsh binary

mkdir ~/bin
echo "export PATH=$PATH:$HOME/bin >> .zshrc
cp ./clsh $HOME/bin/clsh
  1. Now create a lua script with the shebang line. You can find an example under scripts/shebang.lua
#!/usr/bin/env clsh

-- test.lua
print("Hi from shebang.lua")
  1. Check the permissions for the lua script, if you are using this method the script itself has to be executable
chmod +x ./scripts/shebang.lua
./scripts/shebang.lua
# Hi from shebang.lua
  1. (optional) copy the script to a location within your path
cp shebang.lua $HOME/bin/shebang

shebang
# Hi from shebang.lua

License

CLSH is licensed under the MIT License.


About

CLSH is a lightweight, experimental Lua scripting host written in C. The goal of this project is to learn and explore the possibilities with C and Lua.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published