Current-Users archive

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

Re: Building on Solaris, sh problem: empty for loop



On Fri, Nov 28, 2008 at 04:02:18PM +0500, Alan Barrett wrote:
> Inside a Makefile, where there are both make variables and shell variables,
> that would translate as follows:
> 
>       sometarget: somedependency
>               for d in ${MAKEVAR} ; do ... ; done # fails if MAKEVAR is empty
> 
>       sometarget: somedependency
>               shellvar=${MAKEVAR:Q} ; \
>               for d in $$shellvar ; do ... ; done # this should work

Or maybe:
        set -- - ${MAKEVAR}; shift; for d; do ... done

The dummy arg and shift is needed because some shells treat 'set --' as
'set' and output all the variable definitions :-)

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index