help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shell script return on a makefile.


From: John Calcote
Subject: Re: shell script return on a makefile.
Date: Mon, 14 Jun 2010 09:47:19 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.10) Gecko/20100512 Thunderbird/3.0.5

German,

This is easier than you think. Just remove the $(shell ... ) from around
your shell call and add the call to a target like this:

check_code:
        /path/to/my/script.sh

Then put the check_code target in your dependency graph somewhere.
Scripts return values to the shell. If you call these as commands
instead of having the make $(shell) macro invoke them, the exit code
becomes the command status to make.

John

On 6/14/2010 9:34 AM, German Escallon wrote:
> Hello all,
>
> How can I stop a build process based on the outcome of a shell script?
> What I want to do is to run a script that verifies some of my code. 
> If the script succeeds, then I would continue to the next step, but if
> it fails, I want to stop the make process.
>
> First things first.  How can I know if my script succeeded or not?? 
> I've tried reading and printing the $? environment variable.  Here's
> what I've tried with a script that should always fail.
>
> e.g:
>   @$(shell /path/to/my/script.sh)
>   @echo "result: $$?"
>
> The line always prints "result: 0", regardless of the result. When I
> run this same script on the console, and then echo the $? variable, I
> always get the error code I'm hoping for.
> If you have any suggestions on how to know the outcome of a script
> w/out using the $? environment variable, please let me know.  Thank
> you in advance.
>
>
> German
>
>
> _______________________________________________
> Help-make mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-make
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]