File FOO-dir-completion-boo905348.patch of Package bash-completion
---
bash-completion-2.12.0/bash_completion | 38 +++++++++++++++++++++++++++++++++
bash-completion-2.12.0/completions/cd | 11 ++++++++-
2 files changed, 48 insertions(+), 1 deletion(-)
--- bash-completion-2.12.0/bash_completion
+++ bash-completion-2.12.0/bash_completion 2024-02-23 07:34:25.733559088 +0000
@@ -1102,6 +1102,7 @@ _comp_quote_compgen()
_comp_compgen_filedir()
{
_comp_compgen_tilde && return
+ _comp_compgen_dollar "$cur" || return
local -a toks
local _arg=${1-}
@@ -1775,6 +1776,43 @@ _comp_compgen_tilde()
return 1
}
+# Perform dollar ($ or backtick) completion
+# @return True (0) if completion needs further processing,
+# False (> 0) if dollar or backtick is for commands, also if dollar
+# is used for variables, completions are put in COMPREPLY and noq
+# further processing is necessary.
+_comp_compgen_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 string 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
--- bash-completion-2.12.0/completions/cd
+++ bash-completion-2.12.0/completions/cd 2024-02-23 07:45:00.565836867 +0000
@@ -5,7 +5,16 @@
_comp_cmd_cd()
{
local cur prev words cword comp_args
- _comp_initialize -- "$@" || return
+ _comp_initialize -- "$@" || {
+ if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
+ local i=${COMPREPLY[0]}
+ if [[ "$i" == "$cur" && $i != "*/" ]]; then
+ _comp_compgen_dollar "$i" || return
+ COMPREPLY[0]="${i%%/}/"
+ fi
+ fi
+ return
+ }
if [[ $cur == -* ]]; then
_comp_compgen_help -c help "$1"