quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Quilt-dev] Suggested change for bash_completion


From: Joe Green
Subject: Re: [Quilt-dev] Suggested change for bash_completion
Date: Thu, 08 Jul 2004 14:56:06 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113

Martin Quinson wrote:
Anyway. I love when bugs get so ashamed of themselves that they
disapear just like that ;)

I always worry they're still in there. I like them to show themselves long enough for me to squash them :).

I don't know where the "have", "_filedir" or "_longopt" functions are supposed to come from, so I have a patch that replaces them with portable bash functions.

I dunno either, but I'm also interested in that patch since it could help
this file working on non-debian boxes ?

Yes, it should do that. With the attached patch applied, it should be possible to ". /etc/bash_completion.d/quilt" on just about any system that has bash.

The main change is to use "compgen -f" instead of "_filedir" and "compgen -d" instead of "_filedir -d". The "-f" and "-d" options can be used together with "-W", so only one invocation of compgen is needed.

One thing to watch out for: I didn't have a quick replacement for "_longopt grep", so the patch just removes it for now. To fix it portably I guess would mean either adding the options manually to the "-W" clause or including an equivalent function for _longopt.

Also, I changed the completion function name from "_quilt" to "_quilt_completion". That change is kind of arbitrary, but this function stays active in the user's shell environment, and I thought some might have other functions they'd like to call "_quilt".

--
Joe Green <address@hidden>
MontaVista Software, Inc.
Source: MontaVista Software, Inc
Type: Enhancement
Description:
    Use only portable bash features in bash_completion.

Index: quilt-0.34/bash_completion
===================================================================
--- quilt-0.34.orig/bash_completion
+++ quilt-0.34/bash_completion
@@ -6,8 +6,8 @@
 # This file is part of the distribution of quilt, and is distributed under
 # the same licence than quilt itself
 
-have quilt &&
-_quilt()
+if [ "$(type -p quilt)" ] ; then
+_quilt_completion()
 {
     local cur prev cmds
 
@@ -41,8 +41,7 @@ _quilt()
                COMPREPLY=( $( compgen -W "$(quilt applied)" -- $cur ) )
                ;;
             *)
-               _filedir 
-               COMPREPLY=( address@hidden:-} $( compgen -W "-p -h" -- $cur ) )
+               COMPREPLY=( $( compgen -f -W "-p -h" -- $cur ) )
                ;;
           esac
           ;;
@@ -64,14 +63,12 @@ _quilt()
                COMREPLY=(  )
                ;;
             *)
-               _filedir 
-               COMPREPLY=( address@hidden:-} $( compgen -W "-p -P -c -R -z -h 
--snapshot --diff --no-timestamps" -- $cur ) )
+               COMPREPLY=( $( compgen -f -W "-p -P -c -R -z -h --snapshot 
--diff --no-timestamps" -- $cur ) )
                ;;
           esac
           ;;
        edit)
-          _filedir
-          COMPREPLY=( address@hidden:-} $( compgen -W "-h" -- $cur ) )
+          COMPREPLY=( $( compgen -f -W "-h" -- $cur ) )
           ;;
        files)
           COMPREPLY=( $( compgen -W "-v -h $(quilt series)" -- $cur ) )
@@ -82,7 +79,7 @@ _quilt()
                COMPREPLY=( $( compgen -W "0 1" -- $cur ) )
                ;;
             *)
-               COMPREPLY=( address@hidden:-} $( compgen -W "-p" -- $cur ) )
+               COMPREPLY=( $( compgen -W "-p" -- $cur ) )
                ;;
           esac
           ;;
@@ -93,8 +90,7 @@ _quilt()
           COMPREPLY=( $( compgen -W "-h --all --reduce --lines --edge-labels 
$(quilt applied)" -- $cur ) )
           ;;
        grep)
-          _longopt grep
-          COMPREPLY=( address@hidden:-} $( compgen -W "-h" -- $cur ) )
+          COMPREPLY=( $( compgen -W "-h" -- $cur ) )
           ;;
        import)
           case $prev in
@@ -104,8 +100,7 @@ _quilt()
             -n)
                ;;
             *)
-               _filedir 
-               COMPREPLY=( address@hidden:-} $( compgen -W "-p -n -f -h" -- 
$cur ) )
+               COMPREPLY=( $( compgen -f -W "-p -n -f -h" -- $cur ) )
                ;;
           esac
           ;;
@@ -115,8 +110,7 @@ _quilt()
           COMPREPLY=( $( compgen -W "-n $(quilt series)" -- $cur ) )
           ;;
        patches)
-          _filedir 
-          COMPREPLY=( address@hidden:-} $( compgen -W "-v -n -h" -- $cur ) )
+          COMPREPLY=( $( compgen -f -W "-v -n -h" -- $cur ) )
           ;;
        pop)
           COMPREPLY=( $( compgen -W "-a -f -R -q -v -h $(quilt applied)" -- 
$cur ) )
@@ -140,8 +134,7 @@ _quilt()
                COMPREPLY=( $( compgen -W "$(quilt applied)" -- $cur ) )
                ;;
             *)
-               _filedir 
-               COMPREPLY=( address@hidden:-} $( compgen -W "-p -h" -- $cur ) )
+               COMPREPLY=( $( compgen -f -W "-p -h" -- $cur ) )
                ;;
           esac
           ;;
@@ -151,11 +144,10 @@ _quilt()
         setup)
           case $prev in
             -d)
-               _filedir -d
+               COMPREPLY=( $( compgen -d -- $cur ) )
                ;;
             *)
-               _filedir 
-               COMPREPLY=( address@hidden:-} $( compgen -W "-d -v -h" -- $cur 
) )
+               COMPREPLY=( $( compgen -f -W "-d -v -h" -- $cur ) )
                ;;
           esac
           ;;
@@ -172,6 +164,5 @@ _quilt()
     esac
     return 0
 }
-[ "$have" ] && complete -F _quilt $filenames quilt
-
-
+complete -F _quilt_completion "$(type -p quilt)" quilt
+fi

reply via email to

[Prev in Thread] Current Thread [Next in Thread]