zsh-workers
 help / color / mirror / code / Atom feed
* Bug in completion for make
@ 2013-10-18 14:40 luc
  2013-10-18 15:32 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: luc @ 2013-10-18 14:40 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1193 bytes --]

Hello list members,

I'm using zsh 5.0.2 on Mac OSX 10.6 compiled via homebrew.  When I
complete targets for one of my makefiles I get some extra suggestions,
which I should not get.  I have attached a example makefile to reproduce
the issue.

To reproduce the issue copy the attached makefile to a (new) directory
of your choice and run "make prepare".  Then enter "make " and press
CTRL-D. On my system the suggestions are:

  1.pdf
  2.pdf
  3.pdf
  \'s\#src/\(.\*\).tex\#1.pdf
  \|
  clean
  files.mk
  ls
  main
  prepare
  sed
  src/\*.tex

but I expect them to be:

  1.pdf
  2.pdf
  3.pdf
  clean
  files.mk
  main
  prepare

I looked at the code of _make and it seems that the error arises when
the makefile is parsed by _make-parseMakefile.  The line five of my
example file is misinterpreted because it contains a colon.
_make-parseMakefile therefor thinks it is a line containing a target and
a dependency.  The pattern used in _make-parseMakefile (in case ...
esac) is ([[:alnum:]][^$TAB:=]#:[^=]*) .  I do not understand why this
matches a line starting with a TAB-character.  Sadly I also do not know
how to correct this line.

Do you think this can be fixed?

Best regards
Luc

[-- Attachment #2: makefile --]
[-- Type: text/plain, Size: 300 bytes --]

include files.mk
main:
	@echo Compiling main ...
files.mk: $(shell ls -t src/*.tex | head -n 1)
	ls src/*.tex | sed 's#src/\(.*\)\.tex#\1.pdf:#' > files.mk
%.pdf: src/%.tex
	@echo pdflatex ...
clean:
	rm -f files.mk *.pdf
prepare:
	mkdir -p src
	touch src/1.tex src/2.tex src/3.tex
	$(MAKE) files.mk

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug in completion for make
  2013-10-18 14:40 Bug in completion for make luc
@ 2013-10-18 15:32 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2013-10-18 15:32 UTC (permalink / raw)
  To: luc, zsh-workers

On Oct 18,  4:40pm, luc wrote:
}
} The pattern used in _make-parseMakefile (in case ...
} esac) is ([[:alnum:]][^$TAB:=]#:[^=]*) .  I do not understand why this
} matches a line starting with a TAB-character.

It's not the pattern that's the problem, it's the use of the "read"
builtin, which is stripping off the leading tab because a tab is in
the default value of $IFS.

We've had this come up elsewhere in completion functions.

diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make
index 7b4c224..e5a513f 100644
--- a/Completion/Unix/Command/_make
+++ b/Completion/Unix/Command/_make
@@ -59,7 +59,7 @@ _make-expandVars() {
 }
 
 _make-parseMakefile () {
-  local input var val target dep TAB=$'\t' dir=$1 tmp
+  local input var val target dep TAB=$'\t' dir=$1 tmp IFS=
 
   while read input
   do


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-10-18 15:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-18 14:40 Bug in completion for make luc
2013-10-18 15:32 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).