From a4f55d95d4f2a0dcb667f181ebda25ab1f35f0b9 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Fri, 11 May 2018 16:16:14 +0200 Subject: [PATCH] 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. --- share/functions/__fish_print_make_targets.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/functions/__fish_print_make_targets.fish b/share/functions/__fish_print_make_targets.fish index acb1a9fcf..fb8ce9c03 100644 --- a/share/functions/__fish_print_make_targets.fish +++ b/share/functions/__fish_print_make_targets.fish @@ -17,7 +17,7 @@ function __fish_print_make_targets --argument-names directory file end 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 else set bsd_make 1