Detect GNU make via "--version"

Turns out that `make -pn` actually takes a while - about 300ms on
fish's makefile.

That's quite a bit of time just to throw away the output and use the
exit code.

So we just check for "GNU" in the version string.

It would be nice to just _do_ the completion and fall back on the
BSD-style if it doesn't work, but that is tricky to do with the pipe
to `awk` - the awk expression actually does not fail if `make` does
not print output.

And I don't know enough about awk to change that.
This commit is contained in:
Fabian Homborg 2018-05-11 16:16:14 +02:00
parent 9929acd9d8
commit a4f55d95d4

View file

@ -17,7 +17,7 @@ function __fish_print_make_targets --argument-names directory file
end end
set -l bsd_make set -l bsd_make
if make -C $directory -pn >/dev/null 2>/dev/null if make --version 2>/dev/null | string match -q 'GNU*'
set bsd_make 0 set bsd_make 0
else else
set bsd_make 1 set bsd_make 1