Skip to content
Myr

Merge pull request #1543 from pallets/revert-shlex-quote

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Revert "Use shlex.quote for quoting shell arguments"

authored by David Lord · committed by GitHub · parents a6b10db, 0d1b8ea · Browse files · 3 files+9 added−18 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+9 added−18 removed

  • tests:+0 added−1 removed
  • other:+9 added−17 removed

3 files+9 added−18 removed

modified:src/click/_compat.py-4 removed
172 unmodified lines
173 int_types = (int, long)174 iteritems = lambda x: x.iteritems()175 range_type = xrange176177 from pipes import quote as shlex_quote178177 def is_bytes(x):178 return isinstance(x, (buffer, bytearray))179180 _identifier_re = re.compile(r"^[a-zA-Z_][a-zA-Z0-9_]*$")
100 unmodified lines
281 range_type = range282 isidentifier = lambda x: x.isidentifier()283 iteritems = lambda x: iter(x.items())284287 from shlex import quote as shlex_quote288285 def is_bytes(x):286 return isinstance(x, (bytes, memoryview, bytearray))287288 def _is_binary_reader(stream, default=False):
498 unmodified lines
modified:src/click/_termui_impl.py+9 added-13 removed
15 unmodified lines
16from ._compat import int_types17from ._compat import isatty18from ._compat import open_stream19from ._compat import range_type20from ._compat import shlex_quote20from ._compat import strip_ansi21from ._compat import term_len22from ._compat import WIN23from .exceptions import ClickException
320 unmodified lines
344345 fd, filename = tempfile.mkstemp()346 os.close(fd)347 try:349 if (350 hasattr(os, "system")351 and os.system("more {}".format(shlex_quote(filename))) == 0352 ):348 if hasattr(os, "system") and os.system('more "{}"'.format(filename)) == 0:349 return _pipepager(generator, "more", color)350 return _nullpager(stdout, generator, color)351 finally:352 os.unlink(filename)
60 unmodified lines
413 encoding = get_best_encoding(sys.stdout)414 with open_stream(filename, "wb")[0] as f:415 f.write(text.encode(encoding))416 try:421 os.system("{} {}".format(shlex_quote(cmd), shlex_quote(filename)))417 os.system('{} "{}"'.format(cmd, filename))418 finally:419 os.unlink(filename)420421
36 unmodified lines
458 else:459 environ = None460 try:461 c = subprocess.Popen(466 "{} {}".format(shlex_quote(editor), shlex_quote(filename)),467 env=environ,468 shell=True,462 '{} "{}"'.format(editor, filename), env=environ, shell=True,463 )464 exit_code = c.wait()465 if exit_code != 0:466 raise ClickException("{}: Editing failed!".format(editor))
62 unmodified lines
529 null.close()530 elif WIN:531 if locate:532 url = _unquote_file(url)539 args = "explorer /select,{}".format(shlex_quote(url))533 args = 'explorer /select,"{}"'.format(_unquote_file(url.replace('"', "")))534 else:541 args = 'start {} "" {}'.format("/WAIT" if wait else "", shlex_quote(url))535 args = 'start {} "" "{}"'.format(536 "/WAIT" if wait else "", url.replace('"', "")537 )538 return os.system(args)539 elif CYGWIN:540 if locate:541 url = _unquote_file(url)546 args = "cygstart {}".format(shlex_quote(os.path.dirname(url)))542 args = 'cygstart "{}"'.format(os.path.dirname(url).replace('"', ""))543 else:548 args = "cygstart {} {}".format("-w" if wait else "", shlex_quote(url))544 args = 'cygstart {} "{}"'.format("-w" if wait else "", url.replace('"', ""))545 return os.system(args)546547 try:548 if locate:
109 unmodified lines
modified:tests/test_imports.py-1 removed
47 unmodified lines
48 "errno",49 "fcntl",50 "datetime",51 "pipes",52 "shlex",52}5354if WIN:55 ALLOWED_IMPORTS.update(["ctypes", "ctypes.wintypes", "msvcrt", "time", "zlib"])
16 unmodified lines