Last active
October 27, 2020 15:08
-
-
Save SpotlightKid/973288872aecc5912703941c798cb525 to your computer and use it in GitHub Desktop.
Lua environment variables for multiple version support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Lua dev | |
LUA_DIR="$HOME/share/lua" | |
LUA_CDIR="$HOME/lib/lua" | |
if which lua5.1 >/dev/null 2>&1; then | |
if which luarocks >/dev/null 2>&1; then | |
LUA_PATH_5_1="$(luarocks --lua-version 5.1 --local path --lr-path)" | |
LUA_CPATH_5_1="$(luarocks --lua-version 5.1 --local path --lr-cpath)" | |
fi | |
if [[ -d "$LUA_DIR/5.1" ]]; then | |
LUA_PATH_5_1="$LUA_DIR/5.1/?.lua${LUA_PATH_5_1:+;$LUA_PATH_5_1}" | |
fi | |
if [[ -d "$LUA_CDIR/5.1" ]]; then | |
LUA_PATH_5_1="$LUA_DIR/5.1/?.lua${LUA_PATH_5_1:+;$LUA_PATH_5_1}" | |
fi | |
fi | |
if which lua5.2 >/dev/null 2>&1; then | |
if which luarocks >/dev/null 2>&1; then | |
LUA_PATH_5_2="$(luarocks --lua-version 5.2 --local path --lr-path)" | |
LUA_CPATH_5_2="$(luarocks --lua-version 5.2 --local path --lr-cpath)" | |
fi | |
if [[ -d "$LUA_DIR/5.2" ]]; then | |
LUA_PATH_5_2="$LUA_DIR/5.2/?.lua${LUA_PATH_5_2:+;$LUA_PATH_5_2}" | |
fi | |
if [[ -d "$LUA_CDIR/5.2" ]]; then | |
LUA_CPATH_5_2="$LUA_DIR/5.2/?.lua${LUA_CPATH_5_2:+;$LUA_CPATH_5_2}" | |
fi | |
fi | |
if which lua5.3 >/dev/null 2>&1; then | |
if which luarocks >/dev/null 2>&1; then | |
LUA_PATH_5_3="$(luarocks --lua-version 5.3 --local path --lr-path)" | |
LUA_CPATH_5_3="$(luarocks --lua-version 5.3 --local path --lr-cpath)" | |
fi | |
if [[ -d "$LUA_DIR/5.3" ]]; then | |
LUA_PATH_5_3="$LUA_DIR/5.3/?.lua${LUA_PATH_5_3:+;$LUA_PATH_5_3}" | |
fi | |
if [[ -d "$LUA_CDIR/5.3" ]]; then | |
LUA_CPATH_5_3="$LUA_CDIR/5.3/?.lua${LUA_CPATH_5_3:+;$LUA_CPATH_5_3}" | |
fi | |
fi | |
if which lua5.4 >&/dev/null; then | |
if which luarocks >/dev/null 2>&1; then | |
# This also extends PATH | |
eval "$(luarocks --local path)" | |
fi | |
if [[ -d "$LUA_DIR/5.4" ]]; then | |
LUA_PATH="$LUA_DIR/5.4/?.lua;$LUA_DIR/?.lua${LUA_PATH:+;$LUA_PATH}" | |
fi | |
if [[ -d "$LUA_CDIR/5.4" ]]; then | |
LUA_CPATH="$LUA_CDIR/5.4/?.lua;$LUA_CDIR/?.lua${LUA_CPATH:+;$LUA_CPATH}" | |
fi | |
fi | |
export LUA_PATH_5_1 LUA_CPATH_5_1 | |
export LUA_PATH_5_2 LUA_CPATH_5_2 | |
export LUA_PATH_5_3 LUA_CPATH_5_3 | |
export LUA_PATH LUA_CPATH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment