| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
5.3 Recipe Execution
When it is time to execute recipes to update a target, they are
executed by invoking a new sub-shell for each line of the recipe,
unless the .ONESHELL special target is in effect
(see section Using One Shell) (In practice, make may
take shortcuts that do not affect the results.)
Please note: this implies that setting shell variables and
invoking shell commands such as cd that set a context local to
each process will not affect the following lines in the recipe.(2) If you want to use cd to affect the next statement,
put both statements in a single recipe line. Then make will
invoke one shell to run the entire line, and the shell will execute
the statements in sequence. For example:
foo : bar/lose
cd $(@D) && gobble $(@F) > ../$@
Here we use the shell AND operator (&&) so that if the
cd command fails, the script will fail without trying to invoke
the gobble command in the wrong directory, which could cause
problems (in this case it would certainly cause ‘../foo’ to be
truncated, at least).
| 5.3.1 Using One Shell | One shell for all lines in a recipe. | |
| 5.3.2 Choosing the Shell | How make chooses the shell used
to run recipes.
|
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on October 10, 2013 using texi2html 5.0.
