[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Exit status ignored during variable expansion
From: |
John Dill |
Subject: |
Re: Exit status ignored during variable expansion |
Date: |
Fri, 29 Jul 2011 13:45:23 -0400 |
>Date: Thu, 28 Jul 2011 23:54:46 +0300
>From: Angel Tsankov <address@hidden>
>To: address@hidden
>Subject: Re: Exit status ignored during variable expansion?
>
>On 07/28/11 23:41, Stephan Beal wrote:
>> On Thu, Jul 28, 2011 at 9:37 PM, Angel Tsankov<address@hidden>wrote:
>>
>>> If 'make' does not fail on non-zero exit from a command (during variable
>>> expansion) then we have no way to determine if the command completed
>>> successfully (with empty output) or if it failed. This is my only concern.
>>>
>>
>> Here's one way to do this:
>>
>> X := $(shell ....>/dev/null 2>&1&& echo 1 || echo 0)
>>
>
>That seems to work, but seems cumbersome... :(
Nothing is preventing you from defining your own wrapper around it.
# $1 - The shell command.
run_command=$(eval __status:=$(shell ($1) ...))
If you want to assign a variable to the shell command output only if '__status'
is successful, save the shell stdout to a file, check the status result, and
eval the contents of the file to the variable if the status is good.
Here's a rough idea off the top of my head.
# $1 - The shell command.
# $2 - The variable to assign.
run_and_assign_command=$(strip \
$(eval __status:=$(shell ($1) > result.out ...))\
$(if $(filter 1,$(__status)),$(eval $2:=$(shell cat result.out)))\
$(shell (rm result.out) $(stderr_to_null))\
)
If you want to exit, you can simply add an $(error) if you find that __status
is 0.
Best regards,
John D.
<<winmail.dat>>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Exit status ignored during variable expansion,
John Dill <=