Bas*_*hur 2 bash curl makefile
我想bash <(curl SOME_URL)在 Makefile 中运行臭名昭著的组合,我正在努力逃避括号。Makefile 的相关摘录如下所示:
foo:
docker run $(IMAGE_NAME) bash <(curl SOME_URL) \
--some-param1 \
--some-param2
Run Code Online (Sandbox Code Playgroud)
通过make foo只运行上面的结果:/bin/sh: 1: Syntax error: "(" unexpected
有人可以告诉我如何正确转义括号,以便我可以执行上述操作
原因是,您没有使用bash外壳。您makefile不再使用bash支持进程替换的 bourne shell ( ) ( <()),因此系统使用/bin/sh. 默认的/bin/shbourne shell 设计为仅使用标准功能运行。
默认情况下,使用SHELL := /bin/bashin为所有配方Makefile制作bash外壳,或者您可以为每个配方定义它。
foo: SHELL := /bin/bash
foo:
docker run $(IMAGE_NAME) bash <(curl SOME_URL) \
--some-param1 \
--some-param2
Run Code Online (Sandbox Code Playgroud)
来自GNUmake文档:选择 Shell。引用它以显示实际的线条
用作 shell 的程序取自变量
SHELL。如果此变量未在您的 中设置makefile,则该程序/bin/sh将用作外壳