def getInterpreter(cmdline: "typing.Sequence[str]") -> "typing.Optional[typing.List[str]]":
"""
:param cmdline: The command to check
:return: The interpreter command if the executable does not have execute permissions
"""
executable = Path(cmdline[0])
print(executable, os.access(str(executable), os.X_OK), cmdline)
if not executable.exists():
executable = Path(shutil.which(str(executable)))
statusUpdate(executable, "is not executable, looking for shebang:", end=" ")
with executable.open("r", encoding="utf-8") as f:
firstLine = f.readline()
if firstLine.startswith("#!"):
interpreter = shlex.split(firstLine[2:])
statusUpdate("Will run", executable, "using", interpreter)
return interpreter
else:
statusUpdate("No shebang found.")
return None
评论列表
文章目录