@@ 4,18 4,28 @@ set -euo pipefail
# TODO: would be nice to use a non-GNU-specific option (complement)
luaver=$(lua -v | cut -d ' ' -f2 | cut -d. --complement -f3)
modpath="${LUA_MODULESPATH:-lua_modules}"
+luaver__=$(echo ${luaver} | tr . _)
+
+
+# modify LUA_[C]PATH by default, switch to version-specific variables if set
+luapath=LUA_PATH
+luacpath=LUA_CPATH
+verspecific=LUA_PATH_${luaver__}
+if [[ ! -z ${!verspecific:-} ]]; then
+ luapath=${verspecific}
+ luacpath=LUA_CPATH_${luaver__}
+fi
+
+eval "$luapath"="'${modpath}/share/lua/${luaver}/?.lua;${modpath}/share/lua/${luaver}/?/init.lua;${!luapath:-;}'"
+eval "$luacpath"="'${modpath}/lib/lua/${luaver}/?.so;${!luacpath:-;}'"
function __luarun {
- LUA_PATH="${modpath}/share/lua/${luaver}/?.lua;${modpath}/share/lua/${luaver}/?/init.lua;${LUA_PATH:-;}" \
- LUA_CPATH="${modpath}/lib/lua/${luaver}/?.so;${LUA_CPATH:-;}" \
- exec lua "$@"
+ exec lua "$@"
exit
}
function __envrun {
- LUA_PATH="${modpath}/share/lua/${luaver}/?.lua;${modpath}/share/lua/${luaver}/?/init.lua;${LUA_PATH:-;}" \
- LUA_CPATH="${modpath}/lib/lua/${luaver}/?.so;${LUA_CPATH:-;}" \
- "$@"
+ "$@"
exit
}
@@ 24,9 34,7 @@ function __coverrun {
rm luacov.stats.out 2>/dev/null || true
# run the unit tests
- LUA_PATH="${modpath}/share/lua/${luaver}/?.lua;${modpath}/share/lua/${luaver}/?/init.lua;${LUA_PATH:-;}" \
- LUA_CPATH="${modpath}/lib/lua/${luaver}/?.so;${LUA_CPATH:-;}" \
- lua -lluacov "$@"
+ lua -lluacov "$@"
# run luacov to get the report file
"${modpath}"/bin/luacov