help-make
[Top][All Lists]
Advanced

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

Re: $(shell ...) exit status


From: Greg Chicares
Subject: Re: $(shell ...) exit status
Date: Wed, 21 Feb 2007 10:09:55 +0000
User-agent: Thunderbird 1.5.0.4 (Windows/20060516)

On 2007-2-21 6:18 UTC, 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
> 
> And I don't just need to abort on error either. If the command fails I
> have another (slower and less reliable) way to get the data whereas if
> it succeeds with null output I want to continue on happily. Which
> means I need exit status. Is this an oversight in the spec?

Consider this makefile:

x := $(shell false)

.PHONY: all
all:
        @echo $x

The command fails, and 'make' stops--on msw, e.g., I get:

  process_begin: CreateProcess(NULL, false, ...) failed.

But change the above variable definition to:

  x := $(shell false || echo "alternative")

and it does what I think you want:

  C:/tmp[0]$make
  alternative




reply via email to

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