summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Wibberley <tristan.wibberley@gmail.com>2015-09-07 00:23:55 +0100
committerVille Skyttä <ville.skytta@iki.fi>2015-09-09 17:39:16 +0300
commitc5451dbd310074f8bceeada0e48e542713dada1e (patch)
tree06e3dec76f030c4b8d9d965fd0f3b04b791916ba
parentf6618113b55e49c4c81f3a2a9fd5dc95a36a683f (diff)
downloadbash-completion-c5451dbd310074f8bceeada0e48e542713dada1e.tar.gz
make: Don't pick up variables when makefile is reloaded
Ah, I realised why only one variable was picked up. It's the last one only that looks like it might be a target. This third version of the patch has an updated test that should reliably trigger unless there is some other environmental or version specific behaviour.
-rw-r--r--completions/make10
-rw-r--r--test/fixtures/make/.gitignore1
-rw-r--r--test/fixtures/make/Makefile5
-rw-r--r--test/lib/completions/make.exp4
4 files changed, 15 insertions, 5 deletions
diff --git a/completions/make b/completions/make
index e84e5ba9..ad1348bd 100644
--- a/completions/make
+++ b/completions/make
@@ -20,9 +20,13 @@ function _make_target_extract_script()
fi
cat <<EOF
- 1,/^# * Files/ d; # skip until files section
- /^# * Not a target/,/^$/ d; # skip not target blocks
- /^${prefix_pat}/,/^$/! d; # skip anything user dont want
+ 1,/^# * Make data base/ d; # skip any makefile output
+ /^# * Finished Make data base/,/^# * Make data base/{
+ d; # skip any makefile output
+ }
+ /^# * Variables/,/^# * Files/ d; # skip until files section
+ /^# * Not a target/,/^$/ d; # skip not target blocks
+ /^${prefix_pat}/,/^$/! d; # skip anything user dont want
# The stuff above here describes lines that are not
# explicit targets or not targets other than special ones
diff --git a/test/fixtures/make/.gitignore b/test/fixtures/make/.gitignore
new file mode 100644
index 00000000..3d1325c6
--- /dev/null
+++ b/test/fixtures/make/.gitignore
@@ -0,0 +1 @@
+extra_makefile
diff --git a/test/fixtures/make/Makefile b/test/fixtures/make/Makefile
index 3d1d5f32..b04a6eb2 100644
--- a/test/fixtures/make/Makefile
+++ b/test/fixtures/make/Makefile
@@ -39,3 +39,8 @@ clean:
ifndef __BASH_MAKE_COMPLETION__
-include sample.d
endif
+
+VARIABLE_LOOKS_A_BIT_LIKE_A_TARGET := fooled-you
+extra_makefile:
+ touch $@
+include extra_makefile
diff --git a/test/lib/completions/make.exp b/test/lib/completions/make.exp
index 44abcbb1..1dfef8e8 100644
--- a/test/lib/completions/make.exp
+++ b/test/lib/completions/make.exp
@@ -18,10 +18,10 @@ assert_complete_dir "Makefile" "make -f Ma" $dir $test
sync_after_int
-
set test "\"make <TAB>\" should complete targets"
set dir $::srcdir/fixtures/make
-set targets "all sample install clean"
+set targets "all sample install clean extra_makefile"
+file delete $dir/extra_makefile
assert_complete_dir $targets "make " $dir $test