Update regex to correctly identify quoted args (#23494)

Previously the regex was only checking for presence of quotes as a beginning
or end character and not a matching set.  This erroneously identified the
following *single* argument as being quoted:

    source bashenvfile &> /dev/null && python3 -c "import os, json; print(json.dumps(dict(os.environ)))"
This commit is contained in:
edwardsp 2022-05-24 16:26:07 +01:00 committed by GitHub
parent 557845cccc
commit ba701a7cf8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -178,7 +178,7 @@ def streamify(arg, mode):
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:
tty.warn(
"Quotes in command arguments can confuse scripts like"