Skip to content

Commit

Permalink
[lua] automatically set global variable LUA_PATH to executable cwd. L…
Browse files Browse the repository at this point in the history
…UA_PATH global variable is the first thing searched by a `require`, so we want that to be somewhere vaguely sensible
  • Loading branch information
harrand committed Aug 6, 2023
1 parent 2e00bea commit 2bf51e5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/tz/lua/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <iostream>
#include <cstdint>
#include <map>
#include <filesystem>

extern "C"
{
Expand Down Expand Up @@ -300,6 +301,8 @@ namespace tz::lua
s.assign_func("tz.assert", tz_lua_assert);
s.assign_func("print", tz_print);

s.assign_string("LUA_PATH", std::filesystem::current_path().generic_string());

tz::version ver = tz::get_version();

s.assign_uint("tz.version.major", ver.major);
Expand Down

0 comments on commit 2bf51e5

Please sign in to comment.