xargs returns nonzero for negate + not found exe (fixes pcre + not found #447)

This commit is contained in:
Anthony Sottile
2016-12-04 13:31:05 -08:00
parent 0e2c3c1ff9
commit a157e1a63f
7 changed files with 49 additions and 11 deletions

View File

@@ -1,11 +1,12 @@
from __future__ import unicode_literals
from sys import platform
import sys
from pre_commit.xargs import xargs
ENVIRONMENT_DIR = None
GREP = 'ggrep' if sys.platform == 'darwin' else 'grep'
def install_environment(
@@ -19,10 +20,7 @@ def install_environment(
def run_hook(repo_cmd_runner, hook, file_args):
# For PCRE the entry is the regular expression to match
cmd = (
'ggrep' if platform == 'darwin' else 'grep',
'-H', '-n', '-P',
) + tuple(hook['args']) + (hook['entry'],)
cmd = (GREP, '-H', '-n', '-P') + tuple(hook['args']) + (hook['entry'],)
# Grep usually returns 0 for matches, and nonzero for non-matches so we
# negate it here.