summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAdam J. Stewart <ajstewart426@gmail.com>2021-04-06 00:13:54 -0500
committerTodd Gamblin <tgamblin@llnl.gov>2021-05-22 11:51:20 -0700
commit2496c7b514a500da032218960cf8b8e50cc7d29d (patch)
treee48336d1eda4d00a1ac3c1b9f82305b9ddcfbbe5 /lib
parent43cea1b35444f596d75aaad1a1a0bf02a2ba347a (diff)
downloadspack-2496c7b514a500da032218960cf8b8e50cc7d29d.tar.gz
spack-2496c7b514a500da032218960cf8b8e50cc7d29d.tar.bz2
spack-2496c7b514a500da032218960cf8b8e50cc7d29d.tar.xz
spack-2496c7b514a500da032218960cf8b8e50cc7d29d.zip
Remove erroneous warnings about quotes for from_source_file (#22767)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/util/environment.py4
-rw-r--r--lib/spack/spack/util/executable.py24
2 files changed, 18 insertions, 10 deletions
diff --git a/lib/spack/spack/util/environment.py b/lib/spack/spack/util/environment.py
index 53e0da32d7..c4e7ea3260 100644
--- a/lib/spack/spack/util/environment.py
+++ b/lib/spack/spack/util/environment.py
@@ -942,7 +942,9 @@ def environment_after_sourcing_files(*files, **kwargs):
source_file, suppress_output,
concatenate_on_success, dump_environment,
])
- output = shell(source_file_arguments, output=str, env=environment)
+ output = shell(
+ source_file_arguments, output=str, env=environment, ignore_quotes=True
+ )
environment = json.loads(output)
# If we're in python2, convert to str objects instead of unicode
diff --git a/lib/spack/spack/util/executable.py b/lib/spack/spack/util/executable.py
index fb192d6885..c01ae1b61b 100644
--- a/lib/spack/spack/util/executable.py
+++ b/lib/spack/spack/util/executable.py
@@ -92,6 +92,8 @@ class Executable(object):
ignore_errors (int or list): A list of error codes to ignore.
If these codes are returned, this process will not raise
an exception even if ``fail_on_error`` is set to ``True``
+ ignore_quotes (bool): If False, warn users that quotes are not needed
+ as Spack does not use a shell. Defaults to False.
input: Where to read stdin from
output: Where to send stdout
error: Where to send stderr
@@ -140,6 +142,7 @@ class Executable(object):
fail_on_error = kwargs.pop('fail_on_error', True)
ignore_errors = kwargs.pop('ignore_errors', ())
+ ignore_quotes = kwargs.pop('ignore_quotes', False)
# If they just want to ignore one error code, make it a tuple.
if isinstance(ignore_errors, int):
@@ -164,15 +167,18 @@ class Executable(object):
estream, close_estream = streamify(error, 'w')
istream, close_istream = streamify(input, 'r')
- quoted_args = [arg for arg in args if re.search(r'^"|^\'|"$|\'$', arg)]
- if quoted_args:
- tty.warn(
- "Quotes in command arguments can confuse scripts like"
- " configure.",
- "The following arguments may cause problems when executed:",
- str("\n".join([" " + arg for arg in quoted_args])),
- "Quotes aren't needed because spack doesn't use a shell.",
- "Consider removing them")
+ if not ignore_quotes:
+ quoted_args = [arg for arg in args if re.search(r'^"|^\'|"$|\'$', arg)]
+ if quoted_args:
+ tty.warn(
+ "Quotes in command arguments can confuse scripts like"
+ " configure.",
+ "The following arguments may cause problems when executed:",
+ str("\n".join([" " + arg for arg in quoted_args])),
+ "Quotes aren't needed because spack doesn't use a shell. "
+ "Consider removing them.",
+ "If multiple levels of quotation are required, use "
+ "`ignore_quotes=True`.")
cmd = self.exe + list(args)