在 makefile 中使用 exec

Using exec in a makefile

在makefile中,有什么区别

python:
    exec python

python:
    python

我找到了 here。我知道 exec 将 shell 替换为正在执行的命令,在本例中为 python。但我并没有真正看到 makefile 中的含义。

那么为什么我会使用exec python而不是python

exec 命令在编写脚本时对特定情况很有用。一个这样的例子是,当我们希望应用程序在执行后 运行 无法访问 shell 进程时。您可以阅读有关这些用例的更多信息 here.

对于您给出的情况,exec pythonpython 之间没有实际区别,除了不能 return 到您的 shell 之后 python 使用 exec 命令完成执行。你最好只使用 python.