summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/test/module_parsing.py6
-rw-r--r--lib/spack/spack/util/module_cmd.py10
2 files changed, 13 insertions, 3 deletions
diff --git a/lib/spack/spack/test/module_parsing.py b/lib/spack/spack/test/module_parsing.py
index 8779deb0ac..a1d0142b92 100644
--- a/lib/spack/spack/test/module_parsing.py
+++ b/lib/spack/spack/test/module_parsing.py
@@ -123,3 +123,9 @@ def test_get_argument_from_module_line():
for bl in bad_lines:
with pytest.raises(ValueError):
get_path_args_from_module_line(bl)
+
+
+def test_lmod_quote_parsing():
+ lines = ['setenv("SOME_PARTICULAR_DIR","-L/opt/cray/pe/mpich/8.1.4/gtl/lib")']
+ result = get_path_from_module_contents(lines, 'some-module')
+ assert '/opt/cray/pe/mpich/8.1.4/gtl' == result
diff --git a/lib/spack/spack/util/module_cmd.py b/lib/spack/spack/util/module_cmd.py
index 96ca98d39d..fa6996fcbd 100644
--- a/lib/spack/spack/util/module_cmd.py
+++ b/lib/spack/spack/util/module_cmd.py
@@ -195,9 +195,13 @@ def get_path_from_module_contents(text, module_name):
def match_flag_and_strip(line, flag, strip=[]):
flag_idx = line.find(flag)
if flag_idx >= 0:
- end = line.find(' ', flag_idx)
- if end >= 0:
- path = line[flag_idx + len(flag):end]
+ # Search for the first occurence of any separator marking the end of
+ # the path.
+ separators = (' ', '"', "'")
+ occurrences = [line.find(s, flag_idx) for s in separators]
+ indices = [idx for idx in occurrences if idx >= 0]
+ if indices:
+ path = line[flag_idx + len(flag):min(indices)]
else:
path = line[flag_idx + len(flag):]
path = strip_path(path, strip)