Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: _make and perl.

I've finally got frustrated with the limitations of awk.  _make now
looks at the style use-perl to decide if it can do it properly.  Its
use can be extended as necessary.


  (perl -v >/dev/null 2>/dev/null) && useperl=1

would be good enough, but I don't want to deprive people who like being
annoyed by awk.

I'm not keen on the way zsh-specific make stuff is buried in _make.
This should be handled based on directories and possibly other
environmental considerations, but we never decided on an interface.

Index: Completion/Unix/Command/_make
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_make,v
retrieving revision 1.3
diff -u -r1.3 _make
--- Completion/Unix/Command/_make	15 Mar 2002 16:26:09 -0000	1.3
+++ Completion/Unix/Command/_make	12 Aug 2002 13:44:04 -0000
@@ -1,7 +1,8 @@
 #compdef make gmake pmake dmake
-local prev="$words[CURRENT-1]" file expl tmp is_gnu
+local prev="$words[CURRENT-1]" file expl tmp is_gnu cmdargs useperl
+zstyle -t ":completion:${curcontext}:" use-perl && useperl=1
 _pick_variant -r is_gnu gnu=GNU unix -v -f
 if [[ "$prev" = -[CI] ]]; then
@@ -25,7 +26,22 @@
   if [[ -n "$file" ]] && _tags targets; then
     if [[ $is_gnu = gnu ]] &&
        zstyle -t ":completion:${curcontext}:targets" call-command; then
-      tmp=( $(_call_program targets "$words[1]" -nsp --no-print-directory -f "$file" .PHONY 2> /dev/null | awk '/^[a-zA-Z0-9][^\/\t=]+:/ {print $1}' FS=:) )
+       if [[ -n $useperl ]]; then
+        cmdargs=(perl -F: -ane '/^[a-zA-Z0-9][^\/\t=]+:/ && print "$F[0]\n"')
+       else
+        cmdargs=(awk '/^[a-zA-Z0-9][^\/\t=]+:/ {print $1}' FS=:)
+       fi
+       tmp=( $(_call_program targets "$words[1]" -nsp --no-print-directory -f "$file" .PHONY 2> /dev/null | $cmdargs) )
+    elif [[ -n $useperl ]]; then
+      tmp=(
+      $(perl -ne '@matches = /^(?:([a-zA-Z0-9]+[^\/\t=\s]+)\s*)+:/  and
+	print join(" ", @matches);
+if (/^\.include\s+\<bsd\.port\.(subdir\.|pre\.)?mk>/ ||
+    /^\.include\s+\".*mk\/bsd\.pkg\.(subdir\.)?mk\"/) {
+    print "fetch fetch-list extract patch configure build install reinstall deinstall package describe checkpatch checksum makesum\n";
+    }
+' $file)
+	)
             $(awk '/^[a-zA-Z0-9][^\/\t=]+:/ {print $1}
Index: Doc/Zsh/compsys.yo
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.160
diff -u -r1.160 compsys.yo
--- Doc/Zsh/compsys.yo	5 Aug 2002 12:33:27 -0000	1.160
+++ Doc/Zsh/compsys.yo	12 Aug 2002 13:44:04 -0000
@@ -2315,6 +2315,17 @@
 handled by a command function tt(_foo), tt(compctl) would never be tried,
 while if it was handled by tt(_default), tt(compctl) would be tried.
+kindex(use-perl, completion style)
+Various parts of the function system use awk to extract words from
+files or command output as this universally available.  However, many
+versions of awk have arbitrary limits on the size of input.  If this
+style is set, perl will be used instead.  This is almost always
+preferable if perl is available on your system.
+Currently this is only used in completions for `make', but it may be
+extended depending on authorial frustration.
 kindex(users, completion style)
 This may be set to a list of names that should be completed whenever 

Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070

The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
If you received this in error, please contact the sender and 
delete the material from any computer.

Messages sorted by: Reverse Date, Date, Thread, Author