diff --git a/lib/spack/spack/modules/common.py b/lib/spack/spack/modules/common.py index 66fe145f358..b5e084bc0c6 100644 --- a/lib/spack/spack/modules/common.py +++ b/lib/spack/spack/modules/common.py @@ -703,7 +703,7 @@ def configure_options(self): if os.path.exists(pkg.install_configure_args_path): with open(pkg.install_configure_args_path, "r") as args_file: - return args_file.read() + return spack.util.path.padding_filter(args_file.read()) # Returning a false-like value makes the default templates skip # the configure option section diff --git a/lib/spack/spack/util/path.py b/lib/spack/spack/util/path.py index 124e8efec61..f894f6f3d8f 100644 --- a/lib/spack/spack/util/path.py +++ b/lib/spack/spack/util/path.py @@ -444,7 +444,7 @@ def padding_filter(string): r"(/{pad})+" # the padding string repeated one or more times r"(/{longest_prefix})?(?=/)" # trailing prefix of padding as path component ) - regex = regex.replace("/", os.sep) + regex = regex.replace("/", re.escape(os.sep)) regex = regex.format(pad=pad, longest_prefix=longest_prefix) _filter_re = re.compile(regex)