utils.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:cheribuild 作者: CTSRD-CHERI 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号