On Sat, Feb 12, 2005 at 06:32:01PM -0800, Kris Kennaway wrote:
> The following small makefile doesn't behave as one would naively
> expect:
> 
> MANLANG?=foo ""
> all:
> .for i in ${MANLANG}
> .if empty(${i})
>         @echo foo ${i}
> .endif
> .endfor
> 
> ports-i386%make
> foo foo
> foo
> 
> I think this is because the .if evaluation is happening too early, and
> it's not being done after the .for loop is expanded and the i variable
> is set.

Actually it looks like it's happening too late:

For: Iterator i List foo ""
For: end for 1
Global:i = ""
--- i = ""
.if empty(i)
        @echo foo ""
.endif

---- at line 3
Global:delete i
Global:i = foo
--- i = foo
.if empty(i)
        @echo foo foo
.endif

---- at line 3
Global:delete i

i.e. the series of .if statements are expanded out by .for and then
the variable i is deleted, so by the time the .if is evaluated the
unset variable evaluates to empty.

Kris

Attachment: pgpewHu2RdNSN.pgp
Description: PGP signature

Reply via email to