help-make
[Top][All Lists]
Advanced

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

RE: desperate situation with $(shell ... :(


From: John Dill
Subject: RE: desperate situation with $(shell ... :(
Date: Fri, 25 Feb 2011 13:35:30 -0500

> I have asked this question before, in an isolated example, and Paul
> said this is no problem what I am doing, > but...  I have rare,
> impossible to reproduce, yet universally fatal failures...  I just
> want to make double sure, can anybody tell me there is anything
> wrong with this (I want to append the list to the file, and the
> reason why I can't just echo everything, is that this is Windows and
> there is command line length limitation, and the list can exceed that).  
>
> $(foreach item, $(very_long_list), $(shell echo $(item)>>foobar.txt))
>
>
> What I see in those rare unreproducible failures, is that some random
> element of in the middle of the very long list does not get appended
> to the file...  
>
> The reason why I don't post this to the Windows GNU make list, is,
> seems to me, either I am not understanding how foreach, or shell,
> work, or if not, then there is a problem with my understanding of
> Windows, but not, the problem with my misunderstanding of Windows
> GNU make.  

I do not know why it's not working.  However, I can offer an alternative to try 
to see if you can reproduce the same error.

# Configure __mxl_shell to either 'sh' or 'cmd'.
# Configure __mxl_echo to the shell echo command.

# This function appends a single line of text to a file.
# $1 - The file.
# $2 - The text.
ifeq (sh,$(__mxl_shell))
fwrite=$(shell ($(__mxl_echo) "$2") >> $1)
else

ifeq (cmd,$(__mxl_shell))
fwrite=$(shell ($(__mxl_echo)/$2) >> $1)
else
fwrite=$(call _mxl_shell_not_supported)
endif

endif

There was a reason why I needed the extra parentheses to run the echo command 
in a subshell, but it's been so long since I've written it that I don't 
remember the exact reason (I think it's related to your problem though).  I'm 
not sure if this will solve your problem, but I have not noticed any missing 
info from using $(fwrite).  Feel free to give it a try.

$(foreach item,$(very_long_list),$(call fwrite,foobar.txt,$(item)))

Best regards,
John Dill

<<winmail.dat>>


reply via email to

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