bash-completion/FOO-dir-completion-boo905348.patch
Dr. Werner Fink 04f0acee3f Accepting request 760990 from home:marxin:branches:shells
- Update to version 2.10:
  * perltidy: associate *.t (#338)
  * perl: fix completion with space between option and argument
  * _variables: add TERM and LC_* completion (#353)
  * autotools: Replace pkgdatadir with datadir
  * pkg-config: Relative paths
  * pkg-config: generate Name from autotools PACKAGE
  * ssh: option and argument completion updates (#332)
  * test_arp: Skip if ARP tables are empty
  * test_chromium_browser: Skip test_2 if 'chromium-browser --help'
    fails
  * test_rpm2tgz: Fix expected output
  * cppcheck: Add new standards to --std option. (#356)
  * apt-get: fix pkg version completion if it contains a colon (#351)
  * test: bump black to >=19.10b0
  * ssh, scp, sftp, ssh-copy-id, curl: improve identity file
    completion
  * update-rc.d: indentation fix
  * update-rc.d: remove dead code
  * screen: add serial device basic arg (non)completion
  * screen: add //telnet completion
  * test: add some trivial perl -E/-e cases
  * perl: indentation fixes
  * curl: make @filename completion do the right thing with dirs
  * _filedir: avoid duplicate dirs internally, and a compgen -d call
    for files
  * _filedir: remove unused $x
  * bash_completion.sh: shellcheck SC2086 fixes
  * test: shellcheck config cleanups
  * shellcheck: add some option arg (non)completions

OBS-URL: https://build.opensuse.org/request/show/760990
OBS-URL: https://build.opensuse.org/package/show/shells/bash-completion?expand=0&rev=102
2020-01-07 10:08:21 +00:00

75 lines
1.9 KiB
Diff

---
bash_completion | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 46 insertions(+), 1 deletion(-)
--- bash_completion
+++ bash_completion 2017-07-04 07:44:47.556933294 +0000
@@ -555,6 +555,7 @@ _filedir()
local IFS=$'\n'
_tilde "$cur" || return
+ _dollar "$cur" || return
local -a toks
local reset
@@ -1006,6 +1007,41 @@ _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
@@ -1720,7 +1756,16 @@ complete -F _known_hosts traceroute traceroute6 \
_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