相关疑难解决方法(0)

具有here-document重定向的Makefile配方

有谁知道如何在食谱上使用here-document重定向?

test:
  sh <<EOF
  echo I Need This
  echo To Work
  ls
  EOF
Run Code Online (Sandbox Code Playgroud)

我找不到任何解决方案尝试通常的反斜杠方法(基本上以一行中的命令结束).

理由:

我有一组多行配方,我想通过另一个命令代理(例如,sh,docker).

onelinerecipe := echo l1
define twolinerecipe :=
echo l1
echo l2
endef
define threelinerecipe :=
echo l1
echo l2
echo l3
endef

# sh as proxy command and proof of concept
proxy := sh

test1:
  $(proxy) <<EOF
  $(onelinerecipe)
  EOF

test2:
  $(proxy) <<EOF
  $(twolinerecipe)
  EOF

test3:
  $(proxy) <<EOF
  $(threelinerecipe)
  EOF
Run Code Online (Sandbox Code Playgroud)

我希望避免的解决方案:将多行宏转换为单行.

define threelinerecipe :=
echo l1;
echo l2;
echo l3
endef

test3:
  $(proxy) <<< "$(strip …
Run Code Online (Sandbox Code Playgroud)

bash shell makefile heredoc gnu-make

6
推荐指数
1
解决办法
2700
查看次数

标签 统计

bash ×1

gnu-make ×1

heredoc ×1

makefile ×1

shell ×1