diff options
author | Christopher Larson <chris_larson@mentor.com> | 2018-06-22 02:07:31 +0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-06-27 13:55:21 +0100 |
commit | 2fe9a05666c69274fda766a2bec29febe94ba8b4 (patch) | |
tree | f40f3b0e039a1e90fe346962fbfc8e9843735496 /scripts | |
parent | ea4318b78e9b784c3f688cd8474f92704231d613 (diff) | |
download | poky-2fe9a05666c69274fda766a2bec29febe94ba8b4.tar.gz |
oe.scriptutils.run_editor: ditch the error-prone argument quoting
Rather than trying to construct a string by quoting the files in an
error-prone way, parse $EDITOR to pass a list to subprocess rather than
a string.
(From OE-Core rev: c9fdf3d046606a0becb2e6b566a481c483b9021a)
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/scriptutils.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/scripts/lib/scriptutils.py b/scripts/lib/scriptutils.py index 85b1c949bf..31e48ea4dc 100644 --- a/scripts/lib/scriptutils.py +++ b/scripts/lib/scriptutils.py | |||
@@ -15,16 +15,17 @@ | |||
15 | # with this program; if not, write to the Free Software Foundation, Inc., | 15 | # with this program; if not, write to the Free Software Foundation, Inc., |
16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
17 | 17 | ||
18 | import sys | ||
19 | import os | ||
20 | import logging | ||
21 | import glob | ||
22 | import argparse | 18 | import argparse |
23 | import subprocess | 19 | import glob |
24 | import tempfile | 20 | import logging |
25 | import shutil | 21 | import os |
26 | import random | 22 | import random |
23 | import shlex | ||
24 | import shutil | ||
27 | import string | 25 | import string |
26 | import subprocess | ||
27 | import sys | ||
28 | import tempfile | ||
28 | 29 | ||
29 | def logger_create(name, stream=None): | 30 | def logger_create(name, stream=None): |
30 | logger = logging.getLogger(name) | 31 | logger = logging.getLogger(name) |
@@ -214,15 +215,14 @@ def fetch_url(tinfoil, srcuri, srcrev, destdir, logger, preserve_tmp=False, mirr | |||
214 | 215 | ||
215 | def run_editor(fn, logger=None): | 216 | def run_editor(fn, logger=None): |
216 | if isinstance(fn, str): | 217 | if isinstance(fn, str): |
217 | params = '"%s"' % fn | 218 | files = [fn] |
218 | else: | 219 | else: |
219 | params = '' | 220 | files = fn |
220 | for fnitem in fn: | ||
221 | params += ' "%s"' % fnitem | ||
222 | 221 | ||
223 | editor = os.getenv('VISUAL', os.getenv('EDITOR', 'vi')) | 222 | editor = os.getenv('VISUAL', os.getenv('EDITOR', 'vi')) |
224 | try: | 223 | try: |
225 | return subprocess.check_call('%s %s' % (editor, params), shell=True) | 224 | #print(shlex.split(editor) + files) |
225 | return subprocess.check_call(shlex.split(editor) + files) | ||
226 | except subprocess.CalledProcessError as exc: | 226 | except subprocess.CalledProcessError as exc: |
227 | logger.error("Execution of '%s' failed: %s" % (editor, exc)) | 227 | logger.error("Execution of '%s' failed: %s" % (editor, exc)) |
228 | return 1 | 228 | return 1 |