【问题标题】:Prevent execution of command shell in a Makefile防止在 Makefile 中执行命令 shell
【发布时间】:2019-05-30 00:06:43
【问题描述】:

下面的例子定义了一个名为GUNICORN_PID_FILE的变量,这个变量运行命令cat获取文件里面的PID。

SHELL := /bin/sh

GUNICORN_PID_FILE := gunicorn.pid
GUNICORN_PID = "$(shell cat ${GUNICORN_PID_FILE})"

问题是文件gunicorn.pid 不存在。

cat: gunicorn.pid: No such file or directory

有办法防止这个问题吗?

【问题讨论】:

  • 指令 shell 每次调用 Makefile 时都会运行。

标签: shell makefile gnu-make


【解决方案1】:

This answer 就像一个魅力。子流程的简单使用:

GUNICORN_PID = "$$(cat ${GUNICORN_PID_FILE})"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-09
    相关资源
    最近更新 更多