Skip to content

Commit

Permalink
Issue #701: Cleanup paths for PATH, LD_LIBRARY_PATH and MODULEPATH
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert McLay committed Mar 29, 2024
1 parent 303b605 commit 0aadd8d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion rt/spider/mf/Core/intel/intel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ prepend_path('MANPATH', '/vol/local/intel/idb/idb/man')
prepend_path('MANPATH', '/vol/local/intel/mkl/mkl/man')
setenv( 'MKL_DIR', '/vol/local/intel/mkl/mkl/lib/lib')
setenv( 'MKL_INCLUDE', '/vol/local/intel/mkl/mkl/include')
prepend_path('LD_LIBRARY_PATH','/vol/local/intel/mkl/mkl/lib/lib')
prepend_path('LD_LIBRARY_PATH','/vol/local/intel/mkl/mkl/lib/lib:')

family("compiler")

Expand Down
4 changes: 2 additions & 2 deletions rt/spider/spider.tdesc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ testdescript = {
unsetMT
rm $HOME/.cache/lmod/spiderT.lua
rm -f $HOME/.cache/lmod/spiderT.lua
export MODULEPATH_ROOT2=$testDir/mf2
export MODULEPATH=$MODULEPATH_ROOT2/Core
Expand All @@ -145,7 +145,7 @@ testdescript = {
# Test writing of user cache
export LMOD_SHORT_TIME=0
rm $HOME/.cache/lmod/*
rm -f $HOME/.cache/lmod/*
runLmod spider #71
Expand Down
27 changes: 23 additions & 4 deletions src/modfuncs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ function load_any(...)
return b
end

local s_cleanupDirT = { PATH = true, LD_LIBRARY_PATH = true, MODULEPATH = true }

--- PATH functions ---
--------------------------------------------------------------------------
-- convert arguments into a table if necessary.
Expand All @@ -224,22 +226,39 @@ local function l_convert2table(...)

if (argA.n == 1 and type(argA[1]) == "table" ) then
t = argA[1]
t[1] = t[1]:trim()
t[1] = t[1]
else
t[1] = argA[1]:trim()
t[1] = argA[1]
t[2] = argA[2]
t.delim = argA[3]
end

t.priority = tonumber(t.priority or "0")
return t
end

local function l_cleanupPathArgs(t)
local name = t[1]:trim()
local path = t[2]:trim()

if (s_cleanupDirT[name]) then
path = path:gsub(":+$",""):gsub("^:+","")
t[2] = path
end

return t
end


--------------------------------------------------------------------------
-- Prepend a value to a path like variable.
function prepend_path(...)
local t = l_convert2table(...)
dbg.start{"prepend_path(",l_concatTbl(t,", "),")"}
if (not l_validateStringTable(2, "prepend_path",t)) then return end
l_cleanupPathArgs(t)



mcp:prepend_path(t)
dbg.fini("prepend_path")
Expand All @@ -251,7 +270,7 @@ function append_path(...)
local t = l_convert2table(...)
dbg.start{"append_path(",l_concatTbl(t,", "),")"}
if (not l_validateStringTable(2, "append_path",t)) then return end

l_cleanupPathArgs(t)
mcp:append_path(t)
dbg.fini("append_path")
end
Expand All @@ -262,7 +281,7 @@ function remove_path(...)
local t = l_convert2table(...)
dbg.start{"remove_path(",l_concatTbl(t,", "),")"}
if (not l_validateStringTable(2, "remove_path",t)) then return end

l_cleanupPathArgs(t)
mcp:remove_path(t)
dbg.fini("remove_path")
end
Expand Down

0 comments on commit 0aadd8d

Please sign in to comment.