From ebbaae8d1f42f051282af79d60f19cb1161088a5 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Wed, 15 Dec 2021 11:07:37 +0100 Subject: git pre commit hook: use shlex.split() Signed-off-by: Giampaolo Rodola --- scripts/internal/git_pre_commit.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/internal/git_pre_commit.py b/scripts/internal/git_pre_commit.py index 92bc0f0a..dca17ffb 100755 --- a/scripts/internal/git_pre_commit.py +++ b/scripts/internal/git_pre_commit.py @@ -22,6 +22,7 @@ Install this with "make install-git-hooks". from __future__ import print_function import os +import shlex import subprocess import sys @@ -118,24 +119,21 @@ def main(): # Python linters if py_files: - # Flake8 + # flake8 assert os.path.exists('.flake8') - # XXX: we should escape spaces and possibly other amenities here cmd = "%s -m flake8 --config=.flake8 %s" % (PYTHON, " ".join(py_files)) - ret = subprocess.call(cmd, shell=True) + ret = subprocess.call(shlex.split(cmd)) if ret != 0: return exit("python code is not flake8 compliant; " "try running 'make fix-flake8'") - # isort assert os.path.exists('.isort.cfg') cmd = "%s -m isort --settings=.isort.cfg --check-only %s" % ( PYTHON, " ".join(py_files)) - ret = subprocess.call(cmd, shell=True) + ret = subprocess.call(shlex.split(cmd)) if ret != 0: return exit("python code is not flake8 compliant; " "try running 'make fix-imports'") - # C linter if c_files: # XXX: we should escape spaces and possibly other amenities here -- cgit v1.2.1