File FOO-dir-completion-boo905348.patch of Package bash-completion

---
 bash_completion |   47 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

Index: bash-completion-2.11/bash_completion
===================================================================
--- bash-completion-2.11.orig/bash_completion
+++ bash-completion-2.11/bash_completion
@@ -566,6 +566,7 @@ _filedir()
     local IFS=$'\n'
 
     _tilde "${cur-}" || return
+    _dollar "$cur" || return
 
     local -a toks
     local reset arg=${1-}
@@ -1044,6 +1045,42 @@ _tilde()
     return $result
 }
 
+# Perform dollar ($) completion
+# @return  True (0) if completion needs further processing,
+#          False (> 0) if dollar is followed by a valid username, completions
+#          are put in COMPREPLY and no further processing is necessary.
+_dollar()
+{
+    local s=""
+    local -i glob=0
+
+    shopt -q extglob && let glob++
+    ((glob == 0)) && shopt -s extglob
+
+    [[ "$COMP_LINE" == cd* ]] && s="/"
+
+    case "$1" in
+    \$\(*|\`*)
+        COMPREPLY=($(compgen -c -P '$(' -S ")$s" -- ${1#??})) ;;
+    \$\{*)
+        COMPREPLY=($(compgen -v -P '${' -S "}$s" -- ${1#??})) ;;
+    \$*)
+        COMPREPLY=($(compgen -v -P '$' ${s:+-S $s} -- ${1#?})) ;;
+    *)
+        ((glob == 0)) && shopt -u extglob
+        return 0
+    esac
+
+    if ((${#COMPREPLY[@]} > 0)) ; then
+        ((${#COMPREPLY[@]} == 1)) && eval COMPREPLY=\(${COMPREPLY[@]}\)
+    else
+        eval COMPREPLY=\(${1}\)
+    fi
+
+    ((glob == 0)) && shopt -u extglob
+    return ${#COMPREPLY[@]}
+}
+
 # Expand variable starting with tilde (~)
 # We want to expand ~foo/... to /home/foo/... to avoid problems when
 # word-to-complete starting with a tilde is fed to commands and ending up
@@ -1810,7 +1847,16 @@ complete -F _known_hosts traceroute trac
 _cd()
 {
     local cur prev words cword
-    _init_completion || return
+    _init_completion || {
+        if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
+            local i=${COMPREPLY[0]}
+            if [[ "$i" == "$cur" && $i != "*/" ]]; then
+                _dollar "$i" || return
+                COMPREPLY[0]="${i%%/}/"
+            fi
+        fi
+        return
+    }
 
     local IFS=$'\n' i j k
 
openSUSE Build Service is sponsored by