The following Makefile illustrates the issue:
$ cat >Makefile <<EOF
all:
echo "abc" | grep "b"
.PHONY: all
$ make all # works as expected
$ make all > /dev/null
grep: (standard input): Invalid argument
make: *** [Makefile:2: all] Error 2
The bug was introduced by commit 4fa6f48b573267e758650e114ec158d97916411e (introducing the usage of splice), which was first released in grep version 2.27.
My environment:
$ make --version
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ grep --version
grep (GNU grep) 2.27
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Patch attached.
--
Benno Fünfstück