Fix double shebang in Windows hook template

In its current form, `_install_hook_script` appends Windows-specific shebang
on top of the previous one when it should replace it instead (probably).

I got triggered by this, so I went ahead and wrote a fix.
This commit is contained in:
mataha 2023-04-01 13:43:31 +02:00 committed by GitHub
parent bb49560dc9
commit 377b8937a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -99,7 +99,7 @@ def _install_hook_script(
# bash in "POSIXLY_CORRECT" mode which still supports the features we # bash in "POSIXLY_CORRECT" mode which still supports the features we
# use: subshells / arrays # use: subshells / arrays
if sys.platform == 'win32': # pragma: win32 cover if sys.platform == 'win32': # pragma: win32 cover
hook_file.write('#!/bin/sh\n') before = before.replace("#!/usr/bin/env bash", "#!/bin/sh", 1)
hook_file.write(before + TEMPLATE_START) hook_file.write(before + TEMPLATE_START)
hook_file.write(f'INSTALL_PYTHON={shlex.quote(sys.executable)}\n') hook_file.write(f'INSTALL_PYTHON={shlex.quote(sys.executable)}\n')