help-make
[Top][All Lists]
Advanced

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

Re: Original stdout inside the $(shell ...) function


From: David Boyce
Subject: Re: Original stdout inside the $(shell ...) function
Date: Tue, 10 Apr 2018 07:25:54 -0700

This looks like a basic shell programming issue, not a make problem at all.
Try pulling this logic out of make and running it directly in the shell; if
it behaves correctly there but not when plugged back into make, then you'll
have a make question. This looks more like a scoping problem. Here is
(effectively) your original script:

% sh -c ">&2 echo finding SQLFILES... && date" 1>1 2>2

% head 1 2
==> 1 <==
Tue Apr 10 07:18:56 PDT 2018

==> 2 <==
finding SQLFILES...

And here's a variant with different scoping:

% sh -c "(echo finding SQLFILES... && date) 1>&2" 1>1 2>2

% head 1 2
==> 1 <==

==> 2 <==
finding SQLFILES...
Tue Apr 10 07:19:09 PDT 2018

It's not clear to me exactly what you want but this should illustrate that
the issue is shell redirection.

Personally I prefer techniques that let the shell handle verbosity instead
of typing ad-hoc messages:

SQLFILES := $(shell set -x; cd "$(srcdir)" && find . -name "*.sql")

David

On Tue, Apr 10, 2018 at 3:07 AM, Basin Ilya <address@hidden> wrote:

> Hi. I want to print a diagnostic message whenever my shell expression is
> evaluated. Currently, I have the following line in my makefile:
>
>     SQLFILES := $(shell >&2 echo finding SQLFILES... && cd "$(srcdir)" &&
> find . -name "*.sql")
>
> As you can see, the message "finding SQLFILES..." is printed to stderr,
> but I want the original stdout instead. Does GNU Make make it available as
> some other fd, say, "4"?
>
> _______________________________________________
> Help-make mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-make
>


reply via email to

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