Reputation: 31216
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:
SHELL:=/usr/bin/env bash -c "source sourceme.sh" # or something along these lines
Can this be done, and if so, how?
Upvotes: 1
Views: 526
Reputation: 100856
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.
You can do it yourself, from outside your makefile, by writing your own wrapper:
$ cat wrapper.sh
#!/usr/bin/env bash
shift
source sourceme.sh
eval "$@"
$ cat Makefile
SHELL := wrapper.sh
commands:
alias
Upvotes: 1