[英]Is there a way to source a shell script in the makefile SHELL declaration?
Suppose I write:假设我写:
SHELL:=/usr/bin/env bash
commands:
source sourceme.sh && alias
But I wanted to push that source sourceme.sh
back into the SHELL
declaration:但我想将该
source sourceme.sh
sourceme.sh 推回到SHELL
声明中:
SHELL:=/usr/bin/env bash -c "source sourceme.sh" # or something along these lines
Can this be done, and if so, how?可以做到这一点,如果可以,怎么做?
No, you can't do that.不,你不能那样做。 Make takes your recipe lines and sends them to, effectively,
$(SHELL) -c <recipeline>
The shell, unfortunately, doesn't accept multiple -c
options so to do what you want you'd need to have a way for make to insert that string at the beginning of every recipe line and there's no way to do that. Make 将您的食谱行有效地发送到
$(SHELL) -c <recipeline>
不幸的是,shell 不接受多个-c
选项,因此要执行您想要的操作,您需要有一种方法来制作在每个配方行的开头插入该字符串,但没有办法做到这一点。
You can do it yourself, from outside your makefile, by writing your own wrapper:您可以通过编写自己的包装器,从 makefile 外部自己完成:
$ cat wrapper.sh
#!/usr/bin/env bash
shift
source sourceme.sh
eval "$@"
$ cat Makefile
SHELL := wrapper.sh
commands:
alias
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.