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

Re: Contributing with Completions



On 7/22/07, Clint Adams <clint@xxxxxxx> wrote:
On Thu, Jul 19, 2007 at 10:01:34AM -0300, Renato Botelho wrote:
> _portsnap -> Tool for get/update FreeBSD ports tree using snapshots
>
> Comments, suggestions, critics are welcome, like I said, these are my
> first lines in zsh since i'm using it for less than a week.

When you use ->state, you should declare the scope of the parameters
context, state, line, opt_args.

Index: Completion/BSD/Command/_portsnap
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/BSD/Command/_portsnap,v
retrieving revision 1.1
diff -u -r1.1 _portsnap
--- Completion/BSD/Command/_portsnap    20 Jul 2007 16:39:15 -0000      1.1
+++ Completion/BSD/Command/_portsnap    22 Jul 2007 11:12:05 -0000
@@ -1,5 +1,8 @@
 #compdef portsnap

+local context state line
+typeset -A opt_args
+
 flags=(
   '(cron)fetch[Fetch a compressed snapshot or update existing one]'
   '(fetch)cron[Sleep rand(3600) seconds, and then fetch updates]'
@@ -17,7 +20,7 @@
     '-s:Server from which to fetch updates:_hosts' \
     '*:principal:->principal' && ret=0

-if [[ $state = principal ]]; then
+if [[ $state == principal ]]; then
   _alternative \
     ':file flag:_values -S " " -w "commands" $flags[@]' \
     '*:path:_files -/'

Thanks

--
Renato Botelho



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