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

PATCH: _groups and _condition



When completing groups, just checking that the ypcat command exists is
not a reliable way of determining if YP is being used: it exists here
but isn't used. This patch to _groups, makes it also check the exit code
from ypcat (which fails here). There may be better ways of determining
if NIS is being used. Doesn't it use something like '+:+' as the last
line of /etc/passwd?

Also here, is a patch against _condition so that it completes only files
after more of its options. Incidentally, I had a look at whether it
would be possible to add a completion for test and, more specifically,
the '[' builtin. Putting [ or \[ after #compdef doesn't work. I can't
use '[' as a key to an associative array if I use an assignment like:
foo[\[]=whatever  though it works fine if I do: a='[';foo[$a]=whatever 
or use an array style assignment.

Oliver Kiddle

--- Completion/User/_groups.bak	Thu Feb 17 17:52:19 2000
+++ Completion/User/_groups	Sun Mar 12 07:18:55 2000
@@ -1,13 +1,13 @@
 #compdef newgrp
 
-local expl groups
+local expl groups tmp
 
 _wanted groups expl group || return 1
 
 if ! zstyle -a ":completion:${curcontext}:" groups groups; then
   (( $+_cache_groups )) ||
-      if (( ${+commands[ypcat]} )); then
-        : ${(A)_cache_groups:=${${(s: :)$(ypcat group.byname)}%%:*}} #
If you use YP
+      if (( ${+commands[ypcat]} )) && tmp=$(ypcat group.byname); then
+        : ${(A)_cache_groups:=${${(f)tmp}%%:*}} # If you use YP
       else
         : ${(A)_cache_groups:=${${(s: :)$(</etc/group)}%%:*}}
       fi
--- Completion/Base/_condition.bak	Sun Mar 12 06:42:06 2000
+++ Completion/Base/_condition	Sun Mar 12 06:46:23 2000
@@ -4,7 +4,7 @@
 
 if [[ "$prev" = -o ]]; then
   _tags -C -o options && _options
-elif [[ "$prev" = -([no]t|ef) ]]; then
+elif [[ "$prev" = -([a-hkprsuwxLOGSN]|[no]t|ef) ]]; then
   _tags -C "$prev" files && _files
 else
   _alternative 'files:: _files' 'parameters:: _parameters'



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