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

Re: Patch for completion with svn 1.5.0



Peter Stephenson wrote:
> Christopher Key wrote:
>   
>> I thought I'd tested this with the old version of svn, but hadn't
>> actually managed to (the command being called by the completion logic
>> was still version 1.5).  The ?: in the pattern is a perl thing to tell
>> it not store the result of the match grouped by the brackets, but would
>> appear not apply to shell scripting.  Instead, "arg" should be replaced
>> simply with "(arg|ARG)".  I've attached a patch for this.  There are a
>> few other oddities with svn 1.5 too, I'll have a look and see if I can
>> deal with any of them.
>>     
>
> Thanks, I had to restore a space...
>
>   
>>          args=(
>> -          ${=${${${(M)${(f)"$(LC_ALL=C _call_program options svnadmin help $
>> cmd)"##*Valid options:}:#*:*}%% #:*}/ arg/:arg:}/(#b)-([[:alpha:]]) \[--([a-z
>> -]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$matc
>> h[3]}
>> +          ${=${${${(M)${(f)"$(LC_ALL=C _call_program options svnadmin help $
>> cmd)"##*Valid options:}:#*:*}%% #:*}/ (arg|ARG)/:arg:}/(#b)-([[:alpha:]]) \[-
>>     
>                             ^ here, before the colon.
>   
>> -([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2
>> ]$match[3]}
>>          )
>>     
>
> for "svnadmin help help" to work.  This was 1.4.4.  I got it simply by
> copying from the svn help equivalent.  I don't know if this is correct
> for other versions.  I don't really understand why, either, but it seems
> to make everything happy.
>
>   
I was just having a play at getting svnadmin help help to work, and had
come up with a different solution.  The innermost pattern substitution
look for "Valid options:" in the output from "svnadmin help $cmd", and
strips that out. The next substition removes any items *not* containing
":", whereas this should correctly remove anything not containing " :",
as it does for "svn help $cmd".

Now, when you run


#svnadmin help help
help (?, h): usage: svnadmin help [SUBCOMMAND...]

Describe the usage of this program or its subcommands.


the output doesn't contain the magic "Valid options", but neither does
any of it contain " :", so nothing gets passed to the substitution
looking for command line options.  This doesn't seem quite the correct
way to solve the problem though.  A better way seems to me to be to
refine the innermost substitution to removed everything up to and
including "Valid options:", or everything if "Valid options:" isn't
contained in the string.  The reason being that we're only interested in
trying to parse content following this phrase, and if it doesn't appear,
then it's not worth parsing anything.

The attached patch should achieve this, although I've only had about 2h
worth of experience with shell pattern substitutions, so it may not be
the best way!

Regards,

Chris
--- Completion/Unix/Command/_subversion~	2007-03-19 13:02:49.000000000 +0000
+++ Completion/Unix/Command/_subversion	2008-01-31 15:59:48.000000000 +0000
@@ -30,7 +30,7 @@
 
         usage=${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"}:#usage:*}#usage:*$cmd] }
         args=(
-          ${=${${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"##*Valid options:}:#* :*}%% #:*}/ arg/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}
+          ${=${${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"#(*Valid options:|(#e))}:#* :*}%% #:*}/ (arg|ARG)/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}
         )
 
         case $cmd in;
@@ -142,7 +142,7 @@
 
         usage=${${(M)${(f)"$(LC_ALL=C _call_program options svnadmin help $cmd)"}:#$cmd: usage:*}#$cmd: usage: svnadmin $cmd }
         args=(
-          ${=${${${(M)${(f)"$(LC_ALL=C _call_program options svnadmin help $cmd)"##*Valid options:}:#*:*}%% #:*}/ arg/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}
+          ${=${${${(M)${(f)"$(LC_ALL=C _call_program options svnadmin help $cmd)"#(*Valid options:|(#e))}:#* :*}%% #:*}/ (arg|ARG)/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}
         )
         if [[ $_svnadmin_subcmd_usage == *REPOS_PATH* ]]; then
           args+=( ":path:_files -/" )


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