summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorChristopher Larson <chris_larson@mentor.com>2018-06-22 02:07:31 +0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-06-27 13:55:21 +0100
commit2fe9a05666c69274fda766a2bec29febe94ba8b4 (patch)
treef40f3b0e039a1e90fe346962fbfc8e9843735496 /scripts
parentea4318b78e9b784c3f688cd8474f92704231d613 (diff)
downloadpoky-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.py24
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
18import sys
19import os
20import logging
21import glob
22import argparse 18import argparse
23import subprocess 19import glob
24import tempfile 20import logging
25import shutil 21import os
26import random 22import random
23import shlex
24import shutil
27import string 25import string
26import subprocess
27import sys
28import tempfile
28 29
29def logger_create(name, stream=None): 30def 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
215def run_editor(fn, logger=None): 216def 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