Merge branch '7.x'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Lord · committed by David Lord · parents 97de2c9, 1784558 · Browse files · 4 files·+26 added−16 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+26 added−16 removed
- tests:+0 added−1 removed
- other:+26 added−15 removed
Provenance
- Commit
bce4ea4- Tree
ffdbe1a- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent 1
97de2c9- Parent 2
1784558
4 files changed+26 added−16 removed
modified:docs/options.rst+1 added-1 removed
384 unmodified lines385 Choices should be unique after considering the effects of386 ``case_sensitive`` and any specified token normalization function.387 388 .. versionchanged:: 7.1389- The resulting value from an option will always be on the of the389+ The resulting value from an option will always be one of the390 originally passed choices regardless of ``case_sensitive``.391 392 .. _option-prompting:393 459 unmodified linesmodified:src/click/_termui_impl.py+13 added-14 removed
4 unmodified lines5 """6 import contextlib7 import math8 import os9-import shlex9 import sys10 import time11 12 from ._compat import _default_text_stdout337 unmodified lines350 351 fd, filename = tempfile.mkstemp()352 os.close(fd)353 try:355- if hasattr(os, "system") and os.system(f"more {shlex.quote(filename)}") == 0:354+ if hasattr(os, "system") and os.system(f'more "{filename}"') == 0:355 return _pipepager(generator, "more", color)356 return _nullpager(stdout, generator, color)357 finally:358 os.unlink(filename)60 unmodified lines419 encoding = get_best_encoding(sys.stdout)420 with open_stream(filename, "wb")[0] as f:421 f.write(text.encode(encoding))422 try:424- os.system(f"{shlex.quote(cmd)} {shlex.quote(filename)}")423+ os.system(f'{cmd} "{filename}"')424 finally:425 os.unlink(filename)426 427 35 unmodified lines463 environ.update(self.env)464 else:465 environ = None466 try:468- c = subprocess.Popen(469- f"{shlex.quote(editor)} {shlex.quote(filename)}",470- env=environ,471- shell=True,472- )467+ c = subprocess.Popen(f'{editor} "{filename}"', env=environ, shell=True)468 exit_code = c.wait()469 if exit_code != 0:470 raise ClickException(f"{editor}: Editing failed!")471 except OSError as e:64 unmodified lines536 finally:537 null.close()538 elif WIN:539 if locate:545- url = _unquote_file(url)546- args = f"explorer /select,{shlex.quote(url)}"540+ url = _unquote_file(url.replace('"', ""))541+ args = f'explorer /select,"{url}"'542 else:548- args = f"start {'/WAIT' if wait else ''} \"\" {shlex.quote(url)}"543+ url = url.replace('"', "")544+ wait = "/WAIT" if wait else ""545+ args = f'start {wait} "" "{url}"'546 return os.system(args)547 elif CYGWIN:548 if locate:552- url = _unquote_file(url)553- args = f"cygstart {shlex.quote(os.path.dirname(url))}"549+ url = os.path.dirname(_unquote_file(url).replace('"', ""))550+ args = f'cygstart "{url}"'551 else:555- args = f"cygstart {'-w' if wait else ''} {shlex.quote(url)}"552+ url = url.replace('"', "")553+ wait = "-w" if wait else ""554+ args = f'cygstart {wait} "{url}"'555 return os.system(args)556 557 try:558 if locate:109 unmodified linesmodified:tests/test_imports.py-1 removed
44 unmodified lines45 "errno",46 "fcntl",47 "datetime",48 "pipes",49- "shlex",49 }50 51 if WIN:52 ALLOWED_IMPORTS.update(["ctypes", "ctypes.wintypes", "msvcrt", "time", "zlib"])14 unmodified linesmodified:CHANGES.rst+12 added
12 unmodified lines13 - Add an optional parameter to ``ProgressBar.update`` to set the14 ``current_item``. :issue:`1226`, :pr:`1332`15 16 17+Version 7.1.218+-------------19+20+Released 2020-04-2721+22+- Revert applying shell quoting to commands for ``echo_with_pager``23+ and ``edit``. This was intended to allows spaces in commands, but24+ caused issues if the string was actually a command and arguments, or25+ on Windows. Instead, the string must be quoted manually as it should26+ appear on the command line. :issue:`1514`27+28+29 Version 7.1.130 -------------31 32 Released 2020-03-09619 unmodified lines