Skip to content

Commit e3dc3f7

Browse files
committed
always use #!/bin/sh on windows
1 parent cccbc9d commit e3dc3f7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pre_commit/commands/install_uninstall.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ def _install_hook_script(
8282
before, rest = contents.split(TEMPLATE_START)
8383
_, after = rest.split(TEMPLATE_END)
8484

85+
# on windows always use `/bin/sh` since `bash` might not be on PATH
86+
# though we use bash-specific features `sh` on windows is actually
87+
# bash in "POSIXLY_CORRECT" mode which still supports the features we
88+
# use: subshells / arrays
89+
if sys.platform == 'win32': # pragma: win32 cover
90+
hook_file.write('#!/bin/sh\n')
91+
8592
hook_file.write(before + TEMPLATE_START)
8693
hook_file.write(f'INSTALL_PYTHON={shlex.quote(sys.executable)}\n')
8794
# TODO: python3.8+: shlex.join

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
covdefaults>=2.1
1+
covdefaults>=2.2
22
coverage
33
distlib
44
pytest

0 commit comments

Comments
 (0)