zsh-workers
 help / color / mirror / code / Atom feed
* Re: Bug#482662: zsh: completion with locate gives extra output
       [not found]   ` <20080524164656.GA2682@nexus>
@ 2008-05-24 20:21     ` Clint Adams
  2008-05-25 14:52       ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Clint Adams @ 2008-05-24 20:21 UTC (permalink / raw)
  To: Sykora; +Cc: 482662, zsh-workers

On Sat, May 24, 2008 at 10:16:56PM +0530, Sykora wrote:
> I just typed "locate" at the prompt and pressed space, followed by tab. 
> 
> 
> $> locate Usage: locate [-d path | --database=path] [-e | -E | --[non-]existing]
>       [-i | --ignore-case] [-w | --wholename] [-b | --basename] 
>       [--limit=N | -l N] [-S | --statistics] [-0 | --null] [-c | --count]
>       [-P | -H | --nofollow] [-L | --follow] [-m | --mmap ] [ -s | --stdio ]
>       [-A | --all] [-p | --print] [-r | --regex ] [--regextype=TYPE]
>       [--max-database-age D] [--version] [--help]
>       pattern...
> 
> Report bugs to <bug-findutils@gnu.org>.
> <CURSOR HERE>

Ah, okay. You are using GNU locate and I am using mlocate.

> If I try to complete an option, it places the normal completion list
> following the cursor, but after the help text.
> 
> If you're unable to reproduce it, then I'm wondering if it's simply a
> conflict with my shell setup. But yet, when I checked on #zsh, some were
> able to recreate it.
> 
> I'll see if I can find out what it is.
> 
> Further, I found that I could (nominally) fix the problem by commenting
> out :
> 
>     input="$(_call_program locate $words[1])"
>     
> at line 14 of _locate, and setting ltype to gnu directly. But then, I
> have little clue what I did, just thought I'd mention it.

So _locate is trying to match *(#i)gnu locate*, which does not appear in the
`locate -V` output (nor does it appear in the `locate --version` output).
Does anyone have an older version of findutils handy? Would matching for
*findutils* or (#i)*findutils*gnu* cover all possibilities?

% locate: invalid option -- V
Usage: locate [-d path | --database=path] [-e | -E | --[non-]existing]
      [-i | --ignore-case] [-w | --wholename] [-b | --basename] 
      [--limit=N | -l N] [-S | --statistics] [-0 | --null] [-c | --count]
      [-P | -H | --nofollow] [-L | --follow] [-m | --mmap ] [ -s | --stdio ]
      [-A | --all] [-p | --print] [-r | --regex ] [--regextype=TYPE]
      [--max-database-age D] [--version] [--help]
      pattern...

Report bugs to <bug-findutils@gnu.org>.

% locate --version
locate (GNU findutils) 4.4.0
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Eric B. Decker, James Youngman, and Kevin Dalley.
Built using GNU gnulib version e5573b1bad88bfabcda181b9e0125fb0c52b7d3b


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

* Re: Bug#482662: zsh: completion with locate gives extra output
  2008-05-24 20:21     ` Bug#482662: zsh: completion with locate gives extra output Clint Adams
@ 2008-05-25 14:52       ` Peter Stephenson
  2008-05-26 10:14         ` Jun T.
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2008-05-25 14:52 UTC (permalink / raw)
  To: zsh-workers; +Cc: Sykora, 482662

On Sat, 24 May 2008 20:21:35 +0000
Clint Adams <schizo@debian.org> wrote:
> On Sat, May 24, 2008 at 10:16:56PM +0530, Sykora wrote:
> > I just typed "locate" at the prompt and pressed space, followed by tab. 
> > 
> > 
> > $> locate Usage: locate [-d path | --database=path] [-e | -E | --[non-]existing]
> >       [-i | --ignore-case] [-w | --wholename] [-b | --basename] 
> >       [--limit=N | -l N] [-S | --statistics] [-0 | --null] [-c | --count]
> >       [-P | -H | --nofollow] [-L | --follow] [-m | --mmap ] [ -s | --stdio ]
> >       [-A | --all] [-p | --print] [-r | --regex ] [--regextype=TYPE]
> >       [--max-database-age D] [--version] [--help]
> >       pattern...
> > 
> > Report bugs to <bug-findutils@gnu.org>.
> > <CURSOR HERE>
> 
> Ah, okay. You are using GNU locate and I am using mlocate.
> 
> So _locate is trying to match *(#i)gnu locate*, which does not appear in the
> `locate -V` output (nor does it appear in the `locate --version` output).
> Does anyone have an older version of findutils handy? Would matching for
> *findutils* or (#i)*findutils*gnu* cover all possibilities?

Presumably also copying stderr to stdout.

Index: Completion/Unix/Command/_locate
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_locate,v
retrieving revision 1.2
diff -u -r1.2 _locate
--- Completion/Unix/Command/_locate	11 Feb 2008 16:28:30 -0000	1.2
+++ Completion/Unix/Command/_locate	25 May 2008 14:50:52 -0000
@@ -11,7 +11,7 @@
   ;;
 
   (locate)
-  input="$(_call_program locate $words[1] -V)"
+  input="$(_call_program locate $words[1] -V 2>&1)"
   case $input in
     (*mlocate*)
     ltype=mlocate
@@ -21,7 +21,7 @@
     ltype=slocate
     ;;
 
-    (*(#i)gnu locate*)
+    (*(#i)gnu locate*|*findutils*gnu*)
     ltype=gnu
     ;;
 

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


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

* Re: Bug#482662: zsh: completion with locate gives extra output
  2008-05-25 14:52       ` Peter Stephenson
@ 2008-05-26 10:14         ` Jun T.
  2008-05-26 13:39           ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Jun T. @ 2008-05-26 10:14 UTC (permalink / raw)
  To: zsh-workers

I want take this opportunity to make it support MacOSX.
I believe this will work on (free|Open)BSD as well.

NOTES: 
(1) this includes the patch by PWS, which is not yet committed.

(2) I'm not sure if we should 'setopt EXTENDED_GLOB' at the top
of this script. (the globbing flag (#i) requires the option).

(3) I used '_arguments -S' also for mlocate and slocate.
Should it be used also for gnu locate?

(4) '_arguments -A' is used only for bsd locate, since mlocate/slocate
accepts options after pattern(s).


Index: Completion/Unix/Command/_locate
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_locate,v
retrieving revision 1.2
diff -u -r1.2 _locate
--- Completion/Unix/Command/_locate	11 Feb 2008 16:28:30 -0000	1.2
+++ Completion/Unix/Command/_locate	26 May 2008 10:10:49 -0000
@@ -11,7 +11,7 @@
   ;;
 
   (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 @@
     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 @@
   # -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 @@
   # -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 @@
     --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


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

* Re: Bug#482662: zsh: completion with locate gives extra output
  2008-05-26 10:14         ` Jun T.
@ 2008-05-26 13:39           ` Peter Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2008-05-26 13:39 UTC (permalink / raw)
  To: zsh-workers

On Mon, 26 May 2008 19:14:33 +0900
"Jun T." <takimoto-j@kba.biglobe.ne.jp> wrote:
> (2) I'm not sure if we should 'setopt EXTENDED_GLOB' at the top
> of this script. (the globbing flag (#i) requires the option).

EXTENDED_GLOB is supposed to be set on entry to the completion code in
the standard set of options ($_comp_options).

I've committed this.  I didn't look at the _arguments issues.

Thanks.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


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

end of thread, other threads:[~2008-05-26 13:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20080524095358.26811.79795.reportbug@nexus>
     [not found] ` <20080524135404.GA9888@scru.org>
     [not found]   ` <20080524164656.GA2682@nexus>
2008-05-24 20:21     ` Bug#482662: zsh: completion with locate gives extra output Clint Adams
2008-05-25 14:52       ` Peter Stephenson
2008-05-26 10:14         ` Jun T.
2008-05-26 13:39           ` Peter Stephenson

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).