[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Trees and forests problem found but on how to solve it.
From: |
Ted Stern |
Subject: |
Re: Trees and forests problem found but on how to solve it. |
Date: |
Tue, 11 Apr 2006 12:06:15 -0700 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) |
On 10 Apr 2006 10:24:18 -0700, BILLY PATTON wrote:
>
> I have this :
> define refresh_proj_bb_sub
> $(1)+$(2)+$(3)+$(4) :
> cdir='$(CURDIR)' ; \
> $(CD) $(SRC_TREE)/$(2)/$(3)/$(4) ;\
> for X in $($(call merge,+,$(call uc,$(1)) $(2) $(3) $(4))) ; do
> \
> if test -f $$$$X ; then \
> $(EXEC_LOG) -proj $(2) -bb $(3) $(PVCS_GET)
> -v$(3)$(PVCS_VER) $$$$X ; \
> fi ; \
> done ; \
> $(CD) $$$$cdir
> endef
>
> When $($(call merge,+,$(call uc,$(1)) $(2) $(3) $(4))) produces the
> names of
> a variable (a list) and this variable does not exist the result, from
> warning, is:
> CR inserted for readability
> cdir='/home/users/bp1497' ;
> cd v0506/SOURCE_TREE/ldb/celltools/pub ;
> for X in ;
> do
> if test -f $X ; then
> /home/users/bp1497/exec_log -log
> /home/users/bp1497/v0506/log.2010115843
> -proj ldb -bb celltools
> /home/pvcs/vm/hpux/bin/get -vcelltools05.06.00.00 $X ;
> fi ;
> done ;
> cd $cdir
>
>
> Notice at the for X in is empty.
>
> This list does not exist.
>
> So how can I set this up to see that the list exists?
Modify your /bin/sh syntax slightly:
for X in $($(....)) /dev/null ; do \
if test -s $$$$X ; then \
... ; \
endif ; \
done ; \
...
In other words, add a file to your Bourne shell 'for' loop list that
always exists but is always empty. 'test -s file' tests to see if the
file exists and is of size > 0. Since you have added /dev/null to
your shell file list, the list will never be null, but /dev/null will
never pass the 'if test -s' test and won't perturb the results.
This is a common shell trick, for example when you do something like
find . -print | egrep '\.(some|filename|regexp)$' | \
xargs egrep '(some|expression)' /dev/null
I.e., you filter a 'find' list for some filename type, then past the
list to egrep, but add /dev/null so that there are always at least 2
files to grep through. This ensures that, just in case only one file
matches, grep or egrep will include the filename before the match.
Ted
--
dodecatheon at gmail dot com
Frango ut patefaciam -- I break so that I may reveal