[oe-commits] [openembedded-core] 23/29: oe.scriptutils.run_editor: ditch the error-prone argument quoting
git at git.openembedded.org
git at git.openembedded.org
Mon Jun 25 07:08:32 UTC 2018
This is an automated email from the git hooks/post-receive script.
rpurdie pushed a commit to branch master-next
in repository openembedded-core.
commit 74d4663ecef92f562a87453c45c1e83bfcfc08d2
Author: Christopher Larson <chris_larson at mentor.com>
AuthorDate: Fri Jun 22 02:07:31 2018 +0500
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.
Signed-off-by: Christopher Larson <chris_larson at mentor.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
scripts/lib/scriptutils.py | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/scripts/lib/scriptutils.py b/scripts/lib/scriptutils.py
index 85b1c94..470f769 100644
--- a/scripts/lib/scriptutils.py
+++ b/scripts/lib/scriptutils.py
@@ -15,16 +15,17 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-import sys
-import os
-import logging
-import glob
import argparse
-import subprocess
-import tempfile
-import shutil
+import glob
+import logging
+import os
import random
+import shlex
+import shutil
import string
+import subprocess
+import sys
+import tempfile
def logger_create(name, stream=None):
logger = logging.getLogger(name)
@@ -214,15 +215,14 @@ def fetch_url(tinfoil, srcuri, srcrev, destdir, logger, preserve_tmp=False, mirr
def run_editor(fn, logger=None):
if isinstance(fn, str):
- params = '"%s"' % fn
+ files = [fn]
else:
- params = ''
- for fnitem in fn:
- params += ' "%s"' % fnitem
+ files = fn
editor = os.getenv('VISUAL', os.getenv('EDITOR', 'vi'))
try:
- return subprocess.check_call('%s %s' % (editor, params), shell=True)
+ print(shlex.split(editor) + files)
+ return subprocess.check_call(shlex.split(editor) + files)
except subprocess.CalledProcessError as exc:
logger.error("Execution of '%s' failed: %s" % (editor, exc))
return 1
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list