3 ms·
Random: did you know that you can write your recipes in python? Or any language for that matter? This is as simple as SHELL = python (technically one also h
by tpoacher 4y ago
Random: did you know that you can write your recipes in python? Or any language for that matter? This is as simple as
SHELL = python
(technically one also has to set shellflags, but python happens to share the same "execute command" flags as bash)
- Izkata 4y agoIf you're actually going to do this, you'll probably also want: .ONESHELL: This puts the entire recipe into one script, instead of running each line separately, so you can use (for example) variables across lines. It does mean you lose the "abort the recipe immediately if any individual line fails" functionality in make, but for python that's just how it works anyway when an exception is raised.
- tpoacher 4y agoOneshell is indeed a useful thing to keep in mind, but it's mostly when you want to retain state between commands; why would it be more relevant to python than other languages?
- Izkata 4y ago...you used python as the example.
- tpoacher 4y agoYes, and your comment seemed to imply that state between commands in make recipes (and thus use of oneshell) is somehow more important with a python shell than with the default bash shell. And I'm curious why you say this, as I wouldn't have thought it to necessarily be the case, so I thought perhaps you had some nice insight about the use of python as a make shell that I hadn't considered.
- Izkata 4y agoJust because with default (ba)sh recipes it's usually unnecessary, to the point where people are surprised when learn make does this. You're working directly on files so you don't need to carry any state in memory across lines. With python, this isn't really possible - even the most basic "open a file and write a value" spans two lines with state, so you need to write it in an unusual way, use backslashes to escape the newline, or use ONESHELL.