bug-make
[Top][All Lists]
Advanced

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

Re: [bug #55137] $(file …) is executed too early when used in recipe


From: Marcin Kasperski
Subject: Re: [bug #55137] $(file …) is executed too early when used in recipe
Date: Mon, 3 Dec 2018 13:36:35 +0100

> > I tried using the following snippet:
> >
> >    OUTPUT/something :
> >          mkdir -p OUTPUT
> >          $(file > $@, something)
> > (…)
>
> That's the defined behaviour.
> All variables are evaluated and all functions called before any commands are 
> run.
> It's the result of that evaluation that is the text of the commands to be 
> run, after all.

1. The fact that second line is evaluated, and has it's functions
called before first line is run, is not that obvious.
2. The behaviour of this very example is extremely confusing.
3. … and it makes $(file) almost useless in recipes (it can't be used
to append something to file generated by command, it can't be used to
read file generated by command, it can't be coordinated with anything
done by recipe in general)

Abstractly speaking: $(file) is syntactically similar to make
functions, but in fact it has absolutely different behaviour (other
make functions are mostly idempotent and functional, $(file) is all
about side effects). So handling it in the same way is not necessarily
good idea. In particular $(file >) doesn't calculate and return
anything, it's not the function and will never be.

At the very least, please add some strong warning about this behaviour to the
  https://www.gnu.org/software/make/manual/html_node/File-Function.html
page.



reply via email to

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