[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 07c71e0aad0c870d7c891ccd6e3511f5a8a4f4b8

Ville Skyttä ville.skytta at iki.fi
Thu May 21 21:48:16 UTC 2009


The following commit has been merged in the master branch:
commit 07c71e0aad0c870d7c891ccd6e3511f5a8a4f4b8
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Fri May 22 00:48:12 2009 +0300

    Use _split_longopt with postgresql, other option completion improvements.

diff --git a/CHANGES b/CHANGES
index 2964d88..b886d26 100644
--- a/CHANGES
+++ b/CHANGES
@@ -38,8 +38,8 @@ bash-completion (1.x)
   * Add _split_longopt() helper for improved handling of long options that
     take arguments in both "--foo bar" and "--foo=bar" formats.
   * Use _split_longopt to improve and clean up aspell, chgrp, chown, chkconfig,
-    cpio, iptables, make, mc, mii-diag, mii-tool, mkinitrd, smartctl, and
-    generic long option completion (Alioth: #311398).
+    cpio, iptables, make, mc, mii-diag, mii-tool, mkinitrd, postgresql,
+    smartctl, and generic long option completion (Alioth: #311398).
   * Add chown --from and --reference value completions.
   * Add chgrp --reference value completion.
   * Do not assume all --foo= options take filenames in generic long option
diff --git a/contrib/postgresql b/contrib/postgresql
index d0b974e..cdd3ca1 100644
--- a/contrib/postgresql
+++ b/contrib/postgresql
@@ -24,27 +24,40 @@ _pg_users()
 #
 _createdb()
 {
-	local cur prev
+	local cur prev split=false
 
 	COMPREPLY=()
 	cur=`_get_cword`
 	prev=${COMP_WORDS[COMP_CWORD-1]}
 
+	_split_longopt && split=true
+
 	case "$prev" in
-	-@(h|-host=))
-		_known_hosts
-		return 0
-		;;
-	-@(U|-username=))
-		_pg_users
-		return 0
-		;;
+		-h|--host)
+			_known_hosts
+			return 0
+			;;
+		-U|--username|-O|--owner)
+			_pg_users
+			return 0
+			;;
+		-p|--port|-D|--tablespace|-E|--encoding|-T|--template)
+			# argument required but no completions available
+			return 0
+			;;
+		--help|--version)
+			# all other arguments are noop with these
+			return 0
+			;;
 	esac
 
+	$split && return 0
+
 	if [[ "$cur" == -* ]]; then
 		COMPREPLY=( $( compgen -W '-D -T -E -h -p -U -W -e -q \
-			--location= --template= --encoding= --host= --port= \
-			--username= --password --echo --quiet --help' -- $cur ))
+			--tablespace --template --encoding --host --port \
+			--username --password --echo --quiet --help --version' \
+			-- $cur ))
 	else
 		_pg_databases
 	fi
@@ -55,27 +68,35 @@ complete -F _createdb $default createdb
 #
 _dropdb()
 {
-	local cur prev
+	local cur prev split=false
 
 	COMPREPLY=()
 	cur=`_get_cword`
 	prev=${COMP_WORDS[COMP_CWORD-1]}
 
+	_split_longopt && split=true
+
 	case "$prev" in
-	-@(h|-host=))
-		_known_hosts
-		return 0
-		;;
-	-@(U|-username=))
-		_pg_users
-		return 0
-		;;
+		-h|--host)
+			_known_hosts
+			return 0
+			;;
+		-U|--username)
+			_pg_users
+			return 0
+			;;
+		--help|--version)
+			# all other arguments are noop with these
+			return 0
+			;;
 	esac
 
+	$split && return 0
+
 	if [[ "$cur" == -* ]]; then
-		COMPREPLY=( $( compgen -W '-h -p -U -W -e -q \
-				--host= --port= --username= --password \
-				--interactive --echo --quiet --help' -- $cur ) )
+		COMPREPLY=( $( compgen -W '-h -p -U -W -i -e -q \
+			--host --port --username --password --interactive \
+			--echo --quiet --help --version' -- $cur ) )
 	else
 		_pg_databases
 	fi
@@ -86,46 +107,60 @@ complete -F _dropdb $default dropdb
 #
 _psql()
 {
-	local cur prev
+	local cur prev split=false
 
 	COMPREPLY=()
 	cur=`_get_cword`
 	prev=${COMP_WORDS[COMP_CWORD-1]}
 
+	_split_longopt && split=true
+
 	case "$prev" in
-	-h|--host)
-		_known_hosts
-		return 0
-		;;
-	-U|--username)
-		_pg_users
-		return 0
-		;;
-	-d|--dbname)
-		_pg_databases
-		return 0
-		;;
-	-@(o|f)|--output|--file)
-		_filedir
-		return 0
-		;;
+		-h|--host)
+			_known_hosts
+			return 0
+			;;
+		-U|--username)
+			_pg_users
+			return 0
+			;;
+		-d|--dbname)
+			_pg_databases
+			return 0
+			;;
+		-o|--output|-f|--file|-L|--log-file)
+			_filedir
+			return 0
+			;;
+		-c|--command|-F|--field-separator|-p|--port|-P|--pset|\
+		-R|--record-separator|-T|--table-attr|-v|--set|--variable)
+			# argument required but no completions available
+			return 0
+			;;
+		-\?|--help|-V|--version)
+			# all other arguments are noop with these
+			return 0
+			;;
 	esac
 
+	$split && return 0
+
 	if [[ "$cur" == -* ]]; then
 		# return list of available options
 		COMPREPLY=( $( compgen -W '-a --echo-all -A --no-align \
 			-c --command -d --dbname -e --echo-queries \
-			-E --echo-hidden -f --file -F --filed-separator \
-			-h --host -H --html -l --list -n -o --output \
-			-p --port -P --pset -q -R --record-separator \
-			-s --single-step -S --single-line -t --tuples-only \
-			-T --table-attr -U --username -v --variable \
-			-V --version -W --password -x --expanded -X --nopsqlrc \
-			-? --help ' -- $cur ) )
+			-E --echo-hidden -f --file -F --field-separator \
+			-h --host -H --html -l --list -L --log-file -n \
+			-o --output -p --port -P --pset -q --quiet \
+			-R --record-separator -s --single-step \
+			-S --single-line -t --tuples-only -T --table-attr \
+			-U --username -v --set --variable -V --version \
+			-W --password -x --expanded -X --no-psqlrc \
+			-1 --single-transaction -? --help' -- $cur ) )
 	else
 		# return list of available databases
 		_pg_databases
 	fi
 }
-complete -F _psql $default psql
+complete -F _psql $filenames psql
 }

-- 
bash-completion



More information about the Bash-completion-commits mailing list