From 3132833570c90d52f6c2a422506732e82d772cdd Mon Sep 17 00:00:00 2001 From: Felix Krull Date: Sun, 26 Jun 2016 01:48:30 +0200 Subject: Ensure shebang lines are correctly quoted if sys.executable contains spaces. Fixes issue #398. This only special-cases sys.executable; if the --executable parameter is used, paths with spaces have to be quoted there explicitly. While this change also applies to Unix platforms, if sys.executable contains spaces on Unix, any shebang lines created with it aren't going to work either way, whether they are quoted or not. --- setuptools/command/easy_install.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'setuptools/command/easy_install.py') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 9ca1554e..d63fb529 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1985,9 +1985,18 @@ class CommandSpec(list): def as_header(self): return self._render(self + list(self.options)) + @staticmethod + def _strip_quotes(item): + _QUOTES = '"\'' + for q in _QUOTES: + if item.startswith(q) and item.endswith(q): + return item[1:-1] + return item + @staticmethod def _render(items): - cmdline = subprocess.list2cmdline(items) + cmdline = subprocess.list2cmdline( + CommandSpec._strip_quotes(item.strip()) for item in items) return '#!' + cmdline + '\n' # For pbr compat; will be removed in a future version. -- cgit v1.2.1