Date: Sat, 12 Feb 2005 18:45:24 -0800 From: Kris Kennaway <kris@obsecurity.org> To: Kris Kennaway <kris@obsecurity.org> Cc: hackers@FreeBSD.org Subject: Re: Makefile .for and .if expansion Message-ID: <20050213024524.GA24740@xor.obsecurity.org> In-Reply-To: <20050213023201.GB24426@xor.obsecurity.org> References: <20050213023201.GB24426@xor.obsecurity.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
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 #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (FreeBSD)
iD8DBQFCDr9EWry0BWjoQKURAlFhAJ9E3wZ31rE+8mFXIYYamxaGqvhBhwCg/5bq
WAYdKl9f2212Gw7rCT8KShg=
=nIdg
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050213024524.GA24740>
