Remove erroneous warnings about quotes for from_source_file (#22767)

This commit is contained in:
Adam J. Stewart 2021-04-06 00:13:54 -05:00 committed by Todd Gamblin
parent 43cea1b354
commit 2496c7b514
2 changed files with 18 additions and 10 deletions

View file

@ -942,7 +942,9 @@ def _source_single_file(file_and_args, environment):
source_file, suppress_output, source_file, suppress_output,
concatenate_on_success, dump_environment, 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) environment = json.loads(output)
# If we're in python2, convert to str objects instead of unicode # If we're in python2, convert to str objects instead of unicode

View file

@ -92,6 +92,8 @@ def __call__(self, *args, **kwargs):
ignore_errors (int or list): A list of error codes to ignore. ignore_errors (int or list): A list of error codes to ignore.
If these codes are returned, this process will not raise If these codes are returned, this process will not raise
an exception even if ``fail_on_error`` is set to ``True`` 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 input: Where to read stdin from
output: Where to send stdout output: Where to send stdout
error: Where to send stderr error: Where to send stderr
@ -140,6 +142,7 @@ def __call__(self, *args, **kwargs):
fail_on_error = kwargs.pop('fail_on_error', True) fail_on_error = kwargs.pop('fail_on_error', True)
ignore_errors = kwargs.pop('ignore_errors', ()) 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 they just want to ignore one error code, make it a tuple.
if isinstance(ignore_errors, int): if isinstance(ignore_errors, int):
@ -164,6 +167,7 @@ def streamify(arg, mode):
estream, close_estream = streamify(error, 'w') estream, close_estream = streamify(error, 'w')
istream, close_istream = streamify(input, 'r') istream, close_istream = streamify(input, 'r')
if not ignore_quotes:
quoted_args = [arg for arg in args if re.search(r'^"|^\'|"$|\'$', arg)] quoted_args = [arg for arg in args if re.search(r'^"|^\'|"$|\'$', arg)]
if quoted_args: if quoted_args:
tty.warn( tty.warn(
@ -171,8 +175,10 @@ def streamify(arg, mode):
" configure.", " configure.",
"The following arguments may cause problems when executed:", "The following arguments may cause problems when executed:",
str("\n".join([" " + arg for arg in quoted_args])), str("\n".join([" " + arg for arg in quoted_args])),
"Quotes aren't needed because spack doesn't use a shell.", "Quotes aren't needed because spack doesn't use a shell. "
"Consider removing them") "Consider removing them.",
"If multiple levels of quotation are required, use "
"`ignore_quotes=True`.")
cmd = self.exe + list(args) cmd = self.exe + list(args)