makefiles and "diff foo bar | head -10"

makefiles and "diff foo bar | head -10"

Post by jeff deifi » Sat, 01 Nov 1997 04:00:00



I have a makefile I am using to compile and test programs.
If there are problems with the output, I want diff to report them, and
exit the makefile.
Right now I say something like

diff foo bar

in the makefile, and if there are differences, they are printed out, and
the makefile exits.
Sometimes, diff will spew thousands of lines, since there are lots of
differences. I would
like diff to shut up after 10 lines or so, and still exit the makefile.
I tried

diff foo bar | head -10

but that took the exit status of head (which was ok), and make continued
on.

I tried

(diff foo bar | head -10)

but that didn't help either.

I even tried

$(shell diff foo bar | head -10)

but that seemd to execute diff, and the head part disappeared.

I have read the gnu info about make, but I can't figure how to propogate
the exit status of diff.
If I were using csh, I know that

(diff foo bar | head -10)

would work fine.

How do I make this work from inside of a makefile?

--


 
 
 

makefiles and "diff foo bar | head -10"

Post by era eriksso » Sat, 01 Nov 1997 04:00:00


On Fri, 31 Oct 1997 10:14:51 -0800, jeff deifik

 > diff foo bar | head -10
 > but that took the exit status of head (which was ok), and make continued
 > on.

In this case, when you are certain you really want to return false at
all times, just say so:

target: foo bar
        diff $^ | head -10 && false

I have seen some elaborate ways to pass back exit codes from a program
in the middle of a pipeline, but you don't need that here. If
interested, I think the FAQ has some coverage of this.

Hope this helps,

/* era */

--
 Paparazzi of the Net: No matter what you do to protect your privacy,
  they'll hunt you down and spam you. <http://www.iki.fi/~era/spam/>