[Top][All Lists]
[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: |
Sun, 11 Jul 2004 12:03:12 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 |
Martin Quinson wrote:
Here is the relevant chunk of /etc/bash_completion. I have no idea why
debian differs that much from upstream with that regard. In general, I hate
when improvement are not reported upstream, making the debian version
forking for obscure reasons. But this one may be a special case, no idea.
I'm gonna commit your changes soon, but I would like you to react on this
first, just in case you want to adjust your patch ;)
Thanks, yes, I would.
I changed things around a bit. Instead of removing all the calls to
_filedir and such, I just provide any functions that are missing. The
script should still work without any extra infrastructure at all, and
should still fit well into debian or other environments. At least I
hope so :).
--
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 2004-07-07 03:00:05.000000000 +0000
+++ quilt-0.34/bash_completion 2004-07-11 16:32:13.000000000 +0000
@@ -6,8 +6,74 @@
# This file is part of the distribution of quilt, and is distributed under
# the same licence than quilt itself
-have quilt &&
-_quilt()
+if type quilt &> /dev/null ; then
+
+if ! type _expand &> /dev/null ; then
+ # This function expands tildes in pathnames
+ #
+ _expand()
+ {
+ [ "$cur" != "${cur%\\}" ] && cur="$cur"'\'
+
+ # expand ~username type directory specifications
+ if [[ "$cur" == \~*/* ]]; then
+ eval cur=$cur
+ elif [[ "$cur" == \~* ]]; then
+ cur=${cur#\~}
+ COMPREPLY=( $( compgen -P '~' -u $cur ) )
+ return address@hidden
+ fi
+ }
+fi
+
+if ! type _filedir &> /dev/null ; then
+ # This function performs file and directory completion. It's better than
+ # simply using 'compgen -f', because it honours spaces in filenames
+ #
+ _filedir()
+ {
+ local IFS=$'\t\n'
+
+ _expand || return 0
+
+ if [ "$1" = -d ]; then
+ COMPREPLY=( address@hidden $( compgen -d -- $cur ) )
+ return 0
+ fi
+ COMPREPLY=( address@hidden $( eval compgen -f -- \"$cur\" ) )
+ }
+fi
+
+if ! type _longopt &> /dev/null ; then
+ _longopt()
+ {
+ local cur opt
+
+ cur=${COMP_WORDS[COMP_CWORD]}
+
+ if [[ "$cur" == "--*=*" ]]; then
+ opt=${cur%%=*}
+ # cut backlash that gets inserted before '=' sign
+ opt=${opt%\\*}
+ cur=${cur#*=}
+ _filedir
+ COMPREPLY=( $( compgen -P "$opt=" -W 'address@hidden' -- $cur))
+ return 0
+ fi
+
+ if [[ "$cur" == "-*" ]]; then
+ COMPREPLY=( $( $1 --help 2>&1 | sed -e '/--/!d' \
+ -e 's/.*\(--[-A-Za-z0-9]\+=\?\).*/\1/' | \
+ grep "^$cur" | sort -u ) )
+ elif [[ "$1" == "@(mk|rm)dir" ]]; then
+ _filedir -d
+ else
+ _filedir
+ fi
+ }
+fi
+
+_quilt_completion()
{
local cur prev cmds
@@ -172,6 +238,9 @@ _quilt()
esac
return 0
}
-[ "$have" ] && complete -F _quilt $filenames quilt
+[ ${BASH_VERSINFO[1]} '>' 04 ] && _quilt_complete_opt="-o filenames"
+complete -F _quilt_completion $_quilt_complete_opt quilt
+unset -v _quilt_complete_opt
+fi