[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: bash completion for subversion

From: Brian W. Fitzpatrick <fitz_at_collab.net>
Date: 2004-11-08 21:34:55 CET

On Mon, 2004-11-08 at 13:24, Philip Martin wrote:
> Martin Blais <martin.blais@gmail.com> writes:
>
> > a little potential contribution: i took the bash completion file for
> > subversion and modified it so that it uses the output of subversion
> > itself to provide the completions, similar in idea to optcomplete
> > (http://furius.ca/optcomplete). the idea is that the completions will
> > never go out-of-sync with whatever version of subversion you have
> > installed (well, unless the help format changes, which i estimate to
> > be unlikely).
> >
> > cheers,
> >
> > p.s. if someone thinks that this is worth adding to the codebase, feel
> > free to do so.
>
> I like the idea, but when I try to use it bash goes awol, using more
> and more memory until I interrupt the completion.
>
> > #!/bin/sh
>
> Why? Doesn't it need to be sourced by a shell, rather than executed?
>
> > #
> > # $Id: bashrc,v 1.1 2004/11/08 00:09:46 blais Exp $
> > # $Source: /u/blais/cvsroot/oversion/etc/bashrc,v $
> > #
> > # Author: Martin Blais
> > # Date: 2004-11-07
> > #
> >
> > _svn_common ()
> > {
> > exe=$1
> > local cur cmds cmdOpts pOpts mOpts rOpts qOpts nOpts optsParam opt
> > local helpCmds optBase i
>
> A lot of these are now not used and could be removed.
>
> >
> > COMPREPLY=()
> > cur=${COMP_WORDS[COMP_CWORD]}
> >
> > # Possible expansions, without unambiguous abbreviations such as "up".
> > cmds=$($exe help| egrep '^ ' | sed -e 's/(//;s/)//;s/,//g')
> >
> > if [[ $COMP_CWORD -eq 1 ]] ; then
> > COMPREPLY=( $( compgen -W "$cmds" -- $cur ) )
> > return 0
> > fi
> >
> > # find the current command
> > cmd=${COMP_WORDS[1]}
> >
> > # options that require a parameter
> > helpOut=$($exe $cmd --help | egrep '^ .* : ' | \
> > sed -e 's/[ ]*:.*//;s/\[//;s/\]//;')
> >
> > optsParam=$(echo "$helpOut" | grep arg$)
> > optsParam=$(echo $optsParam | sed -e 's/ arg//g;s/ /|/g')
> >
> > # if not typing an option, or if the previous option required a
> > # parameter, then fallback on ordinary filename expansion
> > helpCmds='help|--help|h|\?'
> > if [[ ${COMP_WORDS[1]} != @($helpCmds) ]] && \
> > [[ "$cur" != -* ]] || \
> > [[ ${COMP_WORDS[COMP_CWORD-1]} == @($optsParam) ]] ; then
> > return 0
> > fi
> >
> > cmdOpts=$(echo $helpOut | sed -e 's/ arg//g')
> >
> > COMPREPLY=( $( compgen -W "$cmdOpts" -- $cur ) )
> >
> > return 0
> > }
> >
> > _svn_new ()
> > {
> > _svn_common "svn"
> > }
> > complete -F _svn_new -o default svn
> >
> > _svnadmin_new ()
> > {
> > _svn_common "svnadmin"
> > }
>
> You have also removed the alternatives/exclusives handling, I'd like
> to see that back.
>
> My real problem is that I can't get it to work. The things that don't
> work are:
>
> $ svn <TAB>
>
> The shell uses CPU and memory (it goes into swap) but doesn't generate
> a list of commands. Command completion fails in the same way:
>
> $ svn che<TAB>

Odd. Both of these work for me. Here's my version info:

$ bash --version
GNU bash, version 2.05b.0(1)-release (i386-redhat-linux-gnu)

> but option expansion works fine:

Same here.

-Fitz

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Nov 8 21:35:21 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.