~mna/llrocks

2fa8f58a318daf67b7e1980143b8689c126ccff7 — Martin Angers 2 years ago 90dc04e
Make it work when version-specific LUA_PATH is set
1 files changed, 17 insertions(+), 9 deletions(-)

M llrocks
M llrocks => llrocks +17 -9
@@ 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