diff options
author | David Lord <davidism@gmail.com> | 2020-04-27 08:47:06 -0700 |
---|---|---|
committer | David Lord <davidism@gmail.com> | 2020-04-27 12:22:43 -0700 |
commit | 0d1b8eab4d44047b52746639d7836cc849626e59 (patch) | |
tree | 4b6e31df6097523c92c9b0812a18703839d609ee /src/click/_termui_impl.py | |
parent | a6b10db3882fe464898f1ffaa6fbba6fc390f894 (diff) | |
download | click-0d1b8eab4d44047b52746639d7836cc849626e59.tar.gz |
Revert "Use shlex.quote for quoting shell arguments"
This reverts commit e798f64ffde20c549e2e0df5834e4194c74adb0a.
This caused issues if the editor command (etc.) had options like
"less -FRSX" because they would then get quoted as a single word.
Diffstat (limited to 'src/click/_termui_impl.py')
-rw-r--r-- | src/click/_termui_impl.py | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/click/_termui_impl.py b/src/click/_termui_impl.py index c6e86cc..88bec37 100644 --- a/src/click/_termui_impl.py +++ b/src/click/_termui_impl.py @@ -17,7 +17,6 @@ from ._compat import int_types from ._compat import isatty from ._compat import open_stream from ._compat import range_type -from ._compat import shlex_quote from ._compat import strip_ansi from ._compat import term_len from ._compat import WIN @@ -346,10 +345,7 @@ def pager(generator, color=None): fd, filename = tempfile.mkstemp() os.close(fd) try: - if ( - hasattr(os, "system") - and os.system("more {}".format(shlex_quote(filename))) == 0 - ): + if hasattr(os, "system") and os.system('more "{}"'.format(filename)) == 0: return _pipepager(generator, "more", color) return _nullpager(stdout, generator, color) finally: @@ -418,7 +414,7 @@ def _tempfilepager(generator, cmd, color): with open_stream(filename, "wb")[0] as f: f.write(text.encode(encoding)) try: - os.system("{} {}".format(shlex_quote(cmd), shlex_quote(filename))) + os.system('{} "{}"'.format(cmd, filename)) finally: os.unlink(filename) @@ -463,9 +459,7 @@ class Editor(object): environ = None try: c = subprocess.Popen( - "{} {}".format(shlex_quote(editor), shlex_quote(filename)), - env=environ, - shell=True, + '{} "{}"'.format(editor, filename), env=environ, shell=True, ) exit_code = c.wait() if exit_code != 0: @@ -536,16 +530,18 @@ def open_url(url, wait=False, locate=False): elif WIN: if locate: url = _unquote_file(url) - args = "explorer /select,{}".format(shlex_quote(url)) + args = 'explorer /select,"{}"'.format(_unquote_file(url.replace('"', ""))) else: - args = 'start {} "" {}'.format("/WAIT" if wait else "", shlex_quote(url)) + args = 'start {} "" "{}"'.format( + "/WAIT" if wait else "", url.replace('"', "") + ) return os.system(args) elif CYGWIN: if locate: url = _unquote_file(url) - args = "cygstart {}".format(shlex_quote(os.path.dirname(url))) + args = 'cygstart "{}"'.format(os.path.dirname(url).replace('"', "")) else: - args = "cygstart {} {}".format("-w" if wait else "", shlex_quote(url)) + args = 'cygstart {} "{}"'.format("-w" if wait else "", url.replace('"', "")) return os.system(args) try: |