Skip to content

Commit

Permalink
Suggest usable call when exec files lack shebang on Windows
Browse files Browse the repository at this point in the history
Resolves Issue pre-commit#686
  • Loading branch information
pujitm committed Nov 19, 2021
1 parent 56b4a7e commit 7988eb7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pre_commit_hooks/check_executables_have_shebangs.py
Expand Up @@ -60,10 +60,12 @@ def has_shebang(path: str) -> int:


def _message(path: str) -> None:
is_windows = sys.platform == 'win32'
remove_execute_permissions_command = 'git add --chmod=-x' if is_windows else 'chmod -x'
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'`{remove_execute_permissions_command} {shlex.quote(path)}`\n'
f' If it is supposed to be executable, double-check its shebang.',
file=sys.stderr,
)
Expand Down

0 comments on commit 7988eb7

Please sign in to comment.