[Bash-completion-devel] [PATCH 2/2] make: Don't pick up variables when makefile is reloaded

Tristan Wibberley tristan.wibberley at gmail.com
Sat Sep 5 21:03:14 UTC 2015


Please apply this patch to "make" completion. This avoids completion
getting confused on variables when a makefile is reloaded.

---
 completions/make              | 10 +++++++---
 test/fixtures/make/.gitignore |  1 +
 test/fixtures/make/Makefile   |  5 +++++
 test/lib/completions/make.exp |  2 +-
 4 files changed, 14 insertions(+), 4 deletions(-)
 create mode 100644 test/fixtures/make/.gitignore

diff --git a/completions/make b/completions/make
index e84e5ba..ad1348b 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 0000000..3d1325c
--- /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 3d1d5f3..c04602f 100644
--- a/test/fixtures/make/Makefile
+++ b/test/fixtures/make/Makefile
@@ -39,3 +39,8 @@ clean:
 ifndef __BASH_MAKE_COMPLETION__
 -include sample.d
 endif
+
+extra_makefile:
+ touch $@
+include extra_makefile
+
diff --git a/test/lib/completions/make.exp b/test/lib/completions/make.exp
index 93a53db..041ef86 100644
--- a/test/lib/completions/make.exp
+++ b/test/lib/completions/make.exp
@@ -21,7 +21,7 @@ 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"
 assert_complete_dir $targets "make " $dir $test


-- 
2.5.0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/bash-completion-devel/attachments/20150905/b10c7d65/attachment.html>


More information about the Bash-completion-devel mailing list