>Date: Thu, 28 Jul 2011 23:54:46 +0300 >From: Angel Tsankov <[email protected]> >To: [email protected] >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<[email protected]>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>>
_______________________________________________ Help-make mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-make
