diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e890f221a0b..1026e256296 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,10 +34,10 @@ repos: files: ^test/t/.+\.py$ pass_filenames: false - - id: update-test-deprecated-links - name: update-test-deprecated-links + - id: update-test-fallback-links + name: update-test-fallback-links language: script - entry: test/deprecated/update-deprecated-links + entry: test/fallback/update-fallback-links files: ^completions/_ pass_filenames: false diff --git a/bash_completion b/bash_completion index 46f0cf1cb24..084465b4227 100644 --- a/bash_completion +++ b/bash_completion @@ -2537,6 +2537,9 @@ __load_completion() backslash=\\ fi + # For loading 3rd party completions wrapped in shopt reset + local IFS=$' \t\n' + for dir in "${dirs[@]}"; do [[ -d $dir ]] || continue for compfile in "$cmd" "$cmd.bash"; do @@ -2554,7 +2557,7 @@ __load_completion() done done - # search deprecated completions "_$cmd" + # Search fallback completions named "_$cmd" for dir in "${dirs[@]}"; do [[ -d $dir ]] || continue compfile="$dir/_$cmd" @@ -2564,7 +2567,7 @@ __load_completion() # Do not warn with . or .. (especially the former is common) [[ $compfile == */.?(.) ]] || echo "bash_completion: $compfile: is a directory" >&2 - elif [[ -e $compfile ]] && . "$compfile"; then + elif [[ -e $compfile ]] && . "$compfile" "$cmd"; then [[ $backslash ]] && $(complete -p "$cmd") "\\$cmd" return 0 fi diff --git a/completions/.gitignore b/completions/.gitignore index 0dd1db1e8d0..1eb41747b3b 100644 --- a/completions/.gitignore +++ b/completions/.gitignore @@ -84,6 +84,7 @@ /host /hping /hping3 +/_hugo /iceweasel /identify /ifdown @@ -95,6 +96,7 @@ /iperf3 /javac /javadoc +/_kn /kplayer /l2ping /lbzip2 @@ -223,12 +225,15 @@ /smbtree /sparc-koji /spovray +/_sshi /star /stream /sudoedit /tightvncviewer /tracepath6 /typeset +/_upctl +/_vacuum /vgcfgbackup /vgcfgrestore /vgchange diff --git a/completions/Makefile.am b/completions/Makefile.am index 1712dd193f0..352be8483d6 100644 --- a/completions/Makefile.am +++ b/completions/Makefile.am @@ -38,6 +38,7 @@ bashcomp_DATA = 2to3 \ bzip2 \ _cal \ cancel \ + _cargo \ cardctl \ carton \ ccache \ @@ -130,12 +131,14 @@ bashcomp_DATA = 2to3 \ geoiplookup \ getconf \ getent \ + _gh \ gkrellm \ gm \ gnatmake \ gnokii \ gnome-mplayer \ gnome-screenshot \ + _golangci-lint \ gpasswd \ gpg \ gpg2 \ @@ -373,7 +376,9 @@ bashcomp_DATA = 2to3 \ rrdtool \ rsync \ _rtcwake \ + _ruff \ _runuser \ + _rustup \ sbcl \ sbopkg \ screen \ @@ -475,6 +480,7 @@ bashcomp_DATA = 2to3 \ xz \ xzdec \ ypmatch \ + _yq \ _yum \ yum-arch \ zopfli \ @@ -593,6 +599,7 @@ CLEANFILES = \ host \ hping \ hping3 \ + _hugo \ iceweasel \ identify \ ifdown \ @@ -604,6 +611,7 @@ CLEANFILES = \ iperf3 \ javac \ javadoc \ + _kn \ kplayer \ l2ping \ lbzip2 \ @@ -764,12 +772,15 @@ CLEANFILES = \ smbtree \ sparc-koji \ spovray \ + _sshi \ star \ stream \ sudoedit \ tightvncviewer \ tracepath6 \ typeset \ + _upctl \ + _vacuum \ vgcfgbackup \ vgcfgrestore \ vgchange \ @@ -866,6 +877,8 @@ symlinks: $(DATA) geoiplookup6 $(ss) gkrellm \ gkrellm2 + $(ss) _golangci-lint \ + _hugo _kn _sshi _upctl _vacuum $(ss) gpgv \ gpgv2 $(ss) gssdp-discover \ diff --git a/completions/_cargo b/completions/_cargo new file mode 100644 index 00000000000..fcb5e2781df --- /dev/null +++ b/completions/_cargo @@ -0,0 +1,13 @@ +# 3rd party completion loader for cargo -*- shell-script -*- +# +# This serves as a fallback in case the completion is not installed otherwise. + +# shellcheck disable=SC2168 # "local" is ok, assume sourced by __load_completion +local rustup="${1%cargo}rustup" # use rustup from same dir +eval -- "$("$rustup" completions bash cargo 2>/dev/null)" + +{ + complete -p "$1" || complete -p "${1##*/}" +} &>/dev/null + +# ex: filetype=sh diff --git a/completions/_gh b/completions/_gh new file mode 100644 index 00000000000..7b0daefed8b --- /dev/null +++ b/completions/_gh @@ -0,0 +1,12 @@ +# 3rd party completion loader for commands emitting -*- shell-script -*- +# their completion using "$cmd completion --shell bash". +# +# This serves as a fallback in case the completion is not installed otherwise. + +eval -- "$("$1" completion --shell bash 2>/dev/null)" + +{ + complete -p "$1" || complete -p "${1##*/}" +} &>/dev/null + +# ex: filetype=sh diff --git a/completions/_golangci-lint b/completions/_golangci-lint new file mode 100644 index 00000000000..830fa536aa0 --- /dev/null +++ b/completions/_golangci-lint @@ -0,0 +1,13 @@ +# 3rd party completion loader for commands emitting -*- shell-script -*- +# their completion using "$cmd completion bash". +# For example, many Go programs using https://github.com/spf13/cobra do. +# +# This serves as a fallback in case the completion is not installed otherwise. + +eval -- "$("$1" completion bash 2>/dev/null)" + +{ + complete -p "$1" || complete -p "${1##*/}" +} &>/dev/null + +# ex: filetype=sh diff --git a/completions/_ruff b/completions/_ruff new file mode 100644 index 00000000000..71f7c0c6524 --- /dev/null +++ b/completions/_ruff @@ -0,0 +1,12 @@ +# 3rd party completion loader for commands emitting -*- shell-script -*- +# their completion using "$cmd generate-shell-completion bash". +# +# This serves as a fallback in case the completion is not installed otherwise. + +eval -- "$("$1" generate-shell-completion bash 2>/dev/null)" + +{ + complete -p "$1" || complete -p "${1##*/}" +} &>/dev/null + +# ex: filetype=sh diff --git a/completions/_rustup b/completions/_rustup new file mode 100644 index 00000000000..0f2fe6e4056 --- /dev/null +++ b/completions/_rustup @@ -0,0 +1,11 @@ +# 3rd party completion loader for rustup -*- shell-script -*- +# +# This serves as a fallback in case the completion is not installed otherwise. + +eval -- "$("$1" completions bash rustup 2>/dev/null)" + +{ + complete -p "$1" || complete -p "${1##*/}" +} &>/dev/null + +# ex: filetype=sh diff --git a/completions/_yq b/completions/_yq new file mode 100644 index 00000000000..ff662bf9ede --- /dev/null +++ b/completions/_yq @@ -0,0 +1,12 @@ +# 3rd party completion loader for commands emitting -*- shell-script -*- +# their completion using "$cmd shell-completion bash". +# +# This serves as a fallback in case the completion is not installed otherwise. + +eval -- "$("$1" shell-completion bash 2>/dev/null)" + +{ + complete -p "$1" || complete -p "${1##*/}" +} &>/dev/null + +# ex: filetype=sh diff --git a/configure.ac b/configure.ac index 633e9dc0aa6..faab8df0de7 100644 --- a/configure.ac +++ b/configure.ac @@ -17,8 +17,8 @@ completions/Makefile doc/Makefile helpers/Makefile test/Makefile -test/deprecated/Makefile -test/deprecated/completions/Makefile +test/fallback/Makefile +test/fallback/completions/Makefile test/t/Makefile test/t/unit/Makefile ]) diff --git a/doc/api-and-naming.md b/doc/api-and-naming.md index 8e25970ef4c..df5682b7aab 100644 --- a/doc/api-and-naming.md +++ b/doc/api-and-naming.md @@ -19,8 +19,8 @@ each call that references the value, variable name, or their existence, typically by `unset -v`ing them when multiple such calls are used, to avoid them interfering with each other. -Everything in deprecated completion files (ones starting with an underscore) -is considered private and is to be named accordingly. Deprecated files are not +Everything in fallback completion files (ones starting with an underscore) +is considered private and is to be named accordingly. Fallback files are not intended to be explicitly used with `_comp_xfunc`, and completion files having precedence over them may have a different API. diff --git a/test/Makefile.am b/test/Makefile.am index 815c8095316..aaf32e02065 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = deprecated t +SUBDIRS = fallback t EXTRA_DIST = config \ fixtures \ diff --git a/test/config/bashrc b/test/config/bashrc index b6296f7c873..3a2d6df11fa 100644 --- a/test/config/bashrc +++ b/test/config/bashrc @@ -34,9 +34,9 @@ export BASH_COMPLETION_USER_FILE=/dev/null # overriding in-tree completions. Setting the user dir would otherwise suffice, # but simple xspec completions are only installed if a separate one is not # found in *any* completion dirs, and we want to use our "shadow" completion -# dir with which we cause loading of our in-tree deprecated completions +# dir with which we cause loading of our in-tree fallback completions # instead of possibly (system-)installed upstream ones. -export BASH_COMPLETION_USER_DIR="$SRCDIRABS/deprecated" +export BASH_COMPLETION_USER_DIR="$SRCDIRABS/fallback" export BASH_COMPLETION_COMPAT_DIR="$SRCDIRABS/../bash_completion.d" export XDG_DATA_DIRS=/var/empty diff --git a/test/deprecated/Makefile.am b/test/deprecated/Makefile.am deleted file mode 100644 index e157948673c..00000000000 --- a/test/deprecated/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -SUBDIRS = completions - -EXTRA_DIST = \ - update-deprecated-links - -update: - ./update-deprecated-links diff --git a/test/deprecated/completions/README.md b/test/deprecated/completions/README.md deleted file mode 100644 index b4184d4a6a1..00000000000 --- a/test/deprecated/completions/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# test/deprecated/completions - -This directory should contain a non-underscore prefixed symlink to -corresponding underscore prefixed, deprecated completions we have in the tree. - -The test suite sets up loading of completions so that this dir is preferred -over system install locations, in order to test our deprecated in-tree -completions over possibly installed non-deprecated out-of-tree ones. diff --git a/test/fallback/Makefile.am b/test/fallback/Makefile.am new file mode 100644 index 00000000000..096a1968254 --- /dev/null +++ b/test/fallback/Makefile.am @@ -0,0 +1,7 @@ +SUBDIRS = completions + +EXTRA_DIST = \ + update-fallback-links + +update: + ./update-fallback-links diff --git a/test/deprecated/completions/Makefile.am b/test/fallback/completions/Makefile.am similarity index 85% rename from test/deprecated/completions/Makefile.am rename to test/fallback/completions/Makefile.am index 2c65094ab0e..9c4194cb424 100644 --- a/test/deprecated/completions/Makefile.am +++ b/test/fallback/completions/Makefile.am @@ -1,10 +1,13 @@ EXTRA_DIST = \ adb \ cal \ + cargo \ chfn \ chsh \ dmesg \ eject \ + gh \ + golangci-lint \ hexdump \ hwclock \ ionice \ @@ -21,7 +24,9 @@ EXTRA_DIST = \ reptyr \ rfkill \ rtcwake \ + ruff \ runuser \ + rustup \ slackpkg \ su \ svn \ @@ -32,4 +37,5 @@ EXTRA_DIST = \ umount.linux \ write \ xm \ + yq \ yum diff --git a/test/fallback/completions/README.md b/test/fallback/completions/README.md new file mode 100644 index 00000000000..020e4b25080 --- /dev/null +++ b/test/fallback/completions/README.md @@ -0,0 +1,8 @@ +# test/fallback/completions + +This directory should contain a non-underscore prefixed symlink to +corresponding underscore prefixed, fallback completions we have in the tree. + +The test suite sets up loading of completions so that this dir is preferred +over system install locations, in order to test our fallback in-tree +completions over possibly installed non-fallback out-of-tree ones. diff --git a/test/deprecated/completions/adb b/test/fallback/completions/adb similarity index 100% rename from test/deprecated/completions/adb rename to test/fallback/completions/adb diff --git a/test/deprecated/completions/cal b/test/fallback/completions/cal similarity index 100% rename from test/deprecated/completions/cal rename to test/fallback/completions/cal diff --git a/test/fallback/completions/cargo b/test/fallback/completions/cargo new file mode 120000 index 00000000000..cdc7c30243d --- /dev/null +++ b/test/fallback/completions/cargo @@ -0,0 +1 @@ +../../../completions/_cargo \ No newline at end of file diff --git a/test/deprecated/completions/chfn b/test/fallback/completions/chfn similarity index 100% rename from test/deprecated/completions/chfn rename to test/fallback/completions/chfn diff --git a/test/deprecated/completions/chsh b/test/fallback/completions/chsh similarity index 100% rename from test/deprecated/completions/chsh rename to test/fallback/completions/chsh diff --git a/test/deprecated/completions/dmesg b/test/fallback/completions/dmesg similarity index 100% rename from test/deprecated/completions/dmesg rename to test/fallback/completions/dmesg diff --git a/test/deprecated/completions/eject b/test/fallback/completions/eject similarity index 100% rename from test/deprecated/completions/eject rename to test/fallback/completions/eject diff --git a/test/fallback/completions/gh b/test/fallback/completions/gh new file mode 120000 index 00000000000..823628f588d --- /dev/null +++ b/test/fallback/completions/gh @@ -0,0 +1 @@ +../../../completions/_gh \ No newline at end of file diff --git a/test/fallback/completions/golangci-lint b/test/fallback/completions/golangci-lint new file mode 120000 index 00000000000..b0fa4ef1c08 --- /dev/null +++ b/test/fallback/completions/golangci-lint @@ -0,0 +1 @@ +../../../completions/_golangci-lint \ No newline at end of file diff --git a/test/deprecated/completions/hexdump b/test/fallback/completions/hexdump similarity index 100% rename from test/deprecated/completions/hexdump rename to test/fallback/completions/hexdump diff --git a/test/deprecated/completions/hwclock b/test/fallback/completions/hwclock similarity index 100% rename from test/deprecated/completions/hwclock rename to test/fallback/completions/hwclock diff --git a/test/deprecated/completions/ionice b/test/fallback/completions/ionice similarity index 100% rename from test/deprecated/completions/ionice rename to test/fallback/completions/ionice diff --git a/test/deprecated/completions/look b/test/fallback/completions/look similarity index 100% rename from test/deprecated/completions/look rename to test/fallback/completions/look diff --git a/test/deprecated/completions/mock b/test/fallback/completions/mock similarity index 100% rename from test/deprecated/completions/mock rename to test/fallback/completions/mock diff --git a/test/deprecated/completions/modules b/test/fallback/completions/modules similarity index 100% rename from test/deprecated/completions/modules rename to test/fallback/completions/modules diff --git a/test/deprecated/completions/mount b/test/fallback/completions/mount similarity index 100% rename from test/deprecated/completions/mount rename to test/fallback/completions/mount diff --git a/test/deprecated/completions/mount.linux b/test/fallback/completions/mount.linux similarity index 100% rename from test/deprecated/completions/mount.linux rename to test/fallback/completions/mount.linux diff --git a/test/deprecated/completions/newgrp b/test/fallback/completions/newgrp similarity index 100% rename from test/deprecated/completions/newgrp rename to test/fallback/completions/newgrp diff --git a/test/deprecated/completions/nmcli b/test/fallback/completions/nmcli similarity index 100% rename from test/deprecated/completions/nmcli rename to test/fallback/completions/nmcli diff --git a/test/deprecated/completions/op b/test/fallback/completions/op similarity index 100% rename from test/deprecated/completions/op rename to test/fallback/completions/op diff --git a/test/deprecated/completions/renice b/test/fallback/completions/renice similarity index 100% rename from test/deprecated/completions/renice rename to test/fallback/completions/renice diff --git a/test/deprecated/completions/repomanage b/test/fallback/completions/repomanage similarity index 100% rename from test/deprecated/completions/repomanage rename to test/fallback/completions/repomanage diff --git a/test/deprecated/completions/reptyr b/test/fallback/completions/reptyr similarity index 100% rename from test/deprecated/completions/reptyr rename to test/fallback/completions/reptyr diff --git a/test/deprecated/completions/rfkill b/test/fallback/completions/rfkill similarity index 100% rename from test/deprecated/completions/rfkill rename to test/fallback/completions/rfkill diff --git a/test/deprecated/completions/rtcwake b/test/fallback/completions/rtcwake similarity index 100% rename from test/deprecated/completions/rtcwake rename to test/fallback/completions/rtcwake diff --git a/test/fallback/completions/ruff b/test/fallback/completions/ruff new file mode 120000 index 00000000000..2d6104b324f --- /dev/null +++ b/test/fallback/completions/ruff @@ -0,0 +1 @@ +../../../completions/_ruff \ No newline at end of file diff --git a/test/deprecated/completions/runuser b/test/fallback/completions/runuser similarity index 100% rename from test/deprecated/completions/runuser rename to test/fallback/completions/runuser diff --git a/test/fallback/completions/rustup b/test/fallback/completions/rustup new file mode 120000 index 00000000000..18b256a7dfd --- /dev/null +++ b/test/fallback/completions/rustup @@ -0,0 +1 @@ +../../../completions/_rustup \ No newline at end of file diff --git a/test/deprecated/completions/slackpkg b/test/fallback/completions/slackpkg similarity index 100% rename from test/deprecated/completions/slackpkg rename to test/fallback/completions/slackpkg diff --git a/test/deprecated/completions/su b/test/fallback/completions/su similarity index 100% rename from test/deprecated/completions/su rename to test/fallback/completions/su diff --git a/test/deprecated/completions/svn b/test/fallback/completions/svn similarity index 100% rename from test/deprecated/completions/svn rename to test/fallback/completions/svn diff --git a/test/deprecated/completions/svnadmin b/test/fallback/completions/svnadmin similarity index 100% rename from test/deprecated/completions/svnadmin rename to test/fallback/completions/svnadmin diff --git a/test/deprecated/completions/svnlook b/test/fallback/completions/svnlook similarity index 100% rename from test/deprecated/completions/svnlook rename to test/fallback/completions/svnlook diff --git a/test/deprecated/completions/udevadm b/test/fallback/completions/udevadm similarity index 100% rename from test/deprecated/completions/udevadm rename to test/fallback/completions/udevadm diff --git a/test/deprecated/completions/umount b/test/fallback/completions/umount similarity index 100% rename from test/deprecated/completions/umount rename to test/fallback/completions/umount diff --git a/test/deprecated/completions/umount.linux b/test/fallback/completions/umount.linux similarity index 100% rename from test/deprecated/completions/umount.linux rename to test/fallback/completions/umount.linux diff --git a/test/deprecated/completions/write b/test/fallback/completions/write similarity index 100% rename from test/deprecated/completions/write rename to test/fallback/completions/write diff --git a/test/deprecated/completions/xm b/test/fallback/completions/xm similarity index 100% rename from test/deprecated/completions/xm rename to test/fallback/completions/xm diff --git a/test/fallback/completions/yq b/test/fallback/completions/yq new file mode 120000 index 00000000000..9ea0a280db2 --- /dev/null +++ b/test/fallback/completions/yq @@ -0,0 +1 @@ +../../../completions/_yq \ No newline at end of file diff --git a/test/deprecated/completions/yum b/test/fallback/completions/yum similarity index 100% rename from test/deprecated/completions/yum rename to test/fallback/completions/yum diff --git a/test/deprecated/update-deprecated-links b/test/fallback/update-fallback-links similarity index 100% rename from test/deprecated/update-deprecated-links rename to test/fallback/update-fallback-links