summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-05-26 13:09:05 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-05-26 13:09:05 +0000
commitddb336e6f76c7dcd19cdf230f7a82cb0a969781c (patch)
tree0ef95069bda5a4cc7c66feaa307daa3cfd30d819 /Completion
parent9e1034a3017744525035b54925d58b338d296707 (diff)
downloadzsh-ddb336e6f76c7dcd19cdf230f7a82cb0a969781c.tar.gz
zsh-ddb336e6f76c7dcd19cdf230f7a82cb0a969781c.tar.xz
zsh-ddb336e6f76c7dcd19cdf230f7a82cb0a969781c.zip
25104; 25111 (Jun T): better completion for multiple versoins of locate
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Command/_locate29
1 files changed, 25 insertions, 4 deletions
diff --git a/Completion/Unix/Command/_locate b/Completion/Unix/Command/_locate
index dc53ee3eb..35dbf062a 100644
--- a/Completion/Unix/Command/_locate
+++ b/Completion/Unix/Command/_locate
@@ -11,7 +11,7 @@ case $basename in
   ;;
 
   (locate)
-  input="$(_call_program locate $words[1] -V)"
+  input="$(_call_program locate $words[1] -V 2>&1)"
   case $input in
     (*mlocate*)
     ltype=mlocate
@@ -21,10 +21,18 @@ case $basename in
     ltype=slocate
     ;;
 
-    (*(#i)gnu locate*)
+    (*(#i)gnu locate*|*findutils*gnu*)
     ltype=gnu
     ;;
 
+    (*illegal option*)
+    if [[ $OSTYPE == (freebsd|openbsd|dragonfly|darwin)* ]]; then
+      ltype=bsd
+    else
+      ltype=$best_guess
+    fi
+    ;;
+
     # guess
     (*)
     ltype=$best_guess
@@ -43,7 +51,7 @@ case $ltype in
   # -r/--regexp mean no normal arguments, so shouldn't complete
   # -m and --mmap are ignored, so don't bother
   # -s and --stdio likewise
-  _arguments -s : \
+  _arguments -s -S : \
     {-b,--basename}'[Match only the basename of files in the database]' \
     {-c,--count}'[Output the number of matching entries]' \
     {-d,--database=}'[Use alternative database]:database:_files' \
@@ -67,7 +75,7 @@ case $ltype in
   # -d can take path
   # -e can take a comma-separated list of directories.
   # -f should complete list of file system types like mount
-  _arguments -s : \
+  _arguments -s -S : \
     -u'[Create slocate database starting at path /]' \
     -U'[Create slocate database starting at given path]:directory:_files -/' \
     -c'[Parse GNU locate updatedb with -u, -U]' \
@@ -108,4 +116,17 @@ case $ltype in
     --help'[Show help]' \
     '*:pattern: '
   ;;
+
+  (bsd)
+  _arguments -s -S -A '-*' \
+    '(-S)-0[Separate file names by NUL characters]' \
+    '(- *)-S[Show database statistics and exit]' \
+    '(-S)-c[Output the number of matching file names]' \
+    '(-S)*-d[Specify database to search]:database:_files' \
+    '(-S)-i[Ignore case distinctions in pattern and database]' \
+    '(-S)-l[Limit output to specified number of file names]:file limit: ' \
+    '(-S)-m[Use mmap(2) instead of stdio(3) (default)]' \
+    '(-S)-s[Use stdio(3) instead of mmap(2)]' \
+    '*:pattern: '
+  ;;
 esac