help-make
[Top][All Lists]
Advanced

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

Re: $(shell ...) exit status


From: John Graham-Cumming
Subject: Re: $(shell ...) exit status
Date: Wed, 21 Feb 2007 10:55:39 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040208 Thunderbird/0.5 Mnenhy/0.6.0.104

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David Boyce wrote:
> How does one determine the exit status of the shell forked by $(shell
> ...)? I see nothing about it in the 3.81 online manual. I need to run
> a command for which the null string is a perfectly legal
> output value, so I can't get away with anything like this:
> 
> foo    :=    $(shell mycommand)
> 
> ifeq($foo),)
> <code to handle error conditions>
> endif

If you don't care about the actual output of the command then you could
just do

    exit_code := $(shell mycommand &> /dev/null ; echo $$?)

In which case you'll get the exit code of mycommand in exit_code.   If
you need the output of the command and the exit code then I'd use a
temporary file to store the exit code like this

    exit_code_file := /tmp/exit_code
    output := $(shell mycommand ; echo $$? > $exit_code_file)
    exit_code := $(shell cat $exit_code_file)

John.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF3BcbLphrp73n/hARAlOcAJ9jS8clp57XJ8ZnGtNkPQEmZH1s3ACgtD6s
X/3ij19jlPgNVExA1btz/uQ=
=awOJ
-----END PGP SIGNATURE-----




reply via email to

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