help-make
[Top][All Lists]
Advanced

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

$(file ...) function and other tools writing to the same file


From: Martin Reinders
Subject: $(file ...) function and other tools writing to the same file
Date: Mon, 14 Mar 2016 14:32:01 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

Hello,

I am experiencing unexpected results if both the $(file ...) function
(that was introduced with GNU make version 4) and other command-line
utilities are used to produce a single file.

Here is a minimal example. (The "echo" command is used for demonstration
purposes, it stands for any external command-line utility writing to
standard output.)

  $ cat Makefile
  all:
        /bin/echo "LINE FROM ECHO COMMAND" > file.txt
        $(file >>file.txt,LINE FROM FILE FUNCTION)

  $ make
  /bin/echo "LINE FROM ECHO COMMAND" > file.txt

  $ cat file.txt
  LINE FROM ECHO COMMAND

I expected that the echo command writes one line to the file, and the
$(file ...) function appends another line. But as one can see, the file
contains the output from the echo command only. It seems to me that the
echo command is executed _after_ executing the $(file ...) function.

The $(file ...) function alone works as expected:

  $ cat Makefile
  all:
        $(file >file.txt,LINE 1 FROM FILE FUNCTION)
        $(file >>file.txt,LINE 2 FROM FILE FUNCTION)

  $ make
  make-4.1: 'all' is up to date.

  $ cat file.txt
  LINE 1 FROM FILE FUNCTION
  LINE 2 FROM FILE FUNCTION

All tests are done with GNU make 4.1 on Mac OS X.

Perhaps I am misunderstanding something completely? Any insight is
highly appreciated.

Best regards,
Martin





reply via email to

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