help-make
[Top][All Lists]
Advanced

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

Re: Implement Check on Input Values


From: Stephan Beal
Subject: Re: Implement Check on Input Values
Date: Mon, 8 Aug 2011 20:35:48 +0200

On Mon, Aug 8, 2011 at 8:20 PM, David Boyce <address@hidden> wrote:

> On Mon, Aug 8, 2011 at 1:19 PM, Stephan Beal <address@hidden>
> wrote:
> >> ifeq (1,$(words $(wildcard $(WORK_DIR)))
>
> The wildcard function is defined to return a null string iff the named
> file doesn't exist, thus:
>
> $(if $(wildcard $(WORK_DIR)),,$(error make: $(WORK_DIR): no such
> directory))
>
> would suffice as a test. You could just as easily do this as an
> if/endif pair if preferred.
>

True, but $(wildcard) can expand to multiple words, so the
ifeq(1,$(words...)) hack is a bit safer against undesired side-effects if
someone accidentally or maliciously adds a ? or * to the value. But it of
course won't work if the path has a space in it, which would cause $(words)
to be >1.

i wasn't aware of $(if) (call me old-fashioned). That is certainly simpler
than using if/endif blocks.

-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/


reply via email to

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