diff --git a/pre_commit_hooks/check_executables_have_shebangs.py b/pre_commit_hooks/check_executables_have_shebangs.py index 33f75c02..85defe3c 100644 --- a/pre_commit_hooks/check_executables_have_shebangs.py +++ b/pre_commit_hooks/check_executables_have_shebangs.py @@ -60,10 +60,11 @@ def has_shebang(path: str) -> int: def _message(path: str) -> None: + is_windows = sys.platform == 'win32' print( f'{path}: marked executable but has no (or invalid) shebang!\n' f" If it isn't supposed to be executable, try: " - f'`chmod -x {shlex.quote(path)}`\n' + f'`{"git add --chmod=-x" if is_windows else "chmod -x"} {shlex.quote(path)}`\n' f' If it is supposed to be executable, double-check its shebang.', file=sys.stderr, )