From 39ef159bc64ac2ba590fce49f52da53f4115c715 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 21 Oct 2016 10:59:09 +1300 Subject: Observe POSIX spec for looking for Makefile name --- bash/bash_completion.d/make.bash | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'bash') diff --git a/bash/bash_completion.d/make.bash b/bash/bash_completion.d/make.bash index c157bdc1..67c577f3 100644 --- a/bash/bash_completion.d/make.bash +++ b/bash/bash_completion.d/make.bash @@ -1,8 +1,13 @@ # Completion setup for Make, completing targets _make() { - # Bail if no legible Makefile - [[ -r Makefile ]] || return 1 + # Find a legible Makefile according to the POSIX spec (look for "makefile" + # first, then "Makefile"). You may want to add "GNU-makefile" after this. + local mf + for mf in makefile Makefile '' ; do + [[ -f $mf ]] && break + done + [[ -n $mf ]] || return 1 # Iterate through the Makefile, line by line while IFS= read -r line ; do @@ -40,6 +45,6 @@ _make() { done ;; esac - done < Makefile + done < "$mf" } complete -F _make -o default make -- cgit v1.2.3