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

Ville Skyttä ville.skytta at iki.fi
Sat Jan 8 21:30:15 UTC 2011


The following commit has been merged in the master branch:
commit fe2d7645df9f619a33feb8c8d7c89b1ea5fcad6b
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Sat Jan 8 23:28:38 2011 +0200

    Re-enable postgresql database and user completion (Alioth: #312914, Ubuntu: #164772).
    
    This implementation uses -w which is available only in psql >= 8.4,
    but the net effect with earlier versions should be the same as when
    the completions were disabled.

diff --git a/CHANGES b/CHANGES
index b6d1053..046cb59 100644
--- a/CHANGES
+++ b/CHANGES
@@ -42,6 +42,8 @@ bash-completion (2.x)
   * Add *.apk to unzip and jar filename completions.
   * Do not load bash_completion in profile.d script if progcomp is not enabled.
   * Ignore muttrc source entries that are not files (Alioth: #312881).
+  * Re-enable postgresql database and user completion (Alioth: #312914,
+    Ubuntu: #164772).
 
   [ Freddy Vulto ]
   * Added _tilde(), fix ~username completion (Alioth: #312613, Debian: #587095)
diff --git a/completions/postgresql b/completions/postgresql
index d42d6e1..f874b67 100644
--- a/completions/postgresql
+++ b/completions/postgresql
@@ -3,19 +3,18 @@
 have psql && {
 _pg_databases()
 {
-    return # See https://launchpad.net/bugs/164772
-    COMPREPLY=( $( compgen -W "$( psql -l 2>/dev/null | \
-        sed -e '1,/^-/d' -e '/^(/,$d' | \
-        awk '{print $1}' )" -- "$cur" ) )
+    # -w was introduced in 8.4, https://launchpad.net/bugs/164772
+    # "Access privileges" in output may contain linefeeds, hence the NF > 1
+    COMPREPLY=( $( compgen -W "$( psql -AtqwlF $'\t' 2>/dev/null | \
+        awk 'NF > 1 { print $1 }' )" -- "$cur" ) )
 }
 
 _pg_users()
 {
-    # See https://launchpad.net/bugs/164772
-    #COMPREPLY=( $( psql -qtc 'select usename from pg_user' template1 2>/dev/null | \
-    #       command grep "^ $cur" ) )
-    #[ ${#COMPREPLY[@]} -eq 0 ] && COMPREPLY=( $( compgen -u -- $cur ) )
-    COMPREPLY=( $( compgen -u -- "$cur" ) )
+    # -w was introduced in 8.4, https://launchpad.net/bugs/164772
+    COMPREPLY=( $( compgen -W "$( psql -Atqwc 'select usename from pg_user' \
+        template1 2>/dev/null )" -- "$cur" ) )
+    [ ${#COMPREPLY[@]} -eq 0 ] && COMPREPLY=( $( compgen -u -- "$cur" ) )
 }
 
 # createdb(1) completion

-- 
bash-completion



More information about the Bash-completion-commits mailing list