Cope with leading whitespace in shebang.

This commit is contained in:
Jelmer Vernooij 2021-03-26 18:21:08 +00:00
parent d6f35c9657
commit 7456ee7d12

View file

@ -55,7 +55,7 @@ def shebang_binary(p):
firstline = f.readline()
if not firstline.startswith(b"#!"):
return None
args = firstline[2:].split(b" ")
args = firstline[2:].strip().split(b" ")
if args[0] in (b"/usr/bin/env", b"env"):
return os.path.basename(args[1].decode()).strip()
return os.path.basename(args[0].decode()).strip()