So, in order to make make evaluate multi line conditional shell scripts correctly, you need to evaluate the whole shell script code in one line (so it all is evaluated in the same shell). In other words, if two commands in a make-target are completely independent of each other (no conditions what so ever), you could just perfectly fine separate them solely by a normal newline and let them execute each in its own shell. However, make will not even get past the first if, because it expects an exit code to go on with the next statement, which it will not get from just changing the shell's state to if. If you would write this in a Makefile though, if would be evaluated in its own shell (changing the shell-state to if) after which technically the condition would be evaluated in its own shell again, without any connection to the previous if. Taking it to an extreme, the following would be possible in a shell script file, because the newline acts as command-evaluation (like in a terminal hitting enter is a newline-feed that evaluates the entered command): if Make spawns a new shell for each command on a line, so you cannot use true multi line shell code as you would e.g. You cannot use real newlines in a Makefile for conditional shell-script code (see Make-specific background)Įcho "Not empty" are all statements that need to be evaluated (similar to pressing enter in terminal after you typed in a command). Change your make target to this (adding semicolons): check:įor evaluating a statement in a shell without newlines (newlines get eaten by the backslash \) you need to properly end it with a semicolon.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |