summaryrefslogtreecommitdiffstats
path: root/completions
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:03:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:03:19 +0000
commit6c09f2a45c5541e9c207d14fc7aa21a4a0066bde (patch)
tree0221189d367bf661f6f9493c4f17a03f0dd4b7d2 /completions
parentReleasing progress-linux version 1:2.11-8~progress7.99u1. (diff)
downloadbash-completion-6c09f2a45c5541e9c207d14fc7aa21a4a0066bde.tar.xz
bash-completion-6c09f2a45c5541e9c207d14fc7aa21a4a0066bde.zip
Merging upstream version 1:2.12.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'completions')
-rw-r--r--completions/.gitignore586
-rw-r--r--completions/2to325
-rw-r--r--completions/7z80
-rw-r--r--completions/Makefile.am312
-rw-r--r--completions/_adb40
-rw-r--r--completions/_cal19
-rw-r--r--completions/_cargo9
-rw-r--r--completions/_chsh32
-rw-r--r--completions/_dmesg16
-rw-r--r--completions/_eject16
-rw-r--r--completions/_flamegraph8
-rw-r--r--completions/_gaiacli8
-rw-r--r--completions/_gh8
-rw-r--r--completions/_golangci-lint9
-rw-r--r--completions/_gsctl8
-rw-r--r--completions/_hexdump15
-rw-r--r--completions/_hwclock14
-rw-r--r--completions/_ionice18
-rw-r--r--completions/_jungle16
-rw-r--r--completions/_keyring9
-rw-r--r--completions/_kontena14
-rw-r--r--completions/_look10
-rw-r--r--completions/_mdbook8
-rw-r--r--completions/_mock32
-rw-r--r--completions/_modules39
-rw-r--r--completions/_mount37
-rw-r--r--completions/_mount.linux221
-rw-r--r--completions/_newgrp10
-rw-r--r--completions/_nmcli116
-rw-r--r--completions/_nox13
-rw-r--r--completions/_nvm8
-rw-r--r--completions/_pip9
-rw-r--r--completions/_pipenv15
-rw-r--r--completions/_renice14
-rw-r--r--completions/_repomanage14
-rw-r--r--completions/_reptyr12
-rw-r--r--completions/_rfkill19
-rw-r--r--completions/_rtcwake18
-rw-r--r--completions/_ruff8
-rw-r--r--completions/_rustup7
-rw-r--r--completions/_slackpkg111
-rw-r--r--completions/_su20
-rw-r--r--completions/_svn27
-rw-r--r--completions/_svnadmin22
-rw-r--r--completions/_svnlook18
-rw-r--r--completions/_tokio-console8
-rw-r--r--completions/_udevadm46
-rw-r--r--completions/_umount11
-rw-r--r--completions/_umount.linux74
-rw-r--r--completions/_vault8
-rw-r--r--completions/_xm131
-rw-r--r--completions/_yq8
-rw-r--r--completions/_yum102
-rw-r--r--completions/a2x28
-rw-r--r--completions/abook32
-rw-r--r--completions/aclocal20
-rw-r--r--completions/acpi20
-rw-r--r--completions/add_members23
-rw-r--r--completions/alias22
-rw-r--r--completions/ant43
-rw-r--r--completions/apache2ctl12
-rw-r--r--completions/appdata-validate19
-rw-r--r--completions/apt-build30
-rw-r--r--completions/apt-cache98
-rw-r--r--completions/apt-get99
-rw-r--r--completions/apt-mark64
-rw-r--r--completions/aptitude74
-rw-r--r--completions/arch25
-rw-r--r--completions/arp38
-rw-r--r--completions/arping16
-rw-r--r--completions/arpspoof16
-rw-r--r--completions/asciidoc48
-rw-r--r--completions/aspell57
-rw-r--r--completions/autoconf22
-rw-r--r--completions/automake20
-rw-r--r--completions/autoreconf22
-rw-r--r--completions/autorpm12
-rw-r--r--completions/autoscan24
-rw-r--r--completions/avahi-browse42
-rw-r--r--completions/avctrl18
-rw-r--r--completions/badblocks17
-rw-r--r--completions/bind20
-rw-r--r--completions/bk14
-rw-r--r--completions/brctl20
-rw-r--r--completions/btdownloadheadless.py17
-rw-r--r--completions/bts96
-rw-r--r--completions/bzip230
-rw-r--r--completions/cancel15
-rw-r--r--completions/cardctl12
-rw-r--r--completions/carton60
-rw-r--r--completions/ccache30
-rw-r--r--completions/ccze35
-rw-r--r--completions/cd59
-rw-r--r--completions/cfagent12
-rw-r--r--completions/cfrun18
-rw-r--r--completions/chage22
-rw-r--r--completions/change_pw19
-rw-r--r--completions/check_db15
-rw-r--r--completions/check_perms10
-rw-r--r--completions/checksec29
-rw-r--r--completions/chgrp22
-rw-r--r--completions/chkconfig26
-rw-r--r--completions/chmod23
-rw-r--r--completions/chown32
-rw-r--r--completions/chpasswd25
-rw-r--r--completions/chromium-browser26
-rw-r--r--completions/chronyc37
-rw-r--r--completions/chrpath20
-rw-r--r--completions/cksfv16
-rw-r--r--completions/cleanarch11
-rw-r--r--completions/clisp16
-rw-r--r--completions/clone_member19
-rw-r--r--completions/complete34
-rw-r--r--completions/config_list21
-rw-r--r--completions/configure37
-rw-r--r--completions/convert280
-rw-r--r--completions/cowsay14
-rw-r--r--completions/cpan2dist24
-rw-r--r--completions/cpio63
-rw-r--r--completions/cppcheck58
-rw-r--r--completions/crontab24
-rw-r--r--completions/cryptsetup75
-rw-r--r--completions/curl145
-rw-r--r--completions/cvs229
-rw-r--r--completions/cvsps36
-rw-r--r--completions/dd33
-rw-r--r--completions/declare41
-rw-r--r--completions/deja-dup16
-rw-r--r--completions/desktop-file-validate12
-rw-r--r--completions/dhclient18
-rw-r--r--completions/dict52
-rw-r--r--completions/dmypy25
-rw-r--r--completions/dnssec-keygen30
-rw-r--r--completions/dnsspoof14
-rw-r--r--completions/dot33
-rw-r--r--completions/dpkg188
-rw-r--r--completions/dpkg-source32
-rw-r--r--completions/dselect17
-rw-r--r--completions/dsniff15
-rw-r--r--completions/dumpdb13
-rw-r--r--completions/dumpe2fs15
-rw-r--r--completions/e2freefrag13
-rw-r--r--completions/e2label11
-rw-r--r--completions/ebtables64
-rw-r--r--completions/ecryptfs-migrate-home12
-rw-r--r--completions/eog14
-rw-r--r--completions/ether-wake15
-rw-r--r--completions/evince20
-rw-r--r--completions/export35
-rw-r--r--completions/faillog20
-rw-r--r--completions/fbgs29
-rw-r--r--completions/fbi36
-rw-r--r--completions/feh76
-rw-r--r--completions/file26
-rw-r--r--completions/file-roller34
-rw-r--r--completions/filefrag12
-rw-r--r--completions/filesnarf12
-rw-r--r--completions/find65
-rw-r--r--completions/find_member18
-rw-r--r--completions/fio115
-rw-r--r--completions/firefox33
-rw-r--r--completions/flake830
-rw-r--r--completions/freebsd-update15
-rw-r--r--completions/freeciv20
-rw-r--r--completions/freeciv-server12
-rw-r--r--completions/function36
-rw-r--r--completions/fusermount17
-rw-r--r--completions/gcc56
-rw-r--r--completions/gcl14
-rw-r--r--completions/gdb41
-rw-r--r--completions/genaliases10
-rw-r--r--completions/gendiff10
-rw-r--r--completions/genisoimage22
-rw-r--r--completions/geoiplookup16
-rw-r--r--completions/getconf25
-rw-r--r--completions/getent47
-rw-r--r--completions/gkrellm18
-rw-r--r--completions/gm22
-rw-r--r--completions/gnatmake16
-rw-r--r--completions/gnokii91
-rw-r--r--completions/gnome-mplayer20
-rw-r--r--completions/gnome-screenshot24
-rw-r--r--completions/gpasswd18
-rw-r--r--completions/gpg47
-rw-r--r--completions/gpg239
-rw-r--r--completions/gpgv27
-rw-r--r--completions/gphoto235
-rw-r--r--completions/gprof30
-rw-r--r--completions/groupadd16
-rw-r--r--completions/groupdel14
-rw-r--r--completions/groupmems16
-rw-r--r--completions/groupmod18
-rw-r--r--completions/growisofs18
-rw-r--r--completions/grpck19
-rw-r--r--completions/gssdp-discover22
-rw-r--r--completions/gzip29
-rw-r--r--completions/hash26
-rw-r--r--completions/hcitool357
-rw-r--r--completions/hddtemp32
-rw-r--r--completions/help16
-rw-r--r--completions/hid2hci11
-rw-r--r--completions/hostname18
-rw-r--r--completions/hping231
-rw-r--r--completions/htop24
-rw-r--r--completions/htpasswd15
-rw-r--r--completions/hunspell31
-rw-r--r--completions/iconv40
-rw-r--r--completions/id15
-rw-r--r--completions/idn22
-rw-r--r--completions/ifstat40
-rw-r--r--completions/iftop14
-rw-r--r--completions/ifup31
-rw-r--r--completions/influx21
-rw-r--r--completions/info62
-rw-r--r--completions/inject19
-rw-r--r--completions/inotifywait35
-rw-r--r--completions/insmod14
-rw-r--r--completions/installpkg20
-rw-r--r--completions/interdiff18
-rw-r--r--completions/invoke-rc.d26
-rw-r--r--completions/ip217
-rw-r--r--completions/ipcalc10
-rw-r--r--completions/iperf75
-rw-r--r--completions/ipmitool104
-rw-r--r--completions/ipsec71
-rw-r--r--completions/iptables56
-rw-r--r--completions/ipv6calc27
-rw-r--r--completions/iscsiadm31
-rw-r--r--completions/isort22
-rw-r--r--completions/isql14
-rw-r--r--completions/iwconfig68
-rw-r--r--completions/iwlist18
-rw-r--r--completions/iwpriv18
-rw-r--r--completions/iwspy14
-rw-r--r--completions/jar16
-rw-r--r--completions/jarsigner39
-rw-r--r--completions/java212
-rw-r--r--completions/javaws16
-rw-r--r--completions/jpegoptim30
-rw-r--r--completions/jps16
-rw-r--r--completions/jq55
-rw-r--r--completions/jshint20
-rw-r--r--completions/json_xs25
-rw-r--r--completions/jsonschema20
-rw-r--r--completions/k3b26
-rw-r--r--completions/kcov34
-rw-r--r--completions/kill21
-rw-r--r--completions/killall28
-rw-r--r--completions/kldload31
-rw-r--r--completions/kldunload12
-rw-r--r--completions/koji123
-rw-r--r--completions/ktutil49
-rw-r--r--completions/larch13
-rw-r--r--completions/lastlog20
-rw-r--r--completions/ldapsearch145
-rw-r--r--completions/ldapvi35
-rw-r--r--completions/lftp22
-rw-r--r--completions/lftpget10
-rw-r--r--completions/lilo39
-rw-r--r--completions/links48
-rw-r--r--completions/lintian119
-rw-r--r--completions/lisp15
-rw-r--r--completions/list_admins15
-rw-r--r--completions/list_lists20
-rw-r--r--completions/list_members26
-rw-r--r--completions/list_owners16
-rw-r--r--completions/locale-gen20
-rw-r--r--completions/lpq16
-rw-r--r--completions/lpr18
-rw-r--r--completions/lrzip44
-rw-r--r--completions/lsof30
-rw-r--r--completions/lspci21
-rw-r--r--completions/lsscsi20
-rw-r--r--completions/lsusb14
-rw-r--r--completions/lua12
-rw-r--r--completions/luac14
-rw-r--r--completions/luseradd30
-rw-r--r--completions/luserdel12
-rw-r--r--completions/lvm754
-rw-r--r--completions/lz425
-rw-r--r--completions/lzip40
-rw-r--r--completions/lzma19
-rw-r--r--completions/lzop28
-rw-r--r--completions/macof12
-rw-r--r--completions/mailmanctl14
-rw-r--r--completions/make214
-rw-r--r--completions/makepkg26
-rw-r--r--completions/man103
-rw-r--r--completions/mc22
-rw-r--r--completions/mcrypt44
-rw-r--r--completions/mdadm116
-rw-r--r--completions/mdtool38
-rw-r--r--completions/medusa18
-rw-r--r--completions/mii-diag18
-rw-r--r--completions/mii-tool28
-rw-r--r--completions/minicom36
-rw-r--r--completions/mkinitrd37
-rw-r--r--completions/mktemp21
-rw-r--r--completions/mmsitepass10
-rw-r--r--completions/modinfo38
-rw-r--r--completions/modprobe63
-rw-r--r--completions/monodevelop14
-rw-r--r--completions/mplayer203
-rw-r--r--completions/mr57
-rw-r--r--completions/msynctool30
-rw-r--r--completions/mtx18
-rw-r--r--completions/munin-node-configure18
-rw-r--r--completions/munin-run17
-rw-r--r--completions/munin-update16
-rw-r--r--completions/munindoc11
-rw-r--r--completions/mussh26
-rw-r--r--completions/mutt159
-rw-r--r--completions/mypy35
-rw-r--r--completions/mysql80
-rw-r--r--completions/mysqladmin44
-rw-r--r--completions/nc32
-rw-r--r--completions/ncftp14
-rw-r--r--completions/nethogs14
-rw-r--r--completions/newlist17
-rw-r--r--completions/newusers16
-rw-r--r--completions/ngrep20
-rw-r--r--completions/nmap25
-rw-r--r--completions/nproc12
-rw-r--r--completions/nslookup77
-rw-r--r--completions/nsupdate20
-rw-r--r--completions/ntpdate18
-rw-r--r--completions/oggdec30
-rw-r--r--completions/op59
-rw-r--r--completions/openssl85
-rw-r--r--completions/opera23
-rw-r--r--completions/optipng27
-rw-r--r--completions/p421
-rw-r--r--completions/pack20050
-rw-r--r--completions/passwd18
-rw-r--r--completions/patch53
-rw-r--r--completions/pdftoppm35
-rw-r--r--completions/pdftotext25
-rw-r--r--completions/perl83
-rw-r--r--completions/perlcritic27
-rw-r--r--completions/perltidy46
-rw-r--r--completions/pgrep56
-rw-r--r--completions/pidof20
-rw-r--r--completions/pine22
-rw-r--r--completions/ping28
-rw-r--r--completions/pkg-config24
-rw-r--r--completions/pkg-get44
-rw-r--r--completions/pkg_delete13
-rw-r--r--completions/pkgadd41
-rw-r--r--completions/pkgrm18
-rw-r--r--completions/pkgtool19
-rw-r--r--completions/pkgutil72
-rw-r--r--completions/plague-client12
-rw-r--r--completions/pm-hibernate11
-rw-r--r--completions/pm-is-supported11
-rw-r--r--completions/pm-powersave10
-rw-r--r--completions/pngfix21
-rw-r--r--completions/portinstall29
-rw-r--r--completions/portsnap14
-rw-r--r--completions/portupgrade14
-rw-r--r--completions/postcat29
-rw-r--r--completions/postconf14
-rw-r--r--completions/postfix22
-rw-r--r--completions/postmap16
-rw-r--r--completions/postsuper44
-rw-r--r--completions/povray47
-rw-r--r--completions/prelink22
-rw-r--r--completions/printenv12
-rw-r--r--completions/protoc37
-rw-r--r--completions/ps70
-rw-r--r--completions/psql150
-rw-r--r--completions/puppet173
-rw-r--r--completions/pv27
-rw-r--r--completions/pwck13
-rw-r--r--completions/pwd12
-rw-r--r--completions/pwdx15
-rw-r--r--completions/pwgen20
-rw-r--r--completions/pycodestyle18
-rw-r--r--completions/pydoc33
-rw-r--r--completions/pydocstyle22
-rw-r--r--completions/pyflakes12
-rw-r--r--completions/pylint116
-rw-r--r--completions/pytest102
-rw-r--r--completions/python112
-rw-r--r--completions/pyvenv14
-rw-r--r--completions/qdbus14
-rw-r--r--completions/qemu76
-rw-r--r--completions/qrunner13
-rw-r--r--completions/querybts31
-rw-r--r--completions/quota116
-rw-r--r--completions/radvdump12
-rw-r--r--completions/rcs14
-rw-r--r--completions/rdesktop35
-rw-r--r--completions/remove_members21
-rw-r--r--completions/removepkg19
-rw-r--r--completions/reportbug94
-rw-r--r--completions/resolvconf12
-rw-r--r--completions/ri101
-rw-r--r--completions/rmlist15
-rw-r--r--completions/rmmod12
-rw-r--r--completions/route21
-rw-r--r--completions/rpcdebug27
-rw-r--r--completions/rpm232
-rw-r--r--completions/rpm2tgz12
-rw-r--r--completions/rpmcheck16
-rw-r--r--completions/rrdtool14
-rw-r--r--completions/rsync96
-rw-r--r--completions/sbcl16
-rw-r--r--completions/sbopkg45
-rw-r--r--completions/screen53
-rw-r--r--completions/scrub30
-rw-r--r--completions/secret-tool30
-rw-r--r--completions/sh25
-rw-r--r--completions/sha256sum38
-rw-r--r--completions/shellcheck50
-rw-r--r--completions/sitecopy30
-rw-r--r--completions/slackpkg112
-rw-r--r--completions/slapt-get40
-rw-r--r--completions/slapt-src36
-rw-r--r--completions/smartctl151
-rw-r--r--completions/smbclient264
-rw-r--r--completions/snownews10
-rw-r--r--completions/sqlite321
-rw-r--r--completions/ss40
-rw-r--r--completions/ssh514
-rw-r--r--completions/ssh-add18
-rw-r--r--completions/ssh-copy-id22
-rw-r--r--completions/ssh-keygen80
-rw-r--r--completions/ssh-keyscan39
-rw-r--r--completions/sshfs16
-rw-r--r--completions/sshmitm12
-rw-r--r--completions/sshow14
-rw-r--r--completions/strace46
-rw-r--r--completions/strings41
-rw-r--r--completions/sudo38
-rw-r--r--completions/svcadm81
-rw-r--r--completions/svk42
-rw-r--r--completions/sync_members23
-rw-r--r--completions/synclient14
-rw-r--r--completions/sysbench77
-rw-r--r--completions/sysctl24
-rw-r--r--completions/tar388
-rw-r--r--completions/tcpdump56
-rw-r--r--completions/tcpkill12
-rw-r--r--completions/tcpnice12
-rw-r--r--completions/timeout35
-rw-r--r--completions/tipc108
-rw-r--r--completions/tox29
-rw-r--r--completions/tracepath13
-rw-r--r--completions/tree46
-rw-r--r--completions/truncate32
-rw-r--r--completions/tshark77
-rw-r--r--completions/tsig-keygen16
-rw-r--r--completions/tune2fs31
-rw-r--r--completions/ulimit21
-rw-r--r--completions/unace14
-rw-r--r--completions/unpack20042
-rw-r--r--completions/unrar18
-rw-r--r--completions/unshunt12
-rw-r--r--completions/update-alternatives36
-rw-r--r--completions/update-rc.d32
-rw-r--r--completions/upgradepkg22
-rw-r--r--completions/urlsnarf14
-rw-r--r--completions/uscan23
-rw-r--r--completions/useradd53
-rw-r--r--completions/userdel20
-rw-r--r--completions/usermod55
-rw-r--r--completions/valgrind69
-rw-r--r--completions/vipw18
-rw-r--r--completions/vmstat20
-rw-r--r--completions/vncviewer74
-rw-r--r--completions/vpnc60
-rw-r--r--completions/watch29
-rw-r--r--completions/webmitm12
-rw-r--r--completions/wget118
-rw-r--r--completions/wine20
-rw-r--r--completions/withlist16
-rw-r--r--completions/wodim47
-rw-r--r--completions/wol37
-rw-r--r--completions/wsimport26
-rw-r--r--completions/wtf29
-rw-r--r--completions/wvdial20
-rw-r--r--completions/xdg-mime75
-rw-r--r--completions/xdg-settings24
-rw-r--r--completions/xev31
-rw-r--r--completions/xfreerdp63
-rw-r--r--completions/xgamma21
-rw-r--r--completions/xhost14
-rw-r--r--completions/xmllint26
-rw-r--r--completions/xmlwf19
-rw-r--r--completions/xmms22
-rw-r--r--completions/xmodmap12
-rw-r--r--completions/xrandr183
-rw-r--r--completions/xrdb14
-rw-r--r--completions/xsltproc24
-rw-r--r--completions/xvfb-run29
-rw-r--r--completions/xxd15
-rw-r--r--completions/xz43
-rw-r--r--completions/xzdec20
-rw-r--r--completions/ypmatch15
-rw-r--r--completions/yum-arch12
-rw-r--r--completions/zopfli19
-rw-r--r--completions/zopflipng25
502 files changed, 11593 insertions, 9589 deletions
diff --git a/completions/.gitignore b/completions/.gitignore
index 5edc172..0837060 100644
--- a/completions/.gitignore
+++ b/completions/.gitignore
@@ -1,235 +1,351 @@
-7za
-aclocal-1.1[0123456]
-alpine
-alternatives
-animate
-apropos
-aptitude-curses
-arm-koji
-asciidoc.py
-autoheader
-automake-1.1[0123456]
-autossh
-autoupdate
-bmake
-bsdtar
-btdownloadcurses.py
-btdownloadgui.py
-c++
-cc
-cdrecord
-chrome
-chromium
-ci
-ciptool
-civclient
-civserver
-clzip
-co
-colormake
-compare
-compgen
-composite
-conjure
-cowthink
-createdb
-createuser
-dcop
-declare
-dfutool
-display
-dpkg-deb
-dpkg-query
-dpkg-reconfigure
-dropdb
-dropuser
-edquota
-etherwake
-f77
-f95
-filebucket
-freeciv-gtk2
-freeciv-gtk3
-freeciv-sdl
-freeciv-xaw
-g++
-g++-[5678]
-g4
-g77
-g95
-gcc-[5678]
-gccgo
-gccgo-[5678]
-gcj
-geoiplookup6
-gfortran
-gfortran-[5678]
-gkrellm2
-gmake
-gmplayer
-gnumake
-google-chrome
-google-chrome-stable
-gpc
-gpgv2
-gtar
-hciattach
-hciconfig
-hd
-host
-hping
-hping3
-iceweasel
-identify
-ifdown
-ifquery
-ifstatus
-import
-inotifywatch
-insmod.static
-iperf3
-javac
-javadoc
-kplayer
-l2ping
-lbzip2
-ldapadd
-ldapcompare
-ldapdelete
-ldapmodify
-ldapmodrdn
-ldappasswd
-ldapwhoami
-links2
-lintian-info
-lusermod
-lvchange
-lvcreate
-lvdisplay
-lvextend
-lvmdiskscan
-lvreduce
-lvremove
-lvrename
-lvresize
-lvs
-lvscan
-lz4c
-mailsnarf
-mdecrypt
-mencoder
-micropython
-mkisofs
-mogrify
-montage
-mozilla-firefox
-mplayer2
-msgsnarf
-muttng
-ncal
-pbzip2
-pccardctl
-pdlzip
-perldoc
-phing
-pigz
-pinfo
-ping6
-pkg_deinstall
-pkg_info
-pkill
-plzip
-pm-suspend
-pm-suspend-hybrid
-pmake
-postalias
-ppc-koji
-puppetca
-puppetd
-puppetdoc
-puppetmasterd
-puppetqd
-puppetrun
-pvchange
-pvcreate
-pvdisplay
-pvmove
-pvremove
-pvs
-pvscan
-pxz
-py.test
-py.test-[23]
-pydoc3
-pylint-[23]
-pytest-[23]
-python2
-python2.7
-python3
-python3.[345678]
-pypy
-pypy3
-pyvenv-3.[45678]
-qemu-kvm
-qemu-system-i386
-qemu-system-x86_64
-quotacheck
-quotaoff
-quotaon
-ralsh
-rcsdiff
-rdict
-repquota
-rfcomm
-rlog
-rpm2targz
-rpm2txz
-rpmbuild
-rpmbuild-md5
-s390-koji
-sbcl-mt
-scp
-sdptool
-setquota
-sftp
-sidedoor
-slogin
-smbcacls
-smbcquotas
-smbget
-smbpasswd
-smbtar
-smbtree
-sparc-koji
-spovray
-star
-stream
-sudoedit
-tightvncviewer
-tracepath6
-typeset
-vgcfgbackup
-vgcfgrestore
-vgchange
-vgck
-vgconvert
-vgcreate
-vgdisplay
-vgexport
-vgextend
-vgimport
-vgmerge
-vgmknodes
-vgreduce
-vgremove
-vgrename
-vgs
-vgscan
-vgsplit
-vigr
-whatis
-wine-development
-wine-stable
-xpovray
-xvnc4viewer
-ypcat
+/7za
+/7zr
+/7zz
+/7zzs
+/aclocal-1.1[0123456]
+/_airflow
+/_allero
+/alpine
+/alternatives
+/animate
+/_ansible
+/_ansible-config
+/_ansible-console
+/_ansible-doc
+/_ansible-galaxy
+/_ansible-inventory
+/_ansible-playbook
+/_ansible-pull
+/_ansible-vault
+/apropos
+/aptitude-curses
+/_arduino-cli
+/arm-koji
+/asciidoc.py
+/autoheader
+/automake-1.1[0123456]
+/autossh
+/autoupdate
+/avahi-browse-domains
+/b2sum
+/_black
+/_blackd
+/bmake
+/bsdtar
+/btdownloadcurses.py
+/btdownloadgui.py
+/_buf
+/c++
+/cc
+/cdrecord
+/_chezmoi
+/chrome
+/chromium
+/ci
+/_cilium
+/ciptool
+/civclient
+/civserver
+/_cloudquery
+/clzip
+/co
+/colormake
+/compare
+/compgen
+/composite
+/_conda
+/conjure
+/_constellation
+/_consul
+/cowthink
+/_crc
+/createdb
+/createuser
+/_cz
+/_datree
+/dcop
+/_deno
+/dfutool
+/_diesel
+/display
+/_docker
+/dpkg-deb
+/dpkg-query
+/dpkg-reconfigure
+/_dprint
+/dropdb
+/dropuser
+/edquota
+/etherwake
+/f77
+/f95
+/filebucket
+/firefox-esr
+/_flask
+/freeciv-gtk2
+/freeciv-gtk3
+/freeciv-sdl
+/freeciv-xaw
+/g++
+/g++-[5678]
+/g4
+/g77
+/g95
+/_gaiad
+/_gardenctl
+/gcc-[5678]
+/gccgo
+/gccgo-[5678]
+/gcj
+/geoiplookup6
+/gfortran
+/gfortran-[5678]
+/_gh-label
+/_git-bump
+/gkrellm2
+/gmake
+/gmplayer
+/gnumake
+/_go-licenses
+/google-chrome
+/google-chrome-stable
+/_gopherjs
+/_goreleaser
+/gpc
+/gpgv2
+/gssdp-device-sniffer
+/gtar
+/hciattach
+/hciconfig
+/hd
+/_helm
+/host
+/hping
+/hping3
+/_httpx
+/_hugo
+/iceweasel
+/identify
+/ifdown
+/ifquery
+/ifstatus
+/_ignite
+/import
+/_infracost
+/inotifywatch
+/insmod.static
+/iperf3
+/_istioctl
+/javac
+/javadoc
+/_k3s
+/_kn
+/_kool
+/kplayer
+/_kratos
+/_kubeadm
+/_kubectl
+/_kubescape
+/l2ping
+/lbzip2
+/ldapadd
+/ldapcompare
+/ldapdelete
+/ldapmodify
+/ldapmodrdn
+/ldappasswd
+/ldapwhoami
+/_lefthook
+/_linkerd
+/links2
+/lintian-info
+/lua5[0-4]
+/lua5.[0-4]
+/luac5[0-4]
+/luac5.[0-4]
+/lusermod
+/lvchange
+/lvcreate
+/lvdisplay
+/lvextend
+/lvmdiskscan
+/lvreduce
+/lvremove
+/lvrename
+/lvresize
+/lvs
+/lvscan
+/lz4c
+/mailsnarf
+/_mattermost
+/md5sum
+/mdecrypt
+/mencoder
+/_metalctl
+/micropython
+/_minikube
+/_mise
+/mkisofs
+/_mmctl
+/mogrify
+/_moldy
+/montage
+/mozilla-firefox
+/mplayer2
+/msgsnarf
+/_multi-gitter
+/muttng
+/ncal
+/neomutt
+/_nfpm
+/_nomad
+/_npm
+/_oc
+/_okteto
+/_op
+/_ory
+/_packer
+/pbzip2
+/pccardctl
+/pdlzip
+/perldoc
+/phing
+/pigz
+/pinfo
+/ping4
+/ping6
+/_pip3
+/pkg_deinstall
+/pkg_info
+/pkgconf
+/pkill
+/plzip
+/pm-suspend
+/pm-suspend-hybrid
+/pmake
+/_polygon-edge
+/postalias
+/ppc-koji
+/_pulumi
+/puppetca
+/puppetd
+/puppetdoc
+/puppetmasterd
+/puppetqd
+/puppetrun
+/pushd
+/pvchange
+/pvcreate
+/pvdisplay
+/pvmove
+/pvremove
+/pvs
+/pvscan
+/_px
+/pxz
+/py.test
+/py.test-[23]
+/pydoc3
+/pylint-[23]
+/pytest-[23]
+/python2
+/python2.7
+/python3
+/python3.[3456789]
+/python3.1[012]
+/pypy
+/pypy3
+/pyston
+/pyston3
+/pyvenv-3.[456789]
+/pyvenv-3.1[012]
+/qemu-kvm
+/qemu-system-i386
+/qemu-system-x86_64
+/_qrpc
+/quotacheck
+/quotaoff
+/quotaon
+/ralsh
+/_random
+/_rclone
+/rcsdiff
+/rdict
+/repquota
+/rfcomm
+/rlog
+/rpm2targz
+/rpm2txz
+/rpmbuild
+/rpmbuild-md5
+/s390-koji
+/sbcl-mt
+/scp
+/sdptool
+/setquota
+/sftp
+/shasum
+/sha1sum
+/sha224sum
+/sha384sum
+/sha512sum
+/sidedoor
+/_skaffold
+/slogin
+/smbcacls
+/smbcquotas
+/smbget
+/smbpasswd
+/smbtar
+/smbtree
+/sparc-koji
+/spovray
+/_sshi
+/_ssh-inscribe
+/star
+/_starship
+/stream
+/sudoedit
+/_tanzu
+/_tanzu-core
+/_tendermint
+/_terraform
+/_tkn
+/_tkn-pac
+/tightvncviewer
+/tracepath6
+/_trivy
+/typeset
+/_upctl
+/_vacuum
+/vgcfgbackup
+/vgcfgrestore
+/vgchange
+/vgck
+/vgconvert
+/vgcreate
+/vgdisplay
+/vgexport
+/vgextend
+/vgimport
+/vgmerge
+/vgmknodes
+/vgreduce
+/vgremove
+/vgrename
+/vgs
+/vgscan
+/vgsplit
+/vigr
+/_virtctl
+/_watchexec
+/whatis
+/wine-development
+/wine-stable
+/wine64
+/wine64-development
+/wine64-stable
+/xpovray
+/xvnc4viewer
+/ypcat
+/_zitadel
diff --git a/completions/2to3 b/completions/2to3
index 7c5b330..0a60e1f 100644
--- a/completions/2to3
+++ b/completions/2to3
@@ -1,39 +1,42 @@
# bash completion for 2to3 -*- shell-script -*-
-_2to3()
+_comp_cmd_2to3()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-h | --help | --add-suffix)
return
;;
-f | --fix | -x | --nofix)
- COMPREPLY=($(compgen -W \
- "$($1 --list-fixes 2>/dev/null | command sed -e 1d)" -- "$cur"))
+ _comp_compgen_split -- "$(
+ "$1" --list-fixes 2>/dev/null | command sed -e 1d
+ )"
return
;;
-j | --processes)
- COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur"))
+ local REPLY
+ _comp_get_ncpus
+ _comp_compgen -- -W "{1..$REPLY}"
return
;;
-o | --output-dir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir py
+ _comp_compgen_filedir py
} &&
- complete -F _2to3 2to3
+ complete -F _comp_cmd_2to3 2to3
# ex: filetype=sh
diff --git a/completions/7z b/completions/7z
index a8acbc5..027f84b 100644
--- a/completions/7z
+++ b/completions/7z
@@ -1,21 +1,21 @@
# 7z(1) completion -*- shell-script -*-
-_7z()
+_comp_cmd_7z()
{
- local cur prev words cword
- _init_completion -n = || return
+ local cur prev words cword comp_args
+ _comp_initialize -n = -- "$@" || return
if ((cword == 1)); then
- COMPREPLY=($(compgen -W 'a b d e l t u x' -- "$cur"))
+ _comp_compgen -- -W 'a b d e h i l rn t u x'
return
fi
local mode
- [[ ${words[1]} == [adu] ]] && mode=w || mode=r
+ [[ ${words[1]} == @(a|d|rn|u) ]] && mode=w || mode=r
case $cur in
-ao*)
- COMPREPLY=($(compgen -P${cur:0:3} -W 'a s t u' -- "${cur:3}"))
+ _comp_compgen -c "${cur:3}" -- -P"${cur:0:3}" -W 'a s t u'
return
;;
-?(a)[ix]*)
@@ -26,59 +26,48 @@ _7z()
opt=${cur:0:2} cur=${cur:2}
fi
if [[ $cur != *[@\!]* ]]; then
- COMPREPLY=($(compgen -P$opt -W '@ ! r@ r-@ r0@ r! r-! r0!' \
- -- "$cur"))
+ _comp_compgen -- -P"$opt" -W '@ ! r@ r-@ r0@ r! r-! r0!'
elif [[ $cur == ?(r@(-|0|))@* ]]; then
- local IFS=$' \t\n' reset=$(shopt -po noglob)
- set -o noglob
- COMPREPLY=($(compgen -P"${opt}${cur%%@*}@" -f -- "${cur#*@}"))
- $reset
+ _comp_compgen -c "${cur#*@}" -- -P"${opt}${cur%%@*}@" -f
compopt -o filenames
fi
return
;;
-mhe=* | -mhc=* | -ms=* | -mt=*)
- COMPREPLY=($(compgen -W 'on off' -- "${cur#*=}"))
+ _comp_compgen -c "${cur#*=}" -- -W 'on off'
return
;;
-mx=*)
- COMPREPLY=($(compgen -W '0 1 3 5 7 9' -- "${cur#*=}"))
+ _comp_compgen -c "${cur#*=}" -- -W '0 1 3 5 7 9'
return
;;
-o* | -w?*)
- local reset=$(shopt -po noglob)
- set -o noglob
compopt -o filenames
- local ifs=$IFS IFS=$'\n'
- COMPREPLY=($(compgen -d -P${cur:0:2} -S/ -- "${cur:2}"))
- IFS=$ifs
- $reset
+ _comp_compgen -c "${cur:2}" -- -d -P"${cur:0:2}" -S/
compopt -o nospace
return
;;
-r?*)
- COMPREPLY=($(compgen -P${cur:0:2} -W '- 0' -- "${cur:2}"))
+ _comp_compgen -c "${cur:2}" -- -P"${cur:0:2}" -W '- 0'
return
;;
-scs*)
- COMPREPLY=($(compgen -P${cur:0:4} -W 'UTF-8 WIN DOS' \
- -- "${cur:4}"))
+ _comp_compgen -c "${cur:4}" -- -P"${cur:0:4}" -W 'UTF-8 WIN DOS'
return
;;
-ssc?*)
- COMPREPLY=($(compgen -P${cur:0:4} -W '-' -- "${cur:4}"))
+ _comp_compgen -c "${cur:4}" -- -P"${cur:0:4}" -W '-'
return
;;
-t*)
if [[ $mode == w ]]; then
- COMPREPLY=($(compgen -P${cur:0:2} -W '7z bzip2 gzip swfc
- tar wim xz zip' -- "${cur:2}"))
+ _comp_compgen -c "${cur:2}" -- -P"${cur:0:2}" -W '7z bzip2 gzip
+ swfc tar wim xz zip'
else
- COMPREPLY=($(compgen -P${cur:0:2} -W '7z apm arj bzip2 cab
- chm cpio cramfs deb dmg elf fat flv gzip hfs iso lzh lzma
- lzma86 macho mbr mslz mub nsis ntfs pe ppmd rar rpm
- squashfs swf swfc tar udf vhd wim xar xz z zip' \
- -- "${cur:2}"))
+ _comp_compgen -c "${cur:2}" -- -P"${cur:0:2}" -W '7z apm arj
+ bzip2 cab chm cpio cramfs deb dmg elf fat flv gzip hfs iso
+ lzh lzma lzma86 macho mbr mslz mub nsis ntfs pe ppmd rar
+ rpm squashfs swf swfc tar udf vhd wim xar xz z zip'
fi
return
;;
@@ -88,18 +77,17 @@ _7z()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-ai -an -ao -ax -bd -i -m{x,s,f,he,hc,mt}=
- -o -p -r -scs -sfx -si -slp -slt -so -ssc -t -u -v -w -x -y' \
- -- "$cur"))
+ _comp_compgen -- -W '-ai -an -ao -ax -bd -i -m{x,s,f,he,hc,mt}=
+ -o -p -r -scs -sfx -si -slp -slt -so -ssc -t -u -v -w -x -y'
[[ ${COMPREPLY-} == -@(an|bd|sfx|si|slt|so|ssc|[rwy]) ]] ||
compopt -o nospace
return
fi
- local args
- _count_args =
- if ((args == 2)); then
- _filedir_xspec unzip
+ local REPLY
+ _comp_count_args
+ if ((REPLY == 2)); then
+ _comp_compgen_filedir_xspec unzip
# TODO: parsing 7z i output?
# - how to figure out if the format is input or output?
# - find string Formats:, read until next empty line
@@ -109,20 +97,20 @@ _7z()
# - terminate on token containing anything [^a-z0-9]
# (assumption: extensions are all lowercase)
[[ $mode == w ]] &&
- _filedir '@(7z|bz2|swf|?(g)tar|?(t)[bglx]z|tb?(z)2|wim)' ||
- _filedir '@(7z|arj|bz2|cab|chm|cpio|deb|dmg|flv|gem|img|iso|lz[ah]|lzma?(86)|msi|pmd|[rx]ar|rpm|sw[fm]|?(g)tar|taz|?(t)[bglx]z|tb?(z)2|vhd|wim|Z)'
+ _comp_compgen -a filedir '@(7z|bz2|swf|?(g)tar|?(t)[bglx]z|tb?(z)2|wim)' ||
+ _comp_compgen -a filedir '@(7z?(.001)|arj|bz2|cab|cb7|chm|cpio|deb|dmg|flv|gem|img|iso|lz[ah]|lzma?(86)|msi|pmd|[rx]ar|rpm|sw[fm]|?(g)tar|taz|?(t)[bglx]z|tb?(z)2|vhd|wim|Z)'
else
if [[ ${words[1]} == d ]]; then
- local IFS=$'\n'
- COMPREPLY=($(compgen -W "$(printf '%s\n' "$($1 l ${words[2]} \
- -slt 2>/dev/null | command sed -n '/^Path =/s/^Path = \(.*\)$/\1/p' \
- 2>/dev/null | tail -n+2)")" -- "$cur"))
+ _comp_compgen_split -l -- "$(
+ "$1" l "${words[2]}" -slt 2>/dev/null | command sed -n \
+ '/^Path =/s/^Path = \(.*\)$/\1/p' 2>/dev/null | tail -n+2
+ )"
compopt -o filenames
else
- _filedir
+ _comp_compgen_filedir
fi
fi
} &&
- complete -F _7z 7z 7za
+ complete -F _comp_cmd_7z 7z 7za 7zr 7zz 7zzs
# ex: filetype=sh
diff --git a/completions/Makefile.am b/completions/Makefile.am
index 723b42f..8f11291 100644
--- a/completions/Makefile.am
+++ b/completions/Makefile.am
@@ -14,6 +14,7 @@ bashcomp_DATA = 2to3 \
apt-build \
apt-cache \
apt-get \
+ apt-mark \
aptitude \
arch \
arp \
@@ -26,6 +27,7 @@ bashcomp_DATA = 2to3 \
autoreconf \
autorpm \
autoscan \
+ avahi-browse \
avctrl \
badblocks \
bind \
@@ -36,10 +38,12 @@ bashcomp_DATA = 2to3 \
bzip2 \
_cal \
cancel \
+ _cargo \
cardctl \
carton \
ccache \
ccze \
+ cd \
cfagent \
cfrun \
chage \
@@ -75,6 +79,7 @@ bashcomp_DATA = 2to3 \
cvs \
cvsps \
dd \
+ declare \
deja-dup \
desktop-file-validate \
dhclient \
@@ -113,11 +118,13 @@ bashcomp_DATA = 2to3 \
fio \
firefox \
flake8 \
+ _flamegraph \
freebsd-update \
freeciv \
freeciv-server \
function \
fusermount \
+ _gaiacli \
gcc \
gcl \
gdb \
@@ -127,12 +134,14 @@ bashcomp_DATA = 2to3 \
geoiplookup \
getconf \
getent \
+ _gh \
gkrellm \
gm \
gnatmake \
gnokii \
gnome-mplayer \
gnome-screenshot \
+ _golangci-lint \
gpasswd \
gpg \
gpg2 \
@@ -145,10 +154,13 @@ bashcomp_DATA = 2to3 \
groupmod \
growisofs \
grpck \
+ _gsctl \
gssdp-discover \
gzip \
+ hash \
hcitool \
hddtemp \
+ help \
_hexdump \
hid2hci \
hostname \
@@ -196,13 +208,16 @@ bashcomp_DATA = 2to3 \
jshint \
json_xs \
jsonschema \
+ _jungle \
k3b \
kcov \
+ _keyring \
kill \
killall \
kldload \
kldunload \
koji \
+ _kontena \
ktutil \
larch \
lastlog \
@@ -243,6 +258,7 @@ bashcomp_DATA = 2to3 \
mc \
mcrypt \
mdadm \
+ _mdbook \
mdtool \
medusa \
mii-diag \
@@ -280,12 +296,13 @@ bashcomp_DATA = 2to3 \
ngrep \
nmap \
_nmcli \
+ _nox \
nproc \
nslookup \
nsupdate \
ntpdate \
+ _nvm \
oggdec \
- op \
openssl \
opera \
optipng \
@@ -293,6 +310,7 @@ bashcomp_DATA = 2to3 \
pack200 \
passwd \
patch \
+ pdftoppm \
pdftotext \
perl \
perlcritic \
@@ -301,6 +319,8 @@ bashcomp_DATA = 2to3 \
pidof \
pine \
ping \
+ _pip \
+ _pipenv \
pkg-config \
pkg-get \
pkg_delete \
@@ -325,6 +345,7 @@ bashcomp_DATA = 2to3 \
prelink \
printenv \
protoc \
+ ps \
psql \
puppet \
pv \
@@ -367,16 +388,19 @@ bashcomp_DATA = 2to3 \
rrdtool \
rsync \
_rtcwake \
+ _ruff \
_runuser \
+ _rustup \
sbcl \
sbopkg \
screen \
scrub \
secret-tool \
sh \
+ sha256sum \
shellcheck \
sitecopy \
- slackpkg \
+ _slackpkg \
slapt-get \
slapt-src \
smartctl \
@@ -388,6 +412,7 @@ bashcomp_DATA = 2to3 \
ssh-add \
ssh-copy-id \
ssh-keygen \
+ ssh-keyscan \
sshfs \
sshmitm \
sshow \
@@ -410,8 +435,11 @@ bashcomp_DATA = 2to3 \
tcpnice \
timeout \
tipc \
+ _tokio-console \
tox \
tracepath \
+ tree \
+ truncate \
tshark \
tsig-keygen \
tune2fs \
@@ -431,6 +459,7 @@ bashcomp_DATA = 2to3 \
userdel \
usermod \
valgrind \
+ _vault \
vipw \
vmstat \
vncviewer \
@@ -448,6 +477,7 @@ bashcomp_DATA = 2to3 \
wvdial \
xdg-mime \
xdg-settings \
+ xev \
xfreerdp \
xgamma \
xhost \
@@ -464,6 +494,7 @@ bashcomp_DATA = 2to3 \
xz \
xzdec \
ypmatch \
+ _yq \
_yum \
yum-arch \
zopfli \
@@ -473,6 +504,9 @@ EXTRA_DIST = $(bashcomp_DATA)
CLEANFILES = \
7za \
+ 7zr \
+ 7zz \
+ 7zzs \
aclocal-1.10 \
aclocal-1.11 \
aclocal-1.12 \
@@ -480,11 +514,23 @@ CLEANFILES = \
aclocal-1.14 \
aclocal-1.15 \
aclocal-1.16 \
+ _airflow \
+ _allero \
alpine \
alternatives \
animate \
+ _ansible \
+ _ansible-config \
+ _ansible-console \
+ _ansible-doc \
+ _ansible-galaxy \
+ _ansible-inventory \
+ _ansible-playbook \
+ _ansible-pull \
+ _ansible-vault \
apropos \
aptitude-curses \
+ _arduino-cli \
arm-koji \
asciidoc.py \
autoheader \
@@ -497,36 +543,52 @@ CLEANFILES = \
automake-1.16 \
autossh \
autoupdate \
+ avahi-browse-domains \
+ _black \
+ _blackd \
bmake \
bsdtar \
btdownloadcurses.py \
btdownloadgui.py \
+ _buf \
c++ \
cc \
cdrecord \
+ _chezmoi \
chrome \
chromium \
ci \
+ _cilium \
ciptool \
civclient \
civserver \
+ _cloudquery \
clzip \
co \
colormake \
compare \
compgen \
composite \
+ _conda \
conjure \
+ _constellation \
+ _consul \
cowthink \
+ _crc \
createdb \
createuser \
+ _cz \
+ _datree \
dcop \
- declare \
+ _deno \
dfutool \
+ _diesel \
display \
+ _docker \
dpkg-deb \
dpkg-query \
dpkg-reconfigure \
+ _dprint \
dropdb \
dropuser \
edquota \
@@ -534,6 +596,8 @@ CLEANFILES = \
f77 \
f95 \
filebucket \
+ firefox-esr \
+ _flask \
freeciv-gtk2 \
freeciv-gtk3 \
freeciv-sdl \
@@ -546,6 +610,8 @@ CLEANFILES = \
g4 \
g77 \
g95 \
+ _gaiad \
+ _gardenctl \
gcc-5 \
gcc-6 \
gcc-7 \
@@ -562,33 +628,52 @@ CLEANFILES = \
gfortran-6 \
gfortran-7 \
gfortran-8 \
+ _gh-label \
+ _git-bump \
gkrellm2 \
gmake \
gmplayer \
gnumake \
+ _go-licenses \
google-chrome \
google-chrome-stable \
+ _gopherjs \
+ _goreleaser \
gpc \
gpgv2 \
+ gssdp-device-sniffer \
gtar \
hciattach \
hciconfig \
hd \
+ _helm \
host \
hping \
hping3 \
+ _httpx \
+ _hugo \
iceweasel \
identify \
ifdown \
ifquery \
ifstatus \
+ _ignite \
import \
+ _infracost \
inotifywatch \
insmod.static \
iperf3 \
+ _istioctl \
javac \
javadoc \
+ _k3s \
+ _kn \
+ _kool \
kplayer \
+ _kratos \
+ _kubeadm \
+ _kubectl \
+ _kubescape \
l2ping \
lbzip2 \
ldapadd \
@@ -598,8 +683,30 @@ CLEANFILES = \
ldapmodrdn \
ldappasswd \
ldapwhoami \
+ _lefthook \
+ _linkerd \
links2 \
lintian-info \
+ lua50 \
+ lua5.0 \
+ lua51 \
+ lua5.1 \
+ lua52 \
+ lua5.2 \
+ lua53 \
+ lua5.3 \
+ lua54 \
+ lua5.4 \
+ luac50 \
+ luac5.0 \
+ luac51 \
+ luac5.1 \
+ luac52 \
+ luac5.2 \
+ luac53 \
+ luac5.3 \
+ luac54 \
+ luac5.4 \
lusermod \
lvchange \
lvcreate \
@@ -614,17 +721,34 @@ CLEANFILES = \
lvscan \
lz4c \
mailsnarf \
+ _mattermost \
+ md5sum \
mdecrypt \
mencoder \
+ _metalctl \
micropython \
+ _minikube \
+ _mise \
mkisofs \
+ _mmctl \
mogrify \
+ _moldy \
montage \
mozilla-firefox \
mplayer2 \
msgsnarf \
+ _multi-gitter \
muttng \
ncal \
+ neomutt \
+ _nfpm \
+ _nomad \
+ _npm \
+ _oc \
+ _okteto \
+ _op \
+ _ory \
+ _packer \
pbzip2 \
pccardctl \
pdlzip \
@@ -632,22 +756,28 @@ CLEANFILES = \
phing \
pigz \
pinfo \
+ ping4 \
ping6 \
+ _pip3 \
pkg_deinstall \
pkg_info \
+ pkgconf \
pkill \
plzip \
pm-suspend \
pm-suspend-hybrid \
pmake \
+ _polygon-edge \
postalias \
ppc-koji \
+ _pulumi \
puppetca \
puppetd \
puppetdoc \
puppetmasterd \
puppetqd \
puppetrun \
+ pushd \
pvchange \
pvcreate \
pvdisplay \
@@ -655,6 +785,7 @@ CLEANFILES = \
pvremove \
pvs \
pvscan \
+ _px \
pxz \
py.test \
py.test-2 \
@@ -664,6 +795,8 @@ CLEANFILES = \
pylint-3 \
pypy \
pypy3 \
+ pyston \
+ pyston3 \
pytest-2 \
pytest-3 \
python2 \
@@ -675,18 +808,29 @@ CLEANFILES = \
python3.6 \
python3.7 \
python3.8 \
+ python3.9 \
+ python3.10 \
+ python3.11 \
+ python3.12 \
pyvenv-3.4 \
pyvenv-3.5 \
pyvenv-3.6 \
pyvenv-3.7 \
pyvenv-3.8 \
+ pyvenv-3.9 \
+ pyvenv-3.10 \
+ pyvenv-3.11 \
+ pyvenv-3.12 \
qemu-kvm \
qemu-system-i386 \
qemu-system-x86_64 \
+ _qrpc \
quotacheck \
quotaoff \
quotaon \
ralsh \
+ _random \
+ _rclone \
rcsdiff \
rdict \
repquota \
@@ -702,7 +846,13 @@ CLEANFILES = \
sdptool \
setquota \
sftp \
+ shasum \
+ sha1sum \
+ sha224sum \
+ sha384sum \
+ sha512sum \
sidedoor \
+ _skaffold \
slogin \
smbcacls \
smbcquotas \
@@ -712,12 +862,24 @@ CLEANFILES = \
smbtree \
sparc-koji \
spovray \
+ _sshi \
+ _ssh-inscribe \
star \
+ _starship \
stream \
sudoedit \
+ _tanzu \
+ _tanzu-core \
+ _tendermint \
+ _terraform \
+ _tkn \
+ _tkn-pac \
tightvncviewer \
tracepath6 \
+ _trivy \
typeset \
+ _upctl \
+ _vacuum \
vgcfgbackup \
vgcfgrestore \
vgchange \
@@ -737,14 +899,25 @@ CLEANFILES = \
vgscan \
vgsplit \
vigr \
+ _virtctl \
+ _watchexec \
whatis \
+ wine-development \
+ wine-stable \
+ wine64 \
+ wine64-development \
+ wine64-stable \
xpovray \
xvnc4viewer \
- ypcat
+ ypcat \
+ _zitadel
symlinks: $(DATA)
$(ss) 7z \
- 7za
+ 7za \
+ 7zr \
+ 7zz \
+ 7zzs
$(ss) aclocal \
aclocal-1.10 aclocal-1.11 aclocal-1.12 aclocal-1.13 \
aclocal-1.14 aclocal-1.15 aclocal-1.16
@@ -761,6 +934,8 @@ symlinks: $(DATA)
autoheader
$(ss) autoscan \
autoupdate
+ $(ss) avahi-browse \
+ avahi-browse-domains
$(ss) btdownloadheadless.py \
btdownloadcurses.py btdownloadgui.py
$(ss) bzip2 \
@@ -769,6 +944,8 @@ symlinks: $(DATA)
ncal
$(ss) cardctl \
pccardctl
+ $(ss) cd \
+ pushd
$(ss) chromium-browser \
chrome chromium google-chrome google-chrome-stable
$(ss) complete \
@@ -778,6 +955,8 @@ symlinks: $(DATA)
mogrify montage stream
$(ss) cowsay \
cowthink
+ $(ss) declare \
+ typeset
$(ss) dict \
rdict
$(ss) dpkg \
@@ -787,13 +966,15 @@ symlinks: $(DATA)
$(ss) filesnarf \
mailsnarf msgsnarf
$(ss) firefox \
- iceweasel mozilla-firefox
+ firefox-esr iceweasel mozilla-firefox
+ $(ss) _flamegraph \
+ _watchexec
$(ss) freeciv \
civclient freeciv-gtk2 freeciv-gtk3 freeciv-sdl freeciv-xaw
$(ss) freeciv-server \
civserver
- $(ss) function \
- declare typeset
+ $(ss) _gaiacli \
+ _gaiad _npm _tendermint
$(ss) gcc \
c++ cc f77 f95 g++ g++-5 g++-6 g++-7 g++-8 g77 g95 gcc-5 \
gcc-6 gcc-7 gcc-8 gccgo gccgo-5 gccgo-6 gccgo-7 gccgo-8 gcj \
@@ -802,10 +983,74 @@ symlinks: $(DATA)
mkisofs
$(ss) geoiplookup \
geoiplookup6
+ $(ss) _gh \
+ _infracost
$(ss) gkrellm \
gkrellm2
+ $(ss) _golangci-lint \
+ _allero \
+ _arduino-cli \
+ _buf \
+ _chezmoi \
+ _cilium \
+ _cloudquery \
+ _constellation \
+ _crc \
+ _datree \
+ _docker \
+ _gardenctl \
+ _gh-label \
+ _git-bump \
+ _go-licenses \
+ _gopherjs \
+ _goreleaser \
+ _helm \
+ _hugo \
+ _ignite \
+ _istioctl \
+ _k3s \
+ _kn \
+ _kool \
+ _kratos \
+ _kubeadm \
+ _kubectl \
+ _kubescape \
+ _lefthook \
+ _linkerd \
+ _mattermost \
+ _metalctl \
+ _minikube \
+ _mise \
+ _mmctl \
+ _moldy \
+ _multi-gitter \
+ _nfpm \
+ _oc \
+ _okteto \
+ _op \
+ _ory \
+ _polygon-edge \
+ _pulumi \
+ _px \
+ _qrpc \
+ _random \
+ _rclone \
+ _skaffold \
+ _sshi \
+ _ssh-inscribe \
+ _tanzu \
+ _tanzu-core \
+ _tkn \
+ _tkn-pac \
+ _trivy \
+ _upctl \
+ _vacuum \
+ _virtctl \
+ _zitadel
$(ss) gpgv \
gpgv2
+ $(ss) gssdp-discover \
+ gssdp-device-sniffer
$(ss) gzip \
pigz
$(ss) hcitool \
@@ -835,6 +1080,12 @@ symlinks: $(DATA)
links2
$(ss) lintian \
lintian-info
+ $(ss) lua \
+ lua50 lua5.0 lua51 lua5.1 lua52 lua5.2 lua53 lua5.3 lua54 \
+ lua5.4
+ $(ss) luac \
+ luac50 luac5.0 luac51 luac5.1 luac52 luac5.2 luac53 luac5.3 \
+ luac54 luac5.4
$(ss) luseradd \
lusermod
$(ss) lvm \
@@ -854,10 +1105,25 @@ symlinks: $(DATA)
apropos whatis
$(ss) mcrypt \
mdecrypt
+ $(ss) _mdbook \
+ _deno _diesel _dprint _starship
$(ss) mplayer \
gmplayer kplayer mencoder mplayer2
$(ss) mutt \
- muttng
+ muttng neomutt
+ $(ss) _nox \
+ _airflow \
+ _ansible \
+ _ansible-config \
+ _ansible-console \
+ _ansible-doc \
+ _ansible-galaxy \
+ _ansible-inventory \
+ _ansible-playbook \
+ _ansible-pull \
+ _ansible-vault \
+ _conda \
+ _cz
$(ss) nslookup \
host
$(ss) p4 \
@@ -867,7 +1133,13 @@ symlinks: $(DATA)
$(ss) pine \
alpine
$(ss) ping \
- ping6
+ ping4 ping6
+ $(ss) _pip \
+ _pip3
+ $(ss) _pipenv \
+ _black _blackd _flask _httpx
+ $(ss) pkg-config \
+ pkgconf
$(ss) pkg_delete \
pkg_deinstall pkg_info
$(ss) pgrep \
@@ -890,9 +1162,12 @@ symlinks: $(DATA)
$(ss) pylint \
pylint-2 pylint-3
$(ss) python \
- micropython pypy pypy3 python2 python2.7 python3 python3.3 python3.4 python3.5 python3.6 python3.7 python3.8
+ micropython pypy pypy3 pyston pyston3 python2 python2.7 \
+ python3 python3.3 python3.4 python3.5 python3.6 python3.7 \
+ python3.8 python3.9 python3.10 python3.11 python3.12
$(ss) pyvenv \
- pyvenv-3.4 pyvenv-3.5 pyvenv-3.6 pyvenv-3.7 pyvenv-3.8
+ pyvenv-3.4 pyvenv-3.5 pyvenv-3.6 pyvenv-3.7 pyvenv-3.8 \
+ pyvenv-3.9 pyvenv-3.10 pyvenv-3.11 pyvenv-3.12
$(ss) qdbus \
dcop
$(ss) qemu \
@@ -909,6 +1184,8 @@ symlinks: $(DATA)
smbcacls smbcquotas smbget smbpasswd smbtar smbtree
$(ss) sbcl \
sbcl-mt
+ $(ss) sha256sum \
+ b2sum md5sum shasum sha1sum sha224sum sha384sum sha512sum
$(ss) ssh \
autossh scp sftp sidedoor slogin
$(ss) sudo \
@@ -919,12 +1196,15 @@ symlinks: $(DATA)
tracepath6
$(ss) update-alternatives \
alternatives
+ $(ss) _vault \
+ _consul _nomad _packer _terraform
$(ss) vipw \
vigr
$(ss) vncviewer \
tightvncviewer xvnc4viewer
$(ss) wine \
- wine-development wine-stable
+ wine-development wine-stable \
+ wine64 wine64-development wine64-stable
$(ss) wodim \
cdrecord
$(ss) xz \
@@ -942,9 +1222,9 @@ install-data-hook: ss = $(SETUP_SYMLINKS) $(DESTDIR)$(bashcompdir)
install-data-hook: symlinks
check-local:
- ret=0; \
+ REPLY=0; \
for file in $(bashcomp_DATA); do \
$${bashcomp_bash:-$${BASH:-bash}} \
- -O extglob -n $(srcdir)/$$file || ret=$$?; \
+ -O extglob -n $(srcdir)/$$file || REPLY=$$?; \
done; \
- exit $$ret
+ exit $$REPLY
diff --git a/completions/_adb b/completions/_adb
index e8ebab1..0189331 100644
--- a/completions/_adb
+++ b/completions/_adb
@@ -3,67 +3,67 @@
# Use of this file is deprecated. Upstream completion is available in
# the Android SDK, use that instead.
-_adb_command_usage()
+_comp_cmd_adb__command_usage()
{
- COMPREPLY=($(compgen -W \
- '$("$1" help 2>&1 | command grep "^ *\(adb \)\? *$2 " \
- | command sed -e "s/[]|[]/\n/g" | _parse_help -)' -- "$cur"))
+ _comp_compgen_help - <<<"$("$1" help 2>&1 |
+ command sed -e "/^ *\(adb \)\{0,1\} *$2 /!d;s/[]|[]/\n/g")"
}
-_adb()
+_comp_cmd_adb()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-s | -p | --algo | --key | --iv)
return
;;
-f)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
- local cmd i
+ local cmd has_cmd="" i
for ((i = 1; i < cword; i++)); do
if [[ ${words[i]} != -* && ${words[i - 1]} != -[sp] ]]; then
cmd="${words[i]}"
+ has_cmd=set
break
fi
done
- if [[ ! -v cmd ]]; then
+ if [[ ! $has_cmd ]]; then
local tmp=()
if [[ ! $cur || $cur == -* ]]; then
- tmp+=($(compgen -W '$(_parse_help "$1" help)' -- "$cur"))
+ _comp_compgen -av tmp help -- help
fi
if [[ ! $cur || $cur != -* ]]; then
- tmp+=($($1 help 2>&1 | awk '$1 == "adb" { print $2 }'))
+ _comp_split -a tmp "$("$1" help 2>&1 | _comp_awk '$1 == "adb" { print $2 }')"
tmp+=(devices connect disconnect sideload)
fi
- COMPREPLY=($(compgen -W '${tmp[@]}' -- "$cur"))
+ ((${#tmp[@]})) &&
+ _comp_compgen -- -W '"${tmp[@]}"'
return
fi
# TODO: more and better command completions
- _adb_command_usage "$1" $cmd
+ _comp_cmd_adb__command_usage "$1" "$cmd"
case $cmd in
push | restore | sideload)
- _filedir
+ _comp_compgen -a filedir
;;
forward)
- COMPREPLY=($(compgen -W \
- '$("$1" help 2>&1 | command sed -ne "s/^ *adb *forward *-/-/p" | \
- _parse_help -)' -- "$cur"))
+ _comp_compgen_help - <<<"$("$1" help 2>&1 |
+ command sed -ne "s/^ *adb *forward *-/-/p")"
;;
reboot)
- COMPREPLY=($(compgen -W 'bootloader recovery' -- "$cur"))
+ _comp_compgen -- -W 'bootloader recovery'
;;
esac
} &&
- complete -F _adb adb
+ complete -F _comp_cmd_adb adb
# ex: filetype=sh
diff --git a/completions/_cal b/completions/_cal
index 1eec267..3f8b3ca 100644
--- a/completions/_cal
+++ b/completions/_cal
@@ -3,15 +3,15 @@
# Use of this file is deprecated on Linux. Upstream completion is
# available in util-linux >= 2.23, use that instead.
-_cal()
+_comp_cmd_cal()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-m)
if [[ $OSTYPE == *bsd* ]]; then
- COMPREPLY=($(compgen -W '{1..12}' -- "$cur"))
+ _comp_compgen -- -W '{1..12}'
return
fi
;;
@@ -24,15 +24,14 @@ _cal()
esac
if [[ $cur == -* ]]; then
- local opts=$(_parse_help "$1")
- COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
return
fi
- local args
- _count_args
- ((args == 1)) && COMPREPLY=($(compgen -W '{1..12}' -- "$cur"))
+ local REPLY
+ _comp_count_args
+ ((REPLY == 1)) && _comp_compgen -- -W '{1..12}'
} &&
- complete -F _cal cal ncal
+ complete -F _comp_cmd_cal cal ncal
# ex: filetype=sh
diff --git a/completions/_cargo b/completions/_cargo
new file mode 100644
index 0000000..257eb35
--- /dev/null
+++ b/completions/_cargo
@@ -0,0 +1,9 @@
+# 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 _comp_load
+local rustup="${1%cargo}rustup" # use rustup from same dir
+eval -- "$("$rustup" completions bash cargo 2>/dev/null)"
+
+# ex: filetype=sh
diff --git a/completions/_chsh b/completions/_chsh
index 8f8a807..4e243ba 100644
--- a/completions/_chsh
+++ b/completions/_chsh
@@ -1,31 +1,43 @@
# chsh(1) completion -*- shell-script -*-
-# Use of this file is deprecated on Linux. Upstream completion is
-# available in util-linux >= 2.23, use that instead.
+# Use of this file is deprecated on Linux systems whose chsh is from
+# util-linux. Upstream completion is in util-linux >= 2.23, use that instead.
-_chsh()
+_comp_cmd_chsh()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+
+ local word chroot="" has_chroot=""
+ for word in "${words[@]}"; do
+ if [[ $has_chroot ]]; then
+ chroot=$word
+ break
+ fi
+ [[ $word != -@(R|-root) ]] || has_chroot=set
+ done
case $prev in
--list-shells | --help | -v | --version)
return
;;
+ -R | --root)
+ _comp_compgen_filedir -d
+ return
+ ;;
-s | --shell)
- _shells
+ _comp_compgen_shells "${chroot-}"
return
;;
esac
if [[ $cur == -* ]]; then
- local opts=$(_parse_help "$1")
- COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
else
- _allowed_users
+ _comp_compgen_allowed_users
fi
} &&
- complete -F _chsh chsh
+ complete -F _comp_cmd_chsh chsh
# ex: filetype=sh
diff --git a/completions/_dmesg b/completions/_dmesg
index 8306654..ad90fcc 100644
--- a/completions/_dmesg
+++ b/completions/_dmesg
@@ -3,31 +3,29 @@
# Use of this file is deprecated on Linux. Upstream completion is
# available in util-linux >= 2.23, use that instead.
-_dmesg()
+_comp_cmd_dmesg()
{
[[ $OSTYPE == *solaris* ]] && return # no args there
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-h | --help | -V | --version | -s | --buffer-size | -M | -N)
return
;;
-f | --facility)
- COMPREPLY=($(compgen -W 'kern user mail daemon auth syslog lpr
- news' -- "$cur"))
+ _comp_compgen -- -W 'kern user mail daemon auth syslog lpr news'
return
;;
-l | --level | -n | --console-level)
- COMPREPLY=($(compgen -W '{1..8}' -- "$cur"))
+ _comp_compgen -- -W '{1..8}'
return
;;
esac
- local opts=$(_parse_help "$1")
- COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
} &&
- complete -F _dmesg dmesg
+ complete -F _comp_cmd_dmesg dmesg
# ex: filetype=sh
diff --git a/completions/_eject b/completions/_eject
index 52168f7..76ae0f8 100644
--- a/completions/_eject
+++ b/completions/_eject
@@ -3,31 +3,31 @@
# Use of this file is deprecated on Linux. Upstream completion is
# available in util-linux >= 2.23, use that instead.
-_eject()
+_comp_cmd_eject()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-h | --help | -V | --version | -c | --changerslot | -x | --cdspeed)
return
;;
-a | --auto | -i | --manualeject)
- COMPREPLY=($(compgen -W 'on off' -- "$cur"))
+ _comp_compgen -- -W 'on off'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
elif [[ $prev == @(-d|--default) ]]; then
return
fi
- _cd_devices
- _dvd_devices
+ _comp_compgen_cd_devices
+ _comp_compgen -a dvd_devices
} &&
- complete -F _eject eject
+ complete -F _comp_cmd_eject eject
# ex: filetype=sh
diff --git a/completions/_flamegraph b/completions/_flamegraph
new file mode 100644
index 0000000..95c86c0
--- /dev/null
+++ b/completions/_flamegraph
@@ -0,0 +1,8 @@
+# 3rd party completion loader for commands emitting -*- shell-script -*-
+# their completion using "$cmd --completions bash".
+#
+# This serves as a fallback in case the completion is not installed otherwise.
+
+eval -- "$("$1" --completions bash 2>/dev/null)"
+
+# ex: filetype=sh
diff --git a/completions/_gaiacli b/completions/_gaiacli
new file mode 100644
index 0000000..2f48598
--- /dev/null
+++ b/completions/_gaiacli
@@ -0,0 +1,8 @@
+# 3rd party completion loader for commands emitting -*- shell-script -*-
+# their completion using "$cmd completion".
+#
+# This serves as a fallback in case the completion is not installed otherwise.
+
+eval -- "$("$1" completion 2>/dev/null)"
+
+# ex: filetype=sh
diff --git a/completions/_gh b/completions/_gh
new file mode 100644
index 0000000..8a0376d
--- /dev/null
+++ b/completions/_gh
@@ -0,0 +1,8 @@
+# 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)"
+
+# ex: filetype=sh
diff --git a/completions/_golangci-lint b/completions/_golangci-lint
new file mode 100644
index 0000000..40fc5c3
--- /dev/null
+++ b/completions/_golangci-lint
@@ -0,0 +1,9 @@
+# 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)"
+
+# ex: filetype=sh
diff --git a/completions/_gsctl b/completions/_gsctl
new file mode 100644
index 0000000..3b1a040
--- /dev/null
+++ b/completions/_gsctl
@@ -0,0 +1,8 @@
+# 3rd party completion loader for commands emitting -*- shell-script -*-
+# their completion using "$cmd completion bash --stdout".
+#
+# This serves as a fallback in case the completion is not installed otherwise.
+
+eval -- "$("$1" completion bash --stdout 2>/dev/null)"
+
+# ex: filetype=sh
diff --git a/completions/_hexdump b/completions/_hexdump
index 785f597..939cfa6 100644
--- a/completions/_hexdump
+++ b/completions/_hexdump
@@ -3,29 +3,28 @@
# Use of this file is deprecated on Linux. Upstream completion is
# available in util-linux >= 2.23, use that instead.
-_hexdump()
+_comp_cmd_hexdump()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-V | -e | -n | -s)
return
;;
-f)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- local opts="$(_parse_help "$1")"
- COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _hexdump hexdump hd
+ complete -F _comp_cmd_hexdump hexdump hd
# ex: filetype=sh
diff --git a/completions/_hwclock b/completions/_hwclock
index ef437a2..a0fd831 100644
--- a/completions/_hwclock
+++ b/completions/_hwclock
@@ -3,24 +3,24 @@
# Use of this file is deprecated. Upstream completion is available in
# util-linux >= 2.23, use that instead.
-_hwclock()
+_comp_cmd_hwclock()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-h | --help | -V | --version | --date | --epoch)
return
;;
-f | --rtc | --adjfile)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
- COMPREPLY=(
- $(PATH="$PATH:/sbin" compgen -W '$(_parse_help "$1")' -- "$cur"))
+ local PATH=$PATH:/sbin
+ _comp_compgen_help
} &&
- complete -F _hwclock hwclock
+ complete -F _comp_cmd_hwclock hwclock
# ex: filetype=sh
diff --git a/completions/_ionice b/completions/_ionice
index b0d96a1..42fcd39 100644
--- a/completions/_ionice
+++ b/completions/_ionice
@@ -3,10 +3,10 @@
# Use of this file is deprecated. Upstream completion is available in
# util-linux >= 2.23, use that instead.
-_ionice()
+_comp_cmd_ionice()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local offset=0 i
for ((i = 1; i <= cword; i++)); do
@@ -31,30 +31,30 @@ _ionice()
done
if ((offset > 0)); then
- _command_offset $offset
+ _comp_command_offset $offset
return
fi
case $prev in
-c)
- COMPREPLY=($(compgen -W '{0..3}' -- "$cur"))
+ _comp_compgen -- -W '{0..3}'
return
;;
-n)
- COMPREPLY=($(compgen -W '{0..7}' -- "$cur"))
+ _comp_compgen -- -W '{0..7}'
return
;;
-p)
- _pids
+ _comp_compgen_pids
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ _comp_compgen_help -- -h
return
fi
} &&
- complete -F _ionice ionice
+ complete -F _comp_cmd_ionice ionice
# ex: filetype=sh
diff --git a/completions/_jungle b/completions/_jungle
new file mode 100644
index 0000000..f08ae91
--- /dev/null
+++ b/completions/_jungle
@@ -0,0 +1,16 @@
+# 3rd party completion loader for commands emitting -*- shell-script -*-
+# their completion using "_${cmdname^^}_COMPLETE=source $cmd".
+# This pattern is very similar to `completions/_pipenv`, but the value of the
+# environment variable is slightly different.
+#
+# This serves as a fallback in case the completion is not installed otherwise.
+
+eval -- "$(
+ # shellcheck disable=SC2154
+ ucname="${cmdname^^}"
+ ucname=${ucname//-/_}
+ export "_${ucname}_COMPLETE=source"
+ "$1" 2>/dev/null
+)"
+
+# ex: filetype=sh
diff --git a/completions/_keyring b/completions/_keyring
new file mode 100644
index 0000000..4dcc58f
--- /dev/null
+++ b/completions/_keyring
@@ -0,0 +1,9 @@
+# 3rd party completion loader for commands emitting -*- shell-script -*-
+# their completion using "$cmd --print-completion bash".
+# For example, many Python programs using https://github.com/iterative/shtab do.
+#
+# This serves as a fallback in case the completion is not installed otherwise.
+
+eval -- "$("$1" --print-completion bash 2>/dev/null)"
+
+# ex: filetype=sh
diff --git a/completions/_kontena b/completions/_kontena
new file mode 100644
index 0000000..94918fe
--- /dev/null
+++ b/completions/_kontena
@@ -0,0 +1,14 @@
+# 3rd party completion loader for kontena -*- shell-script -*-
+#
+# This serves as a fallback in case the completion is not installed otherwise.
+
+# To avoid sourcing an empty string with `. "$(...)"` on failing to obtain the
+# path, we assign the output to a variable `_comp_cmd_kontena__completion_path`
+# and test it before sourcing. The variable is removed on successful loading
+# but left on a failure for the debugging purpose.
+_comp_cmd_kontena__completion_path=$("$1" whoami --bash-completion-path 2>/dev/null) &&
+ [[ -r $_comp_cmd_kontena__completion_path ]] &&
+ . "$_comp_cmd_kontena__completion_path" &&
+ unset -v _comp_cmd_kontena__completion_path
+
+# ex: filetype=sh
diff --git a/completions/_look b/completions/_look
index 9788dec..20613ff 100644
--- a/completions/_look
+++ b/completions/_look
@@ -3,15 +3,15 @@
# Use of this file is deprecated on Linux. Upstream completion is
# available in util-linux >= 2.23, use that instead.
-_look()
+_comp_cmd_look()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if ((cword == 1)); then
- COMPREPLY=($(compgen -W '$(look "$cur" 2>/dev/null)' -- "$cur"))
+ _comp_compgen_split -- "$(look "$cur" 2>/dev/null)"
fi
} &&
- complete -F _look -o default look
+ complete -F _comp_cmd_look -o default look
# ex: filetype=sh
diff --git a/completions/_mdbook b/completions/_mdbook
new file mode 100644
index 0000000..fe32688
--- /dev/null
+++ b/completions/_mdbook
@@ -0,0 +1,8 @@
+# 3rd party completion loader for commands emitting -*- shell-script -*-
+# their completion using "$cmd completions bash".
+#
+# This serves as a fallback in case the completion is not installed otherwise.
+
+eval -- "$("$1" completions bash 2>/dev/null)"
+
+# ex: filetype=sh
diff --git a/completions/_mock b/completions/_mock
index b468148..df778a8 100644
--- a/completions/_mock
+++ b/completions/_mock
@@ -3,10 +3,10 @@
# Use of this file is deprecated. Upstream completion is available in
# mock > 1.1.0, use that instead.
-_mock()
+_comp_cmd_mock()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
local plugins='tmpfs root_cache yum_cache bind_mount ccache'
local cfgdir=/etc/mock count=0 i
@@ -27,43 +27,45 @@ _mock()
return
;;
-r | --root)
- COMPREPLY=($(compgen -W "$(command ls $cfgdir)" -- "$cur"))
- COMPREPLY=(${COMPREPLY[@]/%.cfg/})
+ _comp_compgen_split -- "$(command ls "$cfgdir")" &&
+ COMPREPLY=("${COMPREPLY[@]/%.cfg/}")
return
;;
--configdir | --resultdir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
--spec)
- _filedir spec
+ _comp_compgen_filedir spec
return
;;
--target)
+ # Case-insensitive BRE to match "compatible archs"
+ local regex_header='[cC][oO][mM][pP][aA][tT][iI][bB][lL][eE][[:space:]]\{1,\}[aA][rR][cC][hH][sS]'
+
# Yep, compatible archs, not compatible build archs
# (e.g. ix86 chroot builds in x86_64 mock host)
# This would actually depend on what the target root
# can be used to build for...
- COMPREPLY=($(compgen -W "$(command rpm --showrc |
- command sed -ne 's/^\s*compatible\s\s*archs\s*:\s*\(.*\)/\1/i p')" \
- -- "$cur"))
+ _comp_compgen_split -- "$(command rpm --showrc | command sed -ne \
+ "s/^[[:space:]]*${regex_header}[[:space:]]*:[[:space:]]*\(.*\)/\1/p")"
return
;;
--enable-plugin | --disable-plugin)
- COMPREPLY=($(compgen -W "$plugins" -- "$cur"))
+ _comp_compgen -- -W "$plugins"
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- _filedir '@(?(no)src.r|s)pm'
+ _comp_compgen_filedir '@(?(no)src.r|s)pm'
fi
} &&
- complete -F _mock mock
+ complete -F _comp_cmd_mock mock
# ex: filetype=sh
diff --git a/completions/_modules b/completions/_modules
index 4f7c4d4..830ddfe 100644
--- a/completions/_modules
+++ b/completions/_modules
@@ -19,67 +19,66 @@
# Test for existence of /etc/profile.d/modules.sh too because we may end up
# being sourced before it and thus before the `module' alias has been defined.
-[ -f /etc/profile.d/modules.sh ] || return 1
+[[ -f /etc/profile.d/modules.sh ]] || return 1
-_module_list()
+_comp_cmd_module__compgen_list()
{
- local modules="$(command sed 's/:/ /g' <<<$LOADEDMODULES | sort)"
- compgen -W "$modules" -- $1
+ local modules="$(command sed 's/:/ /g' <<<"$LOADEDMODULES" | sort)"
+ _comp_compgen -- -W "$modules"
}
-_module_path()
+_comp_cmd_module__compgen_path()
{
- local modules="$(command sed 's/:/ /g' <<<$MODULEPATH | sort)"
- compgen -W "$modules" -- $1
+ local modules="$(command sed 's/:/ /g' <<<"$MODULEPATH" | sort)"
+ _comp_compgen -- -W "$modules"
}
-_module_avail()
+_comp_cmd_module__compgen_avail()
{
local modules="$(
module avail 2>&1 |
command grep -E -v '^(-|$)' |
xargs printf '%s\n' | command sed -e 's/(default)//g' | sort
)"
-
- compgen -W "$modules" -- $1
+ _comp_compgen -- -W "$modules"
}
# A completion function for the module alias
-_module()
+_comp_cmd_module()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if ((cword == 1)); then
# First parameter on line -- we expect it to be a mode selection
local options
options="$(module help 2>&1 | command grep -E '^[[:space:]]*\+' |
- awk '{print $2}' | command sed -e 's/|/ /g' | sort)"
+ _comp_awk '{print $2}' | command sed -e 's/|/ /g' | sort)"
- COMPREPLY=($(compgen -W "$options" -- "$cur"))
+ _comp_compgen -- -W "$options"
elif ((cword == 2)); then
case $prev in
add | display | help | load | show | whatis)
- COMPREPLY=($(_module_avail "$cur"))
+ _comp_cmd_module__compgen_avail
;;
rm | switch | swap | unload | update)
- COMPREPLY=($(_module_list "$cur"))
+ _comp_cmd_module__compgen_list
;;
unuse)
- COMPREPLY=($(_module_path "$cur"))
+ _comp_cmd_module__compgen_path
;;
esac
elif ((cword == 3)); then
case ${words[1]} in
swap | switch)
- COMPREPLY=($(_module_avail "$cur"))
+ _comp_cmd_module__compgen_avail
;;
esac
fi
} &&
- complete -F _module -o default module
+ complete -F _comp_cmd_module -o default module
# ex: filetype=sh
diff --git a/completions/_mount b/completions/_mount
index 85f5490..ab385f1 100644
--- a/completions/_mount
+++ b/completions/_mount
@@ -14,16 +14,16 @@ fi
# query the server for a list of all available exports and complete on
# that instead.
#
-_mount()
+_comp_cmd_mount()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
local sm host
case $prev in
-t | --types)
- _fstypes
+ _comp_compgen_fstypes
return
;;
esac
@@ -33,8 +33,9 @@ _mount()
if [[ $cur == *:* ]]; then
for sm in "$(type -P showmount)" {,/usr}/{,s}bin/showmount; do
[[ -x $sm ]] || continue
- COMPREPLY=($(compgen -W "$("$sm" -e ${cur%%:*} |
- awk 'NR>1 {print $1}')" -- "${cur#*:}"))
+ _comp_compgen -c "${cur#*:}" split -- "$(
+ "$sm" -e ${cur%%:*} | _comp_awk 'NR>1 {print $1}'
+ )"
return
done
fi
@@ -42,24 +43,30 @@ _mount()
if [[ $cur == //* ]]; then
host=${cur#//}
host=${host%%/*}
- if [[ -n $host ]]; then
- COMPREPLY=($(compgen -P "//$host" -W \
- "$(smbclient -d 0 -NL $host 2>/dev/null |
+ if [[ $host ]]; then
+ _comp_compgen -c "${cur#//"$host"}" split -P "//$host" -- "$(
+ smbclient -d 0 -NL "$host" 2>/dev/null |
command sed -ne '/^[[:blank:]]*Sharename/,/^$/p' |
- command sed -ne '3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p')" \
- -- "${cur#//$host}"))
+ command sed -ne '3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p'
+ )"
fi
elif [[ -r /etc/vfstab ]]; then
# Solaris
- COMPREPLY=($(compgen -W "$(awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab)" -- "$cur"))
+ _comp_compgen_split -- "$(
+ _comp_awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab
+ )"
elif [[ ! -e /etc/fstab ]]; then
# probably Cygwin
- COMPREPLY=($(compgen -W "$($1 | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}')" -- "$cur"))
+ _comp_compgen_split -- "$(
+ "$1" | _comp_awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}'
+ )"
else
# probably BSD
- COMPREPLY=($(compgen -W "$(awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' /etc/fstab)" -- "$cur"))
+ _comp_compgen_split -- "$(
+ _comp_awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' /etc/fstab
+ )"
fi
} &&
- complete -F _mount -o default -o dirnames mount
+ complete -F _comp_cmd_mount -o default -o dirnames mount
# ex: filetype=sh
diff --git a/completions/_mount.linux b/completions/_mount.linux
index f40865e..3d4c307 100644
--- a/completions/_mount.linux
+++ b/completions/_mount.linux
@@ -3,12 +3,12 @@
# Use of this file is deprecated on Linux. Upstream completion is
# available in util-linux >= 2.28, use that instead.
-_mount()
+_comp_cmd_mount()
{
- local cur prev words cword
- _init_completion -n =: || return
+ local cur prev words cword comp_args
+ _comp_initialize -n =: -- "$@" || return
- local split=false
+ local split=""
case "$prev" in
-t | --types)
# find /lib/modules/$(uname -r)/ -type f -path '*/fs/*.ko' -printf '%f\n' | cut -d. -f1
@@ -16,38 +16,33 @@ _mount()
if [[ $cur == ?*,* ]]; then
prev="${cur%,*}"
cur="${cur##*,}"
- split=true
+ split=set
fi
- COMPREPLY=($(compgen -W 'auto adfs affs autofs btrfs cifs coda
- cramfs davfs debugfs devpts efs ext2 ext3 ext4 fuse hfs hfsplus
- hpfs iso9660 jffs2 jfs minix msdos ncpfs nfs nfs4 ntfs ntfs-3g
- proc qnx4 ramfs reiserfs romfs squashfs smbfs sysv tmpfs ubifs
- udf ufs umsdos usbfs vfat xfs' -- "$cur"))
- _fstypes
- $split && COMPREPLY=(${COMPREPLY[@]/#/$prev,})
+ _comp_compgen -- -W 'auto adfs affs autofs btrfs cifs coda cramfs
+ davfs debugfs devpts efs ext2 ext3 ext4 fuse hfs hfsplus hpfs
+ iso9660 jffs2 jfs minix msdos ncpfs nfs nfs4 ntfs ntfs-3g proc
+ qnx4 ramfs reiserfs romfs squashfs smbfs sysv tmpfs ubifs udf
+ ufs umsdos usbfs vfat xfs'
+ _comp_compgen -a fstypes
+ [[ $split ]] && ((${#COMPREPLY[@]})) &&
+ _comp_compgen -Rv COMPREPLY -- -P "$prev," -W '"${COMPREPLY[@]}"'
return
;;
--bind | -B | --rbind | -R)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-p | --pass-fd)
- COMPREPLY=($(compgen -W '{0..9}'))
+ _comp_compgen -R -- -W '{0..9}'
compopt -o nospace
return
;;
-L)
- COMPREPLY=($(
- cd "/dev/disk/by-label/" 2>/dev/null || return
- compgen -f -- "$cur"
- ))
+ _comp_compgen -C "/dev/disk/by-label/" -- -f
return
;;
-U)
- COMPREPLY=($(
- cd "/dev/disk/by-uuid/" 2>/dev/null || return
- compgen -f -- "$cur"
- ))
+ _comp_compgen -C "/dev/disk/by-uuid/" -- -f
return
;;
-O | --test-opts)
@@ -74,149 +69,152 @@ _mount()
if [[ $cur == ?*,* ]]; then
prev="${cur%,*}"
cur="${cur##*,}"
- split=true
+ split=set
fi
# no completion if $cur is opt=smth
[[ $cur == *=* ]] && return
# mount options
- COMPREPLY=($(compgen -W 'loop {,a}sync {,no}atime {,no}auto
+ _comp_compgen -- -W 'loop {,a}sync {,no}atime {,no}auto
{,fs,def,root}context= defaults {,no}dev {,no}diratime dirsync
{,no}exec group {,no}iversion {,no}mand _netdev nofail
{,no}relatime {,no}strictatime {,no}suid owner remount ro rw
- {,no}user users' -- "$cur"))
+ {,no}user users'
case "$fstype" in
adfs | auto)
- COMPREPLY+=($(compgen -W '{u,g}id= {own,oth}mask=' -- "$cur"))
+ _comp_compgen -a -- -W '{u,g}id= {own,oth}mask='
;;&
affs | auto)
- COMPREPLY+=($(compgen -W '{u,g}id= set{u,g}id= mode= protect
- usemp verbose prefix= volume= reserved= root= bs=
- {,no,usr,grp}quota' -- "$cur"))
+ _comp_compgen -a -- -W '{u,g}id= set{u,g}id= mode= protect
+ usemp verbose prefix= volume= reserved= root= bs=
+ {,no,usr,grp}quota'
;;&
btrfs | auto)
- COMPREPLY+=($(compgen -W 'degraded subvol= subvolid= device=
- nodatasum nodatacow nobarrier max_inline= alloc_start=
- thread_pool= compress= compress-force= ssd noacl notreelog
- flushoncommit metadata_ratio= {,no}space_cache clear_cache
- user_subvol_rm_allowed autodefrag inode_cache' -- "$cur"))
+ _comp_compgen -a -- -W 'degraded subvol= subvolid= device=
+ nodatasum nodatacow nobarrier max_inline= alloc_start=
+ thread_pool= compress= compress-force= ssd noacl
+ notreelog flushoncommit metadata_ratio=
+ {,no}space_cache clear_cache user_subvol_rm_allowed
+ autodefrag inode_cache'
;;&
cifs | auto)
- COMPREPLY+=($(compgen -W 'user= password= credentials= {u,g}id=
- force{u,g}id port= servern= netbiosname= {file,dir}_mode=
- ip= domain= guest iocharset {,no}setuids {,no,dyn}perm
- directio {,no}mapchars {,no}intr hard soft noacl nocase sec=
- nobrl sfu {,no}serverino nounix nouser_xattr {r,w}size=
- rwpidforward backup{u,g}id cache=' -- "$cur"))
+ _comp_compgen -a -- -W 'user= password= credentials=
+ {u,g}id= force{u,g}id port= servern= netbiosname=
+ {file,dir}_mode= ip= domain= guest iocharset
+ {,no}setuids {,no,dyn}perm directio {,no}mapchars
+ {,no}intr hard soft noacl nocase sec= nobrl sfu
+ {,no}serverino nounix nouser_xattr {r,w}size=
+ rwpidforward backup{u,g}id cache='
;;&
davfs | auto)
- COMPREPLY+=($(compgen -W 'conf= {file,dir}_mode= {u,g}id=
- username=' -- "$cur"))
+ _comp_compgen -a -- -W 'conf= {file,dir}_mode= {u,g}id=
+ username='
;;&
ext[2-4] | auto)
- COMPREPLY+=($(compgen -W '{,no}acl bsddf minixdf check= debug
- errors= {,no}grpid {bsd,sysv}groups {,no,usr,grp}quota
- nobh nouid32 oldalloc orlov res{u,g}id= sb=
- {,no}user_xattr' -- "$cur"))
+ _comp_compgen -a -- -W '{,no}acl bsddf minixdf check= debug
+ errors= {,no}grpid {bsd,sysv}groups {,no,usr,grp}quota
+ nobh nouid32 oldalloc orlov res{u,g}id= sb=
+ {,no}user_xattr'
;;&
ext[34] | auto)
- COMPREPLY+=($(compgen -W 'journal= journal_dev= norecovery
- noload data= barrier= commit=' -- "$cur"))
+ _comp_compgen -a -- -W 'journal= journal_dev= norecovery
+ noload data= barrier= commit='
;;&
ext4 | auto)
- COMPREPLY+=($(compgen -W 'journal_checksum journal_async_commit
- nobarrier inode_readahead= stripe= {,no}delalloc abort
- {max,min}_batch_time= journal_ioprio= {,no}auto_da_alloc
- {,no}discard nouid32 resize {,no}block_validity
- dioread_{,no}lock max_dir_size_kb= i_version' -- "$cur"))
+ _comp_compgen -a -- -W 'journal_checksum
+ journal_async_commit nobarrier inode_readahead= stripe=
+ {,no}delalloc abort {max,min}_batch_time=
+ journal_ioprio= {,no}auto_da_alloc {,no}discard nouid32
+ resize {,no}block_validity dioread_{,no}lock
+ max_dir_size_kb= i_version'
;;&
msdos | umsdos | vfat | auto)
- COMPREPLY+=($(compgen -W 'blocksize= {u,g}id= {u,d,f}mask=
- allow_utime= check= codepage= conv= cvf_format= cvf_option=
- debug fat= iocharset= tz= quiet showexec sys_immutable flush
- usefree {,no}dots dotsOK=' -- "$cur"))
+ _comp_compgen -a -- -W 'blocksize= {u,g}id= {u,d,f}mask=
+ allow_utime= check= codepage= conv= cvf_format=
+ cvf_option= debug fat= iocharset= tz= quiet showexec
+ sys_immutable flush usefree {,no}dots dotsOK='
;;&
vfat | auto)
- COMPREPLY+=($(compgen -W 'uni_xlate posix nonumtail utf8
- shortname=' -- "$cur"))
+ _comp_compgen -a -- -W 'uni_xlate posix nonumtail utf8
+ shortname='
;;&
iso9660 | auto)
- COMPREPLY+=($(compgen -W 'norock nojoliet check= {u,g}id= map=
- mode= unhide block= conv= cruft session= sbsector=
- iocharset= utf8' -- "$cur"))
+ _comp_compgen -a -- -W 'norock nojoliet check= {u,g}id=
+ map= mode= unhide block= conv= cruft session= sbsector=
+ iocharset= utf8'
;;&
jffs2 | auto)
- COMPREPLY+=($(compgen -W 'compr= rp_size=' -- "$cur"))
+ _comp_compgen -a -- -W 'compr= rp_size='
;;&
jfs | auto)
- COMPREPLY+=($(compgen -W 'iocharset= resize= {,no}integrity
- errors= {,no,usr,grp}quota' -- "$cur"))
+ _comp_compgen -a -- -W 'iocharset= resize= {,no}integrity
+ errors= {,no,usr,grp}quota'
;;&
nfs | nfs4 | auto)
- COMPREPLY+=($(compgen -W 'soft hard timeo= retrans= {r,w}size=
- {,no}ac acreg{min,max}= acdir{min,max}= actimeo= bg fg
- retry= sec= {,no}sharecache {,no}resvport lookupcache=
- proto= port= {,no}intr {,no}cto {,nfs}vers= ' -- "$cur"))
+ _comp_compgen -a -- -W 'soft hard timeo= retrans= {r,w}size=
+ {,no}ac acreg{min,max}= acdir{min,max}= actimeo= bg fg
+ retry= sec= {,no}sharecache {,no}resvport lookupcache=
+ proto= port= {,no}intr {,no}cto {,nfs}vers='
;;&
nfs | auto)
- COMPREPLY+=($(compgen -W 'udp tcp rdma mount{port,proto,host}=
- mountvers= namlen={,no}lock {,no}acl {,no}rdirplus
- {,no}fsc' -- "$cur"))
+ _comp_compgen -a -- -W 'udp tcp rdma mount{port,proto,host}=
+ mountvers= namlen={,no}lock {,no}acl {,no}rdirplus
+ {,no}fsc'
;;&
nfs4 | auto)
- COMPREPLY+=($(compgen -W 'clientaddr= {,no}migration' \
- -- "$cur"))
+ _comp_compgen -a -- -W 'clientaddr= {,no}migration'
;;&
ntfs-3g)
- COMPREPLY+=($(compgen -W '{u,g}id= {u,f,d}mask= usermapping=
- permissions inherit locale= force {,no}recover
- ignore_case remove_hiberfile show_sys_files
- hide_{hid,dot}_files windows_names allow_other max_read=
- silent no_def_opts streams_interface= user_xattr efs_raw
- {,no}compression debug no_detach' -- "$cur"))
+ _comp_compgen -a -- -W '{u,g}id= {u,f,d}mask= usermapping=
+ permissions inherit locale= force {,no}recover
+ ignore_case remove_hiberfile show_sys_files
+ hide_{hid,dot}_files windows_names allow_other
+ max_read= silent no_def_opts streams_interface=
+ user_xattr efs_raw {,no}compression debug no_detach'
;;&
proc | auto)
- COMPREPLY+=($(compgen -W '{u,g}id=' -- "$cur"))
+ _comp_compgen -a -- -W '{u,g}id='
;;&
reiserfs | auto)
- COMPREPLY+=($(compgen -W 'conv hash= {,no_un}hashed_relocation
- noborder nolog notail replayonly resize= user_xattr acl
- barrier=' -- "$cur"))
+ _comp_compgen -a -- -W 'conv hash=
+ {,no_un}hashed_relocation noborder nolog notail
+ replayonly resize= user_xattr acl barrier='
;;&
tmpfs | auto)
- COMPREPLY+=($(compgen -W 'size= nr_blocks= nr_inodes= mode=
- {u,g}id= mpol=' -- "$cur"))
+ _comp_compgen -a -- -W 'size= nr_blocks= nr_inodes= mode=
+ {u,g}id= mpol='
;;&
udf | auto)
- COMPREPLY+=($(compgen -W '{u,g}id= umask= unhide undelete
- nostrict iocharset bs= novrs session= anchor= volume=
- partition= lastblock= fileset= rootdir=' -- "$cur"))
+ _comp_compgen -a -- -W '{u,g}id= umask= unhide undelete
+ nostrict iocharset bs= novrs session= anchor= volume=
+ partition= lastblock= fileset= rootdir='
;;&
usbfs | auto)
- COMPREPLY+=($(compgen -W 'dev{u,g}id= devmode= bus{u,g}id=
- busmode= list{u,g}id= listmode=' -- "$cur"))
+ _comp_compgen -a -- -W 'dev{u,g}id= devmode= bus{u,g}id=
+ busmode= list{u,g}id= listmode='
;;&
xfs | auto)
- COMPREPLY+=($(compgen -W 'allocsize= {,no}attr2 barrier dmapi
- {,no}grpid {bsd,sysv}groups ihashsize= {,no}ikeep
- inode{32,64} {,no}largeio logbufs= logbsize= logdev=
- rtdev= mtpt= noalign norecovery nouuid osyncisosync
- {u,g,p}qnoenforce {,u,usr,g,grp,p,prj}quota sunit= swidth=
- swalloc' -- "$cur"))
+ _comp_compgen -a -- -W 'allocsize= {,no}attr2 barrier dmapi
+ {,no}grpid {bsd,sysv}groups ihashsize= {,no}ikeep
+ inode{32,64} {,no}largeio logbufs= logbsize= logdev=
+ rtdev= mtpt= noalign norecovery nouuid osyncisosync
+ {u,g,p}qnoenforce {,u,usr,g,grp,p,prj}quota sunit=
+ swidth= swalloc'
;;&
esac
# COMP_WORDBREAKS is a real pain in the ass
- prev="${prev##*[$COMP_WORDBREAKS]}"
- $split && COMPREPLY=(${COMPREPLY[@]/#/"$prev,"})
+ prev="${prev##*["$COMP_WORDBREAKS"]}"
+ [[ $split ]] && ((${COMPREPLY[@]})) &&
+ _comp_compgen -Rv COMPREPLY -- -P "$prev," -W '"${COMPREPLY[@]}"'
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--version --help --verbose --all --fork
- --fake --internal-only -l --no-mtab --no-canonicalize --pass-fd -s
+ _comp_compgen -- -W '--version --help --verbose --all --fork --fake
+ --internal-only -l --no-mtab --no-canonicalize --pass-fd -s
--read-only --rw -L -U --types --test-opts --options --bind --rbind
- --move' -- "$cur"))
+ --move'
[[ ${COMPREPLY-} ]] && return
fi
@@ -227,8 +225,9 @@ _mount()
if [[ $cur == *:* ]]; then
for sm in "$(type -P showmount)" {,/usr}/{,s}bin/showmount; do
[[ -x $sm ]] || continue
- COMPREPLY=($(compgen -W "$("$sm" -e ${cur%%:*} |
- awk 'NR>1 {print $1}')" -- "${cur#*:}"))
+ _comp_compgen -c "${cur#*:}" split -- "$(
+ "$sm" -e ${cur%%:*} | _comp_awk 'NR>1 {print $1}'
+ )"
return
done
fi
@@ -236,17 +235,17 @@ _mount()
if [[ $cur == //* ]]; then
host=${cur#//}
host=${host%%/*}
- if [[ -n $host ]]; then
- COMPREPLY=($(compgen -P "//$host" -W \
- "$(smbclient -d 0 -NL $host 2>/dev/null |
+ if [[ $host ]]; then
+ _comp_compgen -c "${cur#//"$host"}" split -P "//$host" -- "$(
+ smbclient -d 0 -NL "$host" 2>/dev/null |
command sed -ne '/^[[:blank:]]*Sharename/,/^$/p' |
- command sed -ne '3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p')" \
- -- "${cur#//$host}"))
+ command sed -ne '3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p'
+ )"
fi
fi
- _filedir
+ _comp_compgen -a filedir
} &&
- complete -F _mount mount
+ complete -F _comp_cmd_mount mount
# ex: filetype=sh
diff --git a/completions/_newgrp b/completions/_newgrp
index a2dc3ed..7e86672 100644
--- a/completions/_newgrp
+++ b/completions/_newgrp
@@ -3,17 +3,17 @@
# Use of this file is deprecated on Linux. Upstream completion is
# available in util-linux >= 2.23, use that instead.
-_newgrp()
+_comp_cmd_newgrp()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == "-" ]]; then
COMPREPLY=(-)
else
- _allowed_groups "$cur"
+ _comp_compgen_allowed_groups
fi
} &&
- complete -F _newgrp newgrp
+ complete -F _comp_cmd_newgrp newgrp
# ex: filetype=sh
diff --git a/completions/_nmcli b/completions/_nmcli
index eac285b..835db99 100644
--- a/completions/_nmcli
+++ b/completions/_nmcli
@@ -3,83 +3,76 @@
# Use of this file is deprecated. Upstream completion is available in
# NetworkManager >= 0.9.8.0, use that instead.
-_nmcli_list()
+_comp_cmd_nmcli__con_id()
{
- COMPREPLY=($(compgen -W '$1' -- "$cur"))
+ _comp_compgen_split -l -- "$(nmcli con list 2>/dev/null |
+ tail -n +2 | _comp_awk -F ' {2,}' '{print $1}')"
}
-_nmcli_con_id()
+_comp_cmd_nmcli__con_uuid()
{
- local IFS=$'\n'
- COMPREPLY=($(compgen -W "$(nmcli con list 2>/dev/null |
- tail -n +2 | awk -F ' {2,}' '{print $1 }')" -- "$cur"))
+ _comp_compgen_split -- "$(nmcli con list 2>/dev/null |
+ tail -n +2 | _comp_awk -F ' {2,}' '{print $2}')"
}
-_nmcli_con_uuid()
+_comp_cmd_nmcli__ap_ssid()
{
- COMPREPLY=($(compgen -W "$(nmcli con list 2>/dev/null |
- tail -n +2 | awk -F ' {2,}' '{print $2}')" -- "$cur"))
+ _comp_compgen_split -l -- "$(nmcli dev wifi list 2>/dev/null |
+ tail -n +2 | _comp_awk -F ' {2,}' '{print $1}')"
}
-_nmcli_ap_ssid()
+_comp_cmd_nmcli__ap_bssid()
{
- local IFS=$'\n'
- COMPREPLY=($(compgen -W "$(nmcli dev wifi list 2>/dev/null |
- tail -n +2 | awk -F ' {2,}' '{print $1}')" -- "$cur"))
+ _comp_compgen_split -- "$(nmcli dev wifi list 2>/dev/null |
+ tail -n +2 | _comp_awk -F ' {2,}' '{print $2}')"
}
-_nmcli_ab_bssid()
+_comp_cmd_nmcli()
{
- COMPREPLY=($(compgen -W "$(nmcli dev wifi list 2>/dev/null |
- tail -n +2 | awk -F ' {2,}' '{print $2}')" -- "$cur"))
-}
-
-_nmcli()
-{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-m | --mode)
- COMPREPLY=($(compgen -W 'tabular multiline' -- "$cur"))
+ _comp_compgen -- -W 'tabular multiline'
return
;;
-f | --fields)
- COMPREPLY=($(compgen -W 'all common' -- "$cur"))
+ _comp_compgen -- -W 'all common'
return
;;
-e | --escape)
- _nmcli_list "yes no"
+ _comp_compgen -- -W "yes no"
return
;;
id)
- _nmcli_con_id
+ _comp_cmd_nmcli__con_id
return
;;
uuid)
- _nmcli_con_uuid
+ _comp_cmd_nmcli__con_uuid
return
;;
iface)
- _available_interfaces
+ _comp_compgen_available_interfaces
return
;;
bssid)
- _nmcli_ab_bssid
+ _comp_cmd_nmcli__ap_bssid
return
;;
wep-key-type)
- _nmcli_list "key phrase"
+ _comp_compgen -- -W "key phrase"
return
;;
esac
if ((cword == 1)); then
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--terse --pretty --mode --fields
- --escape --version --help' -- "$cur"))
+ _comp_compgen -- -W '--terse --pretty --mode --fields --escape
+ --version --help'
else
- COMPREPLY=($(compgen -W "nm con dev" -- "$cur"))
+ _comp_compgen -- -W "nm con dev"
fi
else
local object=${words[1]}
@@ -89,71 +82,67 @@ _nmcli()
nm)
case $command in
enable)
- _nmcli_list "true false"
+ _comp_compgen -- -W "true false"
return
;;
sleep)
- _nmcli_list "true false"
+ _comp_compgen -- -W "true false"
return
;;
wifi)
- _nmcli_list "on off"
+ _comp_compgen -- -W "on off"
return
;;
wwan)
- _nmcli_list "on off"
+ _comp_compgen -- -W "on off"
return
;;
wimax)
- _nmcli_list "on off"
+ _comp_compgen -- -W "on off"
return
;;
esac
- COMPREPLY=($(compgen -W 'status permissions enable sleep
- wifi wwan wimax' -- "$cur"))
+ _comp_compgen -- -W 'status permissions enable sleep wifi wwan
+ wimax'
;;
con)
case $command in
list)
- COMPREPLY=($(compgen -W 'id uuid' -- "$cur"))
+ _comp_compgen -- -W 'id uuid'
return
;;
up)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--nowait --timeout' \
- -- "$cur"))
+ _comp_compgen -- -W '--nowait --timeout'
else
- COMPREPLY=($(compgen -W 'id uuid iface ap nsp' \
- -- "$cur"))
+ _comp_compgen -- -W 'id uuid iface ap nsp'
fi
return
;;
down)
- COMPREPLY=($(compgen -W 'id uuid' -- "$cur"))
+ _comp_compgen -- -W 'id uuid'
return
;;
delete)
- COMPREPLY=($(compgen -W 'id uuid' -- "$cur"))
+ _comp_compgen -- -W 'id uuid'
return
;;
esac
- COMPREPLY=($(compgen -W 'list status up down delete' \
- -- "$cur"))
+ _comp_compgen -- -W 'list status up down delete'
;;
dev)
case $command in
list)
- COMPREPLY=($(compgen -W 'iface' -- "$cur"))
+ _comp_compgen -- -W 'iface'
return
;;
disconnect)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--nowait --timeout' \
- -- "$cur"))
+ _comp_compgen -- -W '--nowait --timeout'
else
- COMPREPLY=($(compgen -W 'iface' -- "$cur"))
+ _comp_compgen -- -W 'iface'
fi
return
;;
@@ -162,40 +151,37 @@ _nmcli()
case $subcommand in
list)
- COMPREPLY=($(compgen -W 'iface bssid' \
- -- "$cur"))
+ _comp_compgen -- -W 'iface bssid'
return
;;
connect)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--private
- --nowait --timeout' -- "$cur"))
+ _comp_compgen -- -W '--private --nowait
+ --timeout'
else
if [[ $prev == "connect" ]]; then
- _nmcli_ap_ssid
+ _comp_cmd_nmcli__ap_ssid
else
- COMPREPLY=($(compgen -W 'password
- wep-key-type iface bssid name' \
- -- "$cur"))
+ _comp_compgen -- -W 'password
+ wep-key-type iface bssid name'
fi
fi
return
;;
esac
- COMPREPLY=($(compgen -W 'list connect' -- "$cur"))
+ _comp_compgen -- -W 'list connect'
return
;;
esac
- COMPREPLY=($(compgen -W 'status list disconnect wifi' \
- -- "$cur"))
+ _comp_compgen -- -W 'status list disconnect wifi'
;;
esac
fi
} &&
- complete -F _nmcli nmcli
+ complete -F _comp_cmd_nmcli nmcli
# ex: filetype=sh
diff --git a/completions/_nox b/completions/_nox
new file mode 100644
index 0000000..40b8bb1
--- /dev/null
+++ b/completions/_nox
@@ -0,0 +1,13 @@
+# 3rd party completion loader for argcomplete commands -*- shell-script -*-
+# sourced using no args to `register-python-argcomplete`.
+#
+# This serves as a fallback in case the completion is not installed otherwise.
+
+eval -- "$(
+ bin_path=$(type -P "$1" 2>/dev/null | command sed 's,/[^/]*$,,')
+ [[ $bin_path ]] && PATH=$bin_path${PATH:+:$PATH}
+ register-python-argcomplete --shell bash "$1" 2>/dev/null ||
+ register-python-argcomplete3 --shell bash "$1" 2>/dev/null
+)"
+
+# ex: filetype=sh
diff --git a/completions/_nvm b/completions/_nvm
new file mode 100644
index 0000000..e5c2a46
--- /dev/null
+++ b/completions/_nvm
@@ -0,0 +1,8 @@
+# 3rd party completion loader for nvm -*- shell-script -*-
+#
+# This serves as a fallback in case the completion is not installed otherwise.
+
+# shellcheck disable=SC1091
+[[ ${NVM_DIR-} && -r $NVM_DIR/bash_completion ]] && . "$NVM_DIR"/bash_completion
+
+# ex: filetype=sh
diff --git a/completions/_pip b/completions/_pip
new file mode 100644
index 0000000..4439aa7
--- /dev/null
+++ b/completions/_pip
@@ -0,0 +1,9 @@
+# 3rd party completion loader for commands emitting -*- shell-script -*-
+# their completion using "$cmd completion --bash". For example, pip uses this
+# form of dynamic completions.
+#
+# This serves as a fallback in case the completion is not installed otherwise.
+
+eval -- "$("$1" completion --bash 2>/dev/null)"
+
+# ex: filetype=sh
diff --git a/completions/_pipenv b/completions/_pipenv
new file mode 100644
index 0000000..e6d2df6
--- /dev/null
+++ b/completions/_pipenv
@@ -0,0 +1,15 @@
+# 3rd party completion loader for commands emitting -*- shell-script -*-
+# their completion using "_${cmdname^^}_COMPLETE=bash_source $cmd".
+# This pattern is used by programs built with https://click.palletsprojects.com
+#
+# This serves as a fallback in case the completion is not installed otherwise.
+
+eval -- "$(
+ # shellcheck disable=SC2154
+ ucname="${cmdname^^}"
+ ucname=${ucname//-/_}
+ export "_${ucname}_COMPLETE=bash_source"
+ "$1" 2>/dev/null
+)"
+
+# ex: filetype=sh
diff --git a/completions/_renice b/completions/_renice
index a416744..06811ed 100644
--- a/completions/_renice
+++ b/completions/_renice
@@ -3,10 +3,10 @@
# Use of this file is deprecated on Linux. Upstream completion is
# available in util-linux >= 2.23, use that instead.
-_renice()
+_comp_cmd_renice()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local command=$1 curopt i=0
@@ -15,18 +15,18 @@ _renice()
curopt=${words[cword - i]}
case "$curopt" in
-u)
- _allowed_users
+ _comp_compgen_allowed_users
;;
-g)
- _pgids
+ _comp_compgen_pgids
;;
-p | "$command")
- _pids
+ _comp_compgen_pids
;;
esac
((i++))
done
} &&
- complete -F _renice renice
+ complete -F _comp_cmd_renice renice
# ex: filetype=sh
diff --git a/completions/_repomanage b/completions/_repomanage
index ba0787e..3a7c5ad 100644
--- a/completions/_repomanage
+++ b/completions/_repomanage
@@ -3,22 +3,22 @@
# Use of this file is deprecated. Upstream completion is available in
# yum-utils >= 1.1.24, use that instead.
-_repomanage()
+_comp_cmd_repomanage()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
[[ $prev == -@([hk]|-help|-keep) ]] && return
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- _filedir -d
+ _comp_compgen_filedir -d
fi
} &&
- complete -F _repomanage repomanage
+ complete -F _comp_cmd_repomanage repomanage
# ex: filetype=sh
diff --git a/completions/_reptyr b/completions/_reptyr
index 01d61b2..266a545 100644
--- a/completions/_reptyr
+++ b/completions/_reptyr
@@ -3,10 +3,10 @@
# Use of this file is deprecated. Upstream completion is available in
# reptyr > 0.6.2, use that instead.
-_reptyr()
+_comp_cmd_reptyr()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-l)
@@ -15,12 +15,12 @@ _reptyr()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- [[ $prev != +([0-9]) ]] && _pids
+ [[ $prev != +([0-9]) ]] && _comp_compgen_pids
} &&
- complete -F _reptyr reptyr
+ complete -F _comp_cmd_reptyr reptyr
# ex: filetype=sh
diff --git a/completions/_rfkill b/completions/_rfkill
index 96a6c09..c4733e7 100644
--- a/completions/_rfkill
+++ b/completions/_rfkill
@@ -3,29 +3,28 @@
# Use of this file is deprecated on systems with util-linux >= 2.31, which
# ships completion for the rfkill included with it.
-_rfkill()
+_comp_cmd_rfkill()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--version' -- "$cur"))
+ _comp_compgen -- -W '--version'
else
case $cword in
1)
- COMPREPLY=($(compgen -W "help event list block unblock" \
- -- "$cur"))
+ _comp_compgen -- -W "help event list block unblock"
;;
2)
if [[ $prev == block || $prev == unblock ]]; then
- COMPREPLY=($(compgen -W "$($1 list | awk -F: \
- '/^[0-9]/ {print $1}') all wifi bluetooth uwb wimax \
- wwan gps" -- "$cur"))
+ _comp_compgen_split -- "
+ $("$1" list | _comp_awk -F : '/^[0-9]/ {print $1}')
+ all wifi bluetooth uwb wimax wwan gps"
fi
;;
esac
fi
} &&
- complete -F _rfkill rfkill
+ complete -F _comp_cmd_rfkill rfkill
# ex: filetype=sh
diff --git a/completions/_rtcwake b/completions/_rtcwake
index 4ca452d..535079e 100644
--- a/completions/_rtcwake
+++ b/completions/_rtcwake
@@ -3,30 +3,30 @@
# Use of this file is deprecated. Upstream completion is available in
# util-linux >= 2.23, use that instead.
-_rtcwake()
+_comp_cmd_rtcwake()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case "$prev" in
--help | -h | --version | -V | --seconds | -s | --time | -t)
return
;;
--mode | -m)
- COMPREPLY=($(compgen -W 'standby mem disk on no off' -- "$cur"))
+ _comp_compgen -- -W 'standby mem disk on no off'
return
;;
--device | -d)
- COMPREPLY=($(command ls -d /dev/rtc?* 2>/dev/null))
- COMPREPLY=($(compgen -W '${COMPREPLY[@]#/dev/}' -- "$cur"))
+ _comp_expand_glob COMPREPLY '/dev/rtc?*' &&
+ _comp_compgen -- -W '"${COMPREPLY[@]#/dev/}"'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
} &&
- complete -F _rtcwake rtcwake
+ complete -F _comp_cmd_rtcwake rtcwake
# ex: filetype=sh
diff --git a/completions/_ruff b/completions/_ruff
new file mode 100644
index 0000000..b5fd1a5
--- /dev/null
+++ b/completions/_ruff
@@ -0,0 +1,8 @@
+# 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)"
+
+# ex: filetype=sh
diff --git a/completions/_rustup b/completions/_rustup
new file mode 100644
index 0000000..1bcf44d
--- /dev/null
+++ b/completions/_rustup
@@ -0,0 +1,7 @@
+# 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)"
+
+# ex: filetype=sh
diff --git a/completions/_slackpkg b/completions/_slackpkg
new file mode 100644
index 0000000..f8f7810
--- /dev/null
+++ b/completions/_slackpkg
@@ -0,0 +1,111 @@
+# bash completion for slackpkg(8) -*- shell-script -*-
+# options list is based on `grep '\-.*\=.*)' /usr/sbin/slackpkg | cut -f1 -d\)`
+
+# Use of this file is deprecated.
+# Upstream completion is available in slackpkg >= 15.0.4, use that instead.
+
+_comp_cmd_slackpkg()
+{
+ local cur prev words cword comp_args
+ _comp_initialize -n = -- "$@" || return
+
+ local split=""
+ if [[ $cur == -?*=* ]]; then
+ prev="${cur%%?(\\)=*}"
+ cur="${cur#*=}"
+ split=set
+ fi
+
+ case "$prev" in
+ -delall | -checkmd5 | -checkgpg | -checksize | -postinst | -onoff | \
+ -download_all | -dialog | -batch | -only_new_dotnew | \
+ -use_includes | -spinning)
+ _comp_compgen -- -W 'on off'
+ return
+ ;;
+ -default_answer)
+ _comp_compgen -- -W 'yes no'
+ return
+ ;;
+ -dialog_maxargs | -mirror)
+ # argument required but no completions available
+ return
+ ;;
+ esac
+
+ [[ $split ]] && return
+
+ if [[ $cur == -* ]]; then
+ compopt -o nospace
+ _comp_compgen -- -W '-delall= -checkmd5= -checkgpg= -checksize=
+ -postinst= -onoff= -download_all= -dialog= -dialog_maxargs= -batch=
+ -only_new_dotnew= -use_includes= -spinning= -default_answer=
+ -mirror='
+ return
+ fi
+
+ local confdir="/etc/slackpkg"
+ local config="$confdir/slackpkg.conf"
+
+ [[ -r $config ]] || return
+ . "$config"
+
+ local i action
+ for ((i = 1; i < cword; i++)); do
+ if [[ ${words[i]} != -* ]]; then
+ action="${words[i]}"
+ break
+ fi
+ done
+
+ case "$action" in
+ generate-template | search | file-search)
+ # argument required but no completions available
+ return
+ ;;
+ install-template | remove-template)
+ if [[ -e $confdir/templates ]]; then
+ _comp_compgen -C "$confdir/templates" -- -f -X \
+ "!?*.template" && COMPREPLY=("${COMPREPLY[@]%.template}")
+ fi
+ return
+ ;;
+ remove)
+ _comp_compgen_filedir
+ _comp_compgen -a -- -W 'a ap d e f k kde kdei l n t tcl x xap xfce
+ y'
+ _comp_compgen -aC /var/log/packages -- -f
+ return
+ ;;
+ install | reinstall | upgrade | blacklist | download)
+ _comp_compgen_filedir
+ _comp_compgen -a -- -W 'a ap d e f k kde kdei l n t tcl x xap xfce
+ y'
+ _comp_compgen -a split -l -- "$(
+ cut -f 6 -d\ "${WORKDIR}/pkglist" 2>/dev/null
+ )"
+ return
+ ;;
+ info)
+ _comp_compgen_split "$(
+ cut -f 6 -d\ "${WORKDIR}/pkglist" 2>/dev/null
+ )"
+ return
+ ;;
+ update)
+ # we should complete the same as the next `list` + "gpg"
+ _comp_compgen -- -W 'gpg'
+ ;&
+ *)
+ _comp_compgen -a -- -W 'install reinstall upgrade remove blacklist
+ download update install-new upgrade-all clean-system new-config
+ check-updates help generate-template install-template
+ remove-template search file-search info'
+ return
+ ;;
+ esac
+
+} &&
+ complete -F _comp_cmd_slackpkg slackpkg
+
+# ex: filetype=sh
diff --git a/completions/_su b/completions/_su
index 1a03c8f..3354447 100644
--- a/completions/_su
+++ b/completions/_su
@@ -8,34 +8,32 @@ if [[ $OSTYPE != *linux* ]]; then
return
fi
-_su()
+_comp_cmd_su()
{ # linux-specific completion
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case "$prev" in
-s | --shell)
- _shells
+ _comp_compgen_shells
return
;;
-c | --command | --session-command)
- local IFS=$'\n'
- compopt -o filenames
- COMPREPLY=($(compgen -d -c -- "$cur"))
+ _comp_compgen_commands
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
} &&
- complete -F _su su
+ complete -F _comp_cmd_su su
# ex: filetype=sh
diff --git a/completions/_svn b/completions/_svn
index 5d85c2b..862b62c 100644
--- a/completions/_svn
+++ b/completions/_svn
@@ -3,10 +3,10 @@
# Use of this file is deprecated. Upstream completion is available in
# subversion >= 0.12.0, use that instead.
-_svn()
+_comp_cmd_svn()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local commands
commands='add blame praise annotate ann cat checkout co cleanup commit \
@@ -18,28 +18,27 @@ _svn()
if ((cword == 1)); then
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--version' -- "$cur"))
+ _comp_compgen -- -W '--version'
else
- COMPREPLY=($(compgen -W "$commands" -- "$cur"))
+ _comp_compgen -- -W "$commands"
fi
else
case $prev in
--config-dir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-F | --file | --targets)
- _filedir
+ _comp_compgen_filedir
return
;;
--encoding)
- _xfunc iconv _iconv_charsets
+ _comp_compgen -x iconv charsets
return
;;
--editor-cmd | --diff-cmd | --diff3-cmd)
- compopt -o filenames
- COMPREPLY=($(compgen -c -- "$cur"))
+ _comp_compgen_commands
return
;;
esac
@@ -194,17 +193,17 @@ _svn()
esac
options+=" --help --config-dir"
- COMPREPLY=($(compgen -W "$options" -- "$cur"))
+ _comp_compgen -- -W "$options"
else
if [[ $command == @(help|[h?]) ]]; then
- COMPREPLY=($(compgen -W "$commands" -- "$cur"))
+ _comp_compgen -- -W "$commands"
else
- _filedir
+ _comp_compgen_filedir
fi
fi
fi
} &&
- complete -F _svn svn
+ complete -F _comp_cmd_svn svn
# ex: filetype=sh
diff --git a/completions/_svnadmin b/completions/_svnadmin
index 654fd3e..6b4a423 100644
--- a/completions/_svnadmin
+++ b/completions/_svnadmin
@@ -3,10 +3,10 @@
# Use of this file is deprecated. Upstream completion is available in
# subversion >= 0.12.0, use that instead.
-_svnadmin()
+_comp_cmd_svnadmin()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local commands
commands='create deltify dump help ? hotcopy list-dblogs list-unused-dblogs
@@ -14,18 +14,18 @@ _svnadmin()
if ((cword == 1)); then
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--version' -- "$cur"))
+ _comp_compgen -- -W '--version'
else
- COMPREPLY=($(compgen -W "$commands" -- "$cur"))
+ _comp_compgen -- -W "$commands"
fi
else
case $prev in
--config-dir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
--fs-type)
- COMPREPLY=($(compgen -W 'fsfs bdb' -- "$cur"))
+ _comp_compgen -- -W 'fsfs bdb'
return
;;
esac
@@ -62,17 +62,17 @@ _svnadmin()
esac
options+=" --help"
- COMPREPLY=($(compgen -W "$options" -- "$cur"))
+ _comp_compgen -- -W "$options"
else
if [[ $command == @(help|[h?]) ]]; then
- COMPREPLY=($(compgen -W "$commands" -- "$cur"))
+ _comp_compgen -- -W "$commands"
else
- _filedir
+ _comp_compgen_filedir
fi
fi
fi
} &&
- complete -F _svnadmin -o default svnadmin
+ complete -F _comp_cmd_svnadmin -o default svnadmin
# ex: filetype=sh
diff --git a/completions/_svnlook b/completions/_svnlook
index 36188a5..f0c01df 100644
--- a/completions/_svnlook
+++ b/completions/_svnlook
@@ -3,10 +3,10 @@
# Use of this file is deprecated. Upstream completion is available in
# subversion >= 0.12.0, use that instead.
-_svnlook()
+_comp_cmd_svnlook()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local commands
commands='author cat changed date diff dirs-changed help ? h history info
@@ -14,9 +14,9 @@ _svnlook()
if ((cword == 1)); then
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--version' -- "$cur"))
+ _comp_compgen -- -W '--version'
else
- COMPREPLY=($(compgen -W "$commands" -- "$cur"))
+ _comp_compgen -- -W "$commands"
fi
else
local command=${words[1]}
@@ -47,17 +47,17 @@ _svnlook()
esac
options+=" --help"
- COMPREPLY=($(compgen -W "$options" -- "$cur"))
+ _comp_compgen -- -W "$options"
else
if [[ $command == @(help|[h?]) ]]; then
- COMPREPLY=($(compgen -W "$commands" -- "$cur"))
+ _comp_compgen -- -W "$commands"
else
- _filedir
+ _comp_compgen_filedir
fi
fi
fi
} &&
- complete -F _svnlook -o default svnlook
+ complete -F _comp_cmd_svnlook -o default svnlook
# ex: filetype=sh
diff --git a/completions/_tokio-console b/completions/_tokio-console
new file mode 100644
index 0000000..c170044
--- /dev/null
+++ b/completions/_tokio-console
@@ -0,0 +1,8 @@
+# 3rd party completion loader for commands emitting -*- shell-script -*-
+# their completion using "$cmd gen-completion bash".
+#
+# This serves as a fallback in case the completion is not installed otherwise.
+
+eval -- "$("$1" gen-completion bash 2>/dev/null)"
+
+# ex: filetype=sh
diff --git a/completions/_udevadm b/completions/_udevadm
index 19624be..6a3c351 100644
--- a/completions/_udevadm
+++ b/completions/_udevadm
@@ -3,75 +3,73 @@
# Use of this file is deprecated. Upstream completion is available in
# systemd >= 196, use that instead.
-_udevadm()
+_comp_cmd_udevadm()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
- local i udevcmd
+ local i udevcmd="" has_udevcmd=""
for ((i = 1; i < cword; i++)); do
if [[ ${words[i]} != -* ]]; then
udevcmd=${words[i]}
+ has_udevcmd=set
break
fi
done
case $prev in
- --help | --version | --property | --children-max | --timeout | --seq-start | \
- --seq-end | --attr-match | --attr-nomatch | --parent-match | --property-match | \
- --tag-match | --subsystem-match | --subsystem-nomatch | --sysname-match | \
- --path)
+ --help | --version | --property | --children-max | --timeout | \
+ --seq-start | --seq-end | --attr-match | --attr-nomatch | \
+ --parent-match | --property-match | --tag-match | \
+ --subsystem-match | --subsystem-nomatch | --sysname-match | --path)
return
;;
--log-priority)
- COMPREPLY=($(compgen -W 'err info debug' -- "$cur"))
+ _comp_compgen -- -W 'err info debug'
return
;;
--query)
- COMPREPLY=($(compgen -W 'name symlink path property all' \
- -- "$cur"))
+ _comp_compgen -- -W 'name symlink path property all'
return
;;
--name)
- cur=${cur:=/dev/}
- _filedir
+ _comp_compgen -c "${cur:-/dev/}" filedir
return
;;
--device-id-of-file | --exit-if-exists)
- _filedir
+ _comp_compgen_filedir
return
;;
--action)
- COMPREPLY=($(compgen -W 'add change remove' -- "$cur"))
+ _comp_compgen -- -W 'add change remove'
return
;;
--type)
- COMPREPLY=($(compgen -W 'devices subsystems failed' -- "$cur"))
+ _comp_compgen -- -W 'devices subsystems failed'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
- if [[ ! -v udevcmd ]]; then
+ if [[ ! $has_udevcmd ]]; then
case $cur in
-*)
- COMPREPLY=($(compgen -W '--help --version --debug' -- "$cur"))
+ _comp_compgen -- -W '--help --version --debug'
;;
*)
- COMPREPLY=($(compgen -W "$("$1" --help 2>/dev/null |
- awk '/^[ \t]/ { print $1 }')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" --help 2>/dev/null |
+ _comp_awk '/^[ \t]/ { print $1 }')"
;;
esac
return
fi
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W \
- '$("$1" ${udevcmd-} --help 2>/dev/null | _parse_help -)' -- "$cur"))
+ _comp_compgen_help -- ${has_udevcmd:+"$udevcmd"} --help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _udevadm udevadm
+ complete -F _comp_cmd_udevadm udevadm
# ex: filetype=sh
diff --git a/completions/_umount b/completions/_umount
index 36d5703..5a453a8 100644
--- a/completions/_umount
+++ b/completions/_umount
@@ -11,14 +11,13 @@ fi
# umount(8) completion. This relies on the mount point being the third
# space-delimited field in the output of mount(8)
#
-_umount()
+_comp_cmd_umount()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- local IFS=$'\n'
- COMPREPLY=($(compgen -W '$(mount | cut -d" " -f 3)' -- "$cur"))
+ _comp_compgen_split -l -- "$(mount | cut -d" " -f 3)"
} &&
- complete -F _umount -o dirnames umount
+ complete -F _comp_cmd_umount -o dirnames umount
# ex: filetype=sh
diff --git a/completions/_umount.linux b/completions/_umount.linux
index cf8a259..ca515c8 100644
--- a/completions/_umount.linux
+++ b/completions/_umount.linux
@@ -6,7 +6,7 @@
# Just like COMPREPLY=(`compgen -W "${COMPREPLY[*]}" -- "$cur"`), only better!
#
# This will correctly escape special characters in COMPREPLY.
-_reply_compgen_array()
+_comp_cmd_umount__reply_compgen_array()
{
# Create the argument for compgen -W by escaping twice.
#
@@ -15,8 +15,10 @@ _reply_compgen_array()
# argument.
local i wlist
for i in ${!COMPREPLY[*]}; do
- local q=$(quote "$(printf %q "${COMPREPLY[i]}")")
- wlist+=$q$'\n'
+ local REPLY
+ printf -v REPLY %q "${COMPREPLY[i]}"
+ _comp_quote "$REPLY"
+ wlist+=$REPLY$'\n'
done
# We also have to add another round of escaping to $cur.
@@ -25,16 +27,14 @@ _reply_compgen_array()
ecur=${ecur//\'/\\\'}
# Actually generate completions.
- local ifs=$IFS
- IFS=$'\n' eval 'COMPREPLY=(`compgen -W "$wlist" -- "${ecur}"`)'
- IFS=$ifs
+ _comp_compgen -lc "${ecur}" -- -W "$wlist"
}
# Unescape strings in the linux fstab(5) format (with octal escapes).
-__linux_fstab_unescape()
+_comp_cmd_umount__linux_fstab_unescape()
{
- eval $1="'${!1//\'/\\047}'"
- eval $1="'${!1/%\\/\\\\}'"
+ eval "$1='${!1//\'/\\047}'"
+ eval "$1='${!1/%\\/\\\\}'"
eval "$1=$'${!1}'"
}
@@ -43,30 +43,25 @@ __linux_fstab_unescape()
# Reads a file from stdin in the linux fstab(5) format; as used by /etc/fstab
# and /proc/mounts. With 1st arg -L, look for entries by label.
# shellcheck disable=SC2120
-_linux_fstab()
+_comp_cmd_umount__linux_fstab()
{
COMPREPLY=()
# Read and unescape values into COMPREPLY
local fs_spec fs_file fs_other
- local ifs="$IFS"
while read -r fs_spec fs_file fs_other; do
if [[ $fs_spec == [#]* ]]; then continue; fi
if [[ ${1-} == -L ]]; then
local fs_label=${fs_spec/#LABEL=/}
if [[ $fs_label != "$fs_spec" ]]; then
- __linux_fstab_unescape fs_label
- IFS=$'\0'
+ _comp_cmd_umount__linux_fstab_unescape fs_label
COMPREPLY+=("$fs_label")
- IFS=$ifs
fi
else
- __linux_fstab_unescape fs_spec
- __linux_fstab_unescape fs_file
- IFS=$'\0'
+ _comp_cmd_umount__linux_fstab_unescape fs_spec
+ _comp_cmd_umount__linux_fstab_unescape fs_file
[[ $fs_spec == */* ]] && COMPREPLY+=("$fs_spec")
[[ $fs_file == */* ]] && COMPREPLY+=("$fs_file")
- IFS=$ifs
fi
done
@@ -86,37 +81,37 @@ _linux_fstab()
local i
for i in ${!COMPREPLY[*]}; do
[[ ${COMPREPLY[i]} == "$realcur"* ]] &&
- COMPREPLY+=($(cd "$dircur" 2>/dev/null &&
- compgen -f -d -P "$dircur" \
- -X "!${COMPREPLY[i]##"$dirrealcur"}" -- "$basecur"))
+ _comp_compgen -aC "$dircur" -c "$basecur" -- \
+ -f -d -P "$dircur" -X "!${COMPREPLY[i]##"$dirrealcur"}"
done
fi
fi
- _reply_compgen_array
+ _comp_cmd_umount__reply_compgen_array
}
-_umount()
+_comp_cmd_umount()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case "$prev" in
-t)
# FIXME: no<fstype>
- local split=false
+ local split=""
if [[ $cur == ?*,* ]]; then
prev="${cur%,*}"
cur="${cur##*,}"
- split=true
+ split=set
fi
- COMPREPLY=($(compgen -W 'adfs affs autofs btrfs cifs coda
- cramfs debugfs devpts efs ext2 ext3 ext4 fuse hfs hfsplus hpfs
- iso9660 jfs minix msdos ncpfs nfs nfs4 ntfs ntfs-3g proc qnx4
- ramfs reiserfs romfs squashfs smbfs sysv tmpfs ubifs udf ufs
- umsdos usbfs vfat xfs' -- "$cur"))
- _fstypes
- $split && COMPREPLY=(${COMPREPLY[@]/#/$prev,})
+ _comp_compgen -- -W 'adfs affs autofs btrfs cifs coda cramfs
+ debugfs devpts efs ext2 ext3 ext4 fuse hfs hfsplus hpfs iso9660
+ jfs minix msdos ncpfs nfs nfs4 ntfs ntfs-3g proc qnx4 ramfs
+ reiserfs romfs squashfs smbfs sysv tmpfs ubifs udf ufs umsdos
+ usbfs vfat xfs'
+ _comp_compgen -a fstypes
+ [[ $split ]] && ((${#COMPREPLY[@]})) &&
+ _comp_compgen -Rv COMPREPLY -- -P "$prev," -W '"${COMPREPLY[@]}"'
return
;;
-O)
@@ -126,20 +121,19 @@ _umount()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-V -h -v -n -r -d -i -a -t -O -f -l
- --no-canonicalize --fake' -- "$cur"))
+ _comp_compgen -- -W '-V -h -v -n -r -d -i -a -t -O -f -l
+ --no-canonicalize --fake'
[[ ${COMPREPLY-} ]] && return
fi
if [[ -r /proc/mounts ]]; then
# Linux /proc/mounts is properly quoted. This is important when
# unmounting usb devices with pretty names.
- _linux_fstab </proc/mounts
+ _comp_cmd_umount__linux_fstab </proc/mounts
else
- local IFS=$'\n'
- COMPREPLY=($(compgen -W '$(mount | cut -d" " -f 3)' -- "$cur"))
+ _comp_compgen_split -l -- "$(mount | cut -d" " -f 3)"
fi
} &&
- complete -F _umount -o dirnames umount
+ complete -F _comp_cmd_umount -o dirnames umount
# ex: filetype=sh
diff --git a/completions/_vault b/completions/_vault
new file mode 100644
index 0000000..25abbc2
--- /dev/null
+++ b/completions/_vault
@@ -0,0 +1,8 @@
+# 3rd party completion loader for commands -*- shell-script -*-
+# supporting their use of as a `complete -C` handler.
+#
+# This serves as a fallback in case the completion is not installed otherwise.
+
+type "$1" &>/dev/null && complete -C "\"$1\" 2>/dev/null" "$1"
+
+# ex: filetype=sh
diff --git a/completions/_xm b/completions/_xm
index 06b25d3..7577efd 100644
--- a/completions/_xm
+++ b/completions/_xm
@@ -4,26 +4,20 @@
# provided by upstream. It has been replaced with the 'xl' command, for
# which upstream provides completion, use that instead.
-_xen_domain_names()
+_comp_cmd_xm__domain_names()
{
- COMPREPLY=($(compgen -W "$(xm list 2>/dev/null |
- awk '!/Name|Domain-0/ { print $1 }')" -- "$cur"))
+ _comp_compgen_split -- "$(xm list 2>/dev/null |
+ _comp_awk '!/Name|Domain-0/ { print $1 }')"
}
-_xen_domain_ids()
+_comp_cmd_xm()
{
- COMPREPLY=($(compgen -W "$(xm list 2>/dev/null |
- awk '!/Name|Domain-0/ { print $2 }')" -- "$cur"))
-}
-
-_xm()
-{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- # TODO: _split_longopt
+ # TODO: split longopt
- local args command commands options
+ local REPLY command commands options
commands='console vncviewer create new delete destroy domid domname
dump-core list mem-max mem-set migrate pause reboot rename reset
@@ -37,7 +31,7 @@ _xm()
resetpolicy getpolicy shell help'
if ((cword == 1)); then
- COMPREPLY=($(compgen -W "$commands" -- "$cur"))
+ _comp_compgen -- -W "$commands"
else
if [[ $cur == *=* ]]; then
prev=${cur/=*/}
@@ -78,140 +72,139 @@ _xm()
-s --skipdtd -p --paused -c --console_autoconnect'
;;
esac
- COMPREPLY=($(compgen -W "$options" -- "$cur"))
+ _comp_compgen -- -W "$options"
else
case $command in
- console | destroy | domname | domid | list | mem-set | mem-max | \
- pause | reboot | rename | shutdown | unpause | vcpu-list | vcpu-pin | \
- vcpu-set | block-list | network-list | vtpm-list)
- _count_args
- case $args in
+ console | destroy | domname | domid | list | mem-set | \
+ mem-max | pause | reboot | rename | shutdown | unpause | \
+ vcpu-list | vcpu-pin | vcpu-set | block-list | \
+ network-list | vtpm-list)
+ _comp_count_args
+ case $REPLY in
2)
- _xen_domain_names
+ _comp_cmd_xm__domain_names
;;
esac
;;
migrate)
- _count_args
- case $args in
+ _comp_count_args
+ case $REPLY in
2)
- _xen_domain_names
+ _comp_cmd_xm__domain_names
;;
3)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
;;
esac
;;
restore | dry-run | vnet-create)
- _filedir
+ _comp_compgen_filedir
;;
save)
- _count_args
- case $args in
+ _comp_count_args
+ case $REPLY in
2)
- _xen_domain_names
+ _comp_cmd_xm__domain_names
;;
3)
- _filedir
+ _comp_compgen_filedir
;;
esac
;;
sysrq)
- _count_args
- case $args in
+ _comp_count_args
+ case $REPLY in
2)
- _xen_domain_names
+ _comp_cmd_xm__domain_names
;;
3)
- COMPREPLY=($(compgen -W "r s e i u b" -- "$cur"))
+ _comp_compgen -- -W "r s e i u b"
;;
esac
;;
block-attach)
- _count_args
- case $args in
+ _comp_count_args
+ case $REPLY in
2)
- _xen_domain_names
+ _comp_cmd_xm__domain_names
;;
3)
- COMPREPLY=($(compgen -W "phy: file:" -- "$cur"))
+ _comp_compgen -- -W "phy: file:"
;;
5)
- COMPREPLY=($(compgen -W "w r" -- "$cur"))
+ _comp_compgen -- -W "w r"
;;
6)
- _xen_domain_names
+ _comp_cmd_xm__domain_names
;;
esac
;;
block-detach)
- _count_args
- case $args in
+ _comp_count_args
+ case $REPLY in
2)
- _xen_domain_names
+ _comp_cmd_xm__domain_names
;;
3)
- COMPREPLY=($(compgen -W "$(xm block-list $prev \
- 2>/dev/null | awk '!/Vdev/ { print $1 }')" \
- -- "$cur"))
+ _comp_compgen_split -- "$(xm block-list "$prev" \
+ 2>/dev/null | _comp_awk '!/Vdev/ { print $1 }')"
;;
esac
;;
network-attach)
- _count_args
- case $args in
+ _comp_count_args
+ case $REPLY in
2)
- _xen_domain_names
+ _comp_cmd_xm__domain_names
;;
*)
- COMPREPLY=($(compgen -W "script= ip= mac= bridge=
- backend=" -- "$cur"))
+ _comp_compgen -- -W "script= ip= mac= bridge=
+ backend="
;;
esac
;;
network-detach)
- _count_args
- case $args in
+ _comp_count_args
+ case $REPLY in
2)
- _xen_domain_names
+ _comp_cmd_xm__domain_names
;;
3)
- COMPREPLY=($(compgen -W "$(xm network-list $prev \
- 2>/dev/null | awk '!/Idx/ { print $1 }')" \
- -- "$cur"))
+ _comp_compgen_split -- "$(xm network-list "$prev" \
+ 2>/dev/null | _comp_awk '!/Idx/ { print $1 }')"
;;
esac
;;
sched-credit)
case $prev in
-d)
- _xen_domain_names
+ _comp_cmd_xm__domain_names
return
;;
esac
;;
create)
- _filedir
- COMPREPLY+=(
- $(compgen -W '$(command ls /etc/xen 2>/dev/null)' \
- -- "$cur"))
+ _comp_compgen_filedir
+ _comp_compgen -a split -- "$(
+ command ls /etc/xen 2>/dev/null
+ )"
;;
new)
case $prev in
-f | -F | --defconfig | --config)
- _filedir
+ _comp_compgen_filedir
return
;;
--path)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
- _count_args
- case $args in
+ _comp_count_args
+ case $REPLY in
2)
- _xen_domain_names
+ _comp_cmd_xm__domain_names
;;
esac
;;
@@ -219,6 +212,6 @@ _xm()
fi
fi
} &&
- complete -F _xm xm
+ complete -F _comp_cmd_xm xm
# ex: filetype=sh
diff --git a/completions/_yq b/completions/_yq
new file mode 100644
index 0000000..c357bd9
--- /dev/null
+++ b/completions/_yq
@@ -0,0 +1,8 @@
+# 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)"
+
+# ex: filetype=sh
diff --git a/completions/_yum b/completions/_yum
index 224ea25..2899cb3 100644
--- a/completions/_yum
+++ b/completions/_yum
@@ -3,72 +3,79 @@
# Use of this file is deprecated. Upstream completion is available in
# yum > 3.2.25, use that instead.
-_yum_list()
+_comp_cmd_yum__list()
{
if [[ $1 == all ]]; then
# Try to strip in between headings like "Available Packages"
# This will obviously only work for English :P
- COMPREPLY=($(yum -d 0 -C list $1 "$cur*" 2>/dev/null |
- command sed -ne '/^Available /d' -e '/^Installed /d' -e '/^Updated /d' \
- -e 's/[[:space:]].*//p'))
+ _comp_split COMPREPLY "$(yum -d 0 -C list "$1" "$cur*" 2>/dev/null |
+ command sed -ne '/^Available /d' -e '/^Installed /d' \
+ -e '/^Updated /d' -e 's/[[:space:]].*//p')"
else
# Drop first line (e.g. "Updated Packages")
- COMPREPLY=($(yum -d 0 -C list $1 "$cur*" 2>/dev/null |
- command sed -ne 1d -e 's/[[:space:]].*//p'))
+ _comp_split COMPREPLY "$(yum -d 0 -C list "$1" "$cur*" 2>/dev/null |
+ command sed -ne 1d -e 's/[[:space:]].*//p')"
fi
}
-_yum_repolist()
+_comp_cmd_yum__compgen_repolist()
{
# -d 0 causes repolist to output nothing as of yum 3.2.22:
# http://yum.baseurl.org/ticket/83
# Drop first ("repo id repo name") and last ("repolist: ...") rows
- yum --noplugins -C repolist $1 2>/dev/null |
- command sed -ne '/^repo\s\s*id/d' -e '/^repolist:/d' -e 's/[[:space:]].*//p'
+ _comp_compgen_split -- "$(
+ yum --noplugins -C repolist "$1" 2>/dev/null |
+ command sed -ne '/^repo[[:space:]]\{1,\}id/d' -e '/^repolist:/d' \
+ -e 's/[[:space:]].*//p'
+ )"
}
-_yum_plugins()
+_comp_cmd_yum__compgen_plugins()
{
- command ls /usr/lib/yum-plugins/*.py{,c,o} 2>/dev/null |
- command sed -ne 's|.*/\([^./]*\)\.py[co]\{0,1\}$|\1|p' | sort -u
+ local -a files
+ _comp_expand_glob files '/usr/lib/yum-plugins/*.py{,c,o}' || return
+ _comp_compgen -U files split -- "$(
+ printf '%s\n' "${files[@]}" |
+ command sed -ne 's|.*/\([^./]*\)\.py[co]\{0,1\}$|\1|p' | sort -u
+ )"
}
-_yum()
+_comp_cmd_yum()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
- local special i
- for ((i = 1; i < ${#words[@]} - 1; i++)); do
+ local special="" i
+ for ((i = 1; i < cword; i++)); do
if [[ ${words[i]} == @(install|update|upgrade|remove|erase|deplist|info) ]]; then
special=${words[i]}
break
fi
done
- if [[ -v special ]]; then
+ if [[ $special ]]; then
# TODO: install|update|upgrade should not match *src.rpm
- if [[ $cur == @(*/|[.~])* && \
+ if [[ $cur == @(*/|[.~])* &&
$special == @(deplist|install|update|upgrade) ]]; then
- _filedir rpm
+ _comp_compgen_filedir rpm
return
fi
case $special in
install)
- _yum_list available
+ _comp_cmd_yum__list available
return
;;
deplist | info)
- _yum_list all
+ _comp_cmd_yum__list all
return
;;
upgrade | update)
- _yum_list updates
+ _comp_cmd_yum__list updates
return
;;
remove | erase)
- # _rpm_installed_packages is not arch-qualified
- _yum_list installed
+ # _comp_xfunc_rpm_installed_packages is not arch-qualified
+ _comp_cmd_yum__list installed
return
;;
esac
@@ -76,44 +83,43 @@ _yum()
case $prev in
list)
- COMPREPLY=($(compgen -W 'all available updates installed extras
- obsoletes recent' -- "$cur"))
+ _comp_compgen -- -W 'all available updates installed extras
+ obsoletes recent'
;;
clean)
- COMPREPLY=($(compgen -W 'packages headers metadata cache dbcache
- all' -- "$cur"))
+ _comp_compgen -- -W 'packages headers metadata cache dbcache all'
;;
repolist)
- COMPREPLY=($(compgen -W 'all enabled disabled' -- "$cur"))
+ _comp_compgen -- -W 'all enabled disabled'
;;
localinstall | localupdate)
# TODO: should not match *src.rpm
- _filedir rpm
+ _comp_compgen_filedir rpm
;;
-d | -e)
- COMPREPLY=($(compgen -W '{0..10}' -- "$cur"))
+ _comp_compgen -- -W '{0..10}'
;;
-c)
- _filedir
+ _comp_compgen_filedir
;;
--installroot)
- _filedir -d
+ _comp_compgen_filedir -d
;;
--enablerepo)
- COMPREPLY=($(compgen -W '$(_yum_repolist disabled)' -- "$cur"))
+ _comp_cmd_yum__compgen_repolist disabled
;;
--disablerepo)
- COMPREPLY=($(compgen -W '$(_yum_repolist enabled)' -- "$cur"))
+ _comp_cmd_yum__compgen_repolist enabled
;;
--disableexcludes)
- COMPREPLY=($(compgen -W '$(_yum_repolist all) all main' \
- -- "$cur"))
+ _comp_cmd_yum__compgen_repolist all
+ _comp_compgen -a -- -W "all main"
;;
--enableplugin | --disableplugin)
- COMPREPLY=($(compgen -W '$(_yum_plugins)' -- "$cur"))
+ _comp_cmd_yum__compgen_plugins
;;
--color)
- COMPREPLY=($(compgen -W 'always auto never' -- "$cur"))
+ _comp_compgen -- -W 'always auto never'
;;
-R | -x | --exclude)
# argument required but no completions available
@@ -124,21 +130,21 @@ _yum()
return
;;
*)
- COMPREPLY=($(compgen -W 'install update check-update upgrade
- remove erase list info provides whatprovides clean makecache
- groupinstall groupupdate grouplist groupremove groupinfo
- search shell resolvedep localinstall localupdate deplist
- repolist help' -- "$cur"))
+ _comp_compgen -- -W 'install update check-update upgrade remove
+ erase list info provides whatprovides clean makecache
+ groupinstall groupupdate grouplist groupremove groupinfo search
+ shell resolvedep localinstall localupdate deplist repolist
+ help'
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _yum yum
+ complete -F _comp_cmd_yum yum
# ex: filetype=sh
diff --git a/completions/a2x b/completions/a2x
index b59c786..ed1a206 100644
--- a/completions/a2x
+++ b/completions/a2x
@@ -1,39 +1,41 @@
# a2x(1) completion -*- shell-script -*-
-_a2x()
+_comp_cmd_a2x()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[aDd]*)'
+ # shellcheck disable=SC2254
case $prev in
--attribute | --asciidoc-opts | --dblatex-opts | --fop-opts | --help | \
- --version | --xsltproc-opts | -!(-*)[ah])
+ --version | --xsltproc-opts | -${noargopts}[ah])
return
;;
- --destination-dir | --icons-dir | -!(-*)D)
- _filedir -d
+ --destination-dir | --icons-dir | -${noargopts}D)
+ _comp_compgen_filedir -d
return
;;
- --doctype | -!(-*)d)
- _xfunc asciidoc _asciidoc_doctype
+ --doctype | -${noargopts}d)
+ _comp_compgen -x asciidoc doctype
return
;;
--stylesheet)
- _filedir css
+ _comp_compgen_filedir css
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _a2x a2x
+ complete -F _comp_cmd_a2x a2x
# ex: filetype=sh
diff --git a/completions/abook b/completions/abook
index 42197d1..5e4c2f4 100644
--- a/completions/abook
+++ b/completions/abook
@@ -1,12 +1,12 @@
# abook(1) completion -*- shell-script -*-
-_abook()
+_comp_cmd_abook()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
# abook only takes options, tabbing after command name adds a single dash
- [[ $cword -eq 1 && -z $cur ]] &&
+ [[ $cword -eq 1 && ! $cur ]] &&
{
compopt -o nospace
COMPREPLY=("-")
@@ -15,35 +15,33 @@ _abook()
case $cur in
-*)
- _longopt "$1"
+ _comp_complete_longopt "$@"
return
;;
esac
case $prev in
--informat)
- COMPREPLY=($(compgen -W "$($1 --formats |
- command sed -n -e 's/^'$'\t''\([a-z]*\).*/\1/p' -e '/^$/q')" \
- -- "$cur"))
+ _comp_compgen_split -- "$("$1" --formats |
+ command sed -n -e 's/^'$'\t''\([a-z]*\).*/\1/p' -e '/^$/q')"
;;
--outformat)
- COMPREPLY=($(compgen -W "$($1 --formats |
- command sed -n -e '/^$/,$s/^'$'\t''\([a-z]*\).*/\1/p')" \
- -- "$cur"))
+ _comp_compgen_split -- "$("$1" --formats |
+ command sed -n -e '/^$/,$s/^'$'\t''\([a-z]*\).*/\1/p')"
;;
--infile)
- COMPREPLY=($(compgen -W stdin -- "$cur"))
- _filedir
+ _comp_compgen -- -W stdin
+ _comp_compgen -a filedir
;;
--outfile)
- COMPREPLY=($(compgen -W stdout -- "$cur"))
- _filedir
+ _comp_compgen -- -W stdout
+ _comp_compgen -a filedir
;;
--config | --datafile)
- _filedir
+ _comp_compgen_filedir
;;
esac
} &&
- complete -F _abook abook
+ complete -F _comp_cmd_abook abook
# ex: filetype=sh
diff --git a/completions/aclocal b/completions/aclocal
index 010862f..b23ff72 100644
--- a/completions/aclocal
+++ b/completions/aclocal
@@ -1,35 +1,35 @@
# aclocal(1) completion -*- shell-script -*-
-_aclocal()
+_comp_cmd_aclocal()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case "$prev" in
--help | --print-ac-dir | --version)
return
;;
--acdir | -I)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
--output)
- _filedir
+ _comp_compgen_filedir
return
;;
--warnings | -W)
local cats=(syntax unsupported)
- COMPREPLY=($(compgen -W \
- '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur"))
+ _comp_compgen -- -W '"${cats[@]}" "${cats[@]/#/no-}" all none
+ error'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
} &&
- complete -F _aclocal aclocal aclocal-1.1{0..6}
+ complete -F _comp_cmd_aclocal aclocal aclocal-1.1{0..6}
# ex: filetype=sh
diff --git a/completions/acpi b/completions/acpi
index f2c38b2..3d131da 100644
--- a/completions/acpi
+++ b/completions/acpi
@@ -1,22 +1,24 @@
-# acpi(1) completion -*- shell-script -*-
+# acpi(1) completion -*- shell-script -*-
-_acpi()
+_comp_cmd_acpi()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[d]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | -!(-*)[hv])
+ --help | --version | -${noargopts}[hv])
return
;;
- --directory | -!(-*)d)
- _filedir -d
+ --directory | -${noargopts}d)
+ _comp_compgen_filedir -d
return
;;
esac
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
} &&
- complete -F _acpi acpi
+ complete -F _comp_cmd_acpi acpi
# ex: filetype=sh
diff --git a/completions/add_members b/completions/add_members
index efa4f1e..d691884 100644
--- a/completions/add_members
+++ b/completions/add_members
@@ -1,31 +1,34 @@
# mailman add_members completion -*- shell-script -*-
-_add_members()
+_comp_cmd_add_members()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-r | -d | --regular-members-file | --digest-members-file)
- _filedir
+ _comp_compgen_filedir
return
;;
-w | -a | --welcome-msg | --admin-notify)
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ _comp_compgen -- -W 'y n'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--regular-members-file --digest-members-file
- --welcome-msg --admin-notify --help' -- "$cur"))
+ _comp_compgen -- -W '--regular-members-file --digest-members-file
+ --welcome-msg --admin-notify --help'
else
- _xfunc list_lists _mailman_lists
+ # Prefer `list_lists` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_xfunc list_lists mailman_lists
fi
} &&
- complete -F _add_members add_members
+ complete -F _comp_cmd_add_members add_members
# ex: filetype=sh
diff --git a/completions/alias b/completions/alias
index 92211d8..9a0f3d2 100644
--- a/completions/alias
+++ b/completions/alias
@@ -1,20 +1,28 @@
# bash alias completion -*- shell-script -*-
-_alias()
+_comp_cmd_alias()
{
- local cur prev words cword
- _init_completion -n = || return
+ local cur prev words cword comp_args
+ _comp_initialize -n = -- "$@" || return
- case ${words[@]} in
+ case "${words[*]}" in
+ *" -p "*)
+ return
+ ;;
*[^=])
- COMPREPLY=($(compgen -A alias -- "$cur"))
+ _comp_compgen -- -A alias
;;
*=)
- COMPREPLY=("$(alias ${cur%=} 2>/dev/null | command sed \
+ COMPREPLY=("$(alias "${cur%=}" 2>/dev/null | command sed \
-e 's|^alias '"$cur"'\(.*\)$|\1|')")
;;
esac
+
+ if [[ $cur == -* ]]; then
+ _comp_compgen_usage -c help -s "$1"
+ ((${#COMPREPLY[*]} != 1)) || compopt +o nospace
+ fi
} &&
- complete -F _alias -o nospace alias
+ complete -F _comp_cmd_alias -o nospace alias
# ex: filetype=sh
diff --git a/completions/ant b/completions/ant
index 197c0e9..e4f9f29 100644
--- a/completions/ant
+++ b/completions/ant
@@ -1,6 +1,6 @@
# bash completion for ant and phing -*- shell-script -*-
-_ant_parse_targets()
+_comp_cmd_ant__targets()
{
local line basedir
@@ -9,9 +9,9 @@ _ant_parse_targets()
# parse buildfile for targets
while read -rd '>' line; do
if [[ $line =~ \<(target|extension-point)[[:space:]].*name=[\"\']([^\"\']+) ]]; then
- targets+=" ${BASH_REMATCH[2]}"
+ REPLY+=("${BASH_REMATCH[2]}")
fi
- done <$1
+ done <"$1"
# parse imports
while read -rd '>' line; do
@@ -19,39 +19,39 @@ _ant_parse_targets()
local imported_buildfile
imported_buildfile="${basedir}/${BASH_REMATCH[1]}"
if [[ -f $imported_buildfile ]]; then
- _ant_parse_targets $imported_buildfile
+ "$FUNCNAME" "$imported_buildfile"
fi
fi
- done <$1
+ done <"$1"
}
-_ant()
+_comp_cmd_ant()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-h | -help | --h | --help | -projecthelp | -p | -version | -diagnostics)
return
;;
-buildfile | -file | -f)
- _filedir 'xml'
+ _comp_compgen_filedir 'xml'
return
;;
-logfile | -l)
- [[ $1 != *phing || $prev != -l ]] && _filedir
+ [[ $1 != *phing || $prev != -l ]] && _comp_compgen_filedir
return
;;
-propertyfile)
- _filedir properties
+ _comp_compgen_filedir properties
return
;;
-nice)
- COMPREPLY=($(compgen -W '{1..10}' -- "$cur"))
+ _comp_compgen -- -W '{1..10}'
return
;;
-lib)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-logger | -listener | -inputhandler | -main | -find | -s)
@@ -64,8 +64,7 @@ _ant()
elif [[ $cur == -* ]]; then
# The </dev/null prevents "phing -" weirdness/getting just a literal
# tab displayed on complete on CentOS 6 with phing 2.6.1.
- COMPREPLY=(
- $(compgen -W '$(_parse_help "$1" -h </dev/null)' -- "$cur"))
+ _comp_compgen_help -- -h </dev/null
else
# available targets completion
# find which buildfile to use
@@ -77,6 +76,7 @@ _ant()
fi
done
if ((i == cword)); then
+ local IFS=$' \t\n'
for i in ${ANT_ARGS-}; do
if [[ $prev == -@(?(build)file|f) ]]; then
buildfile=$i
@@ -87,16 +87,17 @@ _ant()
fi
[[ ! -f $buildfile ]] && return
- local targets
+ local REPLY=()
# fill targets
- _ant_parse_targets $buildfile
+ _comp_cmd_ant__targets "$buildfile"
- COMPREPLY=($(compgen -W '$targets' -- "$cur"))
+ _comp_compgen -- -W '"${REPLY[@]}"'
fi
} &&
- complete -F _ant ant phing
-type complete-ant-cmd.pl &>/dev/null &&
- complete -C complete-ant-cmd.pl -F _ant ant || :
+ complete -F _comp_cmd_ant ant phing
+if type complete-ant-cmd.pl &>/dev/null; then
+ complete -C complete-ant-cmd.pl -F _comp_cmd_ant ant
+fi
# ex: filetype=sh
diff --git a/completions/apache2ctl b/completions/apache2ctl
index 980b3c5..0807788 100644
--- a/completions/apache2ctl
+++ b/completions/apache2ctl
@@ -1,16 +1,16 @@
# apache2ctl(1) completion -*- shell-script -*-
-_apache2ctl()
+_comp_cmd_apache2ctl()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local APWORDS
- APWORDS=$($1 2>&1 >/dev/null | awk 'NR<2 { print $3; exit }' |
+ APWORDS=$("$1" 2>&1 >/dev/null | _comp_awk 'NR<2 { print $3; exit }' |
tr "|" " ")
- COMPREPLY=($(compgen -W "$APWORDS" -- "$cur"))
+ _comp_compgen -- -W "$APWORDS"
} &&
- complete -F _apache2ctl apache2ctl
+ complete -F _comp_cmd_apache2ctl apache2ctl
# ex: filetype=sh
diff --git a/completions/appdata-validate b/completions/appdata-validate
index 03d8cc9..1b6149e 100644
--- a/completions/appdata-validate
+++ b/completions/appdata-validate
@@ -1,32 +1,31 @@
# appdata-validate(1) completion -*- shell-script -*-
-_appdata_validate()
+_comp_cmd_appdata_validate()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-h | --help | --version)
return
;;
--output-format)
- COMPREPLY=($(compgen -W "$($1 --help |
- command sed -ne 's/--output-format.*\[\(.*\)\]/\1/' -e 's/|/ /gp')" \
- -- "$cur"))
+ _comp_compgen_split -- "$("$1" --help | command sed -ne \
+ 's/--output-format.*\[\(.*\)\]/\1/' -e 's/|/ /gp')"
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir appdata.xml
+ _comp_compgen_filedir appdata.xml
} &&
- complete -F _appdata_validate appdata-validate
+ complete -F _comp_cmd_appdata_validate appdata-validate
# ex: filetype=sh
diff --git a/completions/apt-build b/completions/apt-build
index 713f4c3..5327780 100644
--- a/completions/apt-build
+++ b/completions/apt-build
@@ -1,26 +1,25 @@
# Debian apt-build(1) completion -*- shell-script -*-
-_apt_build()
+_comp_cmd_apt_build()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- local special i
- for ((i = 1; i < ${#words[@]} - 1; i++)); do
+ local special="" i
+ for ((i = 1; i < cword; i++)); do
if [[ ${words[i]} == @(install|remove|source|info|clean) ]]; then
special=${words[i]}
break
fi
done
- if [[ -v special ]]; then
+ if [[ $special ]]; then
case $special in
install | source | info)
- COMPREPLY=($(_xfunc apt-cache _apt_cache_packages))
+ _comp_compgen -x apt-cache packages
;;
remove)
- COMPREPLY=(
- $(_xfunc dpkg _comp_dpkg_installed_packages "$cur"))
+ _comp_compgen -x dpkg installed_packages
;;
esac
return
@@ -28,7 +27,7 @@ _apt_build()
case $prev in
--patch | --build-dir | --repository-dir)
- _filedir
+ _comp_compgen_filedir
return
;;
-h | --help)
@@ -37,18 +36,17 @@ _apt_build()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--help --show-upgraded -u --build-dir
+ _comp_compgen -- -W '--help --show-upgraded -u --build-dir
--repository-dir --build-only --build-command --reinstall --rebuild
--remove-builddep --no-wrapper --purge --patch --patch-strip -p
- --yes -y --version -v --no-source' -- "$cur"))
+ --yes -y --version -v --no-source'
else
- COMPREPLY=($(compgen -W 'update upgrade install remove source
- dist-upgrade world clean info clean-build update-repository' \
- -- "$cur"))
+ _comp_compgen -- -W 'update upgrade install remove source dist-upgrade
+ world clean info clean-build update-repository'
fi
} &&
- complete -F _apt_build apt-build
+ complete -F _comp_cmd_apt_build apt-build
# ex: filetype=sh
diff --git a/completions/apt-cache b/completions/apt-cache
index 61aa07b..1f47d7d 100644
--- a/completions/apt-cache
+++ b/completions/apt-cache
@@ -1,32 +1,69 @@
# Debian apt-cache(8) completion -*- shell-script -*-
# List APT binary packages
+# @since 2.12
+_comp_xfunc_apt_cache_compgen_packages()
+{
+ _comp_cmd_apt_cache__compgen_packages apt-cache
+}
+
+# List APT binary packages
+# @param $1 Name of executable
+_comp_cmd_apt_cache__compgen_packages()
+{
+ _comp_compgen_split -- "$("$1" --no-generate pkgnames "$cur" 2>/dev/null)"
+}
+
+# List APT source packages
+# @since 2.12
+_comp_xfunc_apt_cache_compgen_sources()
+{
+ _comp_cmd_apt_cache__compgen_sources apt-cache
+}
+
+# List APT source packages
+# @param $1 Name of executable
+_comp_cmd_apt_cache__compgen_sources()
+{
+ _comp_compgen_split -- "$("$1" dumpavail |
+ _comp_awk '$1 == "Source:" { print $2 }' | sort -u)"
+}
+
+# List APT binary packages
+# @deprecated 2.12
_apt_cache_packages()
{
- apt-cache --no-generate pkgnames "$cur" 2>/dev/null || :
+ local packages
+ _comp_compgen -v packages -i apt-cache packages apt-cache &&
+ printf '%s\n' "${packages[@]}"
}
# List APT source packages
+# @deprecated 2.12
_apt_cache_sources()
{
- compgen -W "$(apt-cache dumpavail |
- awk '$1 == "Source:" { print $2 }' | sort -u)" -- "$1"
+ local sources
+ _comp_compgen -v sources -c "$1" -i apt-cache sources apt-cache &&
+ printf '%s\n' "${sources[@]}"
}
# List APT source packages
+# @deprecated 2.12
_apt_cache_src_packages()
{
- compgen -W '$(_apt_cache_sources "$cur")' -- "$cur"
+ local sources
+ _comp_compgen -v sources -i apt-cache sources apt-cache &&
+ printf '%s\n' "${sources[@]}"
}
-_apt_cache()
+_comp_cmd_apt_cache()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- local special ispecial
+ local special="" ispecial
if [[ $cur != show ]]; then
- for ((ispecial = 1; ispecial < ${#words[@]} - 1; ispecial++)); do
+ for ((ispecial = 1; ispecial < ${#words[@]}; ispecial++)); do
if [[ ${words[ispecial]} == @(add|depends|dotty|madison|policy|rdepends|show?(pkg|src|)) ]]; then
special=${words[ispecial]}
break
@@ -34,27 +71,34 @@ _apt_cache()
done
fi
- if [[ -v special && $ispecial -lt $cword ]]; then
+ if [[ $special && $ispecial -lt $cword ]]; then
case $special in
add)
- _filedir
+ _comp_compgen_filedir
;;
showsrc)
- COMPREPLY=($(_apt_cache_sources "$cur"))
+ _comp_cmd_apt_cache__compgen_sources "$1"
;;
*)
- COMPREPLY=($(_apt_cache_packages))
+ _comp_cmd_apt_cache__compgen_packages "$1"
;;
esac
return
fi
+ local noargopts='!(-*|*[cps]*)'
+ # shellcheck disable=SC2254
case $prev in
- --config-file | --pkg-cache | --src-cache | -!(-*)[cps])
- _filedir
+ --config-file | --pkg-cache | --src-cache | -${noargopts}[cps])
+ _comp_compgen_filedir
+ return
+ ;;
+ --with-source)
+ _comp_compgen_filedir '@(deb|dsc|changes)'
+ _comp_compgen -a -- -f -o plusdirs -X '!?(*/)@(Sources|Packages)'
return
;;
search)
@@ -65,21 +109,19 @@ _apt_cache()
esac
if [[ $cur == -* ]]; then
-
- COMPREPLY=($(compgen -W '-h -v -p -s -q -i -f -a -g -c -o --help
- --version --pkg-cache --src-cache --quiet --important --full
- --all-versions --no-all-versions --generate --no-generate
- --names-only --all-names --recurse --config-file --option
- --installed' -- "$cur"))
- elif [[ ! -v special ]]; then
-
- COMPREPLY=($(compgen -W 'add gencaches show showpkg showsrc stats
- dump dumpavail unmet search search depends rdepends pkgnames
- dotty xvcg policy madison' -- "$cur"))
-
+ _comp_compgen -- -W '--pkg-cache --src-cache --quiet --important
+ --no-pre-depends --no-depends --no-recommends --no-suggests
+ --no-conflicts --no-breaks --no-replaces --no-enhances --implicit
+ --full --all-versions --no-all-versions --generate --no-generate
+ --names-only --all-names --recurse --installed --with-source
+ --help --version --config-file --option'
+ elif [[ ! $special ]]; then
+ _comp_compgen -- -W 'gencaches showpkg stats showsrc dump dumpavail
+ unmet show search depends rdepends pkgnames dotty xvcg policy
+ madison'
fi
} &&
- complete -F _apt_cache apt-cache
+ complete -F _comp_cmd_apt_cache apt-cache
# ex: filetype=sh
diff --git a/completions/apt-get b/completions/apt-get
index 4aee263..f59c62b 100644
--- a/completions/apt-get
+++ b/completions/apt-get
@@ -1,83 +1,93 @@
# Debian apt-get(8) completion -*- shell-script -*-
-_apt_get()
+# @since 2.12
+_comp_xfunc_apt_get_compgen_installed_packages()
{
- local cur prev words cword package
- _init_completion -n ':=' || return
+ if [[ -f /etc/debian_version ]]; then
+ # Debian system
+ _comp_compgen -x dpkg installed_packages
+ else
+ # assume RPM based
+ _comp_compgen -x rpm installed_packages
+ fi
+}
- local special i
- for ((i = 1; i < ${#words[@]} - 1; i++)); do
- if [[ ${words[i]} == @(install|remove|autoremove|purge|source|build-dep|download|changelog) ]]; then
+_comp_cmd_apt_get()
+{
+ local cur prev words cword comp_args package
+ _comp_initialize -n ':=' -- "$@" || return
+
+ local special="" i
+ for ((i = 1; i < cword; i++)); do
+ if [[ ${words[i]} == @(install|remove|auto?(-)remove|purge|source|build-dep|download|changelog) ]]; then
special=${words[i]}
break
fi
done
- if [[ -v special ]]; then
+ if [[ $special ]]; then
case $special in
- remove | autoremove | purge)
- if [[ -f /etc/debian_version ]]; then
- # Debian system
- COMPREPLY=($(
- _xfunc dpkg _comp_dpkg_installed_packages $cur
- ))
- else
- # assume RPM based
- _xfunc rpm _rpm_installed_packages
- fi
+ remove | auto?(-)remove | purge)
+ _comp_xfunc_apt_get_compgen_installed_packages
;;
source)
- COMPREPLY=($(_xfunc apt-cache _apt_cache_packages)
- $(compgen -W "$(apt-cache dumpavail |
- awk '$1 == "Source:" { print $2 }' | sort -u)" -- "$cur"))
+ # Prefer `apt-cache` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -x apt-cache packages
+ _comp_compgen -a split -- "$(apt-cache dumpavail |
+ _comp_awk '$1 == "Source:" { print $2 }' | sort -u)"
;;
- install)
- if [[ $cur == */* ]]; then
- _filedir deb
+ install | reinstall)
+ if _comp_looks_like_path "$cur"; then
+ _comp_compgen_filedir deb
return
elif [[ $cur == *=* ]]; then
package="${cur%%=*}"
cur="${cur#*=}"
- COMPREPLY=($(IFS=$'\n' compgen -W "$(
+ _comp_compgen_split -l -- "$(
apt-cache --no-generate madison "$package" 2>/dev/null |
while IFS=' |' read -r _ version _; do
echo "$version"
done
- )" \
- -- "$cur"))
- __ltrim_colon_completions "$cur"
+ )"
+ _comp_ltrim_colon_completions "$cur"
return
fi
;;&
build-dep)
- _filedir -d
- [[ $cur != */* ]] || return
+ _comp_compgen_filedir -d
+ _comp_looks_like_path "$cur" && return
;;&
*)
- COMPREPLY+=($(_xfunc apt-cache _apt_cache_packages))
+ _comp_compgen -ax apt-cache packages
;;
esac
return
fi
+ local noargopts='!(-*|*[eoct]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | --option | -!(-*)[hvo])
+ --error-on | --help | --version | --option | -${noargopts}[ehvo])
return
;;
- --config-file | -!(-*)c)
- _filedir
+ --config-file | -${noargopts}c)
+ _comp_compgen_filedir
return
;;
- --target-release | --default-release | -!(-*)t)
- COMPREPLY=($(compgen -W "$(apt-cache policy | command sed -ne \
- 's/^ *release.*[ ,]o=\(Debian\|Ubuntu\),a=\(\w*\).*/\2/p')" \
- -- "$cur"))
+ --target-release | --default-release | -${noargopts}t)
+ # Prefer `apt-cache` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen_split -- "$(apt-cache policy | command sed -ne \
+ 's/^ *release.*[ ,]o=\(Debian\|Ubuntu\),a=\(\w*\).*/\2/p')"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--no-install-recommends --install-suggests
+ _comp_compgen -- -W '--no-install-recommends --install-suggests
--download-only --fix-broken --ignore-missing --fix-missing
--no-download --quiet --simulate --just-print --dry-run --recon
--no-act --yes --assume-yes --assume-no --no-show-upgraded
@@ -89,16 +99,15 @@ _apt_get()
--trivial-only --no-remove --auto-remove --autoremove --only-source
--diff-only --dsc-only --tar-only --arch-only --indep-only
--allow-unauthenticated --no-allow-insecure-repositories
- --allow-releaseinfo-change --show-progress --with-source --help
- --version --config-file --option' -- "$cur"))
+ --allow-releaseinfo-change --show-progress --with-source --error-on
+ --help --version --config-file --option'
else
- COMPREPLY=($(compgen -W 'update upgrade dist-upgrade
- dselect-upgrade install remove purge source build-dep check
- download clean autoclean autoremove changelog indextargets' \
- -- "$cur"))
+ _comp_compgen -- -W 'update upgrade dist-upgrade dselect-upgrade
+ install reinstall remove purge source build-dep satisfy check
+ download clean autoclean autoremove changelog indextargets'
fi
} &&
- complete -F _apt_get apt-get
+ complete -F _comp_cmd_apt_get apt-get
# ex: filetype=sh
diff --git a/completions/apt-mark b/completions/apt-mark
new file mode 100644
index 0000000..7ef3f76
--- /dev/null
+++ b/completions/apt-mark
@@ -0,0 +1,64 @@
+# Debian apt-mark(8) completion -*- shell-script -*-
+
+_comp_cmd_apt_mark()
+{
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+
+ local special="" i
+ for ((i = 1; i < cword; i++)); do
+ if [[ ${words[i]} == @(auto|manual|minimize-manual|showauto|showmanual|hold|unhold|showhold|install|remove|deinstall|purge|showinstall|showremove|showpurge) ]]; then
+ special=${words[i]}
+ break
+ fi
+ done
+
+ if [[ $special ]]; then
+ case $special in
+ auto | manual | unhold)
+ local -A showcmds=([auto]=manual [manual]=auto [unhold]=hold)
+ local showcmd=${showcmds[$special]}
+ _comp_compgen_split -- "$("$1" "show$showcmd" 2>/dev/null)"
+ return
+ ;;
+ minimize-manual)
+ return
+ ;;
+ *)
+ _comp_compgen -x apt-get installed_packages
+ ;;
+ esac
+ return
+ fi
+
+ local noargopts='!(-*|*[ocf]*)'
+ # shellcheck disable=SC2254
+ case $prev in
+ --help | --version | --option | -${noargopts}[hvo])
+ return
+ ;;
+ --config-file | -${noargopts}c)
+ _comp_compgen_filedir conf
+ return
+ ;;
+ --file | -${noargopts}f)
+ _comp_compgen_filedir
+ return
+ ;;
+ esac
+
+ [[ $was_split ]] && return
+
+ if [[ $cur == -* ]]; then
+ _comp_compgen -- -W '--file= --help --version --config-file --option'
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
+ else
+ _comp_compgen -- -W 'auto manual minimize-manual showauto showmanual
+ hold unhold showhold install remove purge showinstall showremove
+ showpurge'
+ fi
+
+} &&
+ complete -F _comp_cmd_apt_mark apt-mark
+
+# ex: filetype=sh
diff --git a/completions/aptitude b/completions/aptitude
index e5ea163..827395a 100644
--- a/completions/aptitude
+++ b/completions/aptitude
@@ -1,24 +1,11 @@
# Debian aptitude(1) completion -*- shell-script -*-
-_have grep-status && {
- _comp_dpkg_hold_packages()
- {
- grep-status -P -e "^$1" -a -FStatus 'hold' -n -s Package
- }
-} || {
- _comp_dpkg_hold_packages()
- {
- command grep -B 2 'hold' /var/lib/dpkg/status |
- awk "/Package: $1/ { print \$2 }"
- }
-}
-
-_aptitude()
+_comp_cmd_aptitude()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- local special i
+ local special="" i
for ((i = 1; i < ${#words[@]} - 1; i++)); do
if [[ ${words[i]} == @(@(|re)install|@(|un)hold|@(|un)markauto|@(dist|full|safe)-upgrade|download|show|forbid-version|purge|remove|changelog|why@(|-not)|keep@(|-all)|build-dep|@(add|remove)-user-tag|versions) ]]; then
special=${words[i]}
@@ -26,65 +13,65 @@ _aptitude()
fi
done
- if [[ -v special ]]; then
+ if [[ $special ]]; then
case $special in
install | hold | markauto | unmarkauto | dist-upgrade | full-upgrade | \
safe-upgrade | download | show | changelog | why | why-not | build-dep | \
add-user-tag | remove-user-tag | versions)
- COMPREPLY=($(_xfunc apt-cache _apt_cache_packages))
+ _comp_compgen -x apt-cache packages
return
;;
purge | remove | reinstall | forbid-version)
- COMPREPLY=(
- $(_xfunc dpkg _comp_dpkg_installed_packages "$cur"))
+ _comp_compgen -x dpkg installed_packages
return
;;
unhold)
- COMPREPLY=($(_comp_dpkg_hold_packages "$cur"))
+ _comp_compgen -x dpkg held_packages
return
;;
esac
fi
+ local noargopts='!(-*|*[SwFoOt]*)'
+ # shellcheck disable=SC2254
case $prev in
# don't complete anything if these options are found
autoclean | clean | forget-new | search | upgrade | update | keep-all)
return
;;
- -!(-*)S)
- _filedir
+ -${noargopts}S)
+ _comp_compgen_filedir
return
;;
- --display-format | --width | -!(-*)[wFo])
+ --display-format | --width | -${noargopts}[wFo])
return
;;
- --sort | -!(-*)O)
- COMPREPLY=($(compgen -W 'installsize installsizechange debsize
- name priority version' -- "$cur"))
+ --sort | -${noargopts}O)
+ _comp_compgen -- -W 'installsize installsizechange debsize name
+ priority version'
return
;;
- --target-release | --default-release | -!(-*)t)
- COMPREPLY=($(apt-cache policy |
- command grep "release.o=Debian,a=$cur" |
- command sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2>/dev/null))
+ --target-release | --default-release | -${noargopts}t)
+ _comp_compgen_split -l -- "$(apt-cache policy |
+ command sed -ne 's/.*release.o=Debian,a=\([_[:alnum:]]*\).*/\1/p')"
return
;;
esac
if [[ $cur == -* ]]; then
- local opts=" $($1 --help 2>&1 | command sed -e \
- 's/--with(out)-recommends/--without-recommends\n--with-recommends/' |
- _parse_help - | tr '\n' ' ') "
+ _comp_compgen -R help - <<<"$("$1" --help 2>&1 | command sed -e \
+ 's/--with(out)-recommends/--without-recommends\n--with-recommends/')"
+ ((${#COMPREPLY[@]})) || return 0
# Exclude some mutually exclusive options
+ local exclude_flags=""
for i in "${words[@]}"; do
- [[ $i == -u ]] && opts=${opts/ -i / }
- [[ $i == -i ]] && opts=${opts/ -u / }
+ [[ $i == -u ]] && exclude_flags+=i
+ [[ $i == -i ]] && exclude_flags+=u
done
# Do known short -> long replacements; at least up to 0.8.12, --help
# outputs mostly only short ones.
- COMPREPLY=($opts)
for i in "${!COMPREPLY[@]}"; do
case ${COMPREPLY[i]} in
-h) COMPREPLY[i]=--help ;;
@@ -104,16 +91,17 @@ _aptitude()
esac
done
- COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur"))
+ _comp_compgen -- -W '"${COMPREPLY[@]}"' \
+ ${exclude_flags:+-X "-[$exclude_flags]"}
else
- COMPREPLY=($(compgen -W 'update upgrade safe-upgrade forget-new
- clean autoclean install reinstall remove hold unhold purge markauto
+ _comp_compgen -- -W 'update upgrade safe-upgrade forget-new clean
+ autoclean install reinstall remove hold unhold purge markauto
unmarkauto why why-not dist-upgrade full-upgrade download search
show forbid-version changelog keep keep-all build-dep add-user-tag
- remove-user-tag versions' -- "$cur"))
+ remove-user-tag versions'
fi
} &&
- complete -F _aptitude -o default aptitude aptitude-curses
+ complete -F _comp_cmd_aptitude -o default aptitude aptitude-curses
# ex: filetype=sh
diff --git a/completions/arch b/completions/arch
index afeed05..7ca9738 100644
--- a/completions/arch
+++ b/completions/arch
@@ -2,27 +2,27 @@
# Try to detect whether this is the mailman "arch" to avoid installing
# it for the coreutils/util-linux-ng one.
-_have mailmanctl &&
- _arch()
+_comp_have_command mailmanctl &&
+ _comp_cmd_arch()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-w | -g | -d | --welcome-msg | --goodbye-msg | --digest)
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ _comp_compgen -- -W 'y n'
return
;;
--file)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
else
local args=$cword
for ((i = 1; i < cword; i++)); do
@@ -32,15 +32,18 @@ _have mailmanctl &&
done
case $args in
1)
- _xfunc list_lists _mailman_lists
+ # Prefer `list_lists` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -x list_lists mailman_lists
;;
2)
- _filedir
+ _comp_compgen_filedir
;;
esac
fi
} &&
- complete -F _arch arch
+ complete -F _comp_cmd_arch arch
# ex: filetype=sh
diff --git a/completions/arp b/completions/arp
index 922e800..3d1669a 100644
--- a/completions/arp
+++ b/completions/arp
@@ -1,43 +1,45 @@
-# arp(8) completion -*- shell-script -*-
+# arp(8) completion -*- shell-script -*-
-_arp()
+_comp_cmd_arp()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[iApfHt]*)'
+ # shellcheck disable=SC2254
case $prev in
- --device | -!(-*)i)
- _available_interfaces -a
+ --device | -${noargopts}i)
+ _comp_compgen_available_interfaces -a
return
;;
- --protocol | -!(-*)[Ap])
+ --protocol | -${noargopts}[Ap])
# TODO protocol/address family
return
;;
- --file | -!(-*)f)
- _filedir
+ --file | -${noargopts}f)
+ _comp_compgen_filedir
return
;;
- --hw-type | -!(-*)[Ht])
+ --hw-type | -${noargopts}[Ht])
# TODO: parse from --help output?
- COMPREPLY=($(compgen -W 'ash ether ax25 netrom rose arcnet \
- dlci fddi hippi irda x25 eui64' -- "$cur"))
+ _comp_compgen -- -W 'ash ether ax25 netrom rose arcnet dlci fddi
+ hippi irda x25 eui64'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
return
fi
- local args
- _count_args "" "@(--device|--protocol|--file|--hw-type|-!(-*)[iApfHt])"
- case $args in
+ local REPLY
+ _comp_count_args -a "@(--device|--protocol|--file|--hw-type|-${noargopts}[iApfHt])"
+ case $REPLY in
1)
local ips=$("$1" -an | command sed -ne \
's/.*(\([0-9]\{1,3\}\(\.[0-9]\{1,3\}\)\{3\}\)).*/\1/p')
- COMPREPLY=($(compgen -W '$ips' -- "$cur"))
+ _comp_compgen -- -W '$ips'
;;
2)
# TODO if -d mode: "pub"; if not -f mode: hw_addr
@@ -54,6 +56,6 @@ _arp()
;;
esac
} &&
- complete -F _arp arp
+ complete -F _comp_cmd_arp arp
# ex: filetype=sh
diff --git a/completions/arping b/completions/arping
index 57e1e19..c69fc2d 100644
--- a/completions/arping
+++ b/completions/arping
@@ -1,31 +1,31 @@
# arping(8) completion -*- shell-script -*-
-_arping()
+_comp_cmd_arping()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*c | -*w)
return
;;
-*I)
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
return
;;
-*s)
- _ip_addresses
+ _comp_compgen_ip_addresses
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ _comp_compgen_help -- -h
return
fi
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
} &&
- complete -F _arping arping
+ complete -F _comp_cmd_arping arping
# ex: filetype=sh
diff --git a/completions/arpspoof b/completions/arpspoof
index d1a1373..8939f2d 100644
--- a/completions/arpspoof
+++ b/completions/arpspoof
@@ -1,28 +1,28 @@
# arpspoof completion -*- shell-script -*-
-_arpspoof()
+_comp_cmd_arpspoof()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-i)
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
return
;;
-t)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
else
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
fi
} &&
- complete -F _arpspoof arpspoof
+ complete -F _comp_cmd_arpspoof arpspoof
# ex: filetype=sh
diff --git a/completions/asciidoc b/completions/asciidoc
index 1ea4abf..7e77857 100644
--- a/completions/asciidoc
+++ b/completions/asciidoc
@@ -1,52 +1,60 @@
# asciidoc(1) completion -*- shell-script -*-
+# @since 2.12
+_comp_xfunc_asciidoc_compgen_doctype()
+{
+ _comp_compgen -- -W 'article book manpage'
+}
+
+# @deprecated 2.12
_asciidoc_doctype()
{
- COMPREPLY+=($(compgen -W 'article book manpage' -- "$cur"))
+ _comp_compgen -ax asciidoc doctype
}
-_asciidoc()
+_comp_cmd_asciidoc()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[abfdo]*)'
+ # shellcheck disable=SC2254
case $prev in
- --attribute | -!(-*)a)
+ --attribute | -${noargopts}a)
return
;;
- --backend | -!(-*)b)
- COMPREPLY=($(compgen -W 'docbook html4 xhtml11' -- "$cur"))
+ --backend | -${noargopts}b)
+ _comp_compgen -- -W 'docbook html4 xhtml11'
return
;;
- --conf-file | -!(-*)f)
- _filedir conf
+ --conf-file | -${noargopts}f)
+ _comp_compgen_filedir conf
return
;;
- --doctype | -!(-*)d)
- _asciidoc_doctype
+ --doctype | -${noargopts}d)
+ _comp_xfunc_asciidoc_compgen_doctype
return
;;
- --help | -!(-*)h)
- COMPREPLY=($(compgen -W 'manpage syntax topics' -- "$cur"))
+ --help | -${noargopts}h)
+ _comp_compgen -- -W 'manpage syntax topics'
return
;;
- --out-file | -!(-*)o)
- _filedir
+ --out-file | -${noargopts}o)
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" "--help manpage")' \
- -- "$cur"))
+ _comp_compgen_help -- --help manpage
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _asciidoc asciidoc asciidoc.py
+ complete -F _comp_cmd_asciidoc asciidoc asciidoc.py
# ex: filetype=sh
diff --git a/completions/aspell b/completions/aspell
index e080a07..89dae17 100644
--- a/completions/aspell
+++ b/completions/aspell
@@ -1,65 +1,66 @@
# bash completion for aspell -*- shell-script -*-
-_aspell_dictionary()
+_comp_cmd_aspell__dictionary()
{
- local datadir aspell=${1:-aspell}
- datadir=$($aspell config data-dir 2>/dev/null || echo /usr/lib/aspell)
+ local datadir aspell=$1
+ datadir=$("$aspell" config data-dir 2>/dev/null || echo /usr/lib/aspell)
# First, get aliases (dicts dump does not list them)
- COMPREPLY=($(printf '%s\n' $datadir/*.alias))
- COMPREPLY=("${COMPREPLY[@]%.alias}")
- COMPREPLY=("${COMPREPLY[@]#$datadir/}")
+ if _comp_expand_glob COMPREPLY '"$datadir"/*.alias'; then
+ COMPREPLY=("${COMPREPLY[@]%.alias}")
+ COMPREPLY=("${COMPREPLY[@]#$datadir/}")
+ fi
# Then, add the canonical dicts
- COMPREPLY+=($($aspell dicts 2>/dev/null))
- COMPREPLY=($(compgen -X '\*' -W '${COMPREPLY[@]}' -- "$cur"))
+ _comp_split -a COMPREPLY "$("$aspell" dicts 2>/dev/null)"
+ ((${#COMPREPLY[@]})) &&
+ _comp_compgen -- -X '\*' -W '"${COMPREPLY[@]}"'
}
-_aspell()
+_comp_cmd_aspell()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-c | -p | check | --conf | --personal | --repl | --per-conf)
- _filedir
+ _comp_compgen_filedir
return
;;
--conf-dir | --data-dir | --dict-dir | --home-dir | --local-data-dir | --prefix)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
dump | create | merge)
- COMPREPLY=($(compgen -W 'master personal repl' -- "$cur"))
+ _comp_compgen -- -W 'master personal repl'
return
;;
--mode)
- COMPREPLY=($(compgen -W "$($1 modes 2>/dev/null |
- awk '{ print $1 }')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" modes 2>/dev/null |
+ _comp_awk '{ print $1 }')"
return
;;
--sug-mode)
- COMPREPLY=($(compgen -W 'ultra fast normal bad-speller' \
- -- "$cur"))
+ _comp_compgen -- -W 'ultra fast normal bad-speller'
return
;;
--keymapping)
- COMPREPLY=($(compgen -W 'aspell ispell' -- "$cur"))
+ _comp_compgen -- -W 'aspell ispell'
return
;;
-d | --master)
- _aspell_dictionary "$1"
+ _comp_cmd_aspell__dictionary "$1"
return
;;
--add-filter | --rem-filter)
- COMPREPLY=($(compgen -W "$($1 filters 2>/dev/null |
- awk '{ print $1 }')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" filters 2>/dev/null |
+ _comp_awk '{ print $1 }')"
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--conf= --conf-dir= --data-dir= --dict-dir=
+ _comp_compgen -- -W '--conf= --conf-dir= --data-dir= --dict-dir=
--encoding= --add-filter= --rem-filter= --mode= --add-extra-dicts=
--rem-extra-dicts= --home-dir= --ignore= --ignore-accents
--dont-ignore-accents --ignore-case --dont-ignore-case
@@ -76,13 +77,13 @@ _aspell()
--add-tex-command= --rem-tex-command= --tex-check-comments
--dont-tex-check-comments --add-tex-extension --rem-tex-extension
--add-sgml-check= --rem-sgml-check= --add-sgml-extension
- --rem-sgml-extension' -- "$cur"))
+ --rem-sgml-extension'
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- COMPREPLY=($(compgen -W 'usage help check pipe list config soundslike
- filter version dump create merge' -- "$cur"))
+ _comp_compgen -- -W 'usage help check pipe list config soundslike
+ filter version dump create merge'
fi
} &&
- complete -F _aspell aspell
+ complete -F _comp_cmd_aspell aspell
# ex: filetype=sh
diff --git a/completions/autoconf b/completions/autoconf
index b51e797..ac27886 100644
--- a/completions/autoconf
+++ b/completions/autoconf
@@ -1,40 +1,40 @@
# autoconf(1) completion -*- shell-script -*-
-_autoconf()
+_comp_cmd_autoconf()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case "$prev" in
--help | -h | --version | -V | --trace | -t)
return
;;
--output | -o)
- _filedir
+ _comp_compgen_filedir
return
;;
--warnings | -W)
local cats=(cross obsolete syntax)
- COMPREPLY=($(compgen -W \
- '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur"))
+ _comp_compgen -- -W '"${cats[@]}" "${cats[@]/#/no-}" all none
+ error'
return
;;
--prepend-include | -B | --include | -I)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir '@(ac|in)'
+ _comp_compgen_filedir '@(ac|in)'
} &&
- complete -F _autoconf autoconf
+ complete -F _comp_cmd_autoconf autoconf
# ex: filetype=sh
diff --git a/completions/automake b/completions/automake
index 5fe5f4f..e20ab4f 100644
--- a/completions/automake
+++ b/completions/automake
@@ -1,9 +1,9 @@
# automake(1) completion -*- shell-script -*-
-_automake()
+_comp_cmd_automake()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case "$prev" in
--help | --version)
@@ -11,26 +11,26 @@ _automake()
;;
--warnings | -W)
local cats=(gnu obsolete override portability syntax unsupported)
- COMPREPLY=($(compgen -W \
- '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur"))
+ _comp_compgen -- -W '"${cats[@]}" "${cats[@]/#/no-}" all none
+ error'
return
;;
--libdir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _automake automake automake-1.1{0..6}
+ complete -F _comp_cmd_automake automake automake-1.1{0..6}
# ex: filetype=sh
diff --git a/completions/autoreconf b/completions/autoreconf
index 9b0f0dc..ef43a5c 100644
--- a/completions/autoreconf
+++ b/completions/autoreconf
@@ -1,9 +1,9 @@
# autoreconf(1) completion -*- shell-script -*-
-_autoreconf()
+_comp_cmd_autoreconf()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case "$prev" in
--help | -h | --version | -V)
@@ -12,30 +12,30 @@ _autoreconf()
--warnings | -W)
local cats=(cross gnu obsolete override portability syntax
unsupported)
- COMPREPLY=($(compgen -W \
- '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur"))
+ _comp_compgen -- -W '"${cats[@]}" "${cats[@]/#/no-}" all none
+ error'
return
;;
--prepend-include | -B | --include | -I)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
if [[ $1 == *autoheader ]]; then
- _filedir '@(ac|in)'
+ _comp_compgen_filedir '@(ac|in)'
else
- _filedir -d
+ _comp_compgen_filedir -d
fi
} &&
- complete -F _autoreconf autoreconf autoheader
+ complete -F _comp_cmd_autoreconf autoreconf autoheader
# ex: filetype=sh
diff --git a/completions/autorpm b/completions/autorpm
index d55322a..3e67091 100644
--- a/completions/autorpm
+++ b/completions/autorpm
@@ -1,14 +1,14 @@
# autorpm(8) completion -*- shell-script -*-
-_autorpm()
+_comp_cmd_autorpm()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- COMPREPLY=($(compgen -W '--notty --debug --help --version auto add
- fullinfo info help install list remove set' -- "$cur"))
+ _comp_compgen -- -W '--notty --debug --help --version auto add fullinfo
+ info help install list remove set'
} &&
- complete -F _autorpm autorpm
+ complete -F _comp_cmd_autorpm autorpm
# ex: filetype=sh
diff --git a/completions/autoscan b/completions/autoscan
index e007143..fe48b56 100644
--- a/completions/autoscan
+++ b/completions/autoscan
@@ -1,34 +1,36 @@
# autoscan(1) completion -*- shell-script -*-
-_autoscan()
+_comp_cmd_autoscan()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[BI]*)'
+ # shellcheck disable=SC2254
case "$prev" in
- --help | --version | -!(-*)[hV])
+ --help | --version | -${noargopts}[hV])
return
;;
- --prepend-include | --include | -!(-*)[BI])
- _filedir -d
+ --prepend-include | --include | -${noargopts}[BI])
+ _comp_compgen_filedir -d
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
if [[ $1 == *autoupdate ]]; then
- _filedir '@(ac|in)'
+ _comp_compgen_filedir '@(ac|in)'
else
- _filedir -d
+ _comp_compgen_filedir -d
fi
} &&
- complete -F _autoscan autoscan autoupdate
+ complete -F _comp_cmd_autoscan autoscan autoupdate
# ex: filetype=sh
diff --git a/completions/avahi-browse b/completions/avahi-browse
new file mode 100644
index 0000000..8e4ece7
--- /dev/null
+++ b/completions/avahi-browse
@@ -0,0 +1,42 @@
+# bash completion for avahi-browse(1) -*- shell-script -*-
+
+_comp_cmd_avahi_browse()
+{
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+
+ local noargopts='!(-*|*[D]*)'
+ # shellcheck disable=SC2254
+ case $prev in
+ --domain | -${noargopts}D)
+ return
+ ;;
+ --help | --version | -${noargopts}[hV]*)
+ return
+ ;;
+ esac
+
+ [[ $was_split ]] && return
+
+ if [[ $cur == -* ]]; then
+ _comp_compgen_help
+ [[ ${COMPREPLY-} != *= ]] || compopt -o nospace
+ return
+ fi
+
+ # Complete service types except with -a/-D/-b
+ [[ $1 != *-domains ]] || return
+ local word
+ for word in "${words[@]}"; do
+ case $word in
+ --all | --browse-domains | --dump-db | -${noargopts}[aDb]*)
+ return
+ ;;
+ esac
+ done
+ _comp_compgen_split -- "$("$1" --dump-db --no-db-lookup)"
+
+} &&
+ complete -F _comp_cmd_avahi_browse avahi-browse avahi-browse-domains
+
+# ex: filetype=sh
diff --git a/completions/avctrl b/completions/avctrl
index 89c24e4..2bb2755 100644
--- a/completions/avctrl
+++ b/completions/avctrl
@@ -1,20 +1,20 @@
# avctrl completion -*- shell-script -*-
-_avctrl()
+_comp_cmd_avctrl()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--help --quiet' -- "$cur"))
+ _comp_compgen -- -W '--help --quiet'
else
- local args
- _count_args
- if ((args == 1)); then
- COMPREPLY=($(compgen -W 'discover switch' -- "$cur"))
+ local REPLY
+ _comp_count_args
+ if ((REPLY == 1)); then
+ _comp_compgen -- -W 'discover switch'
fi
fi
} &&
- complete -F _avctrl avctrl
+ complete -F _comp_cmd_avctrl avctrl
# ex: filetype=sh
diff --git a/completions/badblocks b/completions/badblocks
index 29c4e00..14e4e05 100644
--- a/completions/badblocks
+++ b/completions/badblocks
@@ -1,29 +1,30 @@
# badblocks(8) completion -*- shell-script -*-
-_badblocks()
+_comp_cmd_badblocks()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*[bcedpt])
return
;;
-*[io])
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
# Filter out -w (dangerous) and -X (internal use)
- COMPREPLY=($(compgen -X -[wX] -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen -R usage
+ ((${#COMPREPLY[@]})) &&
+ _comp_compgen -- -X '-[wX]' -W '"${COMPREPLY[@]}"'
return
fi
- cur=${cur:=/dev/}
- _filedir
+ _comp_compgen -c "${cur:-/dev/}" filedir
} &&
- complete -F _badblocks badblocks
+ complete -F _comp_cmd_badblocks badblocks
# ex: filetype=sh
diff --git a/completions/bind b/completions/bind
index 2ee428b..12d2343 100644
--- a/completions/bind
+++ b/completions/bind
@@ -1,36 +1,36 @@
# bash bind completion -*- shell-script -*-
-_bind()
+_comp_cmd_bind()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*[lpPsSvVrxX])
return
;;
-*m)
- COMPREPLY=($(compgen -W "emacs emacs-standard emacs-meta
- emacs-ctlx vi vi-move vi-command vi-insert" -- "$cur"))
+ _comp_compgen -- -W "emacs emacs-standard emacs-meta emacs-ctlx vi
+ vi-move vi-command vi-insert"
return
;;
-*f)
- _filedir
+ _comp_compgen_filedir
return
;;
-*[qu])
- COMPREPLY=($(compgen -W '$("$1" -l)' -- "$cur"))
+ _comp_compgen_split -- "$("$1" -l)"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage -c help -s "$1"
return
fi
- COMPREPLY=($(compgen -A binding -- "$cur"))
+ _comp_compgen -- -A binding
} &&
- complete -F _bind bind
+ complete -F _comp_cmd_bind bind
# ex: filetype=sh
diff --git a/completions/bk b/completions/bk
index 4e4d140..e848c04 100644
--- a/completions/bk
+++ b/completions/bk
@@ -1,18 +1,18 @@
# BitKeeper completion -*- shell-script -*-
# adapted from code by Bart Trojanowski <bart@jukie.net>
-_bk()
+_comp_cmd_bk()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local BKCMDS="$(bk help topics 2>/dev/null |
- awk '/^ bk/ { print $2 }' | xargs printf '%s ')"
+ _comp_awk '/^ bk/ { print $2 }' | xargs printf '%s ')"
- COMPREPLY=($(compgen -W "$BKCMDS" -- "$cur"))
- _filedir
+ _comp_compgen -- -W "$BKCMDS"
+ _comp_compgen -a filedir
} &&
- complete -F _bk bk
+ complete -F _comp_cmd_bk bk
# ex: filetype=sh
diff --git a/completions/brctl b/completions/brctl
index 14569b6..0394fa5 100644
--- a/completions/brctl
+++ b/completions/brctl
@@ -1,40 +1,40 @@
# bash completion for brctl -*- shell-script -*-
-_brctl()
+_comp_cmd_brctl()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local command=${words[1]}
case $cword in
1)
- COMPREPLY=($(compgen -W "addbr delbr addif delif setageing
+ _comp_compgen -- -W "addbr delbr addif delif setageing
setbridgeprio setfd sethello setmaxage setpathcost setportprio
- show showmacs showstp stp" -- "$cur"))
+ show showmacs showstp stp"
;;
2)
case $command in
show) ;;
*)
- COMPREPLY=($(compgen -W "$($1 show |
- awk 'NR>1 {print $1}')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" show |
+ _comp_awk 'NR>1 {print $1}')"
;;
esac
;;
3)
case $command in
addif | delif)
- _configured_interfaces
+ _comp_compgen_configured_interfaces
;;
stp)
- COMPREPLY=($(compgen -W 'on off' -- "$cur"))
+ _comp_compgen -- -W 'on off'
;;
esac
;;
esac
} &&
- complete -F _brctl -o default brctl
+ complete -F _comp_cmd_brctl -o default brctl
# ex: filetype=sh
diff --git a/completions/btdownloadheadless.py b/completions/btdownloadheadless.py
index a470e53..f5b791e 100644
--- a/completions/btdownloadheadless.py
+++ b/completions/btdownloadheadless.py
@@ -1,32 +1,31 @@
# btdownloadheadless(1) completion -*- shell-script -*-
-_btdownload()
+_comp_cmd_btdownload()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--responsefile | --saveas)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--max_uploads --keepalive_interval
+ _comp_compgen -- -W '--max_uploads --keepalive_interval
--download_slice_size --request_backlog --max_message_length
--ip --minport --maxport --responsefile --url --saveas --timeout
--timeout_check_interval --max_slice_length --max_rate_period
--bind --upload_rate_fudge --display_interval --rerequest_interval
--min_peers --http_timeout --max_initiate --max_allow_in
--check_hashes --max_upload_rate --snub_time --spew
- --rarest_first_cutoff --min_uploads --report_hash_failures' \
- -- "$cur"))
+ --rarest_first_cutoff --min_uploads --report_hash_failures'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _btdownload btdownloadheadless.py btdownloadcurses.py \
+ complete -F _comp_cmd_btdownload btdownloadheadless.py btdownloadcurses.py \
btdownloadgui.py
# ex: filetype=sh
diff --git a/completions/bts b/completions/bts
index d535d13..e4f8079 100644
--- a/completions/bts
+++ b/completions/bts
@@ -1,81 +1,85 @@
-# bts completion -*- shell-script -*-
+# bts completion -*- shell-script -*-
-# List bug numbers from bugs cache in ~/.devscripts_cache/bts
-_cached_bugs()
+# Generate bug numbers from bugs cache in ~/.devscripts_cache/bts
+_comp_cmd_bts__compgen_cached_bugs()
{
- [[ -d $HOME/.devscripts_cache/bts ]] &&
- find $HOME/.devscripts_cache/bts -maxdepth 1 -name "${cur}[0-9]*.html" \
+ [[ -d $HOME/.devscripts_cache/bts ]] || return 1
+ local bugs=$(
+ find "$HOME/.devscripts_cache/bts" -maxdepth 1 \
+ -name "${cur}[0-9]*.html" \
-printf "%f\n" | cut -d'.' -f1
+ )
+ _comp_compgen -RU bugs -- -W '$bugs'
}
-# List APT source packages prefixed with "src:"
-_src_packages_with_prefix()
+# Generate APT source packages prefixed with "src:"
+_comp_cmd_bts__compgen_src_packages_with_prefix()
{
- ppn=${cur:4} # partial package name, after stripping "src:"
- compgen -P "src:" -W '$(_xfunc apt-cache _apt_cache_sources "$ppn")' \
- -- "$ppn"
+ local _ppn=${cur:4} # partial package name, after stripping "src:"
+ local sources
+ _comp_compgen -v sources -c "$_ppn" -x apt-cache sources &&
+ _comp_compgen -U sources -- -P "src:" -W '"${sources[@]}"'
}
-_bts()
+_comp_cmd_bts()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
show | bugs)
- COMPREPLY=($(compgen -W 'release-critical RC from: tag:
- usertag:' -- "$cur") $(_cached_bugs)
- $(_src_packages_with_prefix))
+ _comp_compgen -- -W 'release-critical RC from: tag: usertag:'
+ _comp_compgen -ai bts cached_bugs
+ _comp_compgen -ai bts src_packages_with_prefix
return
;;
select)
- COMPREPLY=($(compgen -W 'package: source: maintainer: submitter:
+ _comp_compgen -- -W 'package: source: maintainer: submitter:
severity: status: tag: owner: correspondent: affects: bugs:
- users: archive:' -- "$cur"))
+ users: archive:'
return
;;
status)
- COMPREPLY=($(compgen -W 'file: fields: verbose' -- "$cur")
- $(_cached_bugs))
+ _comp_compgen -- -W 'file: fields: verbose'
+ _comp_compgen -ai bts cached_bugs
return
;;
block | unblock)
- COMPREPLY=($(compgen -W 'by with' -- "$cur"))
+ _comp_compgen -- -W 'by with'
return
;;
severity)
- COMPREPLY=($(compgen -W 'wishlist minor normal important serious
- grave critical' -- "$cur"))
+ _comp_compgen -- -W 'wishlist minor normal important serious grave
+ critical'
return
;;
limit)
- COMPREPLY=($(compgen -W 'submitter date subject msgid package
- source tag severity owner affects archive' -- "$cur"))
+ _comp_compgen -- -W 'submitter date subject msgid package source
+ tag severity owner affects archive'
return
;;
clone | "done" | reopen | archive | unarchive | retitle | summary | submitter | found | notfound | fixed | notfixed | merge | forcemerge | unmerge | claim | unclaim | forwarded | notforwarded | owner | noowner | subscribe | unsubscribe | reportspam | spamreport | affects | usertag | usertags | reassign | tag | tags)
- COMPREPLY=($(_cached_bugs))
+ _comp_compgen -i bts cached_bugs
return
;;
package)
- COMPREPLY=($(_xfunc apt-cache _apt_cache_packages))
+ _comp_compgen -x apt-cache packages
return
;;
cache)
- COMPREPLY=($(_xfunc apt-cache _apt_cache_packages)
- $(_src_packages_with_prefix)
- $(compgen -W 'from: release-critical RC' -- "$cur"))
+ _comp_compgen -x apt-cache packages
+ _comp_compgen -ai bts src_packages_with_prefix
+ _comp_compgen -a -- -W 'from: release-critical RC'
return
;;
cleancache)
- COMPREPLY=($(_xfunc apt-cache _apt_cache_packages)
- $(_src_packages_with_prefix)
- $(compgen -W 'from: tag: usertag: ALL' -- "$cur"))
+ _comp_compgen -x apt-cache packages
+ _comp_compgen -ai bts src_packages_with_prefix
+ _comp_compgen -a -- -W 'from: tag: usertag: ALL'
return
;;
user)
# non-predicible arguments
- COMPREPLY=()
return
;;
:)
@@ -83,30 +87,30 @@ _bts()
# COMP_WORDS would be: "bts cleancache src : <partial_pkg_name>"
pos=$((COMP_CWORD - 2))
if [[ $pos -gt 0 && ${COMP_WORDS[pos]} == "src" ]]; then
- COMPREPLY=($(_xfunc apt-cache _apt_cache_src_packages))
+ _comp_compgen -x apt-cache sources
+
return
fi
;;
esac
- $split && return
+ [[ $was_split ]] && return
- COMPREPLY=($(compgen -W '--offline --online --no-offline
- --no-action --cache --no-cache --cache-mode --cache-delay --mbox
- --mailreader --cc-addr --use-default-cc --no-use-default-cc
- --sendmail --mutt --no-mutt --smtp-host --smtp-username
- --smtp-helo --bts-server --force-refresh --no-force-refresh
- --only-new --include-resolved --no-include-resolved --no-ack --ack
- --interactive --force-interactive --no-interactive --quiet
- --no-conf --noconf
+ _comp_compgen -- -W '--offline --online --no-offline --no-action --cache
+ --no-cache --cache-mode --cache-delay --mbox --mailreader --cc-addr
+ --use-default-cc --no-use-default-cc --sendmail --mutt --no-mutt
+ --smtp-host --smtp-username --smtp-helo --bts-server --force-refresh
+ --no-force-refresh --only-new --include-resolved --no-include-resolved
+ --no-ack --ack --interactive --force-interactive --no-interactive
+ --quiet --no-conf --noconf
show bugs select status clone done reopen archive unarchive retitle
summary submitter reassign found notfound fixed notfixed block unblock
merge forcemerge unmerge tag tags affects user usertag usertags claim
unclaim severity forwarded notforwarded package limit owner noowner
subscribe unsubscribe reportspam spamreport cache cleancache version
- help' -- "$cur"))
+ help'
} &&
- complete -F _bts bts
+ complete -F _comp_cmd_bts bts
# ex: filetype=sh
diff --git a/completions/bzip2 b/completions/bzip2
index 40e50fe..0e5d98f 100644
--- a/completions/bzip2
+++ b/completions/bzip2
@@ -1,28 +1,32 @@
# bash completion for bzip2 -*- shell-script -*-
-_bzip2()
+_comp_cmd_bzip2()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[bpn]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | -!(-*)[bhp])
+ --help | -${noargopts}[bhp])
return
;;
- -!(-*)n)
- COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur"))
+ -${noargopts}n)
+ local REPLY
+ _comp_get_ncpus
+ _comp_compgen -- -W "{1..$REPLY}"
return
;;
esac
if [[ $cur == -* ]]; then
- local helpopts=$(_parse_help "$1")
- COMPREPLY=($(compgen -W "${helpopts//#/} -2 -3 -4 -5 -6 -7 -8 -9" \
- -- "$cur"))
+ local helpopts
+ _comp_compgen -Rv helpopts help
+ _comp_compgen -- -W '${helpopts[*]//#/} -{2..9}'
return
fi
- local IFS=$'\n' xspec="*.?(t)bz2"
+ local xspec="*.?(t)bz2"
if [[ $prev == --* ]]; then
[[ $prev == --@(decompress|list|test) ]] && xspec="!"$xspec
@@ -32,11 +36,11 @@ _bzip2()
[[ $prev == -*z* ]] && xspec=
fi
- _tilde "$cur" || return
+ _comp_compgen_tilde && return
compopt -o filenames
- COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur"))
+ _comp_compgen -- -f -X "$xspec" -o plusdirs
} &&
- complete -F _bzip2 bzip2 pbzip2 lbzip2
+ complete -F _comp_cmd_bzip2 bzip2 pbzip2 lbzip2
# ex: filetype=sh
diff --git a/completions/cancel b/completions/cancel
index 3e0c1d5..38571c5 100644
--- a/completions/cancel
+++ b/completions/cancel
@@ -1,27 +1,26 @@
# cancel(1) completion -*- shell-script -*-
-_cancel()
+_comp_cmd_cancel()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-h)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-U)
return
;;
-u)
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
return
;;
esac
- COMPREPLY=($(compgen -W \
- "$(lpstat 2>/dev/null | cut -d' ' -f1)" -- "$cur"))
+ _comp_compgen_split -- "$(lpstat 2>/dev/null | cut -d' ' -f1)"
} &&
- complete -F _cancel cancel
+ complete -F _comp_cmd_cancel cancel
# ex: filetype=sh
diff --git a/completions/cardctl b/completions/cardctl
index bb3a0db..222f7b1 100644
--- a/completions/cardctl
+++ b/completions/cardctl
@@ -1,15 +1,15 @@
# Linux cardctl(8) completion -*- shell-script -*-
-_cardctl()
+_comp_cmd_cardctl()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if ((cword == 1)); then
- COMPREPLY=($(compgen -W 'status config ident suspend resume reset
- eject insert scheme' -- "$cur"))
+ _comp_compgen -- -W 'status config ident suspend resume reset eject
+ insert scheme'
fi
} &&
- complete -F _cardctl cardctl pccardctl
+ complete -F _comp_cmd_cardctl cardctl pccardctl
# ex: filetype=sh
diff --git a/completions/carton b/completions/carton
index 5d700c8..7f99c90 100644
--- a/completions/carton
+++ b/completions/carton
@@ -1,81 +1,95 @@
# carton(3pm) completion -*- shell-script -*-
-_carton_commands()
+_comp_cmd_carton__commands()
{
- local cmds=$("${1:-carton}" usage 2>&1 |
+ local cmds=$("$1" usage 2>&1 |
command sed -ne '/.*command.* is one of/{n;p;q;}')
- COMPREPLY+=($(IFS="$IFS," compgen -W "$cmds" -- "$cur"))
+ _comp_compgen -aF $' \t\n,' -- -W "$cmds"
}
-_carton_command_help()
+_comp_cmd_carton__command_help()
{
- local help=$(PERLDOC_PAGER=cat PERLDOC=-otext "${1:-carton}" -h $2 2>&1)
- COMPREPLY+=($(compgen -W '$help' -- "$cur"))
+ local help=$(PERLDOC_PAGER=cat PERLDOC=-otext "$1" -h "$2" 2>&1)
+ _comp_compgen -a -- -W '$help'
}
-_carton()
+_comp_cmd_carton()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
- local i command
+ local i command="" has_command=""
for ((i = 1; i < cword; i++)); do
case ${words[i]} in
-*) ;;
*)
command=${words[i]}
+ has_command=set
break
;;
esac
done
- if [[ ! -v command ]]; then
- _carton_commands "$1"
+ if [[ ! $has_command ]]; then
+ _comp_cmd_carton__commands "$1"
return
fi
case $prev in
- --version | -v)
- return
- ;;
- --help | -h)
- [[ -n $command ]] || _carton_commands "$1"
+ --version | --help | -[vh])
return
;;
--cpanfile)
if [[ $command == install ]]; then
- _filedir
+ _comp_compgen_filedir
return
fi
;;
--path)
if [[ $command == install ]]; then
- _filedir -d
+ _comp_compgen_filedir -d
return
fi
;;
--without)
if [[ $command == install ]]; then
local phases="configure build test runtime develop"
- COMPREPLY+=($(compgen -W '$phases' -- "$cur"))
+ _comp_compgen -a -- -W '$phases'
return
fi
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
[[ $command == @(help|usage) ]] || COMPREPLY=(--help)
- _carton_command_help "$1" $command
+ _comp_cmd_carton__command_help "$1" "$command"
fi
case $command in
+ exec)
+ # skip all the options --, -v, etc. and identify the command name
+ # position.
+ for ((i++; i < cword; i++)); do
+ case ${words[i]} in
+ --)
+ ((i++))
+ break
+ ;;
+ -*) ;;
+ *) break ;;
+ esac
+ done
+
+ _comp_command_offset "$i"
+ return
+ ;;
show | update)
: # TODO modules completion
;;
esac
} &&
- complete -F _carton carton
+ complete -F _comp_cmd_carton carton
# ex: filetype=sh
diff --git a/completions/ccache b/completions/ccache
index 80c39de..fb3f3e4 100644
--- a/completions/ccache
+++ b/completions/ccache
@@ -1,38 +1,40 @@
# ccache(1) completion -*- shell-script -*-
-_ccache()
+_comp_cmd_ccache()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
local i
- for ((i = 1; i <= COMP_CWORD; i++)); do
- if [[ ${COMP_WORDS[i]} != -* ]]; then
- _command_offset $i
+ for ((i = 1; i <= cword; i++)); do
+ if [[ ${words[i]} != -* ]]; then
+ _comp_command_offset $i
return
fi
- [[ ${COMP_WORDS[i]} == -*[oFM] ]] && ((i++))
+ [[ ${words[i]} == -*[oFM] ]] && ((i++))
done
+ local noargopts='!(-*|*[FMo]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | --max-files | --max-size | -!(-*)[hVFM])
+ --help | --version | --max-files | --max-size | -${noargopts}[hVFM])
return
;;
- --set-config | -!(-*)o)
+ --set-config | -${noargopts}o)
if [[ $cur != *=* ]]; then
- COMPREPLY=($(compgen -S = -W "$($1 -p 2>/dev/null |
- awk '$3 = "=" { print $2 }')" -- "$cur"))
+ _comp_compgen_split -S = -- "$("$1" -p 2>/dev/null |
+ _comp_awk '$3 = "=" { print $2 }')"
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
} &&
- complete -F _ccache ccache
+ complete -F _comp_cmd_ccache ccache
# ex: filetype=sh
diff --git a/completions/ccze b/completions/ccze
index 35f4c3f..31602b0 100644
--- a/completions/ccze
+++ b/completions/ccze
@@ -1,44 +1,45 @@
# ccze(1) completion -*- shell-script -*-
-_ccze()
+_comp_cmd_ccze()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[acFmop]*)'
+ # shellcheck disable=SC2254
case $prev in
-'?' | --help | --usage | -V | --version)
return
;;
- --argument | --color | -!(-*)[ac])
+ --argument | --color | -${noargopts}[ac])
# TODO?
return
;;
- --rcfile | -!(-*)F)
- _filedir
+ --rcfile | -${noargopts}F)
+ _comp_compgen_filedir
return
;;
- --mode | -!(-*)m)
- COMPREPLY=($(compgen -W "curses ansi html" -- "$cur"))
+ --mode | -${noargopts}m)
+ _comp_compgen -- -W "curses ansi html"
return
;;
- --option | -!(-*)o)
+ --option | -${noargopts}o)
local -a opts=(scroll wordcolor lookups transparent cssfile)
- COMPREPLY=($(compgen -W '${opts[@]} ${opts[@]/#/no}' -- "$cur"))
+ _comp_compgen -- -W '"${opts[@]}" "${opts[@]/#/no}"'
return
;;
- --plugin | -!(-*)p)
- COMPREPLY=($(compgen -W '$("$1" --list-plugins | command \
- sed -ne "s/^\([a-z0-9]\{1,\}\)[[:space:]]\{1,\}|.*/\1/p")' \
- -- "$cur"))
+ --plugin | -${noargopts}p)
+ _comp_compgen_split -- "$("$1" --list-plugins | command \
+ sed -ne 's/^\([a-z0-9]\{1,\}\)[[:space:]]\{1,\}|.*/\1/p')"
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
} &&
- complete -F _ccze ccze
+ complete -F _comp_cmd_ccze ccze
# ex: filetype=sh
diff --git a/completions/cd b/completions/cd
new file mode 100644
index 0000000..67dc3de
--- /dev/null
+++ b/completions/cd
@@ -0,0 +1,59 @@
+# cd(1) completion -*- shell-script -*-
+
+# This meta-cd function observes the CDPATH variable, so that `cd`
+# additionally completes on directories under those specified in CDPATH.
+_comp_cmd_cd()
+{
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+
+ if [[ $cur == -* ]]; then
+ _comp_compgen_help -c help "$1"
+ compopt +o nospace
+ return
+ fi
+
+ local i j k
+
+ compopt -o filenames
+
+ # Use standard dir completion if no CDPATH or parameter starts with /,
+ # ./ or ../
+ if [[ ! ${CDPATH-} || $cur == ?(.)?(.)/* ]]; then
+ _comp_compgen_filedir -d
+ return
+ fi
+
+ local mark_dirs="" mark_symdirs=""
+ _comp_readline_variable_on mark-directories && mark_dirs=set
+ _comp_readline_variable_on mark-symlinked-directories && mark_symdirs=set
+
+ # we have a CDPATH, so loop on its contents
+ local paths dirs
+ _comp_split -F : paths "$CDPATH"
+ for i in "${paths[@]}"; do
+ # create an array of matched subdirs
+ k=${#COMPREPLY[@]}
+ _comp_compgen -v dirs -c "$i/$cur" -- -d
+ for j in "${dirs[@]}"; do
+ if [[ ($mark_symdirs && -L $j || $mark_dirs && ! -L $j) && ! -d ${j#"$i/"} ]]; then
+ j+="/"
+ fi
+ COMPREPLY[k++]=${j#"$i/"}
+ done
+ done
+
+ _comp_compgen -a filedir -d
+
+ if ((${#COMPREPLY[@]} == 1)); then
+ i=${COMPREPLY[0]}
+ if [[ $i == "$cur" && $i != "*/" ]]; then
+ COMPREPLY[0]="${i}/"
+ fi
+ fi
+}
+if shopt -q cdable_vars; then
+ complete -v -F _comp_cmd_cd -o nospace cd pushd
+else
+ complete -F _comp_cmd_cd -o nospace cd pushd
+fi
diff --git a/completions/cfagent b/completions/cfagent
index e7ba04d..113e417 100644
--- a/completions/cfagent
+++ b/completions/cfagent
@@ -1,21 +1,21 @@
# cfagent completion -*- shell-script -*-
-_cfagent()
+_comp_cmd_cfagent()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-f | --file)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
fi
} &&
- complete -F _cfagent cfagent
+ complete -F _comp_cmd_cfagent cfagent
# ex: filetype=sh
diff --git a/completions/cfrun b/completions/cfrun
index 72b6138..445bccd 100644
--- a/completions/cfrun
+++ b/completions/cfrun
@@ -1,9 +1,9 @@
# cfrun completion -*- shell-script -*-
-_cfrun()
+_comp_cmd_cfrun()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local i section=1
for ((i = 1; i < cword; i++)); do
@@ -16,13 +16,13 @@ _cfrun()
1)
case $prev in
-f)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-f -h -d -S -T -v' -- "$cur"))
+ _comp_compgen -- -W '-f -h -d -S -T -v'
else
local hostfile=${CFINPUTS:-/var/lib/cfengine/inputs}/cfrun.hosts
for ((i = 1; i < cword; i++)); do
@@ -33,15 +33,15 @@ _cfrun()
done
[[ ! -f $hostfile ]] && return
- COMPREPLY=($(compgen -W "$(command grep -v \
- -E '(=|^$|^#)' $hostfile)" -- "$cur"))
+ _comp_compgen_split -- "$(command grep -v -E '(=|^$|^#)' \
+ "$hostfile")"
fi
;;
2)
- COMPREPLY=($(compgen -W '$(_parse_help cfagent)' -- "$cur"))
+ _comp_compgen_help -c cfagent --help
;;
esac
} &&
- complete -F _cfrun cfrun
+ complete -F _comp_cmd_cfrun cfrun
# ex: filetype=sh
diff --git a/completions/chage b/completions/chage
index fcf87cd..f00433d 100644
--- a/completions/chage
+++ b/completions/chage
@@ -1,30 +1,32 @@
# chage(1) completion -*- shell-script -*-
-_chage()
+_comp_cmd_chage()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[dEImMWR]*)'
+ # shellcheck disable=SC2254
case $prev in
--lastday | --expiredate | --help | --inactive | --mindays | --maxdays | \
- --warndays | -!(-*)[dEhImMW])
+ --warndays | -${noargopts}[dEhImMW])
return
;;
- --root | -!(-*)R)
- _filedir -d
+ --root | -${noargopts}R)
+ _comp_compgen_filedir -d
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
} &&
- complete -F _chage chage
+ complete -F _comp_cmd_chage chage
# ex: filetype=sh
diff --git a/completions/change_pw b/completions/change_pw
index 04837ea..819c082 100644
--- a/completions/change_pw
+++ b/completions/change_pw
@@ -1,25 +1,28 @@
# mailman change_pw completion -*- shell-script -*-
-_change_pw()
+_comp_cmd_change_pw()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-l | --listname)
- _xfunc list_lists _mailman_lists
+ # Prefer `list_lists` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -x list_lists mailman_lists
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--all --domain --listname --password --quiet
- --help' -- "$cur"))
+ _comp_compgen -- -W '--all --domain --listname --password --quiet
+ --help'
fi
} &&
- complete -F _change_pw change_pw
+ complete -F _comp_cmd_change_pw change_pw
# ex: filetype=sh
diff --git a/completions/check_db b/completions/check_db
index aaec99f..6480a11 100644
--- a/completions/check_db
+++ b/completions/check_db
@@ -1,17 +1,20 @@
# mailman check_db completion -*- shell-script -*-
-_check_db()
+_comp_cmd_check_db()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--all --verbose --help' -- "$cur"))
+ _comp_compgen -- -W '--all --verbose --help'
else
- _xfunc list_lists _mailman_lists
+ # Prefer `list_lists` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -x list_lists mailman_lists
fi
} &&
- complete -F _check_db check_db
+ complete -F _comp_cmd_check_db check_db
# ex: filetype=sh
diff --git a/completions/check_perms b/completions/check_perms
index 8ff276e..0ff1ffd 100644
--- a/completions/check_perms
+++ b/completions/check_perms
@@ -1,15 +1,15 @@
# mailman check_perms completion -*- shell-script -*-
-_check_perms()
+_comp_cmd_check_perms()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-f -v -h' -- "$cur"))
+ _comp_compgen -- -W '-f -v -h'
fi
} &&
- complete -F _check_perms check_perms
+ complete -F _comp_cmd_check_perms check_perms
# ex: filetype=sh
diff --git a/completions/checksec b/completions/checksec
index fc2fef7..95e2dce 100644
--- a/completions/checksec
+++ b/completions/checksec
@@ -1,37 +1,48 @@
# bash completion for checksec -*- shell-script -*-
-_checksec()
+_comp_cmd_checksec()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
--version | --help)
return
;;
--file | --fortify-file)
- _filedir
+ _comp_compgen_filedir
return
;;
--dir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
--proc)
- _pnames
+ _comp_compgen_pnames
return
;;
--proc-libs | --fortify-proc)
- _pids
+ _comp_compgen_pids
return
;;
+ --format)
+ _comp_compgen_split -- "$("$1" --help 2>/dev/null |
+ command sed -ne 's/[{,}]/ /g;s/^[[:space:]]*--format=//p')"
+ ;;
+ --output)
+ _comp_compgen_split -- "$("$1" --help 2>/dev/null |
+ command sed -ne 's/[{,}]/ /g;s/^[[:space:]]*--output=//p')"
+ ;;
esac
+ [[ $was_split ]] && return
+
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
} &&
- complete -F _checksec checksec
+ complete -F _comp_cmd_checksec checksec
# ex: filetype=sh
diff --git a/completions/chgrp b/completions/chgrp
index 4793a45..1e19750 100644
--- a/completions/chgrp
+++ b/completions/chgrp
@@ -1,39 +1,39 @@
# chgrp(1) completion -*- shell-script -*-
-_chgrp()
+_comp_cmd_chgrp()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
cur=${cur//\\\\/}
if [[ $prev == --reference ]]; then
- _filedir
+ _comp_compgen_filedir
return
fi
- $split && return
+ [[ $was_split ]] && return
# options completion
if [[ $cur == -* ]]; then
- local w opts
+ local w opts=""
for w in "${words[@]}"; do
[[ $w == -@(R|-recursive) ]] && opts="-H -L -P" && break
done
- COMPREPLY=($(compgen -W '-c -h -f -R -v --changes --dereference
+ _comp_compgen -- -W '-c -h -f -R -v --changes --dereference
--no-dereference --silent --quiet --reference --recursive --verbose
- --help --version $opts' -- "$cur"))
+ --help --version $opts'
return
fi
# first parameter on line or first since an option?
if [[ $cword -eq 1 && $cur != -* || $prev == -* ]]; then
- _allowed_groups "$cur"
+ _comp_compgen_allowed_groups
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _chgrp chgrp
+ complete -F _comp_cmd_chgrp chgrp
# ex: filetype=sh
diff --git a/completions/chkconfig b/completions/chkconfig
index 8ff6637..32c3392 100644
--- a/completions/chkconfig
+++ b/completions/chkconfig
@@ -1,37 +1,35 @@
# chkconfig(8) completion -*- shell-script -*-
-_chkconfig()
+_comp_cmd_chkconfig()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
--level=[1-6] | [1-6] | --list | --add | --del | --override)
- _services
- _xinetd_services
+ _comp_compgen_services
+ _comp_compgen -a xinetd_services
return
;;
--level)
- COMPREPLY=($(compgen -W '{1..6}' -- "$cur"))
+ _comp_compgen -- -W '{1..6}'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--list --add --del --override --level' \
- -- "$cur"))
+ _comp_compgen -- -W '--list --add --del --override --level'
else
if ((cword == 2 || cword == 4)); then
- COMPREPLY=($(compgen -W 'on off reset resetpriorities' \
- -- "$cur"))
+ _comp_compgen -- -W 'on off reset resetpriorities'
else
- _services
- _xinetd_services
+ _comp_compgen_services
+ _comp_compgen -a xinetd_services
fi
fi
} &&
- complete -F _chkconfig chkconfig
+ complete -F _comp_cmd_chkconfig chkconfig
# ex: filetype=sh
diff --git a/completions/chmod b/completions/chmod
index d3fc349..3dbc16f 100644
--- a/completions/chmod
+++ b/completions/chmod
@@ -1,41 +1,40 @@
# chmod(1) completion -*- shell-script -*-
-_chmod()
+_comp_cmd_chmod()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
--help | --version)
return
;;
--reference)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
# Adapted from coreutils 8.28 chmod man page
local modearg="-@(@(+([rwxXst])|[ugo])|+([0-7]))"
# shellcheck disable=SC2053
if [[ $cur == -* && $cur != $modearg ]]; then
- local opts=$(_parse_help "$1")
- COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- local args
- _count_args "" "" "$modearg"
+ local REPLY
+ _comp_count_args -i "$modearg"
- case $args in
+ case $REPLY in
1) ;; # mode
- *) _filedir ;;
+ *) _comp_compgen_filedir ;;
esac
} &&
- complete -F _chmod chmod
+ complete -F _comp_cmd_chmod chmod
# ex: filetype=sh
diff --git a/completions/chown b/completions/chown
index 1d746b7..25d0d67 100644
--- a/completions/chown
+++ b/completions/chown
@@ -1,46 +1,46 @@
# chown(1) completion -*- shell-script -*-
-_chown()
+_comp_cmd_chown()
{
- local cur prev words cword split
+ local cur prev words cword was_split comp_args
# Don't treat user:group as separate words.
- _init_completion -s -n : || return
+ _comp_initialize -s -n : -- "$@" || return
case "$prev" in
--from)
- _usergroup
+ _comp_compgen_usergroups
return
;;
--reference)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
# Complete -options
- local w opts
+ local w opts=""
for w in "${words[@]}"; do
[[ $w == -@(R|-recursive) ]] && opts="-H -L -P" && break
done
- COMPREPLY=($(compgen -W '-c -h -f -R -v --changes --dereference
+ _comp_compgen -- -W '-c -h -f -R -v --changes --dereference
--no-dereference --from --silent --quiet --reference --recursive
- --verbose --help --version $opts' -- "$cur"))
+ --verbose --help --version $opts'
else
- local args
+ local REPLY
- # The first argument is an usergroup; the rest are filedir.
- _count_args :
+ # The first argument is a usergroup; the rest are filedir.
+ _comp_count_args
- if ((args == 1)); then
- _usergroup -u
+ if ((REPLY == 1)); then
+ _comp_compgen_usergroups -u
else
- _filedir
+ _comp_compgen_filedir
fi
fi
} &&
- complete -F _chown chown
+ complete -F _comp_cmd_chown chown
# ex: filetype=sh
diff --git a/completions/chpasswd b/completions/chpasswd
index 3abea99..996bff0 100644
--- a/completions/chpasswd
+++ b/completions/chpasswd
@@ -1,30 +1,31 @@
# chpasswd(8) completion -*- shell-script -*-
-_chpasswd()
+_comp_cmd_chpasswd()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[csR]*)'
+ # shellcheck disable=SC2254
case $prev in
- --crypt | -!(-*)c)
- COMPREPLY=($(compgen -W 'DES MD5 NONE SHA256 SHA512' \
- -- "$cur"))
+ --crypt | -${noargopts}c)
+ _comp_compgen -- -W 'DES MD5 NONE SHA256 SHA512'
return
;;
- --sha-rounds | -!(-*)s)
+ --sha-rounds | -${noargopts}s)
return
;;
- --root | -!(-*)R)
- _filedir -d
+ --root | -${noargopts}R)
+ _comp_compgen_filedir -d
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
} &&
- complete -F _chpasswd chpasswd
+ complete -F _comp_cmd_chpasswd chpasswd
# ex: filetype=sh
diff --git a/completions/chromium-browser b/completions/chromium-browser
index 9ee9896..2126ac6 100644
--- a/completions/chromium-browser
+++ b/completions/chromium-browser
@@ -1,50 +1,50 @@
# chromium-browser completion -*- shell-script -*-
-_chromium_browser()
+_comp_cmd_chromium_browser()
{
- local cur prev words cword split
- _init_completion -s -n : || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -n : -- "$@" || return
case $prev in
--help | --app | --proxy-pac-url | -h)
return
;;
--user-data-dir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
--proxy-server)
case $cur in
*://*)
local prefix="${cur%%://*}://"
- _known_hosts_real -- "${cur#*://}"
- COMPREPLY=("${COMPREPLY[@]/#/$prefix}")
- __ltrim_colon_completions "$cur"
+ _comp_compgen_known_hosts -- "${cur#*://}" &&
+ _comp_compgen -Rv COMPREPLY -- -P "$prefix" -W '"${COMPREPLY[@]}"'
+ _comp_ltrim_colon_completions "$cur"
;;
*)
compopt -o nospace
- COMPREPLY=($(compgen -S :// -W 'http socks socks4 socks5' -- "$cur"))
+ _comp_compgen -- -S :// -W 'http socks socks4 socks5'
;;
esac
return
;;
--password-store)
- COMPREPLY=($(compgen -W 'basic gnome kwallet' -- "$cur"))
+ _comp_compgen -- -W 'basic gnome kwallet'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir "@(?([mxs])htm?(l)|pdf|txt)"
+ _comp_compgen_filedir "@(?([mxs])htm?(l)|pdf|txt)"
} &&
- complete -F _chromium_browser chromium-browser google-chrome \
+ complete -F _comp_cmd_chromium_browser chromium-browser google-chrome \
google-chrome-stable chromium chrome
# ex: filetype=sh
diff --git a/completions/chronyc b/completions/chronyc
index e6bb8e9..15a784b 100644
--- a/completions/chronyc
+++ b/completions/chronyc
@@ -1,34 +1,36 @@
# chronyc(1) completion -*- shell-script -*-
-_chronyc_command_args()
+_comp_cmd_chronyc__command_args()
{
local -a args
- args=($(compgen -W "$($1 help 2>/dev/null |
- awk '/^'$prev'\s[^ []/ { gsub("\\|", " ", $2); print $2 }')"))
+ _comp_split args "$("$1" help 2>/dev/null |
+ _comp_awk '/^'"$prev"'[ \t][^ []/ { gsub("\\|", " ", $2); print $2 }')"
case $args in
- \<address\>) _known_hosts_real -- "$cur" ;;
+ \<address\>) _comp_compgen_known_hosts -- "$cur" ;;
\<*) ;;
- *) COMPREPLY+=($(compgen -W '${args[@]}' -- "$cur")) ;;
+ *) ((${#args[@]})) &&
+ _comp_compgen -a -- -W '"${args[@]}"' ;;
esac
}
-_chronyc()
+_comp_cmd_chronyc()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--help | -*p)
return
;;
-*h)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1") -6' -- "$cur"))
+ _comp_compgen_usage
+ _comp_compgen -a -- -W '-6'
return
fi
@@ -40,22 +42,21 @@ _chronyc()
case $args in
0)
- COMPREPLY=($(compgen -W "$($1 help 2>/dev/null |
- awk '!/(^ |: *$)/ { sub("\\|", " ", $1); print $1 }')" \
- -- "$cur"))
+ _comp_compgen_split -- "$("$1" help 2>/dev/null |
+ _comp_awk '!/(^ |: *$)/ { sub("\\|", " ", $1); print $1 }')"
;;
1)
- _chronyc_command_args "$1"
+ _comp_cmd_chronyc__command_args "$1"
if [[ ! ${COMPREPLY-} && $prev == sources?(tats) ]]; then
- # [-v] not handled by _chronyc_command_args yet
- COMPREPLY=($(compgen -W '-v' -- "$cur"))
+ # [-v] not handled by _comp_cmd_chronyc__command_args yet
+ _comp_compgen -- -W '-v'
fi
;;
2)
- [[ $prev == @(peer|server) ]] && _known_hosts_real -- "$cur"
+ [[ $prev == @(peer|server) ]] && _comp_compgen_known_hosts -- "$cur"
;;
esac
} &&
- complete -F _chronyc chronyc
+ complete -F _comp_cmd_chronyc chronyc
# ex: filetype=sh
diff --git a/completions/chrpath b/completions/chrpath
index 2883967..c248a05 100644
--- a/completions/chrpath
+++ b/completions/chrpath
@@ -1,27 +1,29 @@
# chrpath(1) completion -*- shell-script -*-
-_chrpath()
+_comp_cmd_chrpath()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[r]*)'
+ # shellcheck disable=SC2254
case $prev in
- --version | --help | -!(-*)[vh])
+ --version | --help | -${noargopts}[vh])
return
;;
- --replace | -!(-*)r)
- _filedir -d
+ --replace | -${noargopts}r)
+ _comp_compgen_filedir -d
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _chrpath chrpath
+ complete -F _comp_cmd_chrpath chrpath
# ex: filetype=sh
diff --git a/completions/cksfv b/completions/cksfv
index da404dd..406c8de 100644
--- a/completions/cksfv
+++ b/completions/cksfv
@@ -1,29 +1,29 @@
# cksfv completion by Chris <xris@forevermore.net> -*- shell-script -*-
-_cksfv()
+_comp_cmd_cksfv()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if ((cword == 1)); then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
case "$prev" in
-*C | -*g)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-*f)
- _filedir 'sfv'
+ _comp_compgen_filedir 'sfv'
return
;;
esac
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _cksfv cksfv
+ complete -F _comp_cmd_cksfv cksfv
# ex: filetype=sh
diff --git a/completions/cleanarch b/completions/cleanarch
index 0f7d5f5..c34d038 100644
--- a/completions/cleanarch
+++ b/completions/cleanarch
@@ -1,16 +1,15 @@
# mailman cleanarch completion -*- shell-script -*-
-_cleanarch()
+_comp_cmd_cleanarch()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--status --dry-run --quiet --help' \
- -- "$cur"))
+ _comp_compgen -- -W '--status --dry-run --quiet --help'
fi
} &&
- complete -F _cleanarch cleanarch
+ complete -F _comp_cmd_cleanarch cleanarch
# ex: filetype=sh
diff --git a/completions/clisp b/completions/clisp
index c4259a0..73bf8b2 100644
--- a/completions/clisp
+++ b/completions/clisp
@@ -2,21 +2,21 @@
# bash brogrammable completion for various Common Lisp implementations by
# Nikodemus Siivola <nikodemus@random-state.net>
-_clisp()
+_comp_cmd_clisp()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
# completing an option (may or may not be separated by a space)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-h --help --version --license -B -K -M -m -L
- -N -E -q --quiet --silent -w -I -ansi -traditional -p -C -norc -i
- -c -l -o -x ' -- "$cur"))
+ _comp_compgen -- -W '-h --help --version --license -B -K -M -m -L -N -E
+ -q --quiet --silent -w -I -ansi -traditional -p -C -norc -i -c -l
+ -o -x '
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _clisp -o default clisp
+ complete -F _comp_cmd_clisp -o default clisp
# ex: filetype=sh
diff --git a/completions/clone_member b/completions/clone_member
index a3ca2b3..01f87e6 100644
--- a/completions/clone_member
+++ b/completions/clone_member
@@ -1,25 +1,28 @@
# mailman clone_member completion -*- shell-script -*-
-_clone_member()
+_comp_cmd_clone_member()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-l | --listname)
- _xfunc list_lists _mailman_lists
+ # Prefer `list_lists` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -x list_lists mailman_lists
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--listname --remove --admin --quiet
- --nomodify --help' -- "$cur"))
+ _comp_compgen -- -W '--listname --remove --admin --quiet --nomodify
+ --help'
fi
} &&
- complete -F _clone_member clone_member
+ complete -F _comp_cmd_clone_member clone_member
# ex: filetype=sh
diff --git a/completions/complete b/completions/complete
index a57f366..74ae3f9 100644
--- a/completions/complete
+++ b/completions/complete
@@ -1,49 +1,49 @@
# bash complete completion -*- shell-script -*-
-_complete()
+_comp_cmd_complete()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*o)
- COMPREPLY=($(compgen -W 'bashdefault default dirnames filenames
- nospace plusdirs' -- "$cur"))
+ _comp_compgen -- -W 'bashdefault default dirnames filenames nospace
+ plusdirs'
return
;;
-*A)
- COMPREPLY=($(compgen -W 'alias arrayvar binding builtin command
+ _comp_compgen -- -W 'alias arrayvar binding builtin command
directory disabled enabled export file function group helptopic
hostname job keyword running service setopt shopt signal
- stopped user variable' -- "$cur"))
+ stopped user variable'
return
;;
-*C)
- COMPREPLY=($(compgen -A command -- "$cur"))
+ _comp_compgen -- -A command
return
;;
-*F)
- COMPREPLY=($(compgen -A function -- "$cur"))
+ _comp_compgen -- -A function
return
;;
-*p | -*r)
- COMPREPLY=($(complete -p | command sed -e 's|.* ||'))
- COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur"))
+ _comp_compgen_split -l -- "$(complete -p | command sed -e 's|.* ||')"
return
;;
esac
if [[ $cur == -* ]]; then
- # relevant options completion
- local opts="-a -b -c -d -e -f -g -j -k -o -s -u -v -A -G -W -P -S -X"
- [[ $1 != compgen ]] && opts+=" -F -C"
- COMPREPLY=($(compgen -W "$opts" -- "$cur"))
+ local -a opts
+ _comp_compgen -v opts usage -c help -s "$1"
+ # -F, -C do not work the expected way with compgen
+ [[ $1 != *compgen ]] || opts=("${opts[@]//-[FC]/}")
+ _comp_compgen -- -W '"${opts[@]}"' -X ''
else
- COMPREPLY=($(compgen -A command -- "$cur"))
+ _comp_compgen -- -A command
fi
} &&
- complete -F _complete compgen complete
+ complete -F _comp_cmd_complete compgen complete
# ex: filetype=sh
diff --git a/completions/config_list b/completions/config_list
index 1807e33..d75ef2e 100644
--- a/completions/config_list
+++ b/completions/config_list
@@ -1,27 +1,30 @@
# mailman config_list completion -*- shell-script -*-
-_config_list()
+_comp_cmd_config_list()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-i | -o | --inputfile | --outputfile)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--inputfile --outputfile --checkonly
- --verbose --help' -- "$cur"))
+ _comp_compgen -- -W '--inputfile --outputfile --checkonly
+ --verbose --help'
else
- _xfunc list_lists _mailman_lists
+ # Prefer `list_lists` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_xfunc list_lists mailman_lists
fi
} &&
- complete -F _config_list config_list
+ complete -F _comp_cmd_config_list config_list
# ex: filetype=sh
diff --git a/completions/configure b/completions/configure
index 3f59a01..a61a05d 100644
--- a/completions/configure
+++ b/completions/configure
@@ -1,9 +1,12 @@
# bash completion for configure -*- shell-script -*-
-_configure()
+_comp_deprecate_var 2.12 \
+ COMP_CONFIGURE_HINTS BASH_COMPLETION_CMD_CONFIGURE_HINTS
+
+_comp_cmd_configure()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-h | --help | -V | --version | --program-prefix | --program-suffix | \
@@ -11,32 +14,32 @@ _configure()
return
;;
--*file)
- _filedir
+ _comp_compgen_filedir
return
;;
--*prefix | --*dir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
- $split && return
-
- # if $COMP_CONFIGURE_HINTS is not null, then completions of the form
- # --option=SETTING will include 'SETTING' as a contextual hint
- [[ $cur != -* ]] && return
+ if [[ $was_split || $cur != -* ]]; then
+ _comp_compgen_filedir
+ return
+ fi
- if [[ ${COMP_CONFIGURE_HINTS-} ]]; then
- COMPREPLY=($(compgen -W "$($1 --help 2>&1 |
- awk '/^ --[A-Za-z]/ { print $1; \
- if ($2 ~ /--[A-Za-z]/) print $2 }' | command sed -e 's/[[,].*//g')" \
- -- "$cur"))
+ # if $BASH_COMPLETION_CMD_CONFIGURE_HINTS is not null, then completions of
+ # the form --option=SETTING will include 'SETTING' as a contextual hint
+ if [[ ${BASH_COMPLETION_CMD_CONFIGURE_HINTS-} ]]; then
+ _comp_compgen_split -- "$("$1" --help 2>&1 |
+ _comp_awk '/^ --[A-Za-z]/ { print $1; \
+ if ($2 ~ /--[A-Za-z]/) print $2 }' | command sed -e 's/[[,].*//g')"
[[ ${COMPREPLY-} == *=* ]] && compopt -o nospace
else
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _configure configure
+ complete -F _comp_cmd_configure configure
# ex: filetype=sh
diff --git a/completions/convert b/completions/convert
index ef7baea..b01633b 100644
--- a/completions/convert
+++ b/completions/convert
@@ -1,125 +1,118 @@
# bash completion for ImageMagick -*- shell-script -*-
-_ImageMagick()
+_comp_cmd_convert__common_options()
{
case $prev in
-channel)
- COMPREPLY=($(compgen -W 'Red Green Blue Opacity Matte Cyan
- Magenta Yellow Black' -- "$cur"))
+ _comp_compgen -- -W 'Red Green Blue Opacity Matte Cyan Magenta
+ Yellow Black'
return
;;
-colormap)
- COMPREPLY=($(compgen -W 'shared private' -- "$cur"))
+ _comp_compgen -- -W 'shared private'
return
;;
-colorspace)
- COMPREPLY=($(compgen -W 'GRAY OHTA RGB Transparent XYZ YCbCr YIQ
- YPbPr YUV CMYK' -- "$cur"))
+ _comp_compgen -- -W 'GRAY OHTA RGB Transparent XYZ YCbCr YIQ YPbPr
+ YUV CMYK'
return
;;
-compose)
- COMPREPLY=($(compgen -W 'Over In Out Atop Xor Plus Minus Add
- Subtract Difference Multiply Bumpmap Copy CopyRed CopyGreen
- CopyBlue CopyOpacity' -- "$cur"))
+ _comp_compgen -- -W 'Over In Out Atop Xor Plus Minus Add Subtract
+ Difference Multiply Bumpmap Copy CopyRed CopyGreen CopyBlue
+ CopyOpacity'
return
;;
-compress)
- COMPREPLY=($(compgen -W 'None BZip Fax Group4 JPEG Lossless LZW
- RLE Zip' -- "$cur"))
+ _comp_compgen -- -W 'None BZip Fax Group4 JPEG Lossless LZW RLE
+ Zip'
return
;;
-dispose)
- COMPREPLY=($(compgen -W 'Undefined None Background Previous' \
- -- "$cur"))
+ _comp_compgen -- -W 'Undefined None Background Previous'
return
;;
-encoding)
- COMPREPLY=($(compgen -W 'AdobeCustom AdobeExpert AdobeStandard
+ _comp_compgen -- -W 'AdobeCustom AdobeExpert AdobeStandard
AppleRoman BIG5 GB2312 Latin2 None SJIScode Symbol Unicode
- Wansung' -- "$cur"))
+ Wansung'
return
;;
-endian)
- COMPREPLY=($(compgen -W 'MSB LSB' -- "$cur"))
+ _comp_compgen -- -W 'MSB LSB'
return
;;
-filter)
- COMPREPLY=($(compgen -W 'Point Box Triangle Hermite Hanning
- Hamming Blackman Gaussian Quadratic Cubic Catrom Mitchell
- Lanczos Bessel Sinc' -- "$cur"))
+ _comp_compgen -- -W 'Point Box Triangle Hermite Hanning Hamming
+ Blackman Gaussian Quadratic Cubic Catrom Mitchell Lanczos
+ Bessel Sinc'
return
;;
-format)
- COMPREPLY=($(compgen -W "$(convert -list format | awk \
- '/ [r-][w-][+-] / { sub("[*]$","",$1); print tolower($1) }')" \
- -- "$cur"))
+ _comp_compgen_split -- "$(convert -list format | _comp_awk \
+ '/ [r-][w-][+-] / { sub("[*]$","",$1); print tolower($1) }')"
return
;;
-gravity)
- COMPREPLY=($(compgen -W 'Northwest North NorthEast West Center
- East SouthWest South SouthEast' -- "$cur"))
+ _comp_compgen -- -W 'Northwest North NorthEast West Center East
+ SouthWest South SouthEast'
return
;;
-intent)
- COMPREPLY=($(compgen -W 'Absolute Perceptual Relative
- Saturation' -- "$cur"))
+ _comp_compgen -- -W 'Absolute Perceptual Relative Saturation'
return
;;
-interlace)
- COMPREPLY=($(compgen -W 'None Line Plane Partition' -- "$cur"))
+ _comp_compgen -- -W 'None Line Plane Partition'
return
;;
-limit)
- COMPREPLY=($(compgen -W 'Disk File Map Memory' -- "$cur"))
+ _comp_compgen -- -W 'Disk File Map Memory'
return
;;
-list)
- COMPREPLY=($(compgen -W 'Delegate Format Magic Module Resource
- Type' -- "$cur"))
+ _comp_compgen -- -W 'Delegate Format Magic Module Resource Type'
return
;;
-map)
- COMPREPLY=($(compgen -W 'best default gray red green blue' \
- -- "$cur"))
- _filedir
+ _comp_compgen -- -W 'best default gray red green blue'
+ _comp_compgen -a filedir
return
;;
-noise)
- COMPREPLY=($(compgen -W 'Uniform Gaussian Multiplicative
- Impulse Laplacian Poisson' -- "$cur"))
+ _comp_compgen -- -W 'Uniform Gaussian Multiplicative Impulse
+ Laplacian Poisson'
return
;;
-preview)
- COMPREPLY=($(compgen -W 'Rotate Shear Roll Hue Saturation
- Brightness Gamma Spiff Dull Grayscale Quantize Despeckle
- ReduceNoise AddNoise Sharpen Blur Treshold EdgeDetect Spread
- Shade Raise Segment Solarize Swirl Implode Wave OilPaint
- CharcoalDrawing JPEG' -- "$cur"))
+ _comp_compgen -- -W 'Rotate Shear Roll Hue Saturation Brightness
+ Gamma Spiff Dull Grayscale Quantize Despeckle ReduceNoise
+ AddNoise Sharpen Blur Threshold EdgeDetect Spread Shade Raise
+ Segment Solarize Swirl Implode Wave OilPaint CharcoalDrawing
+ JPEG'
return
;;
-mask | -profile | -texture | -tile | -write)
- _filedir
+ _comp_compgen_filedir
return
;;
-type)
- COMPREPLY=($(compgen -W 'Bilevel Grayscale Palette PaletteMatte
+ _comp_compgen -- -W 'Bilevel Grayscale Palette PaletteMatte
TrueColor TrueColorMatte ColorSeparation ColorSeparationlMatte
- Optimize' -- "$cur"))
+ Optimize'
return
;;
-units)
- COMPREPLY=($(compgen -W 'Undefined PixelsPerInch
- PixelsPerCentimeter' -- "$cur"))
+ _comp_compgen -- -W 'Undefined PixelsPerInch PixelsPerCentimeter'
return
;;
-virtual-pixel)
- COMPREPLY=($(compgen -W 'Constant Edge mirror tile' -- "$cur"))
+ _comp_compgen -- -W 'Constant Edge mirror tile'
return
;;
-visual)
- COMPREPLY=($(compgen -W 'StaticGray GrayScale StaticColor
- PseudoColor TrueColor DirectColor defaut visualid' \
- -- "$cur"))
+ _comp_compgen -- -W 'StaticGray GrayScale StaticColor PseudoColor
+ TrueColor DirectColor default visualid'
return
;;
esac
@@ -127,198 +120,197 @@ _ImageMagick()
return 1
}
-_convert()
+_comp_cmd_convert()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- _ImageMagick && return
+ _comp_cmd_convert__common_options && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
elif [[ $cur == +* ]]; then
- COMPREPLY=($(compgen -W '+adjoin +append +compress +contrast +debug
- +dither +endian +gamma +label +map +mask +matte +negate +noise
- +page +raise +render +write' -- "$cur"))
+ _comp_compgen -- -W '+adjoin +append +compress +contrast +debug +dither
+ +endian +gamma +label +map +mask +matte +negate +noise +page +raise
+ +render +write'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _convert convert
+ complete -F _comp_cmd_convert convert
-_mogrify()
+_comp_cmd_mogrify()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- _ImageMagick && return
+ _comp_cmd_convert__common_options && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
elif [[ $cur == +* ]]; then
- COMPREPLY=($(compgen -W '+compress +contrast +debug +dither +endian
- +gamma +label +map +mask +matte +negate +page +raise' -- "$cur"))
+ _comp_compgen -- -W '+compress +contrast +debug +dither +endian +gamma
+ +label +map +mask +matte +negate +page +raise'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _mogrify mogrify
+ complete -F _comp_cmd_mogrify mogrify
-_display()
+_comp_cmd_display()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- _ImageMagick && return
+ _comp_cmd_convert__common_options && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
elif [[ $cur == +* ]]; then
- COMPREPLY=($(compgen -W '+compress +contrast +debug +dither +endian
- +gamma +label +map +matte +negate +page +raise +write' -- "$cur"))
+ _comp_compgen -- -W '+compress +contrast +debug +dither +endian +gamma
+ +label +map +matte +negate +page +raise +write'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _display display
+ complete -F _comp_cmd_display display
-_animate()
+_comp_cmd_animate()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- _ImageMagick && return
+ _comp_cmd_convert__common_options && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
elif [[ $cur == +* ]]; then
- COMPREPLY=($(compgen -W '+debug +dither +gamma +map +matte' \
- -- "$cur"))
+ _comp_compgen -- -W '+debug +dither +gamma +map +matte'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _animate animate
+ complete -F _comp_cmd_animate animate
-_identify()
+_comp_cmd_identify()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- _ImageMagick && return
+ _comp_cmd_convert__common_options && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
elif [[ $cur == +* ]]; then
- COMPREPLY=($(compgen -W '+debug' -- "$cur"))
+ _comp_compgen -- -W '+debug'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _identify identify
+ complete -F _comp_cmd_identify identify
-_montage()
+_comp_cmd_montage()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- _ImageMagick && return
+ _comp_cmd_convert__common_options && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
elif [[ $cur == +* ]]; then
- COMPREPLY=($(compgen -W '+adjoin +compress +debug +dither +endian
- +gamma +label +matte +page' -- "$cur"))
+ _comp_compgen -- -W '+adjoin +compress +debug +dither +endian +gamma
+ +label +matte +page'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _montage montage
+ complete -F _comp_cmd_montage montage
-_composite()
+_comp_cmd_composite()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- _ImageMagick && return
+ _comp_cmd_convert__common_options && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
elif [[ $cur == +* ]]; then
- COMPREPLY=($(compgen -W '+compress +debug +dither +endian +label
- +matte +negate +page +write' -- "$cur"))
+ _comp_compgen -- -W '+compress +debug +dither +endian +label +matte
+ +negate +page +write'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _composite composite
+ complete -F _comp_cmd_composite composite
-_compare()
+_comp_cmd_compare()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- _ImageMagick && return
+ _comp_cmd_convert__common_options && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
elif [[ $cur == +* ]]; then
- COMPREPLY=($(compgen -W '+debug' -- "$cur"))
+ _comp_compgen -- -W '+debug'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _compare compare
+ complete -F _comp_cmd_compare compare
-_conjure()
+_comp_cmd_conjure()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- _ImageMagick && return
+ _comp_cmd_convert__common_options && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
elif [[ $cur == +* ]]; then
- COMPREPLY=($(compgen -W '+debug' -- "$cur"))
+ _comp_compgen -- -W '+debug'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _conjure conjure
+ complete -F _comp_cmd_conjure conjure
-_import()
+_comp_cmd_import()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- _ImageMagick && return
+ _comp_cmd_convert__common_options && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
elif [[ $cur == +* ]]; then
- COMPREPLY=($(compgen -W '+debug' -- "$cur"))
+ _comp_compgen -- -W '+debug'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _import import
+ complete -F _comp_cmd_import import
-_stream()
+_comp_cmd_stream()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- _ImageMagick && return
+ _comp_cmd_convert__common_options && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
elif [[ $cur == +* ]]; then
- COMPREPLY=($(compgen -W '+debug' -- "$cur"))
+ _comp_compgen -- -W '+debug'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _stream stream
+ complete -F _comp_cmd_stream stream
# ex: filetype=sh
diff --git a/completions/cowsay b/completions/cowsay
index 6ba1d0f..ea1468c 100644
--- a/completions/cowsay
+++ b/completions/cowsay
@@ -1,23 +1,21 @@
# bash completion for cowsay -*- shell-script -*-
-_cowsay()
+_comp_cmd_cowsay()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-f)
- COMPREPLY=($(compgen -W \
- '$(cowsay -l 2>/dev/null | tail -n +2)' -- "$cur"))
+ _comp_compgen_split -- "$(cowsay -l 2>/dev/null | tail -n +2)"
return
;;
esac
# relevant options completion
- COMPREPLY=($(compgen -W '-b -d -g -p -s -t -w -y -e -f -h -l -n -T -W' \
- -- "$cur"))
+ _comp_compgen -- -W '-b -d -g -p -s -t -w -y -e -f -h -l -n -T -W'
} &&
- complete -F _cowsay -o default cowsay cowthink
+ complete -F _comp_cmd_cowsay -o default cowsay cowthink
# ex: filetype=sh
diff --git a/completions/cpan2dist b/completions/cpan2dist
index b5e59da..e53933d 100644
--- a/completions/cpan2dist
+++ b/completions/cpan2dist
@@ -1,37 +1,37 @@
# bash completion for cpan2dist -*- shell-script -*-
-_cpan2dist()
+_comp_cmd_cpan2dist()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--format)
# should remove ":" from COMP_WORDBREAKS, but doesn't work (?)
- COMPREPLY=($(compgen -W '$(perl -MCPANPLUS::Dist -e \
- "print map { \"\$_\n\" } CPANPLUS::Dist->dist_types")' \
- -- "$cur"))
+ _comp_compgen_split -- "$(perl -MCPANPLUS::Dist -e \
+ 'print map { "$_n" } CPANPLUS::Dist->dist_types')"
return
;;
--banlist | --ignorelist | --modulelist | --logfile)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
else
local cpandirs=("$HOME/.cpanplus/" "$HOME/.cpan/source/modules/")
- local packagelist
+ local dir packagelist=
for dir in "${cpandirs[@]}"; do
[[ -d $dir && -r "$dir/02packages.details.txt.gz" ]] &&
packagelist="$dir/02packages.details.txt.gz"
done
- [[ -v packagelist ]] && COMPREPLY=($(zgrep "^${cur//-/::}" \
- $packagelist 2>/dev/null | awk '{print $1}' | command sed -e 's/::/-/g'))
+ [[ $packagelist ]] && _comp_split COMPREPLY "$(zgrep "^${cur//-/::}" \
+ "$packagelist" 2>/dev/null | _comp_awk '{print $1}' |
+ command sed -e 's/::/-/g')"
fi
} &&
- complete -F _cpan2dist -o default cpan2dist
+ complete -F _comp_cmd_cpan2dist -o default cpan2dist
# ex: filetype=sh
diff --git a/completions/cpio b/completions/cpio
index d6fde0c..e7b70cd 100644
--- a/completions/cpio
+++ b/completions/cpio
@@ -1,78 +1,75 @@
# bash completion for cpio -*- shell-script -*-
-_cpio()
+_comp_cmd_cpio()
{
- local cur prev words cword split
- _init_completion -s -n : || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -n : -- "$@" || return
# --name value style option
+ local noargopts='!(-*|*[HEFIR]*)'
+ # shellcheck disable=SC2254
case $prev in
- --format | -!(-*)H)
- COMPREPLY=($(compgen -W \
- 'bin odc newc crc tar ustar hpbin hpodc' -- "$cur"))
+ --format | -${noargopts}H)
+ _comp_compgen -- -W 'bin odc newc crc tar ustar hpbin hpodc'
return
;;
- --file | --pattern-file | -!(-*)[EFI])
- _filedir
+ --file | --pattern-file | -${noargopts}[EFI])
+ _comp_compgen_filedir
return
;;
- --owner | -!(-*)R)
- _usergroup
+ --owner | -${noargopts}R)
+ _comp_compgen_usergroups
return
;;
--rsh-command)
- compopt -o filenames
- COMPREPLY=($(compgen -c -- "$cur"))
+ _comp_compgen_commands
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if ((cword == 1)); then
- COMPREPLY=($(compgen -W '-o --create -i --extract -p --pass-through
- -? --help --license --usage --version' -- "$cur"))
+ _comp_compgen -- -W '-o --create -i --extract -p --pass-through -?
+ --help --license --usage --version'
else
case ${words[1]} in
-o | --create)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-0 -a -c -v -A -B -L -V -C -H -M
- -O -F --file --format --message --null
- --reset-access-time --verbose --dot --append
- --block-size --dereference --io-size --quiet
- --force-local --rsh-command --help --version' \
- -- "$cur"))
+ _comp_compgen -- -W '-0 -a -c -v -A -B -L -V -C -H -M -O -F
+ --file --format --message --null --reset-access-time
+ --verbose --dot --append --block-size --dereference
+ --io-size --quiet --force-local --rsh-command --help
+ --version'
fi
;;
-i | --extract)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-b -c -d -f -m -n -r -t -s -u -v
- -B -S -V -C -E -H -M -R -I -F --file --make-directories
+ _comp_compgen -- -W '-b -c -d -f -m -n -r -t -s -u -v -B -S
+ -V -C -E -H -M -R -I -F --file --make-directories
--nonmatching --preserve-modification-time
--numeric-uid-gid --rename --list --swap-bytes --swap
--dot --unconditional --verbose --block-size
--swap-halfwords --io-size --pattern-file --format
--owner --no-preserve-owner --message --force-local
--no-absolute-filenames --sparse --only-verify-crc
- --quiet --rsh-command --help --to-stdout --version' \
- -- "$cur"))
+ --quiet --rsh-command --help --to-stdout --version'
fi
;;
-p* | --pass-through)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-0 -a -d -l -m -u -v -L -V -R
- --null --reset-access-time --make-directories --link
- --quiet --preserve-modification-time --unconditional
- --verbose --dot --dereference --owner
- --no-preserve-owner --sparse --help --version' \
- -- "$cur"))
+ _comp_compgen -- -W '-0 -a -d -l -m -u -v -L -V -R --null
+ --reset-access-time --make-directories --link --quiet
+ --preserve-modification-time --unconditional --verbose
+ --dot --dereference --owner --no-preserve-owner
+ --sparse --help --version'
else
- _filedir -d
+ _comp_compgen_filedir -d
fi
;;
esac
fi
} &&
- complete -F _cpio cpio
+ complete -F _comp_cmd_cpio cpio
# ex: filetype=sh
diff --git a/completions/cppcheck b/completions/cppcheck
index 8ea9571..5867fc7 100644
--- a/completions/cppcheck
+++ b/completions/cppcheck
@@ -1,14 +1,14 @@
# bash completion for cppcheck(1) -*- shell-script -*-
-_cppcheck()
+_comp_cmd_cppcheck()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
--append | --exitcode-suppressions | --rule-file | --config-excludes-file | \
--suppressions-list | --includes-file | --include | -i)
- _filedir
+ _comp_compgen_filedir
return
;;
-D | -U | --rule | --suppress | --template | --max-configs | -h | --help | --version | \
@@ -17,75 +17,75 @@ _cppcheck()
;;
--enable)
# split comma-separated list
- split=false
+ local split=""
if [[ $cur == ?*,* ]]; then
prev="${cur%,*}"
cur="${cur##*,}"
- split=true
+ split="set"
fi
- COMPREPLY=($(compgen -W 'all warning style performance
- portability information unusedFunction missingInclude' \
- -- "$cur"))
- $split && COMPREPLY=(${COMPREPLY[@]/#/"$prev,"})
+ _comp_compgen -- -W 'all warning style performance portability
+ information unusedFunction missingInclude' &&
+ [[ $split ]] &&
+ _comp_compgen -Rv COMPREPLY -- -P "$prev," -W '"${COMPREPLY[@]}"'
return
;;
--error-exitcode)
- COMPREPLY=($(compgen -W '{0..255}' -- "$cur"))
+ _comp_compgen -- -W '{0..255}'
return
;;
--file-list)
- _filedir
- [[ -z $cur || $cur == - ]] && COMPREPLY+=(-)
+ _comp_compgen_filedir
+ [[ ! $cur || $cur == - ]] && COMPREPLY+=(-)
return
;;
-I)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-j)
- COMPREPLY=($(compgen -W "{2..$(_ncpus)}" -- "$cur"))
+ local REPLY
+ _comp_get_ncpus
+ _comp_compgen -- -W "{1..$REPLY}"
return
;;
--language | -x)
- COMPREPLY=($(compgen -W 'c c++' -- "$cur"))
+ _comp_compgen -- -W 'c c++'
return
;;
--std)
- COMPREPLY=($(compgen -W 'c89 c99 c11 c++03 c++11 c++14 c++17
- c++20' -- "$cur"))
+ _comp_compgen -- -W 'c89 c99 c11 c++03 c++11 c++14 c++17 c++20'
return
;;
--platform)
- _filedir
- COMPREPLY+=($(compgen -W 'unix32 unix64 win32A win32W win64
- native' -- "$cur"))
+ _comp_compgen_filedir
+ _comp_compgen -a -- -W 'unix32 unix64 win32A win32W win64 native'
return
;;
-rp | --relative-paths)
- if $split; then # -rp without argument is allowed
- _filedir -d
+ if [[ $was_split ]]; then # -rp without argument is allowed
+ _comp_compgen_filedir -d
return
fi
;;
--library)
- _filedir cfg
+ _comp_compgen_filedir cfg
return
;;
--xml-version)
- COMPREPLY=($(compgen -W '1 2' -- "$cur"))
+ _comp_compgen -- -W '1 2'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- _filedir '@([cht]pp|[cht]xx|cc|[ch]++|[ch])'
+ _comp_compgen_filedir '@([cht]pp|[cht]xx|cc|[ch]++|[ch])'
fi
} &&
- complete -F _cppcheck cppcheck
+ complete -F _comp_cmd_cppcheck cppcheck
# ex: filetype=sh
diff --git a/completions/crontab b/completions/crontab
index cac7853..4f80347 100644
--- a/completions/crontab
+++ b/completions/crontab
@@ -1,13 +1,13 @@
# crontab(1) completion -*- shell-script -*-
-_crontab()
+_comp_cmd_crontab()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*u)
- _allowed_users
+ _comp_compgen_allowed_users
return
;;
esac
@@ -18,31 +18,31 @@ _crontab()
local i
for i in "${!words[@]}"; do
- [[ ${words[i]} && $i -ne $cword ]] && unset "opts[${words[i]}]"
+ [[ ${words[i]} && $i -ne $cword ]] && unset -v "opts[${words[i]}]"
case "${words[i]}" in
-l)
- unset 'opts[-r]' 'opts[-e]' 'opts[-i]' 'opts[-s]'
+ unset -v 'opts[-r]' 'opts[-e]' 'opts[-i]' 'opts[-s]'
;;
-e)
- unset 'opts[-l]' 'opts[-r]' 'opts[-i]'
+ unset -v 'opts[-l]' 'opts[-r]' 'opts[-i]'
;;
-r)
- unset 'opts[-l]' 'opts[-e]'
+ unset -v 'opts[-l]' 'opts[-e]'
;;
-u)
- unset 'opts[-i]'
+ unset -v 'opts[-i]'
;;
esac
done
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '${!opts[@]}' -- "$cur"))
+ _comp_compgen -- -W '"${!opts[@]}"'
return
fi
# do filenames only if we did not have -l, -r, or -e
- [[ ${words[*]} == *\ -[lre]* ]] || _filedir
+ [[ ${words[*]} == *\ -[lre]* ]] || _comp_compgen_filedir
} &&
- complete -F _crontab crontab
+ complete -F _comp_cmd_crontab crontab
# ex: filetype=sh
diff --git a/completions/cryptsetup b/completions/cryptsetup
index e73e165..9d23bfa 100644
--- a/completions/cryptsetup
+++ b/completions/cryptsetup
@@ -1,61 +1,52 @@
# bash completion for cryptsetup -*- shell-script -*-
-_cryptsetup_name()
+_comp_cmd_cryptsetup__name()
{
- COMPREPLY=($(compgen -X control -W '$(command ls /dev/mapper)' -- "$cur"))
+ _comp_compgen_split -X control -- "$(command ls /dev/mapper)"
}
-_cryptsetup_device()
+_comp_cmd_cryptsetup__device()
{
- cur=${cur:=/dev/}
- _filedir
+ _comp_compgen -c "${cur:-/dev/}" filedir
}
-_cryptsetup()
+_comp_cmd_cryptsetup()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[cslSbopitTdM]*)'
+ # shellcheck disable=SC2254
case $prev in
--help | --version | --cipher | --hash | --*-size | --key-slot | --size | --offset | \
- --skip | --iter-time | --timeout | --tries | -!(-*)[chslSbopitT])
+ --skip | --iter-time | --timeout | --tries | -${noargopts}[chslSbopitT])
return
;;
- --key-file | --master-key-file | --header-backup-file | -!(-*)d)
- _filedir
+ --key-file | --master-key-file | --header-backup-file | -${noargopts}d)
+ _comp_compgen_filedir
return
;;
- --type | -!(-*)M)
- COMPREPLY=($(compgen -W "luks plain loopaes tcrypt" -- "$cur"))
+ --type | -${noargopts}M)
+ _comp_compgen -- -W "luks plain loopaes tcrypt"
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
- local arg
- _get_first_arg
- if [[ -z $arg ]]; then
- if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
- [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
- else
- COMPREPLY=($(compgen -W 'open close resize status benchmark
- repair erase luksFormat luksAddKey luksRemoveKey luksChangeKey
- luksKillSlot luksUUID isLuks luksDump tcryptDump luksSuspend
- luksResume luksHeaderBackup luksHeaderRestore' -- "$cur"))
- fi
- else
- local args
- _count_args "" "-!(-*)[chslSbopitTdM]"
+ local REPLY
+ if _comp_get_first_arg; then
+ local arg=$REPLY
+ _comp_count_args -a "-${noargopts}[chslSbopitTdM]"
+ local args=$REPLY
case $arg in
open | create | luksOpen | loopaesOpen | tcryptOpen)
case $args in
2)
- _cryptsetup_device
+ _comp_cmd_cryptsetup__device
;;
3)
- _cryptsetup_name
+ _comp_cmd_cryptsetup__name
;;
esac
;;
@@ -63,31 +54,31 @@ _cryptsetup()
luksSuspend | luksResume)
case $args in
2)
- _cryptsetup_name
+ _comp_cmd_cryptsetup__name
;;
esac
;;
luksFormat | luksAddKey | luksRemoveKey | luksChangeKey)
case $args in
2)
- _cryptsetup_device
+ _comp_cmd_cryptsetup__device
;;
3)
- _filedir
+ _comp_compgen_filedir
;;
esac
;;
luksKillSlot | luksDelKey | luksUUID | isLuks | luksDump)
case $args in
2)
- _cryptsetup_device
+ _comp_cmd_cryptsetup__device
;;
esac
;;
luksHeaderBackup | luksHeaderRestore)
case $args in
2)
- _cryptsetup_device
+ _comp_cmd_cryptsetup__device
;;
3)
COMPREPLY=('--header-backup-file')
@@ -95,9 +86,19 @@ _cryptsetup()
esac
;;
esac
+ else
+ if [[ $cur == -* ]]; then
+ _comp_compgen_help
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
+ else
+ _comp_compgen -- -W 'open close resize status benchmark repair
+ erase luksFormat luksAddKey luksRemoveKey luksChangeKey
+ luksKillSlot luksUUID isLuks luksDump tcryptDump luksSuspend
+ luksResume luksHeaderBackup luksHeaderRestore'
+ fi
fi
} &&
- complete -F _cryptsetup cryptsetup
+ complete -F _comp_cmd_cryptsetup cryptsetup
# ex: filetype=sh
diff --git a/completions/curl b/completions/curl
index 6e84269..6cbbca4 100644
--- a/completions/curl
+++ b/completions/curl
@@ -1,48 +1,59 @@
# curl(1) completion -*- shell-script -*-
-_curl()
+_comp_cmd_curl()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
+ local noargopts='!(-*|*[KbcDoTCFmQreYytzuAwEdHPxX]*)'
+ # shellcheck disable=SC2254
case $prev in
- --ciphers | --connect-timeout | --continue-at | --form | --form-string | \
- --ftp-account | --ftp-alternative-to-user | --ftp-port | --header | --help | \
- --hostpubmd5 | --keepalive-time | --krb | --limit-rate | --local-port | \
- --mail-from | --mail-rcpt | --max-filesize | --max-redirs | --max-time | --pass | \
- --proto | --proto-redir | --proxy-user | --proxy1.0 | --quote | --range | \
- --request | --retry | --retry-delay | --retry-max-time | \
- --socks5-gssapi-service | --telnet-option | --tftp-blksize | --time-cond | \
- --url | --user | --user-agent | --version | --write-out | --resolve | --tlsuser | \
- --tlspassword | -!(-*)[CFPHhmQrXtzuAVw])
+ --abstract-unix-socket | --alt-svc | --config | --cookie | \
+ --cookie-jar | --dump-header | --egd-file | --etag-compare | \
+ --etag-save | --hsts | --key | --libcurl | --netrc-file | \
+ --output | --proxy-key | --random-file | --trace | --trace-ascii | \
+ --unix-socket | --upload-file | -${noargopts}[KbcDoT])
+ _comp_compgen_filedir
return
;;
- --config | --cookie | --cookie-jar | --dump-header | --egd-file | \
- --key | --libcurl | --output | --random-file | --upload-file | --trace | \
- --trace-ascii | --netrc-file | -!(-*)[KbcDoT])
- _filedir
+ --ciphers | --connect-timeout | --connect-to | --continue-at | \
+ --curves | --data-raw | --doh-url | --expect100-timeout | --form | \
+ --form-string | --ftp-account | --ftp-alternative-to-user | \
+ --happy-eyeballs-timeout-ms | --hostpubmd5 | --keepalive-time | \
+ --limit-rate | --local-port | --login-options | --mail-auth | \
+ --mail-from | --mail-rcpt | --max-filesize | --max-redirs | \
+ --max-time | --pass | --proto | --proto-default | --proto-redir | \
+ --proxy-ciphers | --proxy-pass | --proxy-service-name | \
+ --proxy-tls13-ciphers | --proxy-tlspassword | --proxy-tlsuser | \
+ --proxy-user | --proxy1.0 | --quote | --range | --referer | \
+ --resolve | --retry | --retry-delay | --retry-max-time | \
+ --sasl-authzid | --service-name | --socks5-gssapi-service | \
+ --speed-limit | --speed-time | --telnet-option | --tftp-blksize | \
+ --time-cond | --tls13-ciphers | --tlspassword | --tlsuser | \
+ --url | --user | --user-agent | --version | --write-out | \
+ -${noargopts}[CFmQreYytzuAVw])
return
;;
- --cacert | --cert | -!(-*)E)
- _filedir '@(c?(e)rt|cer|pem|der)'
+ --cacert | --cert | --proxy-cacert | --proxy-cert | -${noargopts}E)
+ _comp_compgen_filedir '@(c?(e)rt|cer|pem|der)'
return
;;
- --capath)
- _filedir -d
+ --capath | --output-dir | --proxy-capath)
+ _comp_compgen_filedir -d
return
;;
- --cert-type | --key-type)
- COMPREPLY=($(compgen -W 'DER PEM ENG' -- "$cur"))
+ --cert-type | --key-type | --proxy-cert-type | --proxy-key-type)
+ _comp_compgen -- -W 'DER PEM ENG'
return
;;
- --crlfile)
- _filedir crl
+ --crlfile | --proxy-crlfile)
+ _comp_compgen_filedir crl
return
;;
- --data | --data-ascii | --data-binary | --data-urlencode | -!(-*)d)
+ --data | --data-ascii | --data-binary | --data-urlencode | --header | \
+ --proxy-header | -${noargopts}[dH])
if [[ $cur == \@* ]]; then
- cur=${cur:1}
- _filedir
+ _comp_compgen -c "${cur:1}" filedir
if [[ ${#COMPREPLY[@]} -eq 1 && -d ${COMPREPLY[0]} ]]; then
COMPREPLY[0]+=/
compopt -o nospace
@@ -52,48 +63,100 @@ _curl()
return
;;
--delegation)
- COMPREPLY=($(compgen -W 'none policy always' -- "$cur"))
+ _comp_compgen -- -W 'none policy always'
+ return
+ ;;
+ --dns-ipv[46]-addr)
+ _comp_compgen_ip_addresses -"${prev:9:1}"
+ return
+ ;;
+ --dns-servers | --noproxy)
+ _comp_compgen_known_hosts -- "${cur##*,}"
+ ((${#COMPREPLY[@]})) &&
+ _comp_delimited , -W '"${COMPREPLY[@]}"'
return
;;
--engine)
- COMPREPLY=($(compgen -W 'list' -- "$cur"))
+ local engines=$(
+ "$1" --engine list 2>/dev/null |
+ command grep "^[[:space:]]"
+ )
+ _comp_compgen -- -W '$engines list'
+ return
+ ;;
+ --ftp-port | -${noargopts}P)
+ _comp_compgen_available_interfaces -a
+ _comp_compgen -a known_hosts -- "$cur"
+ _comp_compgen -a ip_addresses -a
return
;;
--ftp-method)
- COMPREPLY=($(compgen -W 'multicwd nocwd singlecwd' -- "$cur"))
+ _comp_compgen -- -W 'multicwd nocwd singlecwd'
return
;;
--ftp-ssl-ccc-mode)
- COMPREPLY=($(compgen -W 'active passive' -- "$cur"))
+ _comp_compgen -- -W 'active passive'
return
;;
--interface)
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
+ return
+ ;;
+ --help | -${noargopts}h)
+ local x categories
+ if _comp_split categories "$("$1" --help non-existent-category 2>&1 |
+ _comp_awk '/^[ \t]/ {print $1}')"; then
+ for x in "${categories[@]}"; do
+ # Looks like an option? Likely no --help category support
+ [[ $x != -* ]] || return
+ done
+ _comp_compgen -- -W '"${categories[@]}"'
+ fi
return
;;
- --proxy | --socks4 | --socks4a | --socks5 | --socks5-hostname | -!(-*)x)
- _known_hosts_real -- "$cur"
+ --krb)
+ _comp_compgen -- -W 'clear safe confidential private'
+ return
+ ;;
+ --pinnedpubkey | --proxy-pinnedpubkey)
+ _comp_compgen_filedir '@(pem|der|key)'
+ return
+ ;;
+ --preproxy | --proxy | --socks4 | --socks4a | --socks5 | \
+ --socks5-hostname | -${noargopts}x)
+ _comp_compgen_known_hosts -- "$cur"
return
;;
--pubkey)
- _xfunc ssh _ssh_identityfile pub
+ _comp_compgen -x ssh identityfile pub
+ return
+ ;;
+ --request | -${noargopts}X)
+ # TODO: these are valid for http(s) only
+ _comp_compgen -- -W 'GET HEAD POST PUT DELETE CONNECT OPTIONS TRACE
+ PATCH'
return
;;
--stderr)
- COMPREPLY=($(compgen -W '-' -- "$cur"))
- _filedir
+ _comp_compgen -- -W '-'
+ _comp_compgen -a filedir
+ return
+ ;;
+ --tls-max)
+ _comp_compgen -- -W 'default 1.0 1.1 1.2 1.3'
return
;;
- --tlsauthtype)
- COMPREPLY=($(compgen -W 'SRP' -- "$cur"))
+ --tlsauthtype | --proxy-tlsauthtype)
+ _comp_compgen -- -W 'SRP'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help -- --help all
+ [[ ${COMPREPLY-} ]] || _comp_compgen_help
fi
} &&
- complete -F _curl curl
+ complete -F _comp_cmd_curl curl
# ex: filetype=sh
diff --git a/completions/cvs b/completions/cvs
index ba1f062..5629dfe 100644
--- a/completions/cvs
+++ b/completions/cvs
@@ -1,58 +1,65 @@
# cvs(1) completion -*- shell-script -*-
-_cvs_entries()
+_comp_deprecate_var 2.12 \
+ COMP_CVS_REMOTE BASH_COMPLETION_CMD_CVS_REMOTE
+
+# Usage: _comp_cmd_cvs__compgen_entries [base_path]
+# @param[opt] $1
+# shellcheck disable=SC2120
+_comp_cmd_cvs__compgen_entries()
{
- local prefix=${cur%/*}/ IFS=$'\n'
- [[ -e ${prefix:-}CVS/Entries ]] || prefix=""
- entries=($(cut -d/ -f2 -s ${prefix:-}CVS/Entries 2>/dev/null))
- if [[ $entries ]]; then
- entries=("${entries[@]/#/${prefix:-}}")
+ local base_path=${1-$cur}
+ local _prefix=${base_path%/*}/
+ [[ -e ${_prefix-}CVS/Entries ]] || _prefix=""
+ _comp_compgen -c "${cur#"$_prefix"}" split -lP "$_prefix" -- "$(cut -d/ -f2 -s "${_prefix-}CVS/Entries" 2>/dev/null)" &&
compopt -o filenames
- fi
}
-_cvs_modules()
+_comp_cmd_cvs__modules()
{
- if [[ -n $prefix ]]; then
- COMPREPLY=($(command ls -d ${cvsroot}/${prefix}/!(CVSROOT)))
- else
- COMPREPLY=($(command ls -d ${cvsroot}/!(CVSROOT)))
- fi
+ _comp_expand_glob COMPREPLY '"$cvsroot${prefix:+/$prefix}"/!(CVSROOT)'
}
-_cvs_commands()
+_comp_cmd_cvs__compgen_commands()
{
- cvs --help-commands 2>&1 | awk '/^( *|\t)/ { print $1 }'
+ _comp_compgen_split -- "$(
+ "$1" --help-commands 2>&1 | _comp_awk '/^( *|\t)/ { print $1 }'
+ )"
}
-_cvs_command_options()
+_comp_cmd_cvs__compgen_command_options()
{
- COMPREPLY=($(compgen -W '$(_parse_help "$1" "--help $2")' -- "$cur"))
+ _comp_compgen_help -- --help "$2"
}
-_cvs_kflags()
+_comp_cmd_cvs__compgen_kflags()
{
- COMPREPLY=($(compgen -W 'kv kvl k o b v' -- "$cur"))
+ _comp_compgen -- -W 'kv kvl k o b v'
}
-_cvs_roots()
+# @since 2.12
+_comp_xfunc_cvs_compgen_roots()
{
- local -a cvsroots
+ local -a cvsroots=()
[[ -v CVSROOT ]] && cvsroots=("$CVSROOT")
- [[ -r ~/.cvspass ]] && cvsroots+=($(awk '{ print $2 }' ~/.cvspass))
- [[ -r CVS/Root ]] && mapfile -tO ${#cvsroots[@]} cvsroots <CVS/Root
- COMPREPLY=($(compgen -W '${cvsroots[@]}' -- "$cur"))
- __ltrim_colon_completions "$cur"
+ [[ -r ~/.cvspass ]] && _comp_split -a cvsroots "$(_comp_awk '{ print $2 }' ~/.cvspass)"
+ [[ -r CVS/Root ]] && mapfile -tO "${#cvsroots[@]}" cvsroots <CVS/Root
+ ((${#cvsroots[@]})) &&
+ _comp_compgen -U cvsroots -- -W '"${cvsroots[@]}"'
+ _comp_ltrim_colon_completions "$cur"
}
-_cvs()
+_comp_deprecate_func 2.12 _cvs_roots _comp_xfunc_cvs_compgen_roots
+
+_comp_cmd_cvs()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
- local count mode i cvsroot cvsroots pwd
- local -a flags files entries changed newremoved
+ local count mode="" i cvsroot="" has_cvsroot="" pwd
+ local -a flags files entries
+ local noargopts='!(-*|*[d]*)'
count=0
for i in "${words[@]}"; do
((count == cword)) && break
@@ -60,15 +67,17 @@ _cvs()
if [[ ${words[count]} == "${cvsroot-}" && ${mode-} == cvsroot ]]; then
mode=""
fi
- if [[ ! -v mode ]]; then
+ if [[ ! $mode ]]; then
+ # shellcheck disable=SC2254
case $i in
- --help | -!(-*)H)
- COMPREPLY=($(compgen -W "$(_cvs_commands)" -- "$cur"))
+ --help | -${noargopts}H)
+ _comp_cmd_cvs__compgen_commands "$1"
return
;;
- -!(-*)d)
+ -${noargopts}d)
mode=cvsroot
cvsroot=${words[count + 1]}
+ has_cvsroot=set
;;
add | ad | new)
mode=add
@@ -132,7 +141,7 @@ _cvs()
;;
esac
elif [[ $i == -* ]]; then
- flags+=($i)
+ flags+=("$i")
fi
((count++))
done
@@ -145,32 +154,36 @@ _cvs()
return
;;
-*k)
- _cvs_kflags
+ _comp_cmd_cvs__compgen_kflags
return
;;
esac
if [[ $cur != -* ]]; then
- _cvs_entries
- [[ -z $cur ]] && files=(!(CVS)) ||
- files=($(command ls -d ${cur}* 2>/dev/null))
+ _comp_compgen -Rv entries -i cvs entries "${cur-}"
+ if [[ ! $cur ]]; then
+ _comp_expand_glob files '!(CVS)'
+ else
+ _comp_expand_glob files '"${cur}"*'
+ fi
local f
for i in "${!files[@]}"; do
if [[ ${files[i]} == ?(*/)CVS ]]; then
- unset 'files[i]'
- else
+ unset -v 'files[i]'
+ elif ((${#entries[@]})); then
for f in "${entries[@]}"; do
if [[ ${files[i]} == "$f" && ! -d $f ]]; then
- unset 'files[i]'
+ unset -v 'files[i]'
break
fi
done
fi
done
- COMPREPLY=($(compgen -X "$_backup_glob" -W '${files[@]}' \
- -- "$cur"))
+ # shellcheck disable=SC2154 # global var _comp_backup_glob
+ ((${#files[@]})) &&
+ _comp_compgen -- -X "$_comp_backup_glob" -W '"${files[@]}"'
else
- _cvs_command_options "$1" $mode
+ _comp_cmd_cvs__compgen_command_options "$1" "$mode"
fi
;;
admin)
@@ -180,30 +193,28 @@ _cvs()
return
;;
-*t)
- _filedir
+ _comp_compgen_filedir
return
;;
-*k)
- _cvs_kflags
+ _comp_cmd_cvs__compgen_kflags
return
;;
esac
if [[ $cur == -* ]]; then
- _cvs_command_options "$1" $mode
+ _comp_cmd_cvs__compgen_command_options "$1" "$mode"
else
- _cvs_entries
- COMPREPLY=($(compgen -W '${entries[@]}' -- "$cur"))
+ _comp_cmd_cvs__compgen_entries
fi
;;
annotate)
[[ $prev == -[rD] ]] && return
if [[ $cur == -* ]]; then
- _cvs_command_options "$1" $mode
+ _comp_cmd_cvs__compgen_command_options "$1" "$mode"
else
- _cvs_entries
- COMPREPLY=($(compgen -W '${entries[@]}' -- "$cur"))
+ _comp_cmd_cvs__compgen_entries
fi
;;
checkout)
@@ -213,22 +224,21 @@ _cvs()
return
;;
-*d)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-*k)
- _cvs_kflags
+ _comp_cmd_cvs__compgen_kflags
return
;;
esac
if [[ $cur != -* ]]; then
- [[ ! -v cvsroot ]] && cvsroot=${CVSROOT-}
- COMPREPLY=($(cvs -d "$cvsroot" co -c 2>/dev/null |
- awk '{print $1}'))
- COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur"))
+ [[ ! $has_cvsroot ]] && cvsroot=${CVSROOT-}
+ _comp_compgen_split -- "$(cvs -d "$cvsroot" co -c 2>/dev/null |
+ _comp_awk '{print $1}')"
else
- _cvs_command_options "$1" $mode
+ _comp_cmd_cvs__compgen_command_options "$1" "$mode"
fi
;;
commit)
@@ -238,51 +248,49 @@ _cvs()
return
;;
-*F)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur != -* ]]; then
- # if $COMP_CVS_REMOTE is not null, 'cvs commit' will
- # complete on remotely checked-out files (requires
+ # if $BASH_COMPLETION_CMD_CVS_REMOTE is not null, 'cvs commit'
+ # will complete on remotely checked-out files (requires
# passwordless access to the remote repository
- if [[ -n ${COMP_CVS_REMOTE:-} ]]; then
+ if [[ ${BASH_COMPLETION_CMD_CVS_REMOTE-} ]]; then
# this is the least computationally intensive way found so
# far, but other changes (something other than
- # changed/removed/new) may be missing
- changed=($(cvs -q diff --brief 2>&1 |
- command sed -ne 's/^Files [^ ]* and \([^ ]*\) differ$/\1/p'))
- newremoved=($(cvs -q diff --brief 2>&1 |
- command sed -ne 's/^cvs diff: \([^ ]*\) .*, no comparison available$/\1/p'))
- COMPREPLY=($(compgen -W '${changed[@]:-} \
- ${newremoved[@]:-}' -- "$cur"))
+ # changed/removed/new) may be missing.
+ _comp_compgen -a split -- "$(cvs -q diff --brief 2>&1 |
+ command sed -ne '
+ # changed
+ s/^Files [^ ]* and \([^ ]*\) differ$/\1/p
+ # new/removed
+ s/^cvs diff: \([^ ]*\) .*, no comparison available$/\1/p
+ ')"
else
- _cvs_entries
- COMPREPLY=($(compgen -W '${entries[@]}' -- "$cur"))
+ _comp_cmd_cvs__compgen_entries
fi
else
- _cvs_command_options "$1" $mode
+ _comp_cmd_cvs__compgen_command_options "$1" "$mode"
fi
;;
cvsroot)
- _cvs_roots
+ _comp_xfunc_cvs_compgen_roots
;;
- diff | log)
+ diff | log | status)
if [[ $cur == -* ]]; then
- _cvs_command_options "$1" $mode
+ _comp_cmd_cvs__compgen_command_options "$1" "$mode"
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- _cvs_entries
- COMPREPLY=($(compgen -W '${entries[@]:-}' -- "$cur"))
+ _comp_cmd_cvs__compgen_entries
fi
;;
editors | watchers)
if [[ $cur == -* ]]; then
- _cvs_command_options "$1" $mode
+ _comp_cmd_cvs__compgen_command_options "$1" "$mode"
else
- _cvs_entries
- COMPREPLY=($(compgen -W '${entries[@]}' -- "$cur"))
+ _comp_cmd_cvs__compgen_entries
fi
;;
export)
@@ -292,21 +300,21 @@ _cvs()
return
;;
-*d)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-*k)
- _cvs_kflags
+ _comp_cmd_cvs__compgen_kflags
return
;;
esac
if [[ $cur != -* ]]; then
- [[ ! -v cvsroot ]] && cvsroot=${CVSROOT-}
- COMPREPLY=($(cvs -d "$cvsroot" co -c | awk '{print $1}'))
- COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur"))
+ [[ ! $has_cvsroot ]] && cvsroot=${CVSROOT-}
+ _comp_compgen_split -- "$(cvs -d "$cvsroot" co -c |
+ _comp_awk '{print $1}')"
else
- _cvs_command_options "$1" $mode
+ _comp_cmd_cvs__compgen_command_options "$1" "$mode"
fi
;;
import)
@@ -316,39 +324,42 @@ _cvs()
return
;;
-*k)
- _cvs_kflags
+ _comp_cmd_cvs__compgen_kflags
return
;;
esac
if [[ $cur != -* ]]; then
# starts with same algorithm as checkout
- [[ ! -v cvsroot ]] && cvsroot=${CVSROOT-}
+ [[ ! $has_cvsroot ]] && cvsroot=${CVSROOT-}
local prefix=${cur%/*}
if [[ -r ${cvsroot}/${prefix} ]]; then
- _cvs_modules
- COMPREPLY=(${COMPREPLY[@]#$cvsroot})
- COMPREPLY=(${COMPREPLY[@]#\/})
+ _comp_cmd_cvs__modules
+ COMPREPLY=("${COMPREPLY[@]#"$cvsroot"}")
+ COMPREPLY=("${COMPREPLY[@]#\/}")
fi
pwd=$(pwd)
pwd=${pwd##*/}
- COMPREPLY=($(compgen -W '${COMPREPLY[@]} $pwd' -- "$cur"))
+ [[ $pwd ]] && COMPREPLY+=("$pwd")
+ ((${#COMPREPLY[@]})) &&
+ _comp_compgen -- -W '"${COMPREPLY[@]}"'
else
- _cvs_command_options "$1" $mode
+ _comp_cmd_cvs__compgen_command_options "$1" "$mode"
fi
;;
remove)
if [[ $cur != -* ]]; then
- _cvs_entries
+ _comp_compgen -Rv entries -i cvs entries "${cur-}"
if [[ $prev != -f ]]; then
# find out what files are missing
for i in "${!entries[@]}"; do
- [[ -r ${entries[i]} ]] && unset 'entries[i]'
+ [[ -r ${entries[i]} ]] && unset -v 'entries[i]'
done
fi
- COMPREPLY=($(compgen -W '${entries[@]:-}' -- "$cur"))
+ ((${#entries[@]})) &&
+ _comp_compgen -- -W '"${entries[@]}"'
else
- _cvs_command_options "$1" $mode
+ _comp_cmd_cvs__compgen_command_options "$1" "$mode"
fi
;;
update)
@@ -358,41 +369,41 @@ _cvs()
return
;;
-*k)
- _cvs_kflags
+ _comp_cmd_cvs__compgen_kflags
return
;;
esac
if [[ $cur == -* ]]; then
- _cvs_command_options "$1" $mode
+ _comp_cmd_cvs__compgen_command_options "$1" "$mode"
else
- _cvs_entries
- COMPREPLY=($(compgen -W '${entries[@]}' -- "$cur"))
+ _comp_cmd_cvs__compgen_entries
fi
;;
"")
case $prev in
--*) ;;
-*T)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-*[es])
return
;;
-*z)
- COMPREPLY=($(compgen -W '{1..9}' -- "$cur"))
+ _comp_compgen -- -W '{1..9}'
return
;;
esac
- COMPREPLY=($(compgen -W '$(_cvs_commands)
- $(_parse_help "$1" --help-options) --help --help-commands
- --help-options --version' -- "$cur"))
+ _comp_compgen_help -- --help-options
+ _comp_compgen -a -i cvs commands "$1"
+ _comp_compgen -a -- -W \
+ "--help --help-commands --help-options --version"
;;
esac
} &&
- complete -F _cvs cvs
+ complete -F _comp_cmd_cvs cvs
# ex: filetype=sh
diff --git a/completions/cvsps b/completions/cvsps
index 4fdfefc..c9e6199 100644
--- a/completions/cvsps
+++ b/completions/cvsps
@@ -1,58 +1,58 @@
# bash completion for cvsps -*- shell-script -*-
-_cvsps()
+_comp_cmd_cvsps()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
case $prev in
-h | -z | -f | -d | -l | --diff-opts | --debuglvl)
return
;;
-s)
- COMPREPLY=($(compgen -W "$($1 2>/dev/null |
- awk '/^PatchSet:?[ \t]/ { print $2 }')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" 2>/dev/null |
+ _comp_awk '/^PatchSet:?[ \t]/ { print $2 }')"
return
;;
-a)
- COMPREPLY=($(compgen -W "$($1 2>/dev/null |
- awk '/^Author:[ \t]/ { print $2 }')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" 2>/dev/null |
+ _comp_awk '/^Author:[ \t]/ { print $2 }')"
return
;;
-b)
- COMPREPLY=($(compgen -W "$($1 2>/dev/null |
- awk '/^Branch:[ \t]/ { print $2 }')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" 2>/dev/null |
+ _comp_awk '/^Branch:[ \t]/ { print $2 }')"
return
;;
-r)
- COMPREPLY=($(compgen -W "$($1 2>/dev/null |
- awk '/^Tag:[ \t]+[^(]/ { print $2 }')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" 2>/dev/null |
+ _comp_awk '/^Tag:[ \t]+[^(]/ { print $2 }')"
return
;;
-p)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
--test-log)
- _filedir
+ _comp_compgen_filedir
return
;;
-Z)
- COMPREPLY=($(compgen -W '{1..9}' -- "$cur"))
+ _comp_compgen -- -W '{1..9}'
return
;;
--root)
- _xfunc cvs _cvs_roots
+ _comp_compgen -x cvs roots
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ _comp_compgen_help -- -h
else
- _xfunc cvs _cvs_roots
+ _comp_compgen -x cvs roots
fi
} &&
- complete -F _cvsps cvsps
+ complete -F _comp_cmd_cvsps cvsps
# ex: filetype=sh
diff --git a/completions/dd b/completions/dd
index 04d876a..a9985b1 100644
--- a/completions/dd
+++ b/completions/dd
@@ -1,42 +1,39 @@
# bash completion for dd -*- shell-script -*-
-_dd()
+_comp_cmd_dd()
{
- local cur prev words cword
- _init_completion -n = || return
+ local cur prev words cword comp_args
+ _comp_initialize -n = -- "$@" || return
case $cur in
if=* | of=*)
- cur=${cur#*=}
- _filedir
+ _comp_compgen -c "${cur#*=}" filedir
return
;;
conv=*)
- cur=${cur#*=}
- COMPREPLY=($(compgen -W 'ascii ebcdic ibm block unblock lcase
- ucase sparse swab sync excl nocreat notrunc noerror fdatasync
- fsync' -- "$cur"))
+ _comp_compgen -c "${cur#*=}" -- -W 'ascii ebcdic ibm block unblock
+ lcase ucase sparse swab sync excl nocreat notrunc noerror
+ fdatasync fsync'
return
;;
iflag=* | oflag=*)
- cur=${cur#*=}
- COMPREPLY=($(compgen -W 'append direct directory dsync sync
- fullblock nonblock noatime nocache noctty nofollow count_bytes
- skip_bytes seek_bytes' -- "$cur"))
+ _comp_compgen -c "${cur#*=}" -- -W 'append direct directory dsync
+ sync fullblock nonblock noatime nocache noctty nofollow
+ count_bytes skip_bytes seek_bytes'
return
;;
status=*)
cur=${cur#*=}
- COMPREPLY=($(compgen -W 'none noxfer progress' -- "$cur"))
+ _comp_compgen -- -W 'none noxfer progress'
return
;;
esac
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")
- $(compgen -W 'bs cbs conv count ibs if iflag obs of oflag
- seek skip status' -S '=' -- "$cur"))
+ _comp_compgen_help
+ _comp_compgen -a -- -W 'bs cbs conv count ibs if iflag obs of oflag
+ seek skip status' -S '='
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
} &&
- complete -F _dd dd
+ complete -F _comp_cmd_dd dd
# ex: filetype=sh
diff --git a/completions/declare b/completions/declare
new file mode 100644
index 0000000..128cb30
--- /dev/null
+++ b/completions/declare
@@ -0,0 +1,41 @@
+# bash declare completion -*- shell-script -*-
+
+_comp_cmd_declare()
+{
+ local cur prev words cword comp_args
+ _comp_initialize -n := -- "$@" || return
+
+ if [[ $cur == [-+]* ]]; then
+ local opts
+ _comp_compgen -Rv opts usage -c help -s "$1"
+ # Most options also have a '+' form.
+ # We'll exclude the ones that don't with compgen.
+ opts+=("${opts[@]/-/+}")
+ _comp_compgen -- -W "${opts[*]}" -X '+[Ffgp]'
+ return
+ fi
+
+ local i=1
+ while [[ ${words[i]} == [-+]* ]]; do
+ case ${words[i]} in
+ -*[aA]*)
+ _comp_compgen -- -A arrayvar
+ return
+ ;;
+ -*[fF]*)
+ _comp_compgen -- -A function
+ return
+ ;;
+ esac
+ ((i++))
+ done
+ if ((i > 1)); then
+ # There was at least one option and it was not one that limited
+ # operations to functions and array variables
+ _comp_variable_assignments "$cur" && return
+ _comp_compgen -- -A variable
+ fi
+} &&
+ complete -F _comp_cmd_declare declare typeset
+
+# ex: filetype=sh
diff --git a/completions/deja-dup b/completions/deja-dup
index 1854d6a..0b28928 100644
--- a/completions/deja-dup
+++ b/completions/deja-dup
@@ -1,32 +1,32 @@
# bash completion for deja-dup(1) -*- shell-script -*-
-_deja_dup()
+_comp_cmd_deja_dup()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-'?' | --help | --help-*)
return
;;
--restore)
- _filedir
+ _comp_compgen_filedir
return
;;
--restore-missing)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur"))
+ _comp_compgen_help -- --help-all
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
} &&
- complete -F _deja_dup deja-dup
+ complete -F _comp_cmd_deja_dup deja-dup
# ex: filetype=sh
diff --git a/completions/desktop-file-validate b/completions/desktop-file-validate
index 8f4e139..ef1fe9a 100644
--- a/completions/desktop-file-validate
+++ b/completions/desktop-file-validate
@@ -1,9 +1,9 @@
# desktop-file-validate completion -*- shell-script -*-
-_desktop_file_validate()
+_comp_cmd_desktop_file_validate()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--help)
@@ -12,12 +12,12 @@ _desktop_file_validate()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- _filedir desktop
+ _comp_compgen_filedir desktop
} &&
- complete -F _desktop_file_validate desktop-file-validate
+ complete -F _comp_cmd_desktop_file_validate desktop-file-validate
# ex: filetype=sh
diff --git a/completions/dhclient b/completions/dhclient
index ce4b745..330a298 100644
--- a/completions/dhclient
+++ b/completions/dhclient
@@ -1,34 +1,34 @@
# bash completion for dhclient -*- shell-script -*-
-_dhclient()
+_comp_cmd_dhclient()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-p | -e)
return
;;
-D)
- COMPREPLY=($(compgen -W 'LL LLT' -- "$cur"))
+ _comp_compgen -- -W 'LL LLT'
return
;;
-*f)
- _filedir
+ _comp_compgen_filedir
return
;;
-s)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
else
- _available_interfaces
+ _comp_compgen_available_interfaces
fi
} &&
- complete -F _dhclient dhclient
+ complete -F _comp_cmd_dhclient dhclient
# ex: filetype=sh
diff --git a/completions/dict b/completions/dict
index f3426ff..f3b0cb6 100644
--- a/completions/dict
+++ b/completions/dict
@@ -1,47 +1,54 @@
# dict(1) completion -*- shell-script -*-
-_dictdata()
+_comp_cmd_dict__compgen_dictdata()
{
- dict $host $port $1 2>/dev/null | command sed -ne \
- 's/^[[:blank:]]\{1,\}\([^[:blank:]]*\).*$/\1/p'
+ # shellcheck disable=SC2086
+ _comp_compgen_split -- "$(
+ "$@" 2>/dev/null | command sed -ne \
+ 's/^[[:blank:]]\{1,\}\([^[:blank:]]*\).*$/\1/p'
+ )"
}
-_dict()
+_comp_cmd_dict()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- local host port db i
+ local -a dict_command=("$1")
+ local host="" port="" db i
+ local noargopts='!(-*|*[hpdis]*)'
for ((i = 1; i < cword; i++)); do
+ # shellcheck disable=SC2254
case ${words[i]} in
- --host | -!(-*)h)
+ --host | -${noargopts}h)
host=${words[++i]}
- [[ -n $host ]] && host="-h $host"
+ [[ $host ]] && dict_command+=(-h "$host")
;;
- --port | -!(-*)p)
+ --port | -${noargopts}p)
port=${words[++i]}
- [[ -n $port ]] && port="-p $port"
+ [[ $port ]] && dict_command+=(-p "$port")
;;
- --database | -!(-*)d)
+ --database | -${noargopts}d)
db=${words[++i]}
- [[ -n $db ]] && host="-d $db"
+ [[ $db ]] && dict_command+=(-d "$db")
;;
esac
done
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
+ # shellcheck disable=SC2254
case $prev in
- --database | -info | -!(-*)[di])
- COMPREPLY=($(compgen -W '$(_dictdata -D)' -- "$cur"))
+ --database | -info | -${noargopts}[di])
+ _comp_cmd_dict__compgen_dictdata "${dict_command[@]}" -D
return
;;
- --strategy | -!(-*)s)
- COMPREPLY=($(compgen -W '$(_dictdata -S)' -- "$cur"))
+ --strategy | -${noargopts}s)
+ _comp_cmd_dict__compgen_dictdata "${dict_command[@]}" -S
return
;;
esac
@@ -52,13 +59,14 @@ _dict()
# it down with grep if $cur looks like something that's safe to embed
# in a pattern instead.
if [[ $cur == +([-A-Za-z0-9/.]) ]]; then
- COMPREPLY=($(compgen -W \
- '$(command grep "^${cur//./\\.}" $dictfile)' -- "$cur"))
+ _comp_compgen_split -- "$(
+ command grep "^${cur//./\\.}" "$dictfile"
+ )"
else
- COMPREPLY=($(compgen -W '$(cat $dictfile)' -- "$cur"))
+ _comp_compgen_split -- "$(cat "$dictfile")"
fi
fi
} &&
- complete -F _dict -o default dict rdict
+ complete -F _comp_cmd_dict -o default dict rdict
# ex: filetype=sh
diff --git a/completions/dmypy b/completions/dmypy
index 5abe37d..7fab74f 100644
--- a/completions/dmypy
+++ b/completions/dmypy
@@ -1,48 +1,49 @@
# dmypy completion -*- shell-script -*-
-_dmypy()
+_comp_cmd_dmypy()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--help | --version | -[hV])
return
;;
--status-file)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
- local cmd i
+ local cmd="" has_cmd="" i
for ((i = 1; i < cword; i++)); do
if [[ ${words[i]} != -* && ${words[i - 1]} != --status-file ]]; then
cmd=${words[i]}
+ has_cmd=set
break
fi
done
case ${cmd-} in
check | run)
- _filedir '@(py|pyi)'
+ _comp_compgen_filedir '@(py|pyi)'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- if [[ ! -v cmd ]]; then
- local cmds=$($1 --help 2>&1 |
- command sed -ne '/positional arguments/{p;n;p;q}' |
+ if [[ ! $has_cmd ]]; then
+ local cmds=$("$1" --help 2>&1 |
+ command sed -ne '/positional arguments/{p;n;p;q;}' |
command sed -ne 's/{\(.*\)}/\1/p')
- COMPREPLY=($(IFS="," compgen -W '$cmds' -- "$cur"))
+ _comp_compgen -F , -- -W '$cmds'
return
fi
} &&
- complete -F _dmypy dmypy
+ complete -F _comp_cmd_dmypy dmypy
# ex: filetype=sh
diff --git a/completions/dnssec-keygen b/completions/dnssec-keygen
index 3f68a68..9db55b5 100644
--- a/completions/dnssec-keygen
+++ b/completions/dnssec-keygen
@@ -1,48 +1,48 @@
# bash completion for dnssec-keygen(8) -*- shell-script -*-
-_dnssec_keygen_optarg()
+_comp_cmd_dnssec_keygen__optarg()
{
local args=$("$1" -h 2>&1 |
command sed -e 's/|/ /g' -e 's/(.*//' \
- -ne '/^[[:space:]]*'$2'/,/^[[:space:]]*[(-]/p' |
- command sed -e 's/^[[:space:]]*'$2'.*://' -e '/^[[:space:]]*-/d')
- COMPREPLY+=($(compgen -W '$args' -- "$cur"))
+ -ne '/^[[:space:]]*'"$2"'/,/^[[:space:]]*[(-]/p' |
+ command sed -e 's/^[[:space:]]*'"$2"'.*://' -e '/^[[:space:]]*-/d')
+ _comp_compgen -a -- -W '$args'
}
-_dnssec_keygen()
+_comp_cmd_dnssec_keygen()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-[hbEgLpsPARIDSi])
return
;;
-K)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-[ancdfTtm])
- _dnssec_keygen_optarg "$1" $prev
+ _comp_cmd_dnssec_keygen__optarg "$1" "$prev"
return
;;
-r)
- cur=${cur:=/dev/}
- _filedir
+ _comp_compgen -c "${cur:-/dev/}" filedir
return
;;
-v)
- COMPREPLY=($(compgen -W '{0..10}' -- "$cur"))
+ _comp_compgen -- -W '{0..10}'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" | \
- command sed -e "s/:\$//")' -- "$cur"))
+ _comp_compgen -R help
+ ((${#COMPREPLY[@]})) &&
+ _comp_compgen -- -W '"${COMPREPLY[@]%:}"'
return
fi
} &&
- complete -F _dnssec_keygen dnssec-keygen
+ complete -F _comp_cmd_dnssec_keygen dnssec-keygen
# ex: filetype=sh
diff --git a/completions/dnsspoof b/completions/dnsspoof
index 86ade91..9117b72 100644
--- a/completions/dnsspoof
+++ b/completions/dnsspoof
@@ -1,26 +1,26 @@
# dnsspoof completion -*- shell-script -*-
-_dnsspoof()
+_comp_cmd_dnsspoof()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-i)
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
return
;;
-f)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
fi
} &&
- complete -F _dnsspoof dnsspoof
+ complete -F _comp_cmd_dnsspoof dnsspoof
# ex: filetype=sh
diff --git a/completions/dot b/completions/dot
index 8122229..dcb8436 100644
--- a/completions/dot
+++ b/completions/dot
@@ -1,9 +1,9 @@
# dot(1) completion -*- shell-script -*-
-_dot()
+_comp_cmd_dot()
{
- local cur prev words cword
- _init_completion -n := || return
+ local cur prev words cword comp_args
+ _comp_initialize -n := -- "$@" || return
[[ $prev == -[V?] ]] && return
@@ -12,34 +12,35 @@ _dot()
return
;;
-T*)
- local langs=($("$1" -TNON_EXISTENT 2>&1 |
- command sed -ne 's/.*one of://p'))
- COMPREPLY=($(compgen -P -T -W '${langs[@]}' -- "${cur#-T}"))
+ # generate langs
+ _comp_compgen -c "${cur#-T}" split -P "-T" -- "$(
+ "$1" -TNON_EXISTENT 2>&1 | command sed -ne 's/.*one of://p'
+ )"
return
;;
-K*)
- local layouts=($("$1" -KNON_EXISTENT 2>&1 |
- command sed -ne 's/.*one of://p'))
- COMPREPLY=($(compgen -P -K -W '${layouts[@]}' -- "${cur#-K}"))
+ # generate layouts
+ _comp_compgen -c "${cur#-K}" split -P "-K" -- "$(
+ "$1" -KNON_EXISTENT 2>&1 | command sed -ne 's/.*one of://p'
+ )"
return
;;
-o*)
- cur=${cur#-o}
- _filedir
- COMPREPLY=($(compgen -P -o -W '${COMPREPLY[@]}' -- "$cur"))
+ _comp_compgen -c "${cur#-o}" filedir &&
+ COMPREPLY=("${COMPREPLY[@]/#/-o}")
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-V -v -G -N -E -T -K -l -o -O -P -q -s -y -n
- -n1 -n2 -x -Lg -LO -Ln -LU -LC -LT -m -c -?' -- "$cur"))
+ _comp_compgen -- -W '-V -v -G -N -E -T -K -l -o -O -P -q -s -y -n -n1
+ -n2 -x -Lg -LO -Ln -LU -LC -LT -m -c -?'
[[ ${COMPREPLY-} == -@([GNETKo]|L[nUCT]) ]] && compopt -o nospace
return
fi
- _filedir dot
+ _comp_compgen_filedir '@(gv|dot)'
} &&
- complete -F _dot dot
+ complete -F _comp_cmd_dot dot
# ex: filetype=sh
diff --git a/completions/dpkg b/completions/dpkg
index 0b90b14..7ce5c19 100644
--- a/completions/dpkg
+++ b/completions/dpkg
@@ -1,43 +1,67 @@
-# This function is required by _dpkg and _dpkg-reconfigure -*- shell-script -*-
+# dpkg(1) and related commands completion -*- shell-script -*-
-_have grep-status && {
- _comp_dpkg_installed_packages()
- {
- grep-status -P -e "^$1" -a -FStatus 'ok installed' -n -s Package
- }
-} || {
- _comp_dpkg_installed_packages()
- {
- command grep -A 1 "Package: $1" /var/lib/dpkg/status 2>/dev/null |
- command grep -B 1 -Ee "ok installed|half-installed|unpacked| \
- half-configured" \
- -Ee "^Essential: yes" |
- awk "/Package: $1/ { print \$2 }" 2>/dev/null
- }
+# @since 2.12
+_comp_xfunc_dpkg_compgen_installed_packages()
+{
+ _comp_compgen_split -- "$(
+ grep-status -P -e "^${cur-}" -a \
+ -FStatus 'ok installed' \
+ -n -s Package 2>/dev/null ||
+ _comp_awk -F '\n' -v RS="" "
+ index(\$1, \"Package: ${cur-}\") == 1 &&
+ \$2 ~ /ok installed|half-installed|unpacked|half-configured|^Essential: yes/ {
+ print(substr(\$1, 10));
+ }" /var/lib/dpkg/status 2>/dev/null
+ )"
+}
+
+# @since 2.12
+_comp_xfunc_dpkg_compgen_purgeable_packages()
+{
+ _comp_compgen_split -- "$(
+ grep-status -P -e "^${cur-}" -a \
+ -FStatus 'ok installed' -o -FStatus 'ok config-files' \
+ -n -s Package 2>/dev/null ||
+ _comp_awk -F '\n' -v RS="" "
+ index(\$1, \"Package: ${cur-}\") == 1 &&
+ \$2 ~ /ok installed|half-installed|unpacked|half-configured|config-files|^Essential: yes/ {
+ print(substr(\$1, 10));
+ }" /var/lib/dpkg/status 2>/dev/null
+ )"
+}
+
+# @since 2.12
+_comp_xfunc_dpkg_compgen_held_packages()
+{
+ _comp_compgen_split -- "$(
+ dpkg --get-selections ${cur:+"$cur}"} |
+ _comp_awk '{for(i=2;i<=NF;i++){ if($i=="hold"){ print $1;break }}}'
+ )"
}
-_have grep-status && {
- _comp_dpkg_purgeable_packages()
- {
- grep-status -P -e "^$1" -a -FStatus 'ok installed' -o -FStatus 'ok config-files' -n -s Package
- }
-} || {
- _comp_dpkg_purgeable_packages()
- {
- command grep -A 1 "Package: $1" /var/lib/dpkg/status 2>/dev/null |
- command grep -B 1 -Ee "ok installed|half-installed|unpacked| \
- half-configured|config-files" \
- -Ee "^Essential: yes" |
- awk "/Package: $1/ { print \$2 }" 2>/dev/null
- }
+# @deprecated 2.12 use _comp_xfunc_dpkg_compgen_installed_packages instead
+_comp_dpkg_installed_packages()
+{
+ local COMPREPLY=() cur="${1-}"
+ # shellcheck disable=SC2119
+ _comp_xfunc_dpkg_compgen_installed_packages
+ printf "%s\n" "${COMPREPLY[@]}"
+}
+# @deprecated 2.12 use _comp_xfunc_dpkg_compgen_purgeable_packages instead
+_comp_dpkg_purgeable_packages()
+{
+ local COMPREPLY=() cur="${1-}"
+ # shellcheck disable=SC2119
+ _comp_xfunc_dpkg_compgen_purgeable_packages
+ printf "%s\n" "${COMPREPLY[@]}"
}
# Debian dpkg(1) completion
#
-_dpkg()
+_comp_cmd_dpkg()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
local i=$cword
@@ -48,79 +72,111 @@ _dpkg()
done
fi
+ local noargopts='!(-*|*[ciAIfexXbsplWSrVLPD]*)'
+ # shellcheck disable=SC2254
case $prev in
--install | --unpack | --record-avail | --contents | --info | --fsys-tarfile | \
- --field | --control | --extract | --vextract | --raw-extract | -!(-*)[ciAIfexX])
- _filedir '?(u|d)deb'
+ --field | --control | --extract | --vextract | --raw-extract | -${noargopts}[ciAIfexX])
+ _comp_compgen_filedir '?(u|d)deb'
return
;;
- --build | -!(-*)b)
- _filedir -d
+ --build | --admindir | --instdir | --root | -${noargopts}b)
+ _comp_compgen_filedir -d
return
;;
- --status | --print-avail | --list | -!(-*)[spl])
- COMPREPLY=($(_xfunc apt-cache _apt_cache_packages))
+ --status | --print-avail | --list | -${noargopts}[spl])
+ _comp_compgen -x apt-cache packages
return
;;
- --show | -!(-*)W)
+ --show | -${noargopts}W)
if [[ $1 == *dpkg-query ]]; then
- COMPREPLY=($(_xfunc apt-cache _apt_cache_packages))
+ _comp_compgen -x apt-cache packages
else
- _filedir '?(u|d)deb'
+ _comp_compgen_filedir '?(u|d)deb'
fi
return
;;
- --search | -!(-*)S)
- _filedir
+ --search | -${noargopts}S)
+ _comp_compgen_filedir
+ return
+ ;;
+ --remove | --verify | -${noargopts}[rV])
+ _comp_xfunc_dpkg_compgen_installed_packages
return
;;
- --remove | --verify | -!(-*)[rV])
- COMPREPLY=($(_comp_dpkg_installed_packages "$cur"))
+ --listfiles | --purge | -${noargopts}[LP])
+ _comp_xfunc_dpkg_compgen_purgeable_packages
return
;;
- --listfiles | --purge | -!(-*)[LP])
- COMPREPLY=($(_comp_dpkg_purgeable_packages "$cur"))
+ --debug | -${noargopts}D)
+ _comp_compgen -- -W 'help'
+ return
+ ;;
+ --ignore-depends)
+ local packages
+ _comp_compgen -v packages -c "${cur##*,}" -x apt-cache packages
+ _comp_delimited , -W '"${packages[@]}"'
+ return
+ ;;
+ --log)
+ _comp_compgen_filedir log
+ return
+ ;;
+ --path-exclude | --path-include)
+ return
+ ;;
+ --status-logger)
+ _comp_compgen_commands
+ return
+ ;;
+ --verify-format)
+ _comp_compgen -- -W 'rpm'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
+ for i in ${!COMPREPLY[*]}; do
+ # remove ones ending with a dash (known parse issue, hard to fix)
+ [[ ${COMPREPLY[i]} != *- ]] || unset -v 'COMPREPLY[i]'
+ done
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
} &&
- complete -F _dpkg dpkg dpkg-deb dpkg-query
+ complete -F _comp_cmd_dpkg dpkg dpkg-deb dpkg-query
-# Debian GNU dpkg-reconfigure(8) completion
-#
-_dpkg_reconfigure()
+_comp_cmd_dpkg_reconfigure()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local opt
+ local noargopts='!(-*|*[fp]*)'
+ # shellcheck disable=SC2254
case $prev in
- --frontend | -!(-*)f)
- opt=($(printf '%s\n' /usr/share/perl5/Debconf/FrontEnd/*))
- opt=(${opt[@]##*/})
- opt=(${opt[@]%.pm})
- COMPREPLY=($(compgen -W '${opt[@]}' -- "$cur"))
+ --frontend | -${noargopts}f)
+ if _comp_expand_glob opt '/usr/share/perl5/Debconf/FrontEnd/*'; then
+ opt=("${opt[@]##*/}")
+ opt=("${opt[@]%.pm}")
+ _comp_compgen -- -W '"${opt[@]}"'
+ fi
return
;;
- --priority | -!(-*)p)
- COMPREPLY=($(compgen -W 'low medium high critical' -- "$cur"))
+ --priority | -${noargopts}p)
+ _comp_compgen -- -W 'low medium high critical'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--frontend --priority --all --unseen-only
- --help --showold --force --terse' -- "$cur"))
+ _comp_compgen -- -W '--frontend --priority --all --unseen-only --help
+ --showold --force --terse'
else
- COMPREPLY=($(_comp_dpkg_installed_packages "$cur"))
+ _comp_xfunc_dpkg_compgen_installed_packages
fi
} &&
- complete -F _dpkg_reconfigure -o default dpkg-reconfigure
+ complete -F _comp_cmd_dpkg_reconfigure -o default dpkg-reconfigure
# ex: filetype=sh
diff --git a/completions/dpkg-source b/completions/dpkg-source
index 05fa3a1..c9131b2 100644
--- a/completions/dpkg-source
+++ b/completions/dpkg-source
@@ -1,9 +1,9 @@
# Debian dpkg-source completion -*- shell-script -*-
-_dpkg_source()
+_comp_cmd_dpkg_source()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local options word action packopts unpackopts fields
@@ -29,13 +29,11 @@ _dpkg_source()
unpack)
case $prev in
-x)
- _filedir -d
- _filedir 'dsc'
+ _comp_compgen_filedir 'dsc'
;;
*)
- COMPREPLY=($(compgen -W "$unpackopts" -- "$cur"))
- _filedir -d
- _filedir
+ _comp_compgen -- -W "$unpackopts"
+ _comp_compgen -a filedir
;;
esac
return
@@ -43,7 +41,7 @@ _dpkg_source()
pack)
case $prev in
-b)
- _filedir -d
+ _comp_compgen_filedir -d
;;
-c | -l | -T | -i | -I)
# -c: get controlfile
@@ -52,12 +50,11 @@ _dpkg_source()
# -i: <regexp> filter out files to ignore diffs of.
# -I: filter out files when building tarballs.
# return directory names and file names
- _filedir -d
- _filedir
+ _comp_compgen_filedir
;;
-F)
# -F: force change log format
- COMPREPLY=($(command ls /usr/lib/dpkg/parsechangelog))
+ _comp_compgen_split -- "$(command ls /usr/lib/dpkg/parsechangelog)"
;;
-V)
# -V: set a substitution variable
@@ -72,27 +69,26 @@ _dpkg_source()
# $cur contains a "="
COMPREPLY=()
else
- COMPREPLY=($(compgen -W "$fields" -- "$cur"))
+ _comp_compgen -- -W "$fields"
fi
;;
-U)
# -U: remove a field
# Suggest possible fieldnames
- COMPREPLY=($(compgen -W "$fields" -- "$cur"))
+ _comp_compgen -- -W "$fields"
;;
*)
- COMPREPLY=($(compgen -W "$packopts $unpackopts" \
- -- "$cur"))
+ _comp_compgen -- -W '$packopts $unpackopts'
;;
esac
return
;;
*)
- COMPREPLY=($(compgen -W "$options" -- "$cur"))
+ _comp_compgen -- -W "$options"
return
;;
esac
} &&
- complete -F _dpkg_source dpkg-source
+ complete -F _comp_cmd_dpkg_source dpkg-source
# ex: filetype=sh
diff --git a/completions/dselect b/completions/dselect
index 4c18026..554ab21 100644
--- a/completions/dselect
+++ b/completions/dselect
@@ -1,29 +1,28 @@
# Debian Linux dselect(8) completion -*- shell-script -*-
-_dselect()
+_comp_cmd_dselect()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--admindir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-D | -debug)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
else
- COMPREPLY=($(compgen -W 'access update select install config remove
- quit' -- "$cur"))
+ _comp_compgen -- -W 'access update select install config remove quit'
fi
} &&
- complete -F _dselect dselect
+ complete -F _comp_cmd_dselect dselect
# ex: filetype=sh
diff --git a/completions/dsniff b/completions/dsniff
index 749c533..f09eac2 100644
--- a/completions/dsniff
+++ b/completions/dsniff
@@ -1,26 +1,27 @@
# dsniff completion -*- shell-script -*-
-_dsniff()
+_comp_cmd_dsniff()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-r | -w | -f | -p)
- _filedir
+ _comp_compgen_filedir
return
;;
-i)
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1") -r -w -p' -- "$cur"))
+ _comp_compgen_usage
+ _comp_compgen -a -- -W '-r -w -p'
fi
} &&
- complete -F _dsniff dsniff
+ complete -F _comp_cmd_dsniff dsniff
# ex: filetype=sh
diff --git a/completions/dumpdb b/completions/dumpdb
index eb1927f..0390b4e 100644
--- a/completions/dumpdb
+++ b/completions/dumpdb
@@ -1,18 +1,17 @@
# mailman dumpdb completion -*- shell-script -*-
-_dumpdb()
+_comp_cmd_dumpdb()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--marshal --pickle --noprint --help' \
- -- "$cur"))
+ _comp_compgen -- -W '--marshal --pickle --noprint --help'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _dumpdb dumpdb
+ complete -F _comp_cmd_dumpdb dumpdb
# ex: filetype=sh
diff --git a/completions/dumpe2fs b/completions/dumpe2fs
index 413a5bf..326564e 100644
--- a/completions/dumpe2fs
+++ b/completions/dumpe2fs
@@ -1,28 +1,27 @@
# dumpe2fs(8) completion -*- shell-script -*-
-_dumpe2fs()
+_comp_cmd_dumpe2fs()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*[oV])
return
;;
-*i)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
return
fi
- cur=${cur:=/dev/}
- _filedir
+ _comp_compgen -c "${cur:-/dev/}" filedir
} &&
- complete -F _dumpe2fs dumpe2fs
+ complete -F _comp_cmd_dumpe2fs dumpe2fs
# ex: filetype=sh
diff --git a/completions/e2freefrag b/completions/e2freefrag
index c89dc9c..7fa4841 100644
--- a/completions/e2freefrag
+++ b/completions/e2freefrag
@@ -1,9 +1,9 @@
# e2freefrag(8) completion -*- shell-script -*-
-_e2freefrag()
+_comp_cmd_e2freefrag()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-c | -h)
@@ -12,13 +12,12 @@ _e2freefrag()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" -h)' -- "$cur"))
+ _comp_compgen_usage -- -h
return
fi
- cur=${cur:=/dev/}
- _filedir
+ _comp_compgen -c "${cur:-/dev/}" filedir
} &&
- complete -F _e2freefrag e2freefrag
+ complete -F _comp_cmd_e2freefrag e2freefrag
# ex: filetype=sh
diff --git a/completions/e2label b/completions/e2label
index ac8e4b5..456907c 100644
--- a/completions/e2label
+++ b/completions/e2label
@@ -1,15 +1,14 @@
# e2label(8) completion -*- shell-script -*-
-_e2label()
+_comp_cmd_e2label()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if ((cword == 1)); then
- cur=${cur:=/dev/}
- _filedir
+ _comp_compgen -c "${cur:-/dev/}" filedir
fi
} &&
- complete -F _e2label e2label
+ complete -F _comp_cmd_e2label e2label
# ex: filetype=sh
diff --git a/completions/ebtables b/completions/ebtables
index de6bc54..24f3fe7 100644
--- a/completions/ebtables
+++ b/completions/ebtables
@@ -1,47 +1,49 @@
# bash completion for ebtables -*- shell-script -*-
-_ebtables()
+_comp_cmd_ebtables()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
- local table chain='s/^Bridge chain: \([^ ,]\{1,\}\).*$/\1/p' \
+ local table="" chain='s/^Bridge chain: \([^ ,]\{1,\}\).*$/\1/p' \
targets='ACCEPT DROP CONTINUE RETURN'
+ local IFS=$' \t\n' # for ${table:+-t "$table"}
[[ ${words[*]} =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] &&
- table="-t ${BASH_REMATCH[2]}"
+ table=${BASH_REMATCH[2]}
+ local noargopts='!(-*|*[AIDPFXLZtj]*)'
+ # shellcheck disable=SC2254
case $prev in
- -!(-*)[AIDPFXLZ])
- COMPREPLY=($(compgen -W '`"$1" $table -L 2>/dev/null | \
- command sed -ne "$chain"`' -- "$cur"))
+ -${noargopts}[AIDPFXLZ])
+ _comp_compgen_split -- "$(
+ "$1" ${table:+-t "$table"} -L 2>/dev/null |
+ command sed -ne "$chain"
+ )"
;;
- -!(-*)t)
- COMPREPLY=($(compgen -W 'nat filter broute' -- "$cur"))
+ -${noargopts}t)
+ _comp_compgen -- -W 'nat filter broute'
;;
- -!(-*)j)
- if [[ $table == "-t filter" || -z $table ]]; then
- COMPREPLY=($(compgen -W '$targets
- $("$1" $table -L 2>/dev/null | \
- command sed -n -e "s/INPUT\|OUTPUT\|FORWARD//" \
- -e "$chain")' \
- -- "$cur"))
- elif [[ $table == "-t nat" ]]; then
- COMPREPLY=($(compgen -W '$targets
- $("$1" $table -L 2>/dev/null | \
- command sed -n -e "s/OUTPUT|PREROUTING|POSTROUTING//" \
- -e "$chain")' \
- -- "$cur"))
- elif [[ $table == "-t broute" ]]; then
- COMPREPLY=($(compgen -W 'ACCEPT DROP
- $("$1" $table -L 2>/dev/null | \
- command sed -n -e "s/BROUTING//" -e "$chain")' \
- -- "$cur"))
+ -${noargopts}j)
+ if [[ $table == "filter" || ! $table ]]; then
+ _comp_compgen -- -W '$targets'
+ _comp_compgen -a split -- "$("$1" ${table:+-t "$table"} -L \
+ 2>/dev/null | command sed -n -e \
+ "s/INPUT\|OUTPUT\|FORWARD//" -e "$chain")"
+ elif [[ $table == "nat" ]]; then
+ _comp_compgen -- -W '$targets'
+ _comp_compgen -a split -- "$("$1" -t "$table" -L 2>/dev/null |
+ command sed -n -e "s/OUTPUT|PREROUTING|POSTROUTING//" \
+ -e "$chain")"
+ elif [[ $table == "broute" ]]; then
+ _comp_compgen -- -W 'ACCEPT DROP'
+ _comp_compgen -a split -- "$("$1" -t "$table" -L 2>/dev/null |
+ command sed -n -e "s/BROUTING//" -e "$chain")"
fi
;;
*)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--802_3-sap --802_3-type --among-dst
+ _comp_compgen -- -W '--802_3-sap --802_3-type --among-dst
--among-dst-file --among-src --among-src-file --append
--arp-gratuitous --arp-htype --arp-ip-dst --arp-ip-src
--arp-mac-dst --arp-mac-src --arp-opcode --arp-ptype --arpreply-mac
@@ -67,12 +69,12 @@ _ebtables()
--stp-sender-prio --stp-type --table --to-destination --to-dst
--to-source --to-src --ulog --ulog-cprange --ulog-nlgroup
--ulog-prefix --ulog-qthreshold --version --vlan-encap --vlan-id
- --vlan-prio --zero' -- "$cur"))
+ --vlan-prio --zero'
fi
;;
esac
} &&
- complete -F _ebtables ebtables
+ complete -F _comp_cmd_ebtables ebtables
# ex: filetype=sh
diff --git a/completions/ecryptfs-migrate-home b/completions/ecryptfs-migrate-home
index d2eeb38..7566d6b 100644
--- a/completions/ecryptfs-migrate-home
+++ b/completions/ecryptfs-migrate-home
@@ -1,22 +1,22 @@
# ecryptfs-migrate-home(8) completion -*- shell-script -*-
-_ecryptfs_migrate_home()
+_comp_cmd_ecryptfs_migrate_home()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--help)
return
;;
--user | -u)
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
return
;;
esac
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
} &&
- complete -F _ecryptfs_migrate_home ecryptfs-migrate-home
+ complete -F _comp_cmd_ecryptfs_migrate_home ecryptfs-migrate-home
# ex: filetype=sh
diff --git a/completions/eog b/completions/eog
index 2330e1a..14c448d 100644
--- a/completions/eog
+++ b/completions/eog
@@ -1,9 +1,9 @@
# eog(1) completion -*- shell-script -*-
-_eog()
+_comp_cmd_eog()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-'?' | --help | --help-all | --help-gtk)
@@ -11,16 +11,16 @@ _eog()
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur"))
+ _comp_compgen_help -- --help-all
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir '@(ani|?(w)bmp|gif|ico|j2[ck]|jp[cefgx2]|jpeg|jpg2|pcx|p[gp]m|pn[gm]|ras|svg?(z)|tga|tif?(f)|x[bp]m)'
+ _comp_compgen_filedir '@(ani|avif|?(w)bmp|gif|hei[cf]|ico|j2[ck]|jp[cefgx2]|jpeg|jpg2|jxl|pcx|p[bgp]m|pn[gm]|ras|svg?(z)|tga|tif?(f)|webp|x[bp]m)'
} &&
- complete -F _eog eog
+ complete -F _comp_cmd_eog eog
# ex: filetype=sh
diff --git a/completions/ether-wake b/completions/ether-wake
index d952673..d2c7f83 100644
--- a/completions/ether-wake
+++ b/completions/ether-wake
@@ -1,13 +1,13 @@
# ether-wake(8) completion -*- shell-script -*-
-_ether_wake()
+_comp_cmd_ether_wake()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
case $prev in
-i)
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
return
;;
-p)
@@ -16,12 +16,13 @@ _ether_wake()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -u) -V' -- "$cur"))
+ _comp_compgen_help -- -u
+ _comp_compgen -a -- -W '-V'
return
fi
- _mac_addresses
+ _comp_compgen_mac_addresses
} &&
- complete -F _ether_wake ether-wake etherwake
+ complete -F _comp_cmd_ether_wake ether-wake etherwake
# ex: filetype=sh
diff --git a/completions/evince b/completions/evince
index 1c97dd9..49b67ac 100644
--- a/completions/evince
+++ b/completions/evince
@@ -1,32 +1,34 @@
# evince(1) completion -*- shell-script -*-
-_evince()
+_comp_cmd_evince()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[pil]*)'
+ # shellcheck disable=SC2254
case $prev in
--help* | --sm-client-id | --class | --name | --screen | --gdk-debug | \
--gdk-no-debug | --gtk-module | --gtk-debug | --gtk-no-debug | --page-label | \
- --page-index | --find | --display | -!(-*)[hpil])
+ --page-index | --find | --display | -${noargopts}[hpil])
return
;;
--sm-client-state-file)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur"))
+ _comp_compgen_help -- --help-all
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir '@(@(?(e)ps|?(E)PS|[pf]df|[PF]DF|dvi|DVI)?(.gz|.GZ|.bz2|.BZ2|.xz|.XZ)|cb[rz]|djv?(u)|gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx)'
+ _comp_compgen_filedir '@(@(?(e)ps|?(E)PS|[pf]df|[PF]DF|dvi|DVI)?(.gz|.GZ|.bz2|.BZ2|.xz|.XZ)|cb[7rtz]|djv?(u)|tif?(f)|?(o)xps)'
} &&
- complete -F _evince evince
+ complete -F _comp_cmd_evince evince
# ex: filetype=sh
diff --git a/completions/export b/completions/export
index 8d82361..0f692c9 100644
--- a/completions/export
+++ b/completions/export
@@ -1,11 +1,11 @@
# bash export completion -*- shell-script -*-
-_export()
+_comp_cmd_export()
{
- local cur prev words cword
- _init_completion -n = || return
+ local cur prev words cword comp_args
+ _comp_initialize -n := -- "$@" || return
- local i action=variable remove=false
+ local i action=variable remove=""
for ((i = 1; i < cword; i++)); do
case ${words[i]} in
-p)
@@ -15,7 +15,7 @@ _export()
action=function
;;&
-*n*)
- remove=true
+ remove=set
;;
-*)
continue
@@ -25,41 +25,40 @@ _export()
done
if [[ $cur == *=* ]]; then
- local ocur=$cur oprev=$prev
- prev=${cur%%=*} cur=${cur#*=}
- _variables && return
- cur=$ocur prev=$oprev
+ _comp_variable_assignments "$cur" && return
fi
case $cur in
*=)
- local pval=$(quote "$(eval printf %s \"\$\{${cur%=}-\}\")")
+ local pname=${cur%=}
+ local REPLY
+ _comp_quote "${!pname-}"
+ local pval=$REPLY
# Complete previous value if it's not empty.
if [[ $pval != \'\' ]]; then
COMPREPLY=("$pval")
else
- cur=${cur#*=}
- _filedir
+ _comp_compgen -c "${cur#*=}" filedir
fi
;;
*=*)
- cur=${cur#*=}
- _filedir
+ _comp_compgen -c "${cur#*=}" filedir
;;
*)
if [[ $cword -eq 1 && $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-p $(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage -c help -s "$1"
+ _comp_compgen -a -- -W '-p'
return
fi
local suffix=""
- if ! $remove; then
+ if [[ ! $remove && $action != function ]]; then
suffix="="
compopt -o nospace
fi
- COMPREPLY=($(compgen -A $action -S "$suffix" -- "$cur"))
+ _comp_compgen -- -A $action -S "$suffix"
;;
esac
} &&
- complete -F _export export
+ complete -F _comp_cmd_export export
# ex: filetype=sh
diff --git a/completions/faillog b/completions/faillog
index c8b81bd..5343613 100644
--- a/completions/faillog
+++ b/completions/faillog
@@ -1,27 +1,29 @@
# faillog(8) completion -*- shell-script -*-
-_faillog()
+_comp_cmd_faillog()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[lmtu]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --lock-time | --maximum | --time | -!(-*)[hlmt])
+ --help | --lock-time | --maximum | --time | -${noargopts}[hlmt])
return
;;
- --user | -!(-*)u)
- COMPREPLY=($(compgen -u -- "$cur"))
+ --user | -${noargopts}u)
+ _comp_compgen -- -u
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _faillog faillog
+ complete -F _comp_cmd_faillog faillog
# ex: filetype=sh
diff --git a/completions/fbgs b/completions/fbgs
index 1947b87..66bcbbb 100644
--- a/completions/fbgs
+++ b/completions/fbgs
@@ -1,30 +1,29 @@
# bash completion for fbgs(1) -*- shell-script -*-
-_fbgs()
+_comp_cmd_fbgs()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case "$prev" in
-f | --font)
- local IFS=$'\n'
- COMPREPLY=($(compgen -W '$(fc-list 2>/dev/null)' -- "$cur"))
+ _comp_compgen_split -l -- "$(fc-list 2>/dev/null)"
return
;;
-m | --mode)
- COMPREPLY=($(compgen -W '$(command sed \
- -n "/^mode/{s/^mode \{1,\}\"\([^\"]\{1,\}\)\"/\1/g;p}" \
- /etc/fb.modes 2>/dev/null)' -- "$cur"))
+ _comp_compgen_split -- "$(command sed \
+ -n '/^mode/{s/^mode \{1,\}"\([^"]\{1,\}\)"/\1/g;p}' \
+ /etc/fb.modes 2>/dev/null)"
return
;;
-d | --device)
- COMPREPLY=($(compgen -f -d -- "${cur:-/dev/}"))
+ _comp_compgen -c "${cur:-/dev/}" -- -f -d
return
;;
-fp | --firstpage | -lp | --lastpage | -r | --resolution | -s | --scroll | -t | \
--timeout)
# expect integer value
- COMPREPLY+=($(compgen -W '{0..9}'))
+ _comp_compgen -aR -- -W '{0..9}'
compopt -o nospace
return
;;
@@ -35,16 +34,16 @@ _fbgs()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--bell --help --password -fp --firstpage
- -lp --lastpage --color -l -xl -xxl --resolution --autozoom
+ _comp_compgen -- -W '--bell --help --password -fp --firstpage -lp
+ --lastpage --color -l -xl -xxl --resolution --autozoom
--{,no}autoup --{,no}autodown --{,no}fitwidth --{,no}verbose
--{,no}random --vt --scroll --timeout --{,no}once --gamma --font
- --device --mode' -- "$cur"))
+ --device --mode'
[[ ${COMPREPLY-} ]] && return
fi
- _filedir '?(e)ps|pdf'
+ _comp_compgen_filedir '?(e)ps|pdf'
} &&
- complete -F _fbgs fbgs
+ complete -F _comp_cmd_fbgs fbgs
# ex: filetype=sh
diff --git a/completions/fbi b/completions/fbi
index 455887a..275395e 100644
--- a/completions/fbi
+++ b/completions/fbi
@@ -1,32 +1,31 @@
# bash completion for fbi(1) -*- shell-script -*-
-_fbi()
+_comp_cmd_fbi()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case "$prev" in
-l | --list)
- _filedir
+ _comp_compgen_filedir
return
;;
-r | --resolution)
- COMPREPLY+=($(compgen -W '{1..5}'))
+ _comp_compgen -aR -- -W '{1..5}'
return
;;
-f | --font)
- local IFS=$'\n'
- COMPREPLY=($(compgen -W '$(fc-list 2>/dev/null)' -- "$cur"))
+ _comp_compgen_split -l -- "$(fc-list 2>/dev/null)"
return
;;
-m | --mode)
- COMPREPLY=($(compgen -W '$(command sed \
- -n "/^mode/{s/^mode \{1,\}\"\([^\"]\{1,\}\)\"/\1/g;p}" \
- /etc/fb.modes 2>/dev/null)' -- "$cur"))
+ _comp_compgen_split -- "$(command sed \
+ -n '/^mode/{s/^mode \{1,\}"\([^"]\{1,\}\)"/\1/g;p}' \
+ /etc/fb.modes 2>/dev/null)"
return
;;
-d | --device)
- COMPREPLY=($(compgen -f -d -- "${cur:-/dev/}"))
+ _comp_compgen -c "${cur:-/dev/}" -- -f -d
return
;;
--cachemem | --blend | -T | --vt | -s | --scroll | -t | --timeout | -g | --gamma)
@@ -36,19 +35,18 @@ _fbi()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--help --version --store --list --text
- --autozoom --{,no}autoup --{,no}autodown --{,no}fitwidth
- --{,no}verbose --{,no}random --{,no}comments --{,no}edit
- --{,no}backup --{,no}preserve --{,no}readahead --cachemem --blend
- --vt --scroll --timeout --{,no}once --resolution --gamma --font
- --device --mode' -- "$cur"))
+ _comp_compgen -- -W '--help --version --store --list --text --autozoom
+ --{,no}autoup --{,no}autodown --{,no}fitwidth --{,no}verbose
+ --{,no}random --{,no}comments --{,no}edit --{,no}backup
+ --{,no}preserve --{,no}readahead --cachemem --blend --vt --scroll
+ --timeout --{,no}once --resolution --gamma --font --device --mode'
[[ ${COMPREPLY-} ]] && return
fi
# FIXME: It is hard to determine correct supported extensions.
# fbi can handle any format that imagemagick can plus some others
- _filedir 'bmp|gif|jp?(e)g|pcd|png|p[pgb]m|tif?(f)|webp|xpm|xwd|?(e)ps|pdf|dvi|txt|svg?(z)|cdr|[ot]tf'
+ _comp_compgen_filedir 'bmp|gif|jp?(e)g|pcd|png|p[pgb]m|tif?(f)|webp|xpm|xwd|?(e)ps|pdf|dvi|txt|svg?(z)|cdr|[ot]tf'
} &&
- complete -F _fbi fbi
+ complete -F _comp_cmd_fbi fbi
# ex: filetype=sh
diff --git a/completions/feh b/completions/feh
index f1d4b18..3762574 100644
--- a/completions/feh
+++ b/completions/feh
@@ -1,110 +1,108 @@
# bash completion for feh(1) -*- shell-script -*-
-_feh()
+_comp_cmd_feh()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[foO|KCjeM@TSRHWEyJabgLD~^]*)'
+ # shellcheck disable=SC2254
case "$prev" in
--image-bg | -B)
- COMPREPLY=($(compgen -W 'checks white black' -- "$cur"))
+ _comp_compgen -- -W 'checks white black'
return
;;
- --filelist | --output | --output-only | --start-at | -!(-*)[foO\|])
- _filedir
+ --filelist | --output | --output-only | --start-at | -${noargopts}[foO\|])
+ _comp_compgen_filedir
return
;;
- --caption-path | --fontpath | --output-dir | -!(-*)[KCj])
- _filedir -d
+ --caption-path | --fontpath | --output-dir | -${noargopts}[KCj])
+ _comp_compgen_filedir -d
return
;;
- --font | --menu-font | --title-font | -!(-*)[eM@])
+ --font | --menu-font | --title-font | -${noargopts}[eM@])
# expect string like "dejavu.ttf/12"
if [[ $cur == */* ]]; then # expect integer value
- COMPREPLY=($(compgen -P "$cur" -W '{0..9}'))
+ _comp_compgen -R -- -P "$cur" -W '{0..9}'
compopt -o nospace
return
fi
local font_path
# font_path="$(imlib2-config --prefix 2>/dev/null)/share/imlib2/data/fonts"
- # COMPREPLY=( $(cd "$font_path" 2>/dev/null; compgen -f \
- # -X "!*.@([tT][tT][fF])" -S / -- "$cur") )
+ # _comp_compgen -C "$font_path" -- -f -X "!*.@([tT][tT][fF])" -S /
for ((i = ${#words[@]} - 1; i > 0; i--)); do
if [[ ${words[i]} == -@(C|-fontpath) ]]; then
font_path="${words[i + 1]}"
- COMPREPLY+=($(
- cd "$font_path" 2>/dev/null
- compgen -f \
- -X "!*.@([tT][tT][fF])" -S / -- "$cur"
- ))
+ _comp_compgen -aC "$font_path" -- \
+ -f -X "!*.@([tT][tT][fF])" -S /
fi
done
compopt -o nospace
return
;;
- --theme | -!(-*)T)
+ --theme | -${noargopts}T)
local conf_path=~/.config/feh/themes
local theme_name theme_opts
[[ -r $conf_path ]] || return
- while read theme_name theme_opts; do
+ while read -r theme_name theme_opts; do
if [[ $theme_name == '#'* || $theme_name == "" ]]; then
continue
fi
- COMPREPLY+=($(compgen -W "$theme_name" -- "$cur"))
+ _comp_compgen -a -- -W "$theme_name"
done <"$conf_path"
return
;;
- --sort | -!(-*)S)
- COMPREPLY=($(compgen -W 'name filename mtime width height
- pixels size format' -- "$cur"))
+ --sort | -${noargopts}S)
+ _comp_compgen -- -W 'name filename mtime width height pixels size
+ format'
return
;;
--reload | --limit-height | --limit-width | --thumb-height | --thumb-width | \
- --thumb-redraw | --magick-timeout | -!(-*)[RHWEyJ])
+ --thumb-redraw | --magick-timeout | -${noargopts}[RHWEyJ])
# expect integer value
- COMPREPLY+=($(compgen -W '{0..9}'))
+ _comp_compgen -aR -- -W '{0..9}'
compopt -o nospace
return
;;
--zoom)
# expect integer value or "max", "fill"
- COMPREPLY=($(compgen -W 'max fill' -- "$cur"))
+ _comp_compgen -- -W 'max fill'
if [[ ! $cur || ! ${COMPREPLY-} ]]; then
- COMPREPLY+=($(compgen -W '{0..9}'))
+ _comp_compgen -aR -- -W '{0..9}'
compopt -o nospace
fi
return
;;
- --alpha | -!(-*)a)
- COMPREPLY=($(compgen -W '{0..255}' -- "$cur"))
+ --alpha | -${noargopts}a)
+ _comp_compgen -- -W '{0..255}'
return
;;
- --bg | -!(-*)b)
- _filedir
- COMPREPLY+=($(compgen -W 'trans' -- "$cur"))
+ --bg | -${noargopts}b)
+ _comp_compgen_filedir
+ _comp_compgen -a -- -W 'trans'
return
;;
- --geometry | --max-dimension | --min-dimension | -!(-*)g)
+ --geometry | --max-dimension | --min-dimension | -${noargopts}g)
# expect string like 640x480
if [[ $cur && $cur != *x* ]]; then
COMPREPLY=(x)
fi
- COMPREPLY+=($(compgen -W "{0..9}"))
+ _comp_compgen -aR -- -W "{0..9}"
compopt -o nospace
return
;;
--customlist | --index-info | --info | --slideshow-delay | --thumb-title | \
- --title | -!(-*)[LD~^])
+ --title | -${noargopts}[LD~^])
# argument required but no completions available
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
# Some versions of feh just output "See 'man feh'" for --help :(
- COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur"))
+ _comp_compgen_help
if [[ ${COMPREPLY-} ]]; then
[[ $COMPREPLY == *= ]] && compopt -o nospace
return
@@ -113,8 +111,8 @@ _feh()
# FIXME: It is hard to determine correct supported extensions.
# feh can handle any format that imagemagick can plus some others
- _filedir 'xpm|tif?(f)|png|p[npgba]m|iff|?(i)lbm|jp?(e)g|jfi?(f)|gif|bmp|arg?(b)|tga|xcf|ani|ico|?(e)ps|pdf|dvi|txt|svg?(z)|cdr|[ot]tf'
+ _comp_compgen_filedir 'xpm|tif?(f)|png|p[npgba]m|iff|?(i)lbm|jp?(e)g|jfi?(f)|gif|bmp|arg?(b)|tga|xcf|ani|ico|?(e)ps|pdf|dvi|txt|svg?(z)|cdr|[ot]tf|ff?(.gz|.bz2)|webp|y4m|hei[cf]?(s)|avif?(s)'
} &&
- complete -F _feh feh
+ complete -F _comp_cmd_feh feh
# ex: filetype=sh
diff --git a/completions/file b/completions/file
index 21fbd16..7b07d40 100644
--- a/completions/file
+++ b/completions/file
@@ -1,32 +1,34 @@
# file(1) completion -*- shell-script -*-
-_file()
+_comp_cmd_file()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[Fmfe]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | --separator | -!(-*)[vF])
+ --help | --version | --separator | -${noargopts}[vF])
return
;;
- --magic-file | --files-from | -!(-*)[mf])
- _filedir
+ --magic-file | --files-from | -${noargopts}[mf])
+ _comp_compgen_filedir
return
;;
- --exclude | -!(-*)e)
- COMPREPLY=($(compgen -W 'apptype ascii cdf compress elf encoding
- soft tar text tokens troff' -- "$cur"))
+ --exclude | -${noargopts}e)
+ _comp_compgen -- -W 'apptype ascii cdf compress elf encoding soft
+ tar text tokens troff'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _file file
+ complete -F _comp_cmd_file file
# ex: filetype=sh
diff --git a/completions/file-roller b/completions/file-roller
index 1d223fd..cd745ac 100644
--- a/completions/file-roller
+++ b/completions/file-roller
@@ -1,42 +1,44 @@
# file-roller(1) completion -*- shell-script -*-
-_file_roller()
+_comp_cmd_file_roller()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
- local exts='@(7z|ace|alz|ar|arj|[bglx]z|bz2|tb?(z)2|cab|cb[rz]|iso?(9660)|Z|t[abglx]z|cpio|deb|rar|?(g)tar|gem|lh[az]|lz[4h]|?(t)lrz|lzma|lzo|wim|swm|rpm|sit|zoo)'
+ local exts='@(7z?(.001)|ace|alz|ar|arj|[bglx]z|bz2|tb?(z)2|cab|cb[rz]|iso?(9660)|Z|t[abglx]z|cpio|deb|rar|?(g)tar|gem|lh[az]|lz[4h]|?(t)lrz|lzma|lzo|wim|swm|rpm|sit|zoo|?(t)zst)'
+ local noargopts='!(-*|*[ae]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --help-all | --help-gtk | --help-sm-client | -!(-*)'?')
+ --help | --help-all | --help-gtk | --help-sm-client | -${noargopts}'?')
return
;;
--sm-client-state-file)
- _filedir
+ _comp_compgen_filedir
return
;;
- --add-to | -!(-*)a)
- _filedir_xspec unzip
- _filedir "$exts"
+ --add-to | -${noargopts}a)
+ _comp_compgen_filedir_xspec unzip
+ _comp_compgen -a filedir "$exts"
return
;;
- --extract-to | --default-dir | -!(-*)e)
- _filedir -d
+ --extract-to | --default-dir | -${noargopts}e)
+ _comp_compgen_filedir -d
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur"))
+ _comp_compgen_help -- --help-all
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir_xspec unzip
- _filedir "$exts"
+ _comp_compgen_filedir_xspec unzip
+ _comp_compgen -a filedir "$exts"
} &&
- complete -F _file_roller file-roller
+ complete -F _comp_cmd_file_roller file-roller
# ex: filetype=sh
diff --git a/completions/filefrag b/completions/filefrag
index d26e8c8..6de8a19 100644
--- a/completions/filefrag
+++ b/completions/filefrag
@@ -1,17 +1,17 @@
# filefrag(8) completion -*- shell-script -*-
-_filefrag()
+_comp_cmd_filefrag()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _filefrag filefrag
+ complete -F _comp_cmd_filefrag filefrag
# ex: filetype=sh
diff --git a/completions/filesnarf b/completions/filesnarf
index f959d80..d4c1cb0 100644
--- a/completions/filesnarf
+++ b/completions/filesnarf
@@ -1,22 +1,22 @@
# filesnarf etc completion -*- shell-script -*-
-_snarf()
+_comp_cmd_snarf()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-i)
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
fi
} &&
- complete -F _snarf filesnarf mailsnarf msgsnarf
+ complete -F _comp_cmd_snarf filesnarf mailsnarf msgsnarf
# ex: filetype=sh
diff --git a/completions/find b/completions/find
index 64121ed..92c7fa8 100644
--- a/completions/find
+++ b/completions/find
@@ -2,53 +2,53 @@
# This makes heavy use of ksh style extended globs and contains Linux specific
# code for completing the parameter to the -fstype option.
-_find()
+_comp_cmd_find()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local i
- for i in ${!words[*]}; do
+ for ((i = 1; i < cword; i++)); do
if [[ ${words[i]} == -@(exec|ok)?(dir) ]]; then
- _command_offset $((i + 1))
+ _comp_command_offset $((i + 1))
return
fi
done
case $prev in
-maxdepth | -mindepth)
- COMPREPLY=($(compgen -W '{0..9}' -- "$cur"))
+ _comp_compgen -- -W '{0..9}'
return
;;
-newer | -anewer | -cnewer | -fls | -fprint | -fprint0 | -fprintf | -name | -[il]name | \
-ilname | -wholename | -[il]wholename | -samefile)
- _filedir
+ _comp_compgen_filedir
return
;;
-fstype)
- _fstypes
+ _comp_compgen_fstypes
[[ $OSTYPE == *bsd* ]] &&
- COMPREPLY+=($(compgen -W 'local rdonly' -- "$cur"))
+ _comp_compgen -a -- -W 'local rdonly'
return
;;
-gid)
- _gids
+ _comp_compgen_gids
return
;;
-group)
- COMPREPLY=($(compgen -g -- "$cur" 2>/dev/null))
+ _comp_compgen -- -g
return
;;
-xtype | -type)
- COMPREPLY=($(compgen -W 'b c d p f l s' -- "$cur"))
+ _comp_compgen -- -W 'b c d p f l s'
return
;;
-uid)
- _uids
+ _comp_compgen_uids
return
;;
-user)
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
return
;;
-[acm]min | -[acm]time | -inum | -path | -ipath | -regex | -iregex | -links | -perm | \
@@ -57,35 +57,34 @@ _find()
return
;;
-regextype)
- COMPREPLY=($(compgen -W 'emacs posix-awk posix-basic posix-egrep
- posix-extended' -- "$cur"))
+ _comp_compgen -- -W 'emacs posix-awk posix-basic posix-egrep
+ posix-extended'
return
;;
esac
- local i exprfound=false
+ local i exprfound=""
# set exprfound to true if there is already an expression present
for i in "${words[@]}"; do
- [[ $i == [-\(\),\!]* ]] && exprfound=true && break
+ [[ $i == [-\(\),\!]* ]] && exprfound=set && break
done
# handle case where first parameter is not a dash option
- if ! $exprfound && [[ $cur != [-\(\),\!]* ]]; then
- _filedir -d
+ if [[ ! $exprfound && $cur != [-\(\),\!]* ]]; then
+ _comp_compgen_filedir -d
return
fi
# complete using basic options
- COMPREPLY=($(compgen -W '-daystart -depth -follow -help
- -ignore_readdir_race -maxdepth -mindepth -mindepth -mount
- -noignore_readdir_race -noleaf -regextype -version -warn -nowarn -xdev
- -amin -anewer -atime -cmin -cnewer -ctime -empty -executable -false
- -fstype -gid -group -ilname -iname -inum -ipath -iregex -iwholename
- -links -lname -mmin -mtime -name -newer -nogroup -nouser -path -perm
- -readable -regex -samefile -size -true -type -uid -used -user
- -wholename -writable -xtype -context -delete -exec -execdir -fls
- -fprint -fprint0 -fprintf -ls -ok -okdir -print -print0 -printf -prune
- -quit' -- "$cur"))
+ _comp_compgen -- -W '-daystart -depth -follow -help -ignore_readdir_race
+ -maxdepth -mindepth -mindepth -mount -noignore_readdir_race -noleaf
+ -regextype -version -warn -nowarn -xdev -amin -anewer -atime -cmin
+ -cnewer -ctime -empty -executable -false -fstype -gid -group -ilname
+ -iname -inum -ipath -iregex -iwholename -links -lname -mmin -mtime
+ -name -newer -nogroup -nouser -path -perm -readable -regex -samefile
+ -size -true -type -uid -used -user -wholename -writable -xtype -context
+ -delete -exec -execdir -fls -fprint -fprint0 -fprintf -ls -ok -okdir
+ -print -print0 -printf -prune -quit'
if ((${#COMPREPLY[@]} != 0)); then
# this removes any options from the list of completions that have
@@ -100,14 +99,14 @@ _find()
for i in "${words[@]}"; do
[[ $i && -v onlyonce["$i"] ]] || continue
for j in "${!COMPREPLY[@]}"; do
- [[ ${COMPREPLY[j]} == "$i" ]] && unset 'COMPREPLY[j]'
+ [[ ${COMPREPLY[j]} == "$i" ]] && unset -v 'COMPREPLY[j]'
done
done
fi
- _filedir
+ _comp_compgen -a filedir
} &&
- complete -F _find find
+ complete -F _comp_cmd_find find
# ex: filetype=sh
diff --git a/completions/find_member b/completions/find_member
index cf30c70..d2620e8 100644
--- a/completions/find_member
+++ b/completions/find_member
@@ -1,25 +1,27 @@
# mailman find_member completion -*- shell-script -*-
-_find_member()
+_comp_cmd_find_member()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-l | -x | --listname | --exclude)
- _xfunc list_lists _mailman_lists
+ # Prefer `list_lists` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -x list_lists mailman_lists
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--listname --exclude --owners --help' \
- -- "$cur"))
+ _comp_compgen -- -W '--listname --exclude --owners --help'
fi
} &&
- complete -F _find_member find_member
+ complete -F _comp_cmd_find_member find_member
# ex: filetype=sh
diff --git a/completions/fio b/completions/fio
index f81a4da..7fbcdd4 100644
--- a/completions/fio
+++ b/completions/fio
@@ -1,90 +1,147 @@
# fio(1) completion -*- shell-script -*-
-_fio()
+_comp_cmd_fio__compgen_engines()
{
- local cur prev words cword split
- _init_completion -s || return
+ _comp_compgen_split -l -- "$("$1" --enghelp 2>/dev/null | command sed -ne '/^[[:space:]]/p'))"
+}
+_comp_cmd_fio()
+{
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+
+ local REPLY
case $prev in
--help | --version)
return
;;
--debug)
- local prefix=
- [[ $cur == *,* ]] && prefix="${cur%,*},"
- COMPREPLY=($(compgen -W "process file io mem blktrace verify
- random parse diskutil job mutex profile time net rate compress
- steadystate helperthread" -- "${cur##*,}"))
- ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
+ local opts=$("$1" --debug=help 2>/dev/null)
+ opts=${opts##*:}
+ _comp_delimited , -W "${opts//,/ }"
return
;;
--output-format)
- COMPREPLY=($(compgen -W "terse json json+ normal" -- "$cur"))
+ _comp_compgen -- -W "terse json json+ normal"
return
;;
--terse-version)
- COMPREPLY=($(compgen -W "2 3" -- "$cur"))
+ _comp_compgen -- -W "2 3 4 5"
+ return
+ ;;
+ --crctest)
+ _comp_compgen_split -- "$("$1" --crctest=nonexistent 2>/dev/null)"
return
;;
--cmdhelp)
- # TODO more commands?
- COMPREPLY=($(compgen -W "all" -- "$cur"))
+ _comp_compgen_split -- "$("$1" --cmdhelp=all 2>/dev/null | _comp_awk '{print $1}') all"
return
;;
--enghelp)
- # TODO print ioengine help, or list available ioengines
- # TODO engine,help arg
+ _comp_cmd_fio__compgen_engines "$1"
return
;;
--eta)
- COMPREPLY=($(compgen -W "always never auto" -- "$cur"))
+ _comp_compgen -- -W "always never auto"
return
;;
--daemonize)
- _filedir pid
+ _comp_compgen_filedir pid
return
;;
--client)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
--remote-config)
- _filedir job
+ _comp_compgen_filedir '@(fio|job)'
return
;;
--idle-prof)
- COMPREPLY=($(compgen -W "system percpu calibrate" -- "$cur"))
+ _comp_compgen -- -W "system percpu calibrate"
return
;;
--inflate-log)
- _filedir log
+ _comp_compgen_filedir log
return
;;
--trigger-file)
- _filedir
+ _comp_compgen_filedir
return
;;
--trigger | --trigger-remote)
- compopt -o filenames
- COMPREPLY=($(compgen -c -- "$cur"))
+ _comp_compgen_commands
return
;;
--aux-path)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
+ --ioengine)
+ _comp_cmd_fio__compgen_engines "$1"
+ return
+ ;;
+ --exec_postrun | --exec_prerun)
+ _comp_compgen_commands
+ return
+ ;;
+ --uid)
+ _comp_compgen_uids
+ return
+ ;;
+ --gid)
+ _comp_compgen_gids
+ return
+ ;;
+ --?*)
+ local -a cmdhelp
+ _comp_split -l cmdhelp "$("$1" --cmdhelp="${prev#--}" 2>/dev/null)"
+ case ${cmdhelp[*]-} in
+ *"showing closest match"*)
+ # ignore
+ ;;
+ *" type: boolean "* | *" type: empty or boolean "*)
+ _comp_compgen -- -W '0 1'
+ return
+ ;;
+ *" valid values:"*)
+ # For example, for --kb_base=:
+ # valid values: 1024 [...]
+ # : 1000 [...]
+ local line="" in_values=""
+ REPLY=()
+ for line in "${cmdhelp[@]}"; do
+ if [[ $in_values ]]; then
+ if [[ $line =~ ^[[:space:]]*:[[:space:]]*([^[:space:]]+) ]]; then
+ REPLY+=("${BASH_REMATCH[1]}")
+ else
+ break
+ fi
+ elif [[ $line =~ ^[[:space:]]*valid\ values:[[:space:]]*([^[:space:]]+) ]]; then
+ in_values=set
+ REPLY+=("${BASH_REMATCH[1]}")
+ fi
+ done
+ _comp_compgen -- -W '"${REPLY[@]}"'
+ return
+ ;;
+ esac
+ # else fallthrough
+ ;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
+ _comp_compgen -a split -- "$("$1" --cmdhelp=all 2>/dev/null |
+ _comp_awk '{printf "--%s=\n", $1}')"
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir job
+ _comp_compgen_filedir '@(fio|job)'
} &&
- complete -F _fio fio
+ complete -F _comp_cmd_fio fio
# ex: filetype=sh
diff --git a/completions/firefox b/completions/firefox
index 4656f8d..e84d644 100644
--- a/completions/firefox
+++ b/completions/firefox
@@ -1,46 +1,53 @@
# firefox completion -*- shell-script -*-
-_firefox()
+_comp_cmd_firefox()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
[[ $cur == -MOZ_LOG*=* ]] && prev=${cur%%=*} cur=${cur#*=}
case $prev in
--help | --version | --display | --UILocale | -MOZ_LOG | --new-window | --new-tab | \
--private-window | --window-size | --search | --start-debugger-server | \
- --recording | --debugger-args | -[hvPa])
+ --recording | --debugger-args | -[hva])
+ return
+ ;;
+ -P)
+ _comp_compgen_split -- "$(
+ _comp_awk -F = '$1 == "Name" { print $2 }' \
+ ~/.mozilla/firefox/profiles.ini 2>/dev/null
+ )"
return
;;
--profile | --screenshot)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-MOZ_LOG_FILE)
- _filedir log
+ _comp_compgen_filedir log
return
;;
- --recording-file)
- _filedir
+ --recording-output | --recording-file)
+ _comp_compgen_filedir
return
;;
--debugger | -d)
- COMPREPLY=($(compgen -c -- "$cur"))
+ _comp_compgen_commands
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir "@(?([xs])htm?(l)|pdf|txt)"
+ _comp_compgen_filedir "@(?([xs])htm?(l)|pdf|txt|svg)"
} &&
- complete -F _firefox firefox mozilla-firefox iceweasel
+ complete -F _comp_cmd_firefox firefox firefox-esr iceweasel mozilla-firefox
# ex: filetype=sh
diff --git a/completions/flake8 b/completions/flake8
index 045c409..6889e86 100644
--- a/completions/flake8
+++ b/completions/flake8
@@ -1,42 +1,46 @@
# flake8 completion -*- shell-script -*-
-_flake8()
+_comp_cmd_flake8()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[j]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | -!(-*)h)
+ --help | --version | -${noargopts}h)
return
;;
--format)
- COMPREPLY=($(compgen -W 'default pylint' -- "$cur"))
+ _comp_compgen -- -W 'default pylint'
return
;;
- --jobs | -!(-*)j)
- COMPREPLY=($(compgen -W "auto {1..$(_ncpus)}" -- "$cur"))
+ --jobs | -${noargopts}j)
+ local REPLY
+ _comp_get_ncpus
+ _comp_compgen -- -W "auto {1..$REPLY}"
return
;;
--output-file | --append-config | --config)
- _filedir
+ _comp_compgen_filedir
return
;;
--include-in-doctest | --exclude-from-doctest)
- _filedir py
+ _comp_compgen_filedir py
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir py
+ _comp_compgen_filedir py
} &&
- complete -F _flake8 flake8
+ complete -F _comp_cmd_flake8 flake8
# ex: filetype=sh
diff --git a/completions/freebsd-update b/completions/freebsd-update
index d5be861..8ccc949 100644
--- a/completions/freebsd-update
+++ b/completions/freebsd-update
@@ -2,18 +2,18 @@
[[ $OSTYPE == *freebsd* ]] || return 1
-_freebsd_update()
+_comp_cmd_freebsd_update()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-b | -d)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-f)
- _filedir
+ _comp_compgen_filedir
return
;;
-k | -r | -s | -t)
@@ -21,9 +21,8 @@ _freebsd_update()
;;
esac
- COMPREPLY=($(compgen -W "fetch cron upgrade install rollback IDS" -- \
- $cur))
+ _comp_compgen -- -W 'fetch cron upgrade install rollback IDS'
} &&
- complete -F _freebsd_update freebsd-update
+ complete -F _comp_cmd_freebsd_update freebsd-update
# ex: filetype=sh
diff --git a/completions/freeciv b/completions/freeciv
index 01af311..2dedf37 100644
--- a/completions/freeciv
+++ b/completions/freeciv
@@ -1,41 +1,41 @@
# freeciv client completions -*- shell-script -*-
-_freeciv()
+_comp_cmd_freeciv()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--help | --version | --name | --port | -[hvnp])
return
;;
--file | --log | --music | --read | --Sound | --tiles | -[flmrSt])
- _filedir
+ _comp_compgen_filedir
return
;;
--Announce | -A)
- COMPREPLY=($(compgen -W 'IPv4 IPv6 none' -- "$cur"))
+ _comp_compgen -- -W 'IPv4 IPv6 none'
return
;;
--debug | -d)
- COMPREPLY=($(compgen -W '{0..3}' -- "$cur"))
+ _comp_compgen -- -W '{0..3}'
return
;;
--Meta | --server | -[Ms])
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
--Plugin | -P)
- COMPREPLY=($(compgen -W 'none esd sdl' -- "$cur"))
+ _comp_compgen -- -W 'none esd sdl'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
fi
} &&
- complete -F _freeciv freeciv{,-{gtk{2,3},sdl,xaw}} civclient
+ complete -F _comp_cmd_freeciv freeciv{,-{gtk{2,3},sdl,xaw}} civclient
# ex: filetype=sh
diff --git a/completions/freeciv-server b/completions/freeciv-server
index a34b5a2..fd91fa0 100644
--- a/completions/freeciv-server
+++ b/completions/freeciv-server
@@ -1,22 +1,22 @@
# freeciv-server completion -*- shell-script -*-
-_civserver()
+_comp_cmd_civserver()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-f | -g | -l | -r | --file | --log | --gamelog | --read)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
fi
} &&
- complete -F _civserver civserver freeciv-server
+ complete -F _comp_cmd_civserver civserver freeciv-server
# ex: filetype=sh
diff --git a/completions/function b/completions/function
index 6ae5271..218f0cf 100644
--- a/completions/function
+++ b/completions/function
@@ -1,37 +1,17 @@
# bash shell function completion -*- shell-script -*-
-_function()
+_comp_cmd_function()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- if [[ $1 == @(declare|typeset) ]]; then
- if [[ $cur == [-+]* ]]; then
- local opts
- opts=($(_parse_usage "$1"))
- # Most options also have a '+' form. We'll exclude the ones that don't with compgen.
- opts+=(${opts[*]/-/+})
- COMPREPLY=($(compgen -W "${opts[*]}" -X '+[Ffgp]' -- "$cur"))
- else
- local i=1
- while [[ ${words[i]} == [-+]* ]]; do
- if [[ ${words[i]} == -*[fF]* ]]; then
- COMPREPLY=($(compgen -A function -- "$cur"))
- return
- fi
- ((i++))
- done
- if ((i > 1)); then
- # There was at least one option and it was not one that limited operations to functions
- COMPREPLY=($(compgen -A variable -- "$cur"))
- fi
- fi
- elif ((cword == 1)); then
- COMPREPLY=($(compgen -A function -- "$cur"))
+ if ((cword == 1)); then
+ _comp_compgen -- -A function
else
- COMPREPLY=("() $(type -- ${words[1]} | command sed -e 1,2d)")
+ local funcdef=$(type -- "${words[1]}" 2>/dev/null | command sed -e 1,2d)
+ COMPREPLY=("()${funcdef:+ $funcdef}")
fi
} &&
- complete -F _function function declare typeset
+ complete -F _comp_cmd_function function
# ex: filetype=sh
diff --git a/completions/fusermount b/completions/fusermount
index 7e48922..4f85319 100644
--- a/completions/fusermount
+++ b/completions/fusermount
@@ -1,28 +1,27 @@
# fusermount completion -*- shell-script -*-
-_fusermount()
+_comp_cmd_fusermount()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*[hVo])
return
;;
-*u)
- COMPREPLY=($(compgen -W "$(awk \
- '{ if ($3 ~ /^fuse(\.|$)/) print $2 }' /etc/mtab \
- 2>/dev/null)" -- "$cur"))
+ _comp_compgen_split -- "$(_comp_awk \
+ '{ if ($3 ~ /^fuse(\.|$)/) print $2 }' /etc/mtab 2>/dev/null)"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ _comp_compgen_help -- -h
else
- _filedir -d
+ _comp_compgen_filedir -d
fi
} &&
- complete -F _fusermount fusermount
+ complete -F _comp_cmd_fusermount fusermount
# ex: filetype=sh
diff --git a/completions/gcc b/completions/gcc
index fa95274..ed5bc9b 100644
--- a/completions/gcc
+++ b/completions/gcc
@@ -1,26 +1,26 @@
# gcc(1) completion -*- shell-script -*-
-_gcc()
+_comp_cmd_gcc()
{
- local cur prev prev2 words cword argument prefix prefix_length
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
# Test that GCC is recent enough and if not fallback to
# parsing of --completion option.
- if ! $1 --completion=" " 2>/dev/null; then
+ if ! "$1" --completion=" " 2>/dev/null; then
if [[ $cur == -* ]]; then
- local cc=$($1 -print-prog-name=cc1 2>/dev/null)
+ local cc=$("$1" -print-prog-name=cc1 2>/dev/null)
[[ $cc ]] || return
- COMPREPLY=($(compgen -W "$($cc --help 2>/dev/null | tr '\t' ' ' |
- command sed -e '/^ *-/!d' -e 's/ *-\([^][ <>]*\).*/-\1/')" \
- -- "$cur"))
+ _comp_compgen_split -- "$("$cc" --help 2>/dev/null | tr '\t' ' ' |
+ command sed -e '/^ *-/!d' -e 's/ *-\([^][ <>]*\).*/-\1/')"
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- _filedir
+ _comp_compgen_filedir
fi
return
fi
+ local prev2 argument="" prefix prefix_length
# extract also for situations like: -fsanitize=add
if ((cword > 2)); then
prev2="${COMP_WORDS[cword - 2]}"
@@ -44,32 +44,34 @@ _gcc()
prefix="$prev "
fi
- if [[ ! -v argument ]]; then
- _filedir
+ if [[ ! $argument ]]; then
+ _comp_compgen_filedir
else
# In situation like '-fsanitize=add' $cur is equal to last token.
# Thus we need to strip the beginning of suggested option.
prefix_length=$((${#prefix} + 1))
- local flags=$($1 --completion="$argument" | cut -c $prefix_length-)
+ local flags=$("$1" --completion="$argument" | cut -c $prefix_length-)
[[ ${flags} == "=*" ]] && compopt -o nospace 2>/dev/null
- COMPREPLY=($(compgen -W "$flags" -- ""))
+ _comp_compgen -R -- -W "$flags"
fi
} &&
- complete -F _gcc gcc{,-5,-6,-7,-8} g++{,-5,-6,-7,-8} g77 g95 \
+ complete -F _comp_cmd_gcc gcc{,-5,-6,-7,-8} g++{,-5,-6,-7,-8} g77 g95 \
gccgo{,-5,-6,-7,-8} gcj gfortran{,-5,-6,-7,-8} gpc &&
+ _comp_cmd_gcc__setup_cmd()
{
- cc --version 2>/dev/null | command grep -q GCC ||
- [[ $(_realcommand cc) == *gcc* ]] &&
- complete -F _gcc cc || complete -F _minimal cc
- c++ --version 2>/dev/null | command grep -q GCC ||
- [[ $(_realcommand c++) == *g++* ]] &&
- complete -F _gcc c++ || complete -F _minimal c++
- f77 --version 2>/dev/null | command grep -q GCC ||
- [[ $(_realcommand f77) == *gfortran* ]] &&
- complete -F _gcc f77 || complete -F _minimal f77
- f95 --version 2>/dev/null | command grep -q GCC ||
- [[ $(_realcommand f95) == *gfortran* ]] &&
- complete -F _gcc f95 || complete -F _minimal f95
- }
+ local REPLY
+ _comp_realcommand "$1"
+ if [[ $REPLY == *$2* ]] ||
+ "$1" --version 2>/dev/null | command grep -q GCC; then
+ complete -F _comp_cmd_gcc "$1"
+ else
+ complete -F _comp_complete_minimal "$1"
+ fi
+ } &&
+ _comp_cmd_gcc__setup_cmd cc gcc &&
+ _comp_cmd_gcc__setup_cmd c++ g++ &&
+ _comp_cmd_gcc__setup_cmd f77 gfortran &&
+ _comp_cmd_gcc__setup_cmd f95 gfortran &&
+ unset -f _comp_cmd_gcc__setup_cmd
# ex: filetype=sh
diff --git a/completions/gcl b/completions/gcl
index 73a18b2..7b98767 100644
--- a/completions/gcl
+++ b/completions/gcl
@@ -2,20 +2,20 @@
# bash programmable completion for various Common Lisp implementations by
# Nikodemus Siivola <nikodemus@random-state.net>
-_gcl()
+_comp_cmd_gcl()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
# completing an option (may or may not be separated by a space)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-eval -load -f -batch -dir -libdir -compile
- -o-file -c-file -h-file -data-file -system-p' -- "$cur"))
+ _comp_compgen -- -W '-eval -load -f -batch -dir -libdir -compile
+ -o-file -c-file -h-file -data-file -system-p'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _gcl -o default gcl
+ complete -F _comp_cmd_gcl -o default gcl
# ex: filetype=sh
diff --git a/completions/gdb b/completions/gdb
index f78f8a5..e6a124f 100644
--- a/completions/gdb
+++ b/completions/gdb
@@ -1,47 +1,46 @@
# bash completion for gdb -*- shell-script -*-
-_gdb()
+_comp_cmd_gdb()
{
- local cur prev words cword i
- _init_completion || return
+ local cur prev words cword comp_args i
+ _comp_initialize -- "$@" || return
# gdb [options] --args executable-file [inferior-arguments ...]
for ((i = 1; i < cword; i++)); do
if [[ ${words[i]} == --args ]]; then
- _command_offset $((i + 1))
+ _comp_command_offset $((i + 1))
return $?
fi
done
# gdb [options] [executable-file [core-file or process-id]]
if ((cword == 1)); then
- local IFS
compopt -o filenames
- if [[ $cur == */* ]]; then
+ if _comp_looks_like_path "$cur"; then
# compgen -c works as expected if $cur contains any slashes.
- IFS=$'\n'
- COMPREPLY=($(PATH="$PATH:." compgen -d -c -- "$cur"))
+ local PATH="$PATH:."
+ _comp_compgen_commands
else
# otherwise compgen -c contains Bash's built-in commands,
# functions and aliases. Thus we need to retrieve the program
# names manually.
- IFS=":"
- local path_array=($(
- command sed -e 's/:\{2,\}/:/g' -e 's/^://' -e 's/:$//' <<<"$PATH"
- ))
- IFS=$'\n'
- COMPREPLY=($(compgen -d -W '$(find "${path_array[@]}" . \
- -mindepth 1 -maxdepth 1 -not -type d -executable \
- -printf "%f\\n" 2>/dev/null)' -- "$cur"))
+ local path_array
+ _comp_compgen -Rv path_array split -F : -X '' -S /. -- "$PATH"
+ _comp_compgen_split -o plusdirs -- "$(
+ # Note: ${v+"$@"} does not work with empty IFS in bash < 4.4
+ IFS=$' \t\n'
+ find ${path_array[@]+"${path_array[@]}"} . -name . -o \
+ -type d -prune -o -perm -u+x -print 2>/dev/null |
+ command sed 's|^.*/||' | sort -u
+ )"
fi
elif ((cword == 2)); then
- COMPREPLY=($(compgen -W "$(command ps axo comm,pid |
- awk '{if ($1 ~ /^'"${prev##*/}"'/) print $2}')" -- "$cur"))
+ _comp_compgen_split -- "$(command ps axo comm,pid |
+ _comp_awk '{if ($1 ~ /^'"${prev##*/}"'/) print $2}')"
compopt -o filenames
- COMPREPLY+=($(compgen -f -X '!?(*/)core?(.?*)' -o plusdirs \
- -- "$cur"))
+ _comp_compgen -a -- -f -X '!?(*/)core?(.?*)' -o plusdirs
fi
} &&
- complete -F _gdb gdb
+ complete -F _comp_cmd_gdb gdb
# ex: filetype=sh
diff --git a/completions/genaliases b/completions/genaliases
index 5953b9e..0fec30d 100644
--- a/completions/genaliases
+++ b/completions/genaliases
@@ -1,15 +1,15 @@
# mailman genaliases completion -*- shell-script -*-
-_genaliases()
+_comp_cmd_genaliases()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--quiet --help' -- "$cur"))
+ _comp_compgen -- -W '--quiet --help'
fi
} &&
- complete -F _genaliases genaliases
+ complete -F _comp_cmd_genaliases genaliases
# ex: filetype=sh
diff --git a/completions/gendiff b/completions/gendiff
index d37793f..9fea862 100644
--- a/completions/gendiff
+++ b/completions/gendiff
@@ -1,12 +1,12 @@
# gendiff(1) completion -*- shell-script -*-
-_gendiff()
+_comp_cmd_gendiff()
{
- local cur prev words cword
- _init_completion -o '@(diff|patch)' || return
+ local cur prev words cword comp_args
+ _comp_initialize -o '@(diff|patch)' -- "$@" || return
- ((cword == 1)) && _filedir -d
+ ((cword == 1)) && _comp_compgen_filedir -d
} &&
- complete -F _gendiff gendiff
+ complete -F _comp_cmd_gendiff gendiff
# ex: filetype=sh
diff --git a/completions/genisoimage b/completions/genisoimage
index dfa39c0..d54fdf6 100644
--- a/completions/genisoimage
+++ b/completions/genisoimage
@@ -1,38 +1,38 @@
# bash completion for mkisofs/genisoimage -*- shell-script -*-
-_mkisofs()
+_comp_cmd_mkisofs()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-o | -abstract | -biblio | -check-session | -copyright | -log-file | \
-root-info | -prep-boot | -*-list)
- _filedir
+ _comp_compgen_filedir
return
;;
-*-charset)
- COMPREPLY=($(compgen -W '$(mkisofs -input-charset \
- help 2>&1 | tail -n +3)' -- "$cur"))
+ _comp_compgen_split -- "$(mkisofs -input-charset help 2>&1 |
+ tail -n +3)"
return
;;
-uid)
- _uids
+ _comp_compgen_uids
return
;;
-gid)
- _gids
+ _comp_compgen_gids
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _mkisofs mkisofs genisoimage
+ complete -F _comp_cmd_mkisofs mkisofs genisoimage
# ex: filetype=sh
diff --git a/completions/geoiplookup b/completions/geoiplookup
index c60be89..504c22a 100644
--- a/completions/geoiplookup
+++ b/completions/geoiplookup
@@ -1,33 +1,33 @@
# geoiplookup(1) completion -*- shell-script -*-
-_geoiplookup()
+_comp_cmd_geoiplookup()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-h | -'?' | -v)
return
;;
-d)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-f)
- _filedir dat
+ _comp_compgen_filedir dat
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" -h)' -- "$cur"))
+ _comp_compgen_usage -- -h
return
fi
local ipvx
[[ $1 == *6 ]] && ipvx=-6 || ipvx=-4
- _known_hosts_real $ipvx -- "$cur"
+ _comp_compgen_known_hosts $ipvx -- "$cur"
} &&
- complete -F _geoiplookup geoiplookup geoiplookup6
+ complete -F _comp_cmd_geoiplookup geoiplookup geoiplookup6
# ex: filetype=sh
diff --git a/completions/getconf b/completions/getconf
index de1ad2d..230b0f4 100644
--- a/completions/getconf
+++ b/completions/getconf
@@ -1,32 +1,33 @@
# getconf(1) completion -*- shell-script -*-
-_getconf()
+_comp_cmd_getconf()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-a)
- _filedir
+ _comp_compgen_filedir
return
;;
-v)
- COMPREPLY=($(compgen -W \
- '$("$1" -a 2>/dev/null | awk "{ print \$1 }")' -- \
- "${cur:-POSIX_V}"))
+ _comp_compgen -c "${cur:-POSIX_V}" split -- "$(
+ "$1" -a 2>/dev/null | _comp_awk '{ print $1 }'
+ )"
return
;;
esac
if [[ $prev == PATH_MAX ]]; then # TODO more path vars, better handling
- _filedir
+ _comp_compgen_filedir
elif [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-a -v' -- "$cur"))
+ _comp_compgen -- -W '-a -v'
else
- COMPREPLY=($(compgen -W \
- '$("$1" -a 2>/dev/null | awk "{ print \$1 }")' -- "$cur"))
+ _comp_compgen_split -- "$(
+ "$1" -a 2>/dev/null | _comp_awk '{ print $1 }'
+ )"
fi
} &&
- complete -F _getconf getconf
+ complete -F _comp_cmd_getconf getconf
# ex: filetype=sh
diff --git a/completions/getent b/completions/getent
index 4c54a24..4310434 100644
--- a/completions/getent
+++ b/completions/getent
@@ -1,17 +1,19 @@
# bash completion for getent -*- shell-script -*-
-_getent()
+_comp_cmd_getent()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
- local i db
+ local noargopts='!(-*|*[s]*)'
+ local i db="" has_db=""
for ((i = 1; i < cword; i++)); do
+ # shellcheck disable=SC2254
case ${words[i]} in
- --version | --usage | --help | -!(-*)[V?])
+ --version | --usage | --help | -${noargopts}[V?])
return
;;
- --service | -!(-*)s)
+ --service | -${noargopts}s)
((i++))
;;
-*) ;;
@@ -19,35 +21,35 @@ _getent()
*)
# First non-option value is the db
db=${words[i]}
+ has_db=set
break
;;
esac
done
- case ${db-} in
+ case $db in
passwd)
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
return
;;
group)
- COMPREPLY=($(compgen -g -- "$cur"))
+ _comp_compgen -- -g
return
;;
services)
- COMPREPLY=($(compgen -s -- "$cur"))
+ _comp_compgen -- -s
return
;;
hosts)
- COMPREPLY=($(compgen -A hostname -- "$cur"))
+ _comp_compgen -- -A hostname
return
;;
protocols | networks | ahosts | ahostsv4 | ahostsv6 | rpc)
- COMPREPLY=($(compgen -W "$($1 $db |
- awk '{ print $1 }')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" "$db" | _comp_awk '{ print $1 }')"
return
;;
aliases | shadow | gshadow)
- COMPREPLY=($(compgen -W "$($1 $db | cut -d: -f1)" -- "$cur"))
+ _comp_compgen_split -- "$("$1" "$db" | cut -d: -f1)"
return
;;
ethers | netgroup)
@@ -55,23 +57,24 @@ _getent()
;;
esac
+ # shellcheck disable=SC2254
case $prev in
- -s | --service)
+ -${noargopts}s | --service)
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
- elif [[ ! -v db ]]; then
- COMPREPLY=($(compgen -W 'passwd group hosts services protocols
- networks ahosts ahostsv4 ahostsv6 aliases ethers netgroup rpc
- shadow gshadow' -- "$cur"))
+ elif [[ ! $has_db ]]; then
+ _comp_compgen -- -W 'passwd group hosts services protocols networks
+ ahosts ahostsv4 ahostsv6 aliases ethers netgroup rpc shadow
+ gshadow'
fi
} &&
- complete -F _getent getent
+ complete -F _comp_cmd_getent getent
# ex: filetype=sh
diff --git a/completions/gkrellm b/completions/gkrellm
index c38c5ae..81781fb 100644
--- a/completions/gkrellm
+++ b/completions/gkrellm
@@ -1,25 +1,25 @@
# gkrellm(1) completion -*- shell-script -*-
-_gkrellm()
+_comp_cmd_gkrellm()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-t | --theme)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-p | --plugin)
- _filedir so
+ _comp_compgen_filedir so
return
;;
-s | --server)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-l | --logfile)
- _filedir
+ _comp_compgen_filedir
return
;;
-g | --geometry | -c | --config | -P | --port | -d | --debug-level)
@@ -32,8 +32,8 @@ _gkrellm()
;;
esac
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
} &&
- complete -F _gkrellm gkrellm gkrellm2
+ complete -F _comp_cmd_gkrellm gkrellm gkrellm2
# ex: filetype=sh
diff --git a/completions/gm b/completions/gm
index b86c9cc..7dbaceb 100644
--- a/completions/gm
+++ b/completions/gm
@@ -1,21 +1,21 @@
# bash completion for gm(1) -*- shell-script -*-
-_gm_commands()
+_comp_cmd_gm__commands()
{
- COMPREPLY+=($(compgen -W '$("$1" help |
- awk "/^ +[^ ]+ +- / { print \$1 }")' -- "$cur"))
+ _comp_compgen -a split -- "$("$1" help |
+ _comp_awk '/^ +[^ ]+ +- / { print $1 }')"
}
-_gm()
+_comp_cmd_gm()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if ((cword == 1)); then
- _gm_commands "$1"
+ _comp_cmd_gm__commands "$1"
return
elif [[ $cword -eq 2 && ${words[1]} == time ]]; then
- _gm_commands "$1"
+ _comp_cmd_gm__commands "$1"
return
fi
@@ -24,7 +24,7 @@ _gm()
case $gmcmd in
help)
- [[ $prev == help ]] && _gm_commands "$1"
+ [[ $prev == help ]] && _comp_cmd_gm__commands "$1"
return
;;
version)
@@ -32,9 +32,9 @@ _gm()
;;
esac
- # TODO... defer some commnds to the imagemagick "gm"less completions etc?
+ # TODO... defer some commands to the imagemagick "gm"less completions etc?
compopt -o default
} &&
- complete -F _gm gm
+ complete -F _comp_cmd_gm gm
# ex: filetype=sh
diff --git a/completions/gnatmake b/completions/gnatmake
index 5f4b963..bbeccef 100644
--- a/completions/gnatmake
+++ b/completions/gnatmake
@@ -1,26 +1,26 @@
# Gnatmake completion -*- shell-script -*-
# by Ralf_Schroth@t-online.de (Ralf Schroth)
-_gnatmake()
+_comp_cmd_gnatmake()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
# relevant (and less relevant ;-) )options completion
- COMPREPLY=($(compgen -W '-a -c -f -i -j -k -m -M -n -o -q -s -v -z
- -aL -A -aO -aI -I -I- -L -nostdinc -nostdlib -cargs -bargs -largs
+ _comp_compgen -- -W '-a -c -f -i -j -k -m -M -n -o -q -s -v -z -aL -A
+ -aO -aI -I -I- -L -nostdinc -nostdlib -cargs -bargs -largs
-fstack-check -fno-inline -g -O1 -O0 -O2 -O3 -gnata -gnatA -gnatb
-gnatc -gnatd -gnatD -gnate -gnatE -gnatf -gnatF -gnatg -gnatG
-gnath -gnati -gnatk -gnatl -gnatL -gnatm -gnatn -gnato -gnatO
-gnatp -gnatP -gnatq -gnatR -gnats -gnatt -gnatT -gnatu -gnatU
-gnatv -gnatws -gnatwe -gnatwl -gnatwu -gnatW -gnatx -gnatX -gnaty
- -gnatz -gnatZ -gnat83' -- "$cur"))
+ -gnatz -gnatZ -gnat83'
else
# source file completion
- _filedir '@(adb|ads)'
+ _comp_compgen_filedir '@(adb|ads)'
fi
} &&
- complete -F _gnatmake gnatmake
+ complete -F _comp_cmd_gnatmake gnatmake
# ex: filetype=sh
diff --git a/completions/gnokii b/completions/gnokii
index 039141a..21fb13c 100644
--- a/completions/gnokii
+++ b/completions/gnokii
@@ -1,19 +1,19 @@
# gnokii(1) completion -*- shell-script -*-
-_gnokii_memory_type()
+_comp_cmd_gnokii__memory_type()
{
# TODO: reduce the number of choices
- COMPREPLY=($(compgen -W "IN OU SM ME MT" -- "$cur"))
+ _comp_compgen -- -W "IN OU SM ME MT"
}
-_gnokii()
+_comp_cmd_gnokii()
{
- local cur prev words cword pprev tprev fprev
- _init_completion || return
+ local cur prev words cword comp_args pprev tprev fprev
+ _comp_initialize -- "$@" || return
case $prev in
--config)
- _filedir
+ _comp_compgen_filedir
return
;;
--phone)
@@ -24,15 +24,13 @@ _gnokii()
[[ -f $config_file ]] && break
done
[[ ! -f $config_file ]] && return
- COMPREPLY=($(compgen -W \
- "$(command sed -n 's/^\[phone_\(.*\)\]/\1/p' $config_file)" \
- -- "$cur"))
+ _comp_compgen_split -- "$(command sed -n \
+ 's/^\[phone_\(.*\)\]/\1/p' "$config_file")"
return
;;
--help)
- COMPREPLY=($(compgen -W 'all monitor sms mms phonebook calendar
- todo dial profile settings wap logo ringtone security file
- other' -- "$cur"))
+ _comp_compgen -- -W 'all monitor sms mms phonebook calendar todo
+ dial profile settings wap logo ringtone security file other'
return
;;
--version | --shell | ping)
@@ -41,15 +39,14 @@ _gnokii()
# MONITOR
--monitor)
- COMPREPLY=($(compgen -W 'delay once' -- "$cur"))
+ _comp_compgen -- -W 'delay once'
return
;;
--getdisplaystatus | --displayoutput)
return
;;
--netmonitor)
- COMPREPLY=($(compgen -W 'reset off field devel next nr' \
- -- "$cur"))
+ _comp_compgen -- -W 'reset off field devel next nr'
return
;;
@@ -59,13 +56,13 @@ _gnokii()
return
;;
--savesms)
- COMPREPLY=($(compgen -W '--sender --smsc --smscno --folder
- --location --sent --read --deliver --datetime' -- "$cur"))
+ _comp_compgen -- -W '--sender --smsc --smscno --folder --location
+ --sent --read --deliver --datetime'
return
;;
--memory-type | --memory | --getsms | --deletesms | --getmms | --deletemms | \
--getphonebook | --deletephonebook)
- _gnokii_memory_type
+ _comp_cmd_gnokii__memory_type
return
;;
--getsmsc | --getcalendarnote | --deletecalendarnote | --gettodo | \
@@ -82,12 +79,12 @@ _gnokii()
return
;;
--writephonebook)
- COMPREPLY=($(compgen -W '--overwrite --find-free --memory-type
- --location --vcard --ldif' -- "$cur"))
+ _comp_compgen -- -W '--overwrite --find-free --memory-type
+ --location --vcard --ldif'
return
;;
--writecalendarnote | --writetodo)
- _filedir vcf
+ _comp_compgen_filedir vcf
return
;;
@@ -97,7 +94,7 @@ _gnokii()
return
;;
--divert)
- COMPREPLY=($(compgen -W '--op' -- "$cur"))
+ _comp_compgen -- -W '--op'
return
;;
@@ -112,7 +109,7 @@ _gnokii()
# SETTINGS
--reset)
- COMPREPLY=($(compgen -W 'soft hard' -- "$cur"))
+ _comp_compgen -- -W 'soft hard'
return
;;
--setdatetime | --setalarm)
@@ -131,12 +128,11 @@ _gnokii()
# LOGOS
--sendlogo)
- COMPREPLY=($(compgen -W 'caller op picture' -- "$cur"))
+ _comp_compgen -- -W 'caller op picture'
return
;;
--setlogo | --getlogo)
- COMPREPLY=($(compgen -W 'op startup caller dealer text' \
- -- "$cur"))
+ _comp_compgen -- -W 'op startup caller dealer text'
return
;;
--viewlogo)
@@ -145,7 +141,7 @@ _gnokii()
;;
--entersecuritycode)
- COMPREPLY=($(compgen -W 'PIN PIN2 PUK PUK2 SEC' -- "$cur"))
+ _comp_compgen -- -W 'PIN PIN2 PUK PUK2 SEC'
return
;;
@@ -157,7 +153,7 @@ _gnokii()
pprev=${words[cword - 2]}
case $pprev in
--setspeeddial)
- _gnokii_memory_type
+ _comp_cmd_gnokii__memory_type
return
;;
--getsms | --deletesms | --getmms | --deletemms | --getphonebook | \
@@ -166,16 +162,15 @@ _gnokii()
return
;;
--gettodo | --getcalendarnote)
- COMPREPLY=($(compgen -W '{1..9} end --vCal' -- "$cur"))
+ _comp_compgen -- -W '{1..9} end --vCal'
return
;;
--deletecalendarnote)
- COMPREPLY=($(compgen -W '{1..9} end' -- "$cur"))
+ _comp_compgen -- -W '{1..9} end'
return
;;
--divert)
- COMPREPLY=($(compgen -W 'register enable query disable
- erasure' -- "$cur"))
+ _comp_compgen -- -W 'register enable query disable erasure'
return
;;
esac
@@ -186,20 +181,20 @@ _gnokii()
tprev=${words[cword - 3]}
case $tprev in
--deletesms | --deletemms)
- COMPREPLY=($(compgen -W 'end' -- "$cur"))
+ _comp_compgen -- -W 'end'
return
;;
--getphonebook | --writetodo | --writecalendarnote)
- COMPREPLY=($(compgen -W '{1..9} end' -- "$cur"))
+ _comp_compgen -- -W '{1..9} end'
return
;;
--gettodo | --getcalendarnote)
[[ ${words[cword - 1]} == end ]] &&
- COMPREPLY=($(compgen -W '--vCal' -- "$cur"))
+ _comp_compgen -- -W '--vCal'
return
;;
--divert)
- COMPREPLY=($(compgen -W '--type' -- "$cur"))
+ _comp_compgen -- -W '--type'
return
;;
esac
@@ -210,28 +205,32 @@ _gnokii()
fprev=${words[cword - 4]}
case $fprev in
--getphonebook)
- COMPREPLY=($(compgen -W '--raw --vcard --ldif' -- "$cur"))
+ _comp_compgen -- -W '--raw --vcard --ldif'
return
;;
--divert)
- COMPREPLY=($(compgen -W 'all busy noans outofreach notavail' \
- -- "$cur"))
+ _comp_compgen -- -W 'all busy noans outofreach notavail'
return
;;
esac
fi
- # safer to use LANG=C
- local all_cmd="$(LANG=C _parse_help $1 "--help all")"
- # these 2 below are allowed in combination with others
- local main_cmd=$(command grep -v -- '--config\|--phone' <<<"$all_cmd")
+ local all_cmd
+ _comp_compgen -Rv all_cmd help -- --help all
+ # these 2 below are allowed in combination with others
+ local main_cmd
+ _comp_split -l main_cmd "$(printf '%s\n' "${all_cmd[@]}" |
+ command sed -e '/--config/d;/--phone/d;s/[][\(){}|^$*+?.]/\\&/g')"
# don't provide main command completions if one is
# already on the command line
- [[ $COMP_LINE =~ $(tr ' ' '\b|' <<<$main_cmd) ]] && return
+ local IFS='|'
+ local regex_main_cmd="(${main_cmd[*]})($|[^_[:alnum:]])"
+ IFS=$' \t\n'
+ [[ $COMP_LINE =~ $regex_main_cmd ]] && return
- COMPREPLY=($(compgen -W "$all_cmd" -- "$cur"))
+ _comp_compgen -- -W '"${all_cmd[@]}"'
} &&
- complete -F _gnokii gnokii
+ complete -F _comp_cmd_gnokii gnokii
# ex: filetype=sh
diff --git a/completions/gnome-mplayer b/completions/gnome-mplayer
index 32d93fc..86686fc 100644
--- a/completions/gnome-mplayer
+++ b/completions/gnome-mplayer
@@ -1,38 +1,38 @@
# gnome-mplayer(1) completion -*- shell-script -*-
-_gnome_mplayer()
+_comp_cmd_gnome_mplayer()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-'?' | --help | --help-all | --help-gtk)
return
;;
--showcontrols | --showsubtitles | --autostart)
- COMPREPLY=($(compgen -w '0 1' -- "$cur"))
+ _comp_compgen -- -W '0 1'
return
;;
--subtitle)
- _filedir '@(srt|sub|txt|utf|rar|mpsub|smi|js|ssa|ass)'
+ _comp_compgen_filedir '@(srt|sub|txt|utf|rar|mpsub|smi|js|ssa|ass)'
return
;;
--tvdriver)
- COMPREPLY=($(compgen -W 'v4l v4l2' -- "$cur"))
+ _comp_compgen -- -W 'v4l v4l2'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur"))
+ _comp_compgen_help -- --help-all
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _gnome_mplayer gnome-mplayer
+ complete -F _comp_cmd_gnome_mplayer gnome-mplayer
# ex: filetype=sh
diff --git a/completions/gnome-screenshot b/completions/gnome-screenshot
index b3594d2..a884fa4 100644
--- a/completions/gnome-screenshot
+++ b/completions/gnome-screenshot
@@ -1,31 +1,33 @@
# gnome-screenshot(1) completion -*- shell-script -*-
-_gnome_screenshot()
+_comp_cmd_gnome_screenshot()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[def]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --help-* | --version | --delay | --display | -!(-*)[hd])
+ --help | --help-* | --version | --delay | --display | -${noargopts}[hd])
return
;;
- --border-effect | -!(-*)e)
- COMPREPLY=($(compgen -W 'shadow border vintage none' -- "$cur"))
+ --border-effect | -${noargopts}e)
+ _comp_compgen -- -W 'shadow border vintage none'
return
;;
- --file | -!(-*)f)
- _filedir '@(jp?(e)|pn)g'
+ --file | -${noargopts}f)
+ _comp_compgen_filedir '@(jp?(e)|pn)g'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _gnome_screenshot gnome-screenshot
+ complete -F _comp_cmd_gnome_screenshot gnome-screenshot
# ex: filetype=sh
diff --git a/completions/gpasswd b/completions/gpasswd
index f1f2200..db33c29 100644
--- a/completions/gpasswd
+++ b/completions/gpasswd
@@ -1,25 +1,27 @@
# gpasswd(1) completion -*- shell-script -*-
-_gpasswd()
+_comp_cmd_gpasswd()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[adAM]*)'
+ # shellcheck disable=SC2254
case $prev in
- --add | --delete | --administrators | --members | -!(-*)[adAM])
- COMPREPLY=($(compgen -u -- "$cur"))
+ --add | --delete | --administrators | --members | -${noargopts}[adAM])
+ _comp_compgen -- -u
return
;;
esac
if [[ $cur == -* ]]; then
# TODO: only -A and -M can be combined
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- COMPREPLY=($(compgen -g -- "$cur"))
+ _comp_compgen -- -g
} &&
- complete -F _gpasswd gpasswd
+ complete -F _comp_cmd_gpasswd gpasswd
# ex: filetype=sh
diff --git a/completions/gpg b/completions/gpg
index f0ca884..ca0d8e0 100644
--- a/completions/gpg
+++ b/completions/gpg
@@ -1,38 +1,53 @@
# bash completion for gpg -*- shell-script -*-
-_gpg()
+_comp_cmd_gpg()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[skKr]*)'
+ # shellcheck disable=SC2254
case $prev in
- --sign | --clearsign | --decrypt-files | --load-extension | -!(-*)s)
- _filedir
+ --sign | --clear-sign | --clearsign | --decrypt-files | \
+ --load-extension | -${noargopts}s)
+ _comp_compgen_filedir
return
;;
- --export | --sign-key | --lsign-key | --nrsign-key | --nrlsign-key | --edit-key)
+ --list-keys | --list-public-keys | --locate-keys | \
+ --locate-external-keys | --fingerprint | --delete-keys | \
+ --delete-secret-and-public-keys | --export | --refresh-keys | \
+ --search-keys | --edit-key | --sign-key | --lsign-key | \
+ --nrsign-key | --nrlsign-key | --try-secret-key | -${noargopts}k)
# return list of public keys
- COMPREPLY=($(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \
- 's@^pub.*/\([^ ]*\).*$@\1@p' -ne \
- 's@^.*\(<\([^>]*\)>\).*$@\2@p')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" --list-keys 2>/dev/null |
+ command sed -ne \
+ 's@^pub.*/\([^ ]*\).*$@\1@p' -ne \
+ 's@^.*\(<\([^>]*\)>\).*$@\2@p')"
return
;;
- --recipient | -!(-*)r)
- COMPREPLY=($(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \
- 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur"))
+ --list-secret-keys | --delete-secret-keys | --export-secret-keys | \
+ --export-secret-subkeys | -${noargopts}K)
+ # return list of secret keys
+ _comp_compgen_split -- "$("$1" --list-secret-keys 2>/dev/null |
+ command sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')"
+ return
+ ;;
+ --recipient | -${noargopts}r)
+ _comp_compgen_split -- "$("$1" --list-keys 2>/dev/null |
+ command sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')"
if [[ -e ~/.gnupg/gpg.conf ]]; then
- COMPREPLY+=($(compgen -W "$(command sed -ne \
+ _comp_compgen -a split -- "$(command sed -ne \
's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \
- ~/.gnupg/gpg.conf)" -- "$cur"))
+ ~/.gnupg/gpg.conf)"
fi
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$($1 --dump-options)' -- "$cur"))
+ _comp_compgen_split -- "$("$1" --dump-options)"
fi
} &&
- complete -F _gpg -o default gpg
+ complete -F _comp_cmd_gpg -o default gpg
# ex: filetype=sh
diff --git a/completions/gpg2 b/completions/gpg2
index cfa4023..fc54ff9 100644
--- a/completions/gpg2
+++ b/completions/gpg2
@@ -1,42 +1,47 @@
# gpg2(1) completion -*- shell-script -*-
-_gpg2()
+_comp_cmd_gpg2()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[sr]*)'
+ # shellcheck disable=SC2254
case $prev in
--homedir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
- --sign | --clearsign | --options | --decrypt | -!(-*)s)
- _filedir
+ --sign | --clearsign | --options | --decrypt | -${noargopts}s)
+ _comp_compgen_filedir
return
;;
- --export | --sign-key | --lsign-key | --nrsign-key | --nrlsign-key | --edit-key)
+ --export | --sign-key | --lsign-key | --nrsign-key | --nrlsign-key | \
+ --edit-key | --delete-keys | --delete-secret-and-public-keys | \
+ --locate-keys | --refresh-keys)
# return list of public keys
- COMPREPLY=($(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \
- 's@^pub.*/\([^ ]*\).*$@\1@p' -ne \
- 's@^.*\(<\([^>]*\)>\).*$@\2@p')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" --list-keys 2>/dev/null |
+ command sed -ne \
+ 's@^pub.*/\([^ ]*\).*$@\1@p' -ne \
+ 's@^.*\(<\([^>]*\)>\).*$@\2@p')"
return
;;
- --recipient | -!(-*)r)
- COMPREPLY=($(compgen -W "$($1 --list-keys 2>/dev/null |
- command sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur"))
+ --recipient | -${noargopts}r)
+ _comp_compgen_split -- "$("$1" --list-keys 2>/dev/null |
+ command sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')"
if [[ -e ~/.gnupg/gpg.conf ]]; then
- COMPREPLY+=($(compgen -W "$(command sed -ne \
+ _comp_compgen -a split -- "$(command sed -ne \
's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \
- ~/.gnupg/gpg.conf)" -- "$cur"))
+ ~/.gnupg/gpg.conf)"
fi
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$($1 --dump-options)' -- "$cur"))
+ _comp_compgen_split -- "$("$1" --dump-options)"
fi
} &&
- complete -F _gpg2 -o default gpg2
+ complete -F _comp_cmd_gpg2 -o default gpg2
# ex: filetype=sh
diff --git a/completions/gpgv b/completions/gpgv
index 29315c9..7609a33 100644
--- a/completions/gpgv
+++ b/completions/gpgv
@@ -1,29 +1,30 @@
# gpgv(1) completion -*- shell-script -*-
-_gpgv()
+_comp_cmd_gpgv()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--help | --version | --weak-digest | --*-fd | -!(-*)[?h]*)
return
;;
--keyring)
- _filedir "@(gpg|kbx)"
+ _comp_compgen_filedir "@(gpg|kbx)"
return
;;
--homedir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
- local args
- _count_args "" "--@(weak-digest|*-fd|keyring|homedir)"
+ local REPLY
+ _comp_count_args -a "--@(weak-digest|*-fd|keyring|homedir)"
+ local args=$REPLY
if [[ $cur == -* && $args -eq 1 ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
@@ -31,16 +32,16 @@ _gpgv()
if [[ ${COMP_LINE,,} == *.@(asc|sig|sign)\ * ]]; then
# Detached signature, only complete one arbitrary file arg and -
if ((args == 2)); then
- COMPREPLY=($(compgen -W '-' -- "$cur"))
- _filedir
+ _comp_compgen -- -W '-'
+ _comp_compgen -a filedir
fi
else
- _filedir gpg
+ _comp_compgen_filedir gpg
fi
else
- _filedir "@(asc|gpg|sig|sign)"
+ _comp_compgen_filedir "@(asc|gpg|sig|sign)"
fi
} &&
- complete -F _gpgv gpgv gpgv2
+ complete -F _comp_cmd_gpgv gpgv gpgv2
# ex: filetype=sh
diff --git a/completions/gphoto2 b/completions/gphoto2
index cbf84c0..454ef61 100644
--- a/completions/gphoto2
+++ b/completions/gphoto2
@@ -1,55 +1,52 @@
# bash completion for gphoto2(1) -*- shell-script -*-
-_gphoto2()
+_comp_cmd_gphoto2()
{
- local cur prev words cword split
- _init_completion -s -n : || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -n : -- "$@" || return
case $prev in
--debug-logfile)
- _filedir
+ _comp_compgen_filedir
return
;;
--hook-script)
- _filedir
+ _comp_compgen_filedir
return
;;
--filename)
- _filedir
+ _comp_compgen_filedir
return
;;
-u | --upload-file)
- _filedir
+ _comp_compgen_filedir
return
;;
--port)
- COMPREPLY=($(compgen -W "$($1 --list-ports 2>/dev/null |
- awk 'NR>3 { print $1 }')" -- "$cur"))
- __ltrim_colon_completions "$cur"
+ _comp_compgen_split -- "$("$1" --list-ports 2>/dev/null |
+ _comp_awk 'NR>3 { print $1 }')"
+ _comp_ltrim_colon_completions "$cur"
return
;;
--camera)
- local IFS=$'\n'
- COMPREPLY=($(compgen -W "$($1 --list-cameras 2>/dev/null |
- awk -F'"' 'NR>2 { print $2 }')" -- "$cur"))
+ _comp_compgen_split -l -- "$("$1" --list-cameras 2>/dev/null |
+ _comp_awk -F '"' 'NR>2 { print $2 }')"
return
;;
--get-config | --set-config | --set-config-index | --set-config-value)
- COMPREPLY=($(compgen -W "$(
- $1 --list-config 2>/dev/null
- )" -- "$cur"))
+ _comp_compgen_split -- "$("$1" --list-config 2>/dev/null)"
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _gphoto2 gphoto2
+ complete -F _comp_cmd_gphoto2 gphoto2
# ex: filetype=sh
diff --git a/completions/gprof b/completions/gprof
index 5a4ab2d..cb18633 100644
--- a/completions/gprof
+++ b/completions/gprof
@@ -1,56 +1,54 @@
# gprof(1) completion -*- shell-script -*-
-_gprof()
+_comp_cmd_gprof()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $cur in
-A* | -C* | -J* | -p* | -P* | -q* | -Q* | -n* | -N* | -d*)
return
;;
-S*)
- cur=${cur:2}
- _filedir
- COMPREPLY=("${COMPREPLY[@]/#/-S}")
+ _comp_compgen -c "${cur:2}" filedir
+ ((${#COMPREPLY[@]})) && COMPREPLY=("${COMPREPLY[@]/#/-S}")
return
;;
-O*)
- cur=${cur:2}
- COMPREPLY=($(compgen -P -O -W 'auto bsd 4.4bsd magic prof' \
- -- "$cur"))
+ _comp_compgen -c "${cur:2}" -- -P -O -W 'auto bsd 4.4bsd magic
+ prof'
return
;;
esac
case $prev in
-I | --directory-path)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-R | --file-ordering | --external-symbol-table)
- _filedir
+ _comp_compgen_filedir
return
;;
-w | --width | -k | -m | --min-count | -h | --help | -e | -E | -f | -F)
return
;;
--file-format)
- COMPREPLY=($(compgen -W 'auto bsd 4.4bsd magic prof' -- "$cur"))
+ _comp_compgen -- -W 'auto bsd 4.4bsd magic prof'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _gprof gprof
+ complete -F _comp_cmd_gprof gprof
# ex: filetype=sh
diff --git a/completions/groupadd b/completions/groupadd
index 5f67f29..fe4e600 100644
--- a/completions/groupadd
+++ b/completions/groupadd
@@ -1,26 +1,28 @@
# groupadd(8) completion -*- shell-script -*-
-_groupadd()
+_comp_cmd_groupadd()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
# TODO: if -o/--non-unique is given, could complete on existing gids
# with -g/--gid
+ local noargopts='!(-*|*[gKp]*)'
+ # shellcheck disable=SC2254
case $prev in
- --gid | --key | --password | -!(-*)[gKp])
+ --gid | --key | --password | -${noargopts}[gKp])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _groupadd groupadd
+ complete -F _comp_cmd_groupadd groupadd
# ex: filetype=sh
diff --git a/completions/groupdel b/completions/groupdel
index 4d8ca7f..ab9fb29 100644
--- a/completions/groupdel
+++ b/completions/groupdel
@@ -1,27 +1,27 @@
# groupdel(8) completion -*- shell-script -*-
-_groupdel()
+_comp_cmd_groupdel()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-h | --help)
return
;;
-R | --root)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- COMPREPLY=($(compgen -g -- "$cur"))
+ _comp_compgen -- -g
} &&
- complete -F _groupdel groupdel
+ complete -F _comp_cmd_groupdel groupdel
# ex: filetype=sh
diff --git a/completions/groupmems b/completions/groupmems
index 2e89a5a..c884be2 100644
--- a/completions/groupmems
+++ b/completions/groupmems
@@ -1,27 +1,27 @@
# groupmems(8) completion -*- shell-script -*-
-_groupmems()
+_comp_cmd_groupmems()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-a | --add | -d | --delete)
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
return
;;
-g | --group)
- COMPREPLY=($(compgen -g -- "$cur"))
+ _comp_compgen -- -g
return
;;
-R | --root)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
} &&
- complete -F _groupmems groupmems
+ complete -F _comp_cmd_groupmems groupmems
# ex: filetype=sh
diff --git a/completions/groupmod b/completions/groupmod
index 5516d31..3e8a352 100644
--- a/completions/groupmod
+++ b/completions/groupmod
@@ -1,29 +1,31 @@
# groupmod(8) completion -*- shell-script -*-
-_groupmod()
+_comp_cmd_groupmod()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
# TODO: if -o/--non-unique is given, could complete on existing gids
# with -g/--gid
+ local noargopts='!(-*|*[gnp]*)'
+ # shellcheck disable=SC2254
case $prev in
- --gid | --help | --new-name | --password | -!(-*)[ghnp])
+ --gid | --help | --new-name | --password | -${noargopts}[ghnp])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- COMPREPLY=($(compgen -g -- "$cur"))
+ _comp_compgen -- -g
} &&
- complete -F _groupmod groupmod
+ complete -F _comp_cmd_groupmod groupmod
# ex: filetype=sh
diff --git a/completions/growisofs b/completions/growisofs
index ee09fe6..1ea27c2 100644
--- a/completions/growisofs
+++ b/completions/growisofs
@@ -1,9 +1,9 @@
# growisofs(1) completion -*- shell-script -*-
-_growisofs()
+_comp_cmd_growisofs()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-version | -speed)
@@ -11,14 +11,13 @@ _growisofs()
;;
-Z | -M)
compopt -o nospace
- _dvd_devices
+ _comp_compgen_dvd_devices
return
;;
/?(r)dev/*)
if [[ $cur == =* ]]; then
# e.g. /dev/dvd=foo.iso, /dev/dvdrw=/dev/zero
- cur="${cur#=}"
- _filedir
+ _comp_compgen -c "${cur#=}" filedir
return
fi
;;
@@ -26,14 +25,13 @@ _growisofs()
if [[ $cur == -* ]]; then
# TODO: mkisofs options
- COMPREPLY=($(compgen -W '-dvd-compat -overburn -speed= -Z -M' \
- -- "$cur"))
+ _comp_compgen -- -W '-dvd-compat -overburn -speed= -Z -M'
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _growisofs growisofs
+ complete -F _comp_cmd_growisofs growisofs
# ex: filetype=sh
diff --git a/completions/grpck b/completions/grpck
index 0fadbed..e5ab485 100644
--- a/completions/grpck
+++ b/completions/grpck
@@ -1,25 +1,26 @@
# grpck(8) completion -*- shell-script -*-
-_grpck()
+_comp_cmd_grpck()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[R]*)'
+ # shellcheck disable=SC2254
case $prev in
- --root | -!(-*)R)
- _filedir
+ --root | -${noargopts}R)
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- local opts=$(_parse_help "$1")
- COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _grpck grpck
+ complete -F _comp_cmd_grpck grpck
# ex: filetype=sh
diff --git a/completions/gssdp-discover b/completions/gssdp-discover
index 8454f52..3125912 100644
--- a/completions/gssdp-discover
+++ b/completions/gssdp-discover
@@ -1,34 +1,32 @@
-# bash completion for gssdp-discover -*- shell-script -*-
+# bash completion for gssdp-discover/device-sniffer -*- shell-script -*-
-_gssdp_discover()
+_comp_cmd_gssdp_discover()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
--help | --target | --timeout | --rescan-interval | -[htnr])
return
;;
--interface | -i)
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
return
;;
--message-type | -m)
- local types=$($1 --help 2>&1 |
+ [[ $1 == *gssdp-discover ]] || return
+ local types=$("$1" --help 2>&1 |
command sed -ne 's/^.*--message-type=.*(\([^)]*\))$/\1/p')
- COMPREPLY=($(
- IFS+=,
- compgen -W "$types" -- "$cur"
- ))
+ _comp_compgen -F $' \t\n,' -- -W "$types"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _gssdp_discover gssdp-discover
+ complete -F _comp_cmd_gssdp_discover gssdp-discover gssdp-device-sniffer
# ex: filetype=sh
diff --git a/completions/gzip b/completions/gzip
index 0144c3a..9a41eec 100644
--- a/completions/gzip
+++ b/completions/gzip
@@ -1,27 +1,33 @@
# bash completion for gzip -*- shell-script -*-
-_gzip()
+_comp_cmd_gzip()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[bSACIJp]*)'
+ # shellcheck disable=SC2254
case $prev in
- --blocksize | --suffix | --help | --version | -!(-*)[bShV])
+ --blocksize | --suffix | --help | --version | --alias | --comment | \
+ --iterations | --maxsplits | -${noargopts}[bShVACIJ])
return
;;
- --processes | -!(-*)p)
- COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur"))
+ --processes | -${noargopts}p)
+ local REPLY
+ _comp_get_ncpus
+ _comp_compgen -- -W "{1..$REPLY}"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1") {-1..-9}' -- "$cur"))
+ _comp_compgen_help
+ _comp_compgen -a -- -W '-{1..9}'
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- local IFS=$'\n' xspec="*.@(gz|t[ag]z)"
+ local xspec="*.@(gz|t[ag]z)"
[[ ${1##*/} == pigz ]] && xspec="*.@([gz]z|t[ag]z)"
if [[ $prev == --* ]]; then
@@ -32,12 +38,11 @@ _gzip()
[[ $prev == -*f* ]] && xspec=
fi
- _tilde "$cur" || return
+ _comp_compgen_tilde && return
compopt -o filenames
- COMPREPLY=($(compgen -f -X "$xspec" -- "$cur")
- $(compgen -d -- "$cur"))
+ _comp_compgen -- -f -X "$xspec" -o plusdirs
} &&
- complete -F _gzip gzip pigz
+ complete -F _comp_cmd_gzip gzip pigz
# ex: filetype=sh
diff --git a/completions/hash b/completions/hash
new file mode 100644
index 0000000..4ea517b
--- /dev/null
+++ b/completions/hash
@@ -0,0 +1,26 @@
+# hash completion -*- shell-script -*-
+
+_comp_cmd_hash()
+{
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+
+ local noargopts='!(*[p]*)'
+ # shellcheck disable=SC2254
+ case $prev in
+ -${noargopts}p)
+ _comp_compgen_filedir
+ return
+ ;;
+ esac
+
+ if [[ $cur == -* ]]; then
+ _comp_compgen_help -c help "$1"
+ return
+ fi
+
+ _comp_compgen_commands
+} &&
+ complete -F _comp_cmd_hash hash
+
+# ex: filetype=sh
diff --git a/completions/hcitool b/completions/hcitool
index 58bf5a7..aacc108 100644
--- a/completions/hcitool
+++ b/completions/hcitool
@@ -1,178 +1,168 @@
# bash completion for bluez utils -*- shell-script -*-
-_bluetooth_addresses()
+_comp_cmd_hcitool__bluetooth_addresses()
{
- if [[ -n ${COMP_BLUETOOTH_SCAN:-} ]]; then
- COMPREPLY+=($(compgen -W "$(hcitool scan |
- awk '/^\t/{print $1}')" -- "$cur"))
+ if [[ ${COMP_BLUETOOTH_SCAN-} ]]; then
+ _comp_compgen -a split -- "$(hcitool scan | _comp_awk '/^\t/{print $1}')"
fi
}
-_bluetooth_devices()
+_comp_cmd_hcitool__bluetooth_devices()
{
- COMPREPLY+=($(compgen -W "$(hcitool dev |
- awk '/^\t/{print $1}')" -- "$cur"))
+ _comp_compgen -a split -- "$(hcitool dev | _comp_awk '/^\t/{print $1}')"
}
-_bluetooth_services()
+_comp_cmd_hcitool__bluetooth_services()
{
- COMPREPLY=($(compgen -W 'DID SP DUN LAN FAX OPUSH FTP HS HF HFAG SAP NAP
- GN PANU HCRP HID CIP A2SRC A2SNK AVRCT AVRTG UDIUE UDITE SYNCML' \
- -- "$cur"))
+ _comp_compgen -- -W 'DID SP DUN LAN FAX OPUSH FTP HS HF HFAG SAP NAP
+ GN PANU HCRP HID CIP A2SRC A2SNK AVRCT AVRTG UDIUE UDITE SYNCML'
}
-_bluetooth_packet_types()
+_comp_cmd_hcitool__bluetooth_packet_types()
{
- COMPREPLY=($(compgen -W 'DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3' \
- -- "$cur"))
+ _comp_compgen -- -W 'DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3'
}
-_hcitool()
+_comp_cmd_hcitool()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-i)
- _bluetooth_devices
+ _comp_cmd_hcitool__bluetooth_devices
return
;;
--role)
- COMPREPLY=($(compgen -W 'm s' -- "$cur"))
+ _comp_compgen -- -W 'm s'
return
;;
--pkt-type)
- _bluetooth_packet_types
+ _comp_cmd_hcitool__bluetooth_packet_types
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
- local arg
- _get_first_arg
- if [[ -z $arg ]]; then
- if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
- else
- COMPREPLY=($(compgen -W 'dev inq scan name info spinq epinq cmd
- con cc dc sr cpt rssi lq tpl afh lst auth enc key clkoff
- clock' -- "$cur"))
- fi
- else
- local args
- case $arg in
+ local REPLY
+ if _comp_get_first_arg; then
+ case $REPLY in
name | info | dc | rssi | lq | afh | auth | key | clkoff | lst)
- _count_args
- if ((args == 2)); then
- _bluetooth_addresses
+ _comp_count_args
+ if ((REPLY == 2)); then
+ _comp_cmd_hcitool__bluetooth_addresses
fi
;;
cc)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--role --pkt-type' -- "$cur"))
+ _comp_compgen -- -W '--role --pkt-type'
else
- _count_args
- if ((args == 2)); then
- _bluetooth_addresses
+ _comp_count_args
+ if ((REPLY == 2)); then
+ _comp_cmd_hcitool__bluetooth_addresses
fi
fi
;;
sr)
- _count_args
- if ((args == 2)); then
- _bluetooth_addresses
+ _comp_count_args
+ if ((REPLY == 2)); then
+ _comp_cmd_hcitool__bluetooth_addresses
else
- COMPREPLY=($(compgen -W 'master slave' -- "$cur"))
+ _comp_compgen -- -W 'master slave'
fi
;;
cpt)
- _count_args
- if ((args == 2)); then
- _bluetooth_addresses
+ _comp_count_args
+ if ((REPLY == 2)); then
+ _comp_cmd_hcitool__bluetooth_addresses
else
- _bluetooth_packet_types
+ _comp_cmd_hcitool__bluetooth_packet_types
fi
;;
tpl | enc | clock)
- _count_args
- if ((args == 2)); then
- _bluetooth_addresses
+ _comp_count_args
+ if ((REPLY == 2)); then
+ _comp_cmd_hcitool__bluetooth_addresses
else
- COMPREPLY=($(compgen -W '0 1' -- "$cur"))
+ _comp_compgen -- -W '0 1'
fi
;;
esac
+ else
+ if [[ $cur == -* ]]; then
+ _comp_compgen_help
+ else
+ _comp_compgen -- -W 'dev inq scan name info spinq epinq cmd con cc
+ dc sr cpt rssi lq tpl afh lst auth enc key clkoff clock'
+ fi
fi
} &&
- complete -F _hcitool hcitool
+ complete -F _comp_cmd_hcitool hcitool
-_sdptool()
+_comp_cmd_sdptool()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
--bdaddr)
- _bluetooth_addresses
+ _comp_cmd_hcitool__bluetooth_addresses
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
- local arg
- _get_first_arg
- if [[ -z $arg ]]; then
- if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
- else
- COMPREPLY=($(compgen -W 'search browse records add del get
- setattr setseq' -- "$cur"))
- fi
- else
- case $arg in
+ local REPLY
+ if _comp_get_first_arg; then
+ case $REPLY in
search)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--bdaddr --tree --raw --xml' \
- -- "$cur"))
+ _comp_compgen -- -W '--bdaddr --tree --raw --xml'
else
- _bluetooth_services
+ _comp_cmd_hcitool__bluetooth_services
fi
;;
browse | records)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--tree --raw --xml' -- "$cur"))
+ _comp_compgen -- -W '--tree --raw --xml'
else
- _bluetooth_addresses
+ _comp_cmd_hcitool__bluetooth_addresses
fi
;;
add)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--handle --channel' -- "$cur"))
+ _comp_compgen -- -W '--handle --channel'
else
- _bluetooth_services
+ _comp_cmd_hcitool__bluetooth_services
fi
;;
get)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--bdaddr --tree --raw --xml' \
- -- "$cur"))
+ _comp_compgen -- -W '--bdaddr --tree --raw --xml'
fi
;;
esac
+ else
+ if [[ $cur == -* ]]; then
+ _comp_compgen_help
+ else
+ _comp_compgen -- -W 'search browse records add del get setattr
+ setseq'
+ fi
fi
} &&
- complete -F _sdptool sdptool
+ complete -F _comp_cmd_sdptool sdptool
-_l2ping()
+_comp_cmd_l2ping()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-i)
- _bluetooth_devices
+ _comp_cmd_hcitool__bluetooth_devices
return
;;
-s | -c | -t | -d)
@@ -181,200 +171,193 @@ _l2ping()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
else
- _bluetooth_addresses
+ _comp_cmd_hcitool__bluetooth_addresses
fi
} &&
- complete -F _l2ping l2ping
+ complete -F _comp_cmd_l2ping l2ping
-_rfcomm()
+_comp_cmd_rfcomm()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-f | --config)
- _filedir
+ _comp_compgen_filedir
return
;;
-i)
- _bluetooth_devices
- _bluetooth_addresses
+ _comp_cmd_hcitool__bluetooth_devices
+ _comp_cmd_hcitool__bluetooth_addresses
return
;;
esac
- local arg
- _get_first_arg
- if [[ -z $arg ]]; then
- if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
- else
- COMPREPLY=($(compgen -W 'show connect listen watch bind
- release' -- "$cur"))
- fi
- else
- local args
- _count_args
+ local REPLY
+ if _comp_get_first_arg; then
+ local arg=$REPLY
+ _comp_count_args
+ local args=$REPLY
if ((args == 2)); then
- _bluetooth_devices
+ _comp_cmd_hcitool__bluetooth_devices
else
case $arg in
connect | bind)
if ((args == 3)); then
- _bluetooth_addresses
+ _comp_cmd_hcitool__bluetooth_addresses
fi
;;
esac
fi
+ else
+ if [[ $cur == -* ]]; then
+ _comp_compgen_help
+ else
+ _comp_compgen -- -W 'show connect listen watch bind release'
+ fi
fi
} &&
- complete -F _rfcomm rfcomm
+ complete -F _comp_cmd_rfcomm rfcomm
-_ciptool()
+_comp_cmd_ciptool()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-i)
- _bluetooth_devices
- _bluetooth_addresses
+ _comp_cmd_hcitool__bluetooth_devices
+ _comp_cmd_hcitool__bluetooth_addresses
return
;;
esac
- local arg
- _get_first_arg
- if [[ -z $arg ]]; then
- if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
- else
- COMPREPLY=($(compgen -W 'show search connect release loopback' \
- -- "$cur"))
- fi
- else
- local args
- case $arg in
+ local REPLY
+ if _comp_get_first_arg; then
+ case $REPLY in
connect | release | loopback)
- _count_args
- if ((args == 2)); then
- _bluetooth_addresses
+ local REPLY
+ _comp_count_args
+ if ((REPLY == 2)); then
+ _comp_cmd_hcitool__bluetooth_addresses
fi
;;
esac
+ else
+ if [[ $cur == -* ]]; then
+ _comp_compgen_help
+ else
+ _comp_compgen -- -W 'show search connect release loopback'
+ fi
fi
} &&
- complete -F _ciptool ciptool
+ complete -F _comp_cmd_ciptool ciptool
-_dfutool()
+_comp_cmd_dfutool()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-d | --device)
- _bluetooth_devices
+ _comp_cmd_hcitool__bluetooth_devices
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
else
- local args
- _count_args
- case $args in
+ local REPLY
+ _comp_count_args
+ case $REPLY in
1)
- COMPREPLY=($(compgen -W 'verify modify upgrade archive' \
- -- "$cur"))
+ _comp_compgen -- -W 'verify modify upgrade archive'
;;
2)
- _filedir
+ _comp_compgen_filedir
;;
esac
fi
} &&
- complete -F _dfutool dfutool
+ complete -F _comp_cmd_dfutool dfutool
-_hciconfig()
+_comp_cmd_hciconfig()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- local arg
- _get_first_arg
- if [[ -z $arg ]]; then
- if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--help --all' -- "$cur"))
- else
- COMPREPLY=($(compgen -W 'up down reset rstat auth noauth encrypt
- noencrypt secmgr nosecmgr piscan noscan iscan pscan ptype name
- class voice iac inqmode inqdata inqtype inqparams pageparms
- pageto afhmode aclmtu scomtu putkey delkey commands features
- version revision lm' -- "$cur"))
- fi
- else
- local args
- case $arg in
+ local REPLY
+ if _comp_get_first_arg; then
+ case $REPLY in
putkey | delkey)
- _count_args
- if ((args == 2)); then
- _bluetooth_addresses
+ _comp_count_args
+ if ((REPLY == 2)); then
+ _comp_cmd_hcitool__bluetooth_addresses
fi
;;
lm)
- _count_args
- if ((args == 2)); then
- COMPREPLY=($(compgen -W 'MASTER SLAVE NONE ACCEPT' \
- -- "$cur"))
+ _comp_count_args
+ if ((REPLY == 2)); then
+ _comp_compgen -- -W 'MASTER SLAVE NONE ACCEPT'
fi
;;
ptype)
- _count_args
- if ((args == 2)); then
- _bluetooth_packet_types
+ _comp_count_args
+ if ((REPLY == 2)); then
+ _comp_cmd_hcitool__bluetooth_packet_types
fi
;;
esac
+ else
+ if [[ $cur == -* ]]; then
+ _comp_compgen -- -W '--help --all'
+ else
+ _comp_compgen -- -W 'up down reset rstat auth noauth encrypt
+ noencrypt secmgr nosecmgr piscan noscan iscan pscan ptype name
+ class voice iac inqmode inqdata inqtype inqparams pageparms
+ pageto afhmode aclmtu scomtu putkey delkey commands features
+ version revision lm'
+ fi
fi
} &&
- complete -F _hciconfig hciconfig
+ complete -F _comp_cmd_hciconfig hciconfig
-_hciattach()
+_comp_cmd_hciattach()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-n -p -t -b -s -l' -- "$cur"))
+ _comp_compgen -- -W '-n -p -t -b -s -l'
else
- local args
- _count_args
- case $args in
+ local REPLY
+ _comp_count_args
+ case $REPLY in
1)
- COMPREPLY=($(printf '%s\n' /dev/tty*))
- COMPREPLY=($(compgen -W '${COMPREPLY[@]}
- ${COMPREPLY[@]#/dev/}' -- "$cur"))
+ _comp_expand_glob COMPREPLY '/dev/tty*' &&
+ _comp_compgen -- -W '"${COMPREPLY[@]}"
+ "${COMPREPLY[@]#/dev/}"'
;;
2)
- COMPREPLY=($(compgen -W 'any ericsson digi xircom csr bboxes
- swave bcsp 0x0105 0x080a 0x0160 0x0002' -- "$cur"))
+ _comp_compgen -- -W 'any ericsson digi xircom csr bboxes swave
+ bcsp 0x0105 0x080a 0x0160 0x0002'
;;
3)
- COMPREPLY=($(compgen -W '9600 19200 38400 57600 115200 230400
- 460800 921600' -- "$cur"))
+ _comp_compgen -- -W '9600 19200 38400 57600 115200 230400
+ 460800 921600'
;;
4)
- COMPREPLY=($(compgen -W 'flow noflow' -- "$cur"))
+ _comp_compgen -- -W 'flow noflow'
;;
5)
- _bluetooth_addresses
+ _comp_cmd_hcitool__bluetooth_addresses
;;
esac
fi
} &&
- complete -F _hciattach hciattach
+ complete -F _comp_cmd_hciattach hciattach
# ex: filetype=sh
diff --git a/completions/hddtemp b/completions/hddtemp
index 7b95f0e..7dbdec3 100644
--- a/completions/hddtemp
+++ b/completions/hddtemp
@@ -1,38 +1,40 @@
# hddtemp(8) completion -*- shell-script -*-
-_hddtemp()
+_comp_cmd_hddtemp()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[flupsS]*)'
+ # shellcheck disable=SC2254
case $prev in
- --file | -!(-*)f)
- _filedir db
+ --file | -${noargopts}f)
+ _comp_compgen_filedir db
return
;;
- --listen | -!(-*)l)
- _ip_addresses
+ --listen | -${noargopts}l)
+ _comp_compgen_ip_addresses
return
;;
- --unit | -!(-*)u)
- COMPREPLY=($(compgen -W 'C F' -- "$cur"))
+ --unit | -${noargopts}u)
+ _comp_compgen -- -W 'C F'
return
;;
- --port | --separator | --syslog | --version | --help | -!(-*)[psSvh?])
+ --port | --separator | --syslog | --version | --help | -${noargopts}[psSvh?])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1") --help' -- "$cur"))
+ _comp_compgen_help
+ _comp_compgen -a -- -W '--help'
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- cur=${cur:=/dev/}
- _filedir
+ _comp_compgen -c "${cur:-/dev/}" filedir
fi
} &&
- complete -F _hddtemp hddtemp
+ complete -F _comp_cmd_hddtemp hddtemp
# ex: filetype=sh
diff --git a/completions/help b/completions/help
new file mode 100644
index 0000000..679ea9f
--- /dev/null
+++ b/completions/help
@@ -0,0 +1,16 @@
+# bash completion for help -*- shell-script -*-
+
+_comp_cmd_help()
+{
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+
+ if [[ $cur == -* ]]; then
+ _comp_compgen_usage -c help -s "$1"
+ return
+ fi
+
+ _comp_compgen -- -A helptopic
+ ((${#COMPREPLY[*]} != 1)) || printf -v "COMPREPLY[0]" %q "$COMPREPLY"
+} &&
+ complete -F _comp_cmd_help help
diff --git a/completions/hid2hci b/completions/hid2hci
index f33a495..161f560 100644
--- a/completions/hid2hci
+++ b/completions/hid2hci
@@ -1,15 +1,14 @@
# hid2hci completion -*- shell-script -*-
-_hid2hci()
+_comp_cmd_hid2hci()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--help --quiet -0 --tohci -1 --tohid' \
- -- "$cur"))
+ _comp_compgen -- -W '--help --quiet -0 --tohci -1 --tohid'
fi
} &&
- complete -F _hid2hci hid2hci
+ complete -F _comp_cmd_hid2hci hid2hci
# ex: filetype=sh
diff --git a/completions/hostname b/completions/hostname
index ce1b32e..12b96dc 100644
--- a/completions/hostname
+++ b/completions/hostname
@@ -1,23 +1,25 @@
# hostname(1) completion -*- shell-script -*-
-_hostname()
+_comp_cmd_hostname()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[F]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | -!(-*)[hV])
+ --help | --version | -${noargopts}[hV])
return
;;
- --file | -!(-*)F)
- _filedir
+ --file | -${noargopts}F)
+ _comp_compgen_filedir
return
;;
esac
[[ $cur == -* ]] &&
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
} &&
- complete -F _hostname hostname
+ complete -F _comp_cmd_hostname hostname
# ex: filetype=sh
diff --git a/completions/hping2 b/completions/hping2
index 666838b..66139a9 100644
--- a/completions/hping2
+++ b/completions/hping2
@@ -1,35 +1,38 @@
# bash completion for hping2 -*- shell-script -*-
-_hping2()
+_comp_cmd_hping2()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[IaoE]*)'
+ # shellcheck disable=SC2254
case $prev in
- --interface | -!(-*)I)
- _available_interfaces
+ --interface | -${noargopts}I)
+ _comp_compgen_available_interfaces
return
;;
- --spoof | -!(-*)a)
- _known_hosts_real -- "$cur"
+ --spoof | -${noargopts}a)
+ _comp_compgen_known_hosts -- "$cur"
return
;;
- --tos | -!(-*)o)
- COMPREPLY=($(compgen -W '02 04 08 10'))
+ --tos | -${noargopts}o)
+ # TODO: parse choices from `--tos help`?
+ _comp_compgen -- -W '02 04 08 10'
return
;;
- --file | -!(-*)E)
- _filedir
+ --file | -${noargopts}E)
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
else
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
fi
} &&
- complete -F _hping2 hping hping2 hping3
+ complete -F _comp_cmd_hping2 hping hping2 hping3
# ex: filetype=sh
diff --git a/completions/htop b/completions/htop
index b4916d5..6a0f797 100644
--- a/completions/htop
+++ b/completions/htop
@@ -1,33 +1,35 @@
# htop(1) completion -*- shell-script -*-
-_htop()
+_comp_cmd_htop()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[sud]*)'
+ # shellcheck disable=SC2254
case "$prev" in
- --sort-key | -!(-*)s)
- COMPREPLY=($(compgen -W '$("$1" -s help)' -- "$cur"))
+ --sort-key | -${noargopts}s)
+ _comp_compgen_split -- "$("$1" -s help)"
return
;;
- --user | -!(-*)u)
- COMPREPLY=($(compgen -u -- "$cur"))
+ --user | -${noargopts}u)
+ _comp_compgen -- -u
return
;;
- --delay | -!(-*)d)
+ --delay | -${noargopts}d)
# argument required but no completions available
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
} &&
- complete -F _htop htop
+ complete -F _comp_cmd_htop htop
# ex: filetype=sh
diff --git a/completions/htpasswd b/completions/htpasswd
index 527684b..dafd1d9 100644
--- a/completions/htpasswd
+++ b/completions/htpasswd
@@ -1,9 +1,9 @@
# htpasswd(1) completion -*- shell-script -*-
-_htpasswd()
+_comp_cmd_htpasswd()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local i o=0 # $o is index of first non-option argument
for ((i = 1; i <= cword; i++)); do
@@ -19,18 +19,17 @@ _htpasswd()
if ((o == 0 || o == cword)); then
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
# Password file (first non-option argument)
- _filedir
+ _comp_compgen_filedir
elif ((o == cword - 1)); then
# Username (second non-option argument)
- COMPREPLY=($(compgen -W \
- '$(cut -d: -f1 "${words[o]}" 2>/dev/null)' -- "$cur"))
+ _comp_compgen_split -- "$(cut -d: -f1 "${words[o]}" 2>/dev/null)"
fi
} &&
- complete -F _htpasswd htpasswd
+ complete -F _comp_cmd_htpasswd htpasswd
# ex: filetype=sh
diff --git a/completions/hunspell b/completions/hunspell
index 92b4fe8..28cb7df 100644
--- a/completions/hunspell
+++ b/completions/hunspell
@@ -1,43 +1,40 @@
# hunspell(1) completion -*- shell-script -*-
-_hunspell()
+_comp_cmd_hunspell()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--help | --version | -vv | -[hPv])
return
;;
-d)
- local IFS=$' \t\n' reset=$(shopt -p nullglob)
- shopt -s nullglob
- local -a dicts=(/usr/share/hunspell/*.dic
- /usr/local/share/hunspell/*.dic)
- dicts=("${dicts[@]##*/}")
- dicts=("${dicts[@]%.dic}")
- $reset
- IFS=$'\n'
- COMPREPLY=($(compgen -W '${dicts[@]}' -- "$cur"))
+ local -a dicts
+ if _comp_expand_glob dicts '/usr/share/hunspell/*.dic /usr/local/share/hunspell/*.dic'; then
+ dicts=("${dicts[@]##*/}")
+ dicts=("${dicts[@]%.dic}")
+ _comp_compgen -- -W '"${dicts[@]}"'
+ fi
return
;;
-i)
- _xfunc iconv _iconv_charsets
+ _comp_compgen -x iconv charsets
return
;;
-p)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _hunspell hunspell
+ complete -F _comp_cmd_hunspell hunspell
# ex: filetype=sh
diff --git a/completions/iconv b/completions/iconv
index 81ae01b..bbcbbdd 100644
--- a/completions/iconv
+++ b/completions/iconv
@@ -1,38 +1,52 @@
# iconv(1) completion -*- shell-script -*-
+# @since 2.12
+_comp_xfunc_iconv_compgen_charsets()
+{
+ _comp_cmd_iconv__compgen_charsets iconv
+}
+
+# @deprecated 2.12 use `_comp_xfunc_iconv_compgen_charsets` instead
_iconv_charsets()
{
- COMPREPLY+=($(compgen -X ... -W '$(${1:-iconv} -l | \
- command sed -e "s@/*\$@@" -e "s/[,()]//g")' -- "$cur"))
+ _comp_compgen -ai iconv charsets "${1:-iconv}"
+}
+
+_comp_cmd_iconv__compgen_charsets()
+{
+ _comp_compgen_split -X ... -- "$("$1" -l |
+ command sed -e 's@/*$@@' -e 's/[,()]//g')"
}
-_iconv()
+_comp_cmd_iconv()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[fto]*)'
+ # shellcheck disable=SC2254
case $prev in
--help | --usage | --version | --unicode-subst | --byte-subst | \
- --widechar-subst | -!(-*)[?V])
+ --widechar-subst | -${noargopts}[?V])
return
;;
- --from-code | --to-code | -!(-*)[ft])
- _iconv_charsets $1
+ --from-code | --to-code | -${noargopts}[ft])
+ _comp_cmd_iconv__compgen_charsets "$1"
return
;;
- --output | -!(-*)o)
- _filedir
+ --output | -${noargopts}o)
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _iconv -o default iconv
+ complete -F _comp_cmd_iconv -o default iconv
# ex: filetype=sh
diff --git a/completions/id b/completions/id
index a07e51d..e91ad61 100644
--- a/completions/id
+++ b/completions/id
@@ -1,18 +1,17 @@
# id(1) completion -*- shell-script -*-
-_id()
+_comp_cmd_id()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- local opts=$(_parse_help "$1")
- [[ $opts ]] || opts="-G -g -u" # POSIX fallback
- COMPREPLY=($(compgen -W "$opts" -- "$cur"))
+ _comp_compgen_help ||
+ _comp_compgen -- -W '-G -g -u' # POSIX fallback
else
- COMPREPLY=($(compgen -u "$cur"))
+ _comp_compgen -- -u
fi
} &&
- complete -F _id id
+ complete -F _comp_cmd_id id
# ex: filetype=sh
diff --git a/completions/idn b/completions/idn
index 8023f8f..1a61479 100644
--- a/completions/idn
+++ b/completions/idn
@@ -1,26 +1,28 @@
# idn(1) completion -*- shell-script -*-
-_idn()
+_comp_cmd_idn()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[p]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | -!(-*)[hV])
+ --help | --version | -${noargopts}[hV])
return
;;
- --profile | -!(-*)p)
- COMPREPLY=($(compgen -W 'Nameprep iSCSI Nodeprep Resourceprep
- trace SASLprep' -- "$cur"))
+ --profile | -${noargopts}p)
+ _comp_compgen -- -W 'Nameprep iSCSI Nodeprep Resourceprep trace
+ SASLprep'
return
;;
esac
- if ! $split && [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ if [[ ! $was_split && $cur == -* ]]; then
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _idn idn
+ complete -F _comp_cmd_idn idn
# ex: filetype=sh
diff --git a/completions/ifstat b/completions/ifstat
index 629786e..0f05199 100644
--- a/completions/ifstat
+++ b/completions/ifstat
@@ -1,43 +1,45 @@
# bash completion for ifstat(1) -*- shell-script -*-
-_ifstat()
+_comp_cmd_ifstat()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[idstx]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | --scan | --interval | -!(-*)[hvV])
+ --help | --version | --scan | --interval | -${noargopts}[hvV])
return
;;
- -!(-*)i)
+ -${noargopts}i)
# TODO comma separated
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
return
;;
- -!(-*)d)
+ -${noargopts}d)
# iproute2: no completion (scan delay)
# traditional: parse driver
if ! {
"$1" --help 2>&1 || :
} |
command grep -q -- '-d.*--scan'; then
- COMPREPLY=($(compgen -W '$("$1" -v | command \
- sed -e "s/[,.]//g" -ne "s/^.*drivers://p")' -- "$cur"))
+ _comp_compgen_split -- "$("$1" -v | command sed -e 's/[,.]//g' \
+ -ne 's/^.*drivers://p')"
fi
return
;;
- --noupdate | -!(-*)s)
+ --noupdate | -${noargopts}s)
# iproute2: pass through (skip history update)
# traditional: hostnames (snmp)
if ! {
"$1" --help 2>&1 || :
} |
command grep -q -- '-s.*--noupdate'; then
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
fi
;;
- -!(-*)t)
+ -${noargopts}t)
# iproute2: no completion (interval)
# traditional: pass through (add timestamp)
! {
@@ -45,24 +47,22 @@ _ifstat()
} |
command grep -q -- '-t.*--interval' || return
;;
- --extended | -!(-*)x)
+ --extended | -${noargopts}x)
# iproute2: parse xstat types
- COMPREPLY=($(compgen -W '$("$1" -x nonexistent-xstat 2>&1 |
- awk "found { print \$1 } /supported xstats:/ { found=1 }")' \
- -- "$cur"))
+ _comp_compgen_split -- "$("$1" -x nonexistent-xstat 2>&1 |
+ _comp_awk 'found { print $1 } /supported xstats:/ { found=1 }')"
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- local opts=$(_parse_help "$1")
- COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
} &&
- complete -F _ifstat ifstat
+ complete -F _comp_cmd_ifstat ifstat
# ex: filetype=sh
diff --git a/completions/iftop b/completions/iftop
index b73f4b6..d1635af 100644
--- a/completions/iftop
+++ b/completions/iftop
@@ -1,26 +1,26 @@
# iftop(8) completion -*- shell-script -*-
-_iftop()
+_comp_cmd_iftop()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-h | -f | -F | -m)
return
;;
-i)
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
return
;;
-c)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ _comp_compgen_help -- -h
} &&
- complete -F _iftop iftop
+ complete -F _comp_cmd_iftop iftop
# ex: filetype=sh
diff --git a/completions/ifup b/completions/ifup
index 5b35bfb..bfeee82 100644
--- a/completions/ifup
+++ b/completions/ifup
@@ -1,39 +1,40 @@
# Red Hat & Debian GNU/Linux if{up,down} completion -*- shell-script -*-
-_userland GNU || return 1
+_comp_userland GNU || return 1
-_ifupdown()
+_comp_cmd_ifupdown()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[Xoi]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | --allow | --exclude | --option | -!(-*)[hVXo])
+ --help | --version | --allow | --exclude | --option | -${noargopts}[hVXo])
return
;;
- --interfaces | -!(-*)i)
- _filedir
+ --interfaces | -${noargopts}i)
+ _comp_compgen_filedir
return
;;
--state-dir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- local args
- _count_args "" "@(--allow|-i|--interfaces|--state-dir|-X|--exclude|-o)"
+ local REPLY
+ _comp_count_args -a "@(--allow|-i|--interfaces|--state-dir|-X|--exclude|-o)"
- if ((args == 1)); then
- _configured_interfaces
- COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur"))
+ if ((REPLY == 1)); then
+ _comp_compgen_configured_interfaces
fi
} &&
- complete -F _ifupdown ifup ifdown ifquery ifstatus
+ complete -F _comp_cmd_ifupdown ifup ifdown ifquery ifstatus
# ex: filetype=sh
diff --git a/completions/influx b/completions/influx
index e9362e7..89b90e7 100644
--- a/completions/influx
+++ b/completions/influx
@@ -1,35 +1,32 @@
# bash completion for influx(8) -*- shell-script -*-
-_influx()
+_comp_cmd_influx()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-version | -port | -database | -password | -username | -execute | -pps)
return
;;
-host)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-format | -precision | -consistency)
- local args=$($1 --help 2>&1 | awk "\$1 == \"$prev\" { print \$2 }")
- COMPREPLY=($(
- IFS+="\"'|"
- compgen -W "$args" -- "$cur"
- ))
+ local args=$("$1" --help 2>&1 | _comp_awk "\$1 == \"$prev\" { print \$2 }")
+ _comp_compgen -F $' \t\n'"\"'|" -- -W "$args"
return
;;
-import | -path)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
[[ $cur == -* ]] &&
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
} &&
- complete -F _influx influx
+ complete -F _comp_cmd_influx influx
# ex: filetype=sh
diff --git a/completions/info b/completions/info
index f50f842..3a13565 100644
--- a/completions/info
+++ b/completions/info
@@ -1,40 +1,42 @@
# bash completion for info -*- shell-script -*-
-_info()
+_comp_cmd_info()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
# default completion if parameter looks like a path
if [[ $cur == @(*/|[.~])* ]]; then
- _filedir
+ _comp_compgen_filedir
return
fi
+ local noargopts='!(-*|*[kndfor]*)'
+ # shellcheck disable=SC2254
case $prev in
- --apropos | --index-search | --node | --help | --version | -!(-*)[knhv])
+ --apropos | --index-search | --node | --help | --version | -${noargopts}[knhv])
return
;;
- -!(-*)d)
+ -${noargopts}d)
if [[ ${1##*/} == info ]]; then
- _filedir -d
+ _comp_compgen_filedir -d
return
fi
;;
--directory)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
- --dribble | --file | --output | --restore | --raw-filename | --rcfile | -!(-*)[for])
- _filedir
+ --dribble | --file | --output | --restore | --raw-filename | --rcfile | -${noargopts}[for])
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
@@ -47,28 +49,22 @@ _info()
infopath=$INFOPATH
fi
- _expand || return
-
- infopath=$infopath:
- if [[ -n $cur ]]; then
- infopath="${infopath//://$cur* }"
- else
- infopath="${infopath//:// }"
+ _comp_split -F : infopath "$infopath"
+ if ((${#infopath[@]})); then
+ _comp_compgen -Rv infopath -- -S "/$cur*" -W '"${infopath[@]}"'
+ local IFS=
+ if _comp_expand_glob COMPREPLY '${infopath[@]}'; then
+ # weed out directory path names and paths to info pages (empty
+ # elements will be removed by the later `compgen -X ''`)
+ COMPREPLY=("${COMPREPLY[@]##*/?(:)}")
+ # strip suffix from info pages
+ COMPREPLY=("${COMPREPLY[@]%.@(gz|bz2|xz|lzma)}")
+ # weed out info dir file with -X 'dir'
+ _comp_compgen -c "${cur//\\\\/}" -- -W '"${COMPREPLY[@]%.*}"' -X '@(|dir)'
+ fi
+ _comp_unlocal IFS
fi
-
- # redirect stderr for when path doesn't exist
- COMPREPLY=($(eval command ls "$infopath" 2>/dev/null))
- # weed out directory path names and paths to info pages
- COMPREPLY=(${COMPREPLY[@]##*/?(:)})
- # weed out info dir file
- for i in ${!COMPREPLY[*]}; do
- [[ ${COMPREPLY[i]} == dir ]] && unset "COMPREPLY[i]"
- done
- # strip suffix from info pages
- COMPREPLY=(${COMPREPLY[@]%.@(gz|bz2|xz|lzma)})
- COMPREPLY=($(compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}"))
-
} &&
- complete -F _info info pinfo
+ complete -F _comp_cmd_info info pinfo
# ex: filetype=sh
diff --git a/completions/inject b/completions/inject
index fad73a1..4b46921 100644
--- a/completions/inject
+++ b/completions/inject
@@ -1,26 +1,29 @@
# mailman inject completion -*- shell-script -*-
-_inject()
+_comp_cmd_inject()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-l | --listname)
- _xfunc list_lists _mailman_lists
+ # Prefer `list_lists` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -x list_lists mailman_lists
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--listname --queue --help' -- "$cur"))
+ _comp_compgen -- -W '--listname --queue --help'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _inject inject
+ complete -F _comp_cmd_inject inject
# ex: filetype=sh
diff --git a/completions/inotifywait b/completions/inotifywait
index e5608fc..a069295 100644
--- a/completions/inotifywait
+++ b/completions/inotifywait
@@ -1,47 +1,48 @@
# bash completion for inotifywait(1) and inotifywatch(1) -*- shell-script -*-
-_inotifywait_events()
+_comp_cmd_inotifywait__events()
{
# Expecting line with "Events:", followed by ones starting with one
# tab. Word following the tab is event name, others are line
# wrapped explanations.
- COMPREPLY+=($(compgen -W "$($1 --help 2>/dev/null |
+ _comp_compgen -a split -- "$("$1" --help 2>/dev/null |
command sed -e '/^Events:/,/^[^'$'\t'']/!d' \
- -ne 's/^'$'\t''\([^ '$'\t'']\{1,\}\)[ '$'\t''].*/\1/p')" \
- -- "$cur"))
+ -ne 's/^'$'\t''\([^ '$'\t'']\{1,\}\)[ '$'\t''].*/\1/p')"
}
-_inotifywait()
+_comp_cmd_inotifywait()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[oe]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --exclude | --excludei | --format | --timefmt | --timeout | -!(-*)[ht])
+ --help | --exclude | --excludei | --include | --includei | --format | --timefmt | --timeout | -${noargopts}[ht])
return
;;
- --fromfile | --outfile | -!(-*)o)
- _filedir
+ --fromfile | --outfile | -${noargopts}o)
+ _comp_compgen_filedir
return
;;
- --event | -!(-*)e)
- _inotifywait_events "$1"
+ --event | -${noargopts}e)
+ _comp_cmd_inotifywait__events "$1"
return
;;
--ascending | --descending)
- COMPREPLY=($(compgen -W 'total' -- "$cur"))
- _inotifywait_events "$1"
+ _comp_compgen -- -W 'total'
+ _comp_cmd_inotifywait__events "$1"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _inotifywait inotifywait inotifywatch
+ complete -F _comp_cmd_inotifywait inotifywait inotifywatch
# ex: filetype=sh
diff --git a/completions/insmod b/completions/insmod
index a59e753..2c02f3f 100644
--- a/completions/insmod
+++ b/completions/insmod
@@ -1,18 +1,18 @@
# Linux insmod(8) completion -*- shell-script -*-
-_insmod()
+_comp_cmd_insmod()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
# do filename completion for first argument
if ((cword == 1)); then
- _filedir '@(?(k)o?(.[gx]z))'
+ _comp_compgen_filedir '@(?(k)o?(.[gx]z|.zst))'
else # do module parameter completion
- COMPREPLY=($(compgen -W "$(PATH="$PATH:/sbin" modinfo \
- -p ${words[1]} 2>/dev/null | cut -d: -f1)" -- "$cur"))
+ _comp_compgen_split -- "$(PATH="$PATH:/sbin" modinfo \
+ -p "${words[1]}" 2>/dev/null | cut -d: -f1)"
fi
} &&
- complete -F _insmod insmod insmod.static
+ complete -F _comp_cmd_insmod insmod insmod.static
# ex: filetype=sh
diff --git a/completions/installpkg b/completions/installpkg
index 7455eb1..71116b0 100644
--- a/completions/installpkg
+++ b/completions/installpkg
@@ -1,33 +1,33 @@
# Slackware Linux installpkg completion -*- shell-script -*-
-_installpkg()
+_comp_cmd_installpkg()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case "$prev" in
--root)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
--priority)
- COMPREPLY=($(compgen -W 'ADD REC OPT SKP' -- "$cur"))
+ _comp_compgen -- -W 'ADD REC OPT SKP'
return
;;
--tagfile)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--warn --md5sum --root --infobox --terse
- --menu --ask --priority --tagfile' -- "$cur"))
+ _comp_compgen -- -W '--warn --md5sum --root --infobox --terse --menu
+ --ask --priority --tagfile'
return
fi
- _filedir 't[bglx]z'
+ _comp_compgen_filedir 't[bglx]z'
} &&
- complete -F _installpkg installpkg
+ complete -F _comp_cmd_installpkg installpkg
# ex: filetype=sh
diff --git a/completions/interdiff b/completions/interdiff
index 9933d15..6f56e33 100644
--- a/completions/interdiff
+++ b/completions/interdiff
@@ -1,20 +1,22 @@
# interdiff(1) completion -*- shell-script -*-
-_interdiff()
+_comp_cmd_interdiff()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[Upd]*)'
+ # shellcheck disable=SC2254
case $prev in
- --unified | --strip-match | --drop-context | -!(-*)[Upd])
+ --unified | --strip-match | --drop-context | -${noargopts}[Upd])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
@@ -26,8 +28,8 @@ _interdiff()
break
fi
done
- _filedir "$exts"
+ _comp_compgen_filedir "$exts"
} &&
- complete -F _interdiff interdiff
+ complete -F _comp_cmd_interdiff interdiff
# ex: filetype=sh
diff --git a/completions/invoke-rc.d b/completions/invoke-rc.d
index 4a5045a..e5a66b6 100644
--- a/completions/invoke-rc.d
+++ b/completions/invoke-rc.d
@@ -2,37 +2,37 @@
#
# Copyright (C) 2004 Servilio Afre Puentes <servilio@gmail.com>
-_invoke_rc_d()
+_comp_cmd_invoke_rc_d()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- local sysvdir services options valid_options
+ local sysvdir services options
[[ -d /etc/rc.d/init.d ]] && sysvdir=/etc/rc.d/init.d ||
sysvdir=/etc/init.d
- services=($(printf '%s ' $sysvdir/!(README*|*.sh|$_backup_glob)))
- services=(${services[@]#$sysvdir/})
options=(--help --quiet --force --try-anyway --disclose-deny --query
--no-fallback)
if [[ $cword -eq 1 || $prev == --* ]]; then
- valid_options=($(
+ # generate valid_options
+ _comp_compgen_split -- "$(
tr " " "\n" <<<"${words[*]} ${options[*]}" |
command sed -ne "/$(command sed 's/ /\\|/g' <<<"${options[*]}")/p" |
sort | uniq -u
- ))
- COMPREPLY=($(compgen -W '${valid_options[@]} ${services[@]}' -- "$cur"))
+ )"
+ _comp_expand_glob services '"$sysvdir"/!(README*|*.sh|$_comp_backup_glob)' &&
+ _comp_compgen -a -- -W '"${services[@]#"$sysvdir"/}"'
elif [[ -x $sysvdir/$prev ]]; then
- COMPREPLY=($(compgen -W '`command sed -e "y/|/ /" \
- -ne "s/^.*Usage:[ ]*[^ ]*[ ]*{*\([^}\"]*\).*$/\1/p" \
- $sysvdir/$prev`' -- "$cur"))
+ _comp_compgen_split -- "$(command sed -e 'y/|/ /' \
+ -ne 's/^.*Usage:[ ]*[^ ]*[ ]*{*\([^}"]*\).*$/\1/p' \
+ "$sysvdir/$prev")"
else
COMPREPLY=()
fi
} &&
- complete -F _invoke_rc_d invoke-rc.d
+ complete -F _comp_cmd_invoke_rc_d invoke-rc.d
# ex: filetype=sh
diff --git a/completions/ip b/completions/ip
index 12ad9aa..511f206 100644
--- a/completions/ip
+++ b/completions/ip
@@ -1,58 +1,78 @@
# ip(8) completion -*- shell-script -*-
-_iproute2_etc()
+_comp_cmd_ip__iproute2_etc()
{
- COMPREPLY+=($(compgen -W \
- "$(awk '!/#/ { print $2 }' /etc/iproute2/$1 2>/dev/null)" \
- -- "$cur"))
+ _comp_compgen -a split -- "$(_comp_awk '!/#/ { print $2 }' "/etc/iproute2/$1" \
+ 2>/dev/null)"
}
-_ip()
+_comp_cmd_ip__netns()
{
- local cur prev words cword
- _init_completion || return
+ _comp_compgen_split -- "$(
+ {
+ ${1-ip} -c=never netns list 2>/dev/null || ${1-ip} netns list
+ } | _comp_awk '{print $1}'
+ )"
+}
+
+_comp_cmd_ip()
+{
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
- -V | -Version | -rc | -rcvbuf)
+ -V | -Version | -rc | -rcvbuf | -l | -loops)
return
;;
-f | -family)
- COMPREPLY=($(compgen -W 'inet inet6 ipx dnet link' -- "$cur"))
+ _comp_compgen -- -W 'inet inet6 ipx dnet link'
return
;;
-b | -batch)
- _filedir
+ _comp_compgen_filedir
+ return
+ ;;
+ -n | -netns)
+ _comp_cmd_ip__netns "$1"
return
;;
-force)
- COMPREPLY=($(compgen -W '-batch' -- "$cur"))
+ _comp_compgen -- -W '-batch'
return
;;
esac
- local subcword cmd subcmd=""
- for ((subcword = 1; subcword < ${#words[@]} - 1; subcword++)); do
+ local subcword cmd="" has_cmd="" subcmd=""
+ for ((subcword = 1; subcword < cword; subcword++)); do
[[ ${words[subcword]} == -b?(atch) ]] && return
- [[ -v cmd ]] && subcmd=${words[subcword]} && break
- [[ ${words[subcword]} != -* && \
- ${words[subcword - 1]} != -@(f?(amily)|rc?(vbuf)) ]] &&
- cmd=${words[subcword]}
+ [[ $has_cmd ]] && subcmd=${words[subcword]} && break
+ [[ ${words[subcword]} != -* &&
+ ${words[subcword - 1]} != -@(f?(amily)|rc?(vbuf)) ]] &&
+ cmd=${words[subcword]} has_cmd=set
done
- if [[ ! -v cmd ]]; then
+ if [[ ! $has_cmd ]]; then
case $cur in
-*)
- local c="-Version -statistics -details -resolve -family
- -oneline -timestamp -batch -rcvbuf"
- ((cword == 1)) && c+=" -force"
- COMPREPLY=($(compgen -W "$c" -- "$cur"))
+ _comp_compgen -a help - <<<"$(
+ ((cword == 1)) && printf '%s\n' -force
+ {
+ "$1" -c=never help || "$1" help
+ } 2>&1 | command sed -e \
+ 's/[{|}=]/\n/g' -e \
+ 's/\[\([^]]\{1,\}\)\]/\1/g'
+ )"
;;
*)
- COMPREPLY=($(compgen -W "help $($1 help 2>&1 | command sed -e \
- '/OBJECT := /,/}/!d' -e \
- 's/.*{//' -e \
- 's/}.*//' -e \
- 's/|//g')" -- "$cur"))
+ _comp_compgen_split -- "help $(
+ {
+ $1 -c=never help || $1 help
+ } 2>&1 | command sed -e \
+ '/OBJECT := /,/}/!d' -e \
+ 's/.*{//' -e \
+ 's/}.*//' -e \
+ 's/|//g'
+ )"
;;
esac
return
@@ -69,26 +89,26 @@ _ip()
delete)
case $((cword - subcword)) in
1)
- _available_interfaces
+ _comp_compgen_available_interfaces
;;
2)
- COMPREPLY=($(compgen -W 'type' -- "$cur"))
+ _comp_compgen -- -W 'type'
;;
3)
[[ $prev == type ]] &&
- COMPREPLY=($(compgen -W 'vlan veth vcan dummy
- ifb macvlan can' -- "$cur"))
+ _comp_compgen -- -W 'vlan veth vcan dummy ifb
+ macvlan can'
;;
esac
;;
set)
if ((cword - subcword == 1)); then
- _available_interfaces
+ _comp_compgen_available_interfaces
else
case $prev in
arp | dynamic | multicast | allmulticast | promisc | \
trailers)
- COMPREPLY=($(compgen -W 'on off' -- "$cur"))
+ _comp_compgen -- -W 'on off'
;;
txqueuelen | name | address | broadcast | mtu | netns | alias) ;;
@@ -97,25 +117,24 @@ _ip()
promisc trailers txqueuelen name address
broadcast mtu netns alias"
[[ $prev != @(up|down) ]] && c+=" up down"
- COMPREPLY=($(compgen -W "$c" -- "$cur"))
+ _comp_compgen -- -W "$c"
;;
esac
fi
;;
show)
if ((cword == subcword + 1)); then
- _available_interfaces
- COMPREPLY+=($(compgen -W 'dev group up' -- "$cur"))
+ _comp_compgen_available_interfaces
+ _comp_compgen -a -- -W 'dev group up'
elif [[ $prev == dev ]]; then
- _available_interfaces
+ _comp_compgen_available_interfaces
elif [[ $prev == group ]]; then
- _iproute2_etc group
+ _comp_cmd_ip__iproute2_etc group
fi
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help add delete set show' \
- -- "$cur"))
+ _comp_compgen -- -W 'help add delete set show'
;;
esac
;;
@@ -124,38 +143,38 @@ _ip()
case $subcmd in
add | change | replace)
if [[ $prev == dev ]]; then
- _available_interfaces
+ _comp_compgen_available_interfaces
elif [[ $prev == scope ]]; then
- _iproute2_etc rt_scopes
+ _comp_cmd_ip__iproute2_etc rt_scopes
else
: # TODO
fi
;;
del)
if [[ $prev == dev ]]; then
- _available_interfaces
+ _comp_compgen_available_interfaces
elif [[ $prev == scope ]]; then
- _iproute2_etc rt_scopes
+ _comp_cmd_ip__iproute2_etc rt_scopes
else
: # TODO
fi
;;
show | flush)
if ((cword == subcword + 1)); then
- _available_interfaces
- COMPREPLY+=($(compgen -W 'dev scope to label dynamic
+ _comp_compgen_available_interfaces
+ _comp_compgen -a -- -W 'dev scope to label dynamic
permanent tentative deprecated dadfailed temporary
- primary secondary up' -- "$cur"))
+ primary secondary up'
elif [[ $prev == dev ]]; then
- _available_interfaces
+ _comp_compgen_available_interfaces
elif [[ $prev == scope ]]; then
- _iproute2_etc rt_scopes
+ _comp_cmd_ip__iproute2_etc rt_scopes
fi
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help add change replace del
- show flush' -- "$cur"))
+ _comp_compgen -- -W 'help add change replace del show
+ flush'
;;
esac
;;
@@ -164,15 +183,14 @@ _ip()
case $subcmd in
list | add | del | flush)
if [[ $prev == dev ]]; then
- _available_interfaces
+ _comp_compgen_available_interfaces
else
: # TODO
fi
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help list add del flush' \
- -- "$cur"))
+ _comp_compgen -- -W 'help list add del flush'
;;
esac
;;
@@ -181,7 +199,7 @@ _ip()
case $subcmd in
list | flush)
if [[ $prev == proto ]]; then
- _iproute2_etc rt_protos
+ _comp_cmd_ip__iproute2_etc rt_protos
else
: # TODO
fi
@@ -189,25 +207,32 @@ _ip()
get)
# TODO
;;
- a | add | d | del | change | append | r | replace | monitor)
+ a | add | d | del | change | append | r | replace)
if [[ $prev == via ]]; then
- COMPREPLY=($(compgen -W "$($1 r | command sed -ne \
- 's/.*via \([0-9.]*\).*/\1/p')" -- "$cur"))
+ _comp_compgen_split -- "$(
+ {
+ $1 -c=never r 2>/dev/null || $1 r
+ } | command sed -ne \
+ 's/.*via \([0-9.]*\).*/\1/p'
+ )"
elif [[ $prev == "$subcmd" ]]; then
- COMPREPLY=($(compgen -W "table default \
- $($1 r | cut -d ' ' -f 1)" -- "$cur"))
+ _comp_compgen_split -- "table default $(
+ {
+ $1 -c=never r 2>/dev/null || $1 r
+ } | cut -d ' ' -f 1
+ )"
elif [[ $prev == dev ]]; then
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
elif [[ $prev == table ]]; then
- COMPREPLY=($(compgen -W 'local main default' -- "$cur"))
+ _comp_compgen -- -W 'local main default'
else
- COMPREPLY=($(compgen -W 'via dev weight' -- "$cur"))
+ _comp_compgen -- -W 'via dev weight'
fi
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help list flush get add del
- change append replace monitor' -- "$cur"))
+ _comp_compgen -- -W 'help list flush get add del change
+ append replace'
;;
esac
;;
@@ -221,16 +246,16 @@ _ip()
suppress_ifgroup | realms | nat | goto) ;;
iif | oif)
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
;;
table | lookup)
- COMPREPLY=($(compgen -W 'local main default' -- "$cur"))
+ _comp_compgen -- -W 'local main default'
;;
*)
- COMPREPLY=($(compgen -W 'from to tos dsfield fwmark
- uidrange ipproto sport dport priority table lookup
- protocol suppress_prefixlength suppress_ifgroup realms
- nat goto iif oif not' -- "$cur"))
+ _comp_compgen -- -W 'from to tos dsfield fwmark
+ uidrange ipproto sport dport priority table
+ lookup protocol suppress_prefixlength
+ suppress_ifgroup realms nat goto iif oif not'
;;
esac
;;
@@ -238,14 +263,14 @@ _ip()
if [[ $prev == protocol ]]; then
:
else
- COMPREPLY=($(compgen -W 'protocol' -- "$cur"))
+ _comp_compgen -- -W 'protocol'
fi
;;
restore | show) ;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help add del list flush save
- restore show' -- "$cur"))
+ _comp_compgen -- -W 'help add del list flush save
+ restore show'
;;
esac
;;
@@ -260,8 +285,8 @@ _ip()
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help add del change replace
- show flush' -- "$cur"))
+ _comp_compgen -- -W 'help add del change replace show
+ flush'
;;
esac
;;
@@ -276,8 +301,7 @@ _ip()
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help change show' \
- -- "$cur"))
+ _comp_compgen -- -W 'help change show'
;;
esac
;;
@@ -291,8 +315,7 @@ _ip()
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help add change del show prl
- 6rd' -- "$cur"))
+ _comp_compgen -- -W 'help add change del show prl 6rd'
;;
esac
;;
@@ -304,16 +327,15 @@ _ip()
;;
show)
if [[ $cword -eq $subcword+1 || $prev == dev ]]; then
- _available_interfaces
- [[ $prev != dev ]] &&
- COMPREPLY=($(compgen -W '${COMPREPLY[@]} dev' \
- -- "$cur"))
+ _comp_compgen_available_interfaces
+ if [[ $prev != dev ]]; then
+ _comp_compgen -a -W dev
+ fi
fi
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help add del show' \
- -- "$cur"))
+ _comp_compgen -- -W 'help add del show'
;;
esac
;;
@@ -325,7 +347,7 @@ _ip()
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help show' -- "$cur"))
+ _comp_compgen -- -W 'help show'
;;
esac
;;
@@ -335,7 +357,14 @@ _ip()
all) ;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help all' -- "$cur"))
+ _comp_compgen_split -- "help all $(
+ {
+ "$1" -c=never monitor help || "$1" monitor help
+ } 2>&1 | command sed -e \
+ '/OBJECTS := /,/[^|]$/!d' -e \
+ 's/OBJECTS := *//' -e \
+ 's/|//g'
+ )"
;;
esac
;;
@@ -348,13 +377,12 @@ _ip()
# TODO
;;
delete | exec | pids | set)
- [[ $prev == "$subcmd" ]] &&
- COMPREPLY=($(compgen -W "$($1 netns list)" -- "$cur"))
+ [[ $prev == "$subcmd" ]] && _comp_cmd_ip__netns "$1"
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'help add delete exec
- identify list list-id monitor pids set' -- "$cur"))
+ _comp_compgen -- -W 'help add delete exec identify list
+ list-id monitor pids set'
;;
esac
;;
@@ -366,13 +394,12 @@ _ip()
;;
*)
((cword == subcword)) &&
- COMPREPLY=($(compgen -W 'state policy monitor' \
- -- "$cur"))
+ _comp_compgen -- -W 'state policy monitor'
;;
esac
;;
esac
} &&
- complete -F _ip ip
+ complete -F _comp_cmd_ip ip
# ex: filetype=sh
diff --git a/completions/ipcalc b/completions/ipcalc
index 5603c26..979a8c2 100644
--- a/completions/ipcalc
+++ b/completions/ipcalc
@@ -1,9 +1,9 @@
# ipcalc(1) completion -*- shell-script -*-
-_ipcalc()
+_comp_cmd_ipcalc()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--help | --version | --split | -[hs])
@@ -18,8 +18,8 @@ _ipcalc()
done
[[ $cur != -* ]] ||
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
} &&
- complete -F _ipcalc ipcalc
+ complete -F _comp_cmd_ipcalc ipcalc
# ex: filetype=sh
diff --git a/completions/iperf b/completions/iperf
index 6347fe0..0168814 100644
--- a/completions/iperf
+++ b/completions/iperf
@@ -1,69 +1,90 @@
# iperf(1) completion -*- shell-script -*-
-_iperf()
+_comp_cmd_iperf()
{
- local cur prev words cword split
- _init_completion -s -n : || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -n : -- "$@" || return
+ local noargopts='!(-*|*[ilpwMXbntLPTZCkOSAfIoFBcxy]*)'
+ # shellcheck disable=SC2254
case $prev in
--help | --version | --interval | --len | --port | --window | --mss | --bandwidth | \
--num | --time | --listenport | --parallel | --ttl | --linux-congestion | --omit | \
--congestion | --bytes | --blockcount | --cport | --set-mss | --flowlabel | \
- --title | --tos | --affinity | -!(-*)[hvilpwMbntLPTZCkOSA])
+ --title | --tos | --affinity | --rcv-timeout | --server-bitrate-limit | \
+ --idle-timeout | --time-skew-threshold | --xbind | --nstreams | --connect-timeout | \
+ --bitrate | --pacing-timer | --fq-rate | --length | --dscp | --extra-data | \
+ --username | -${noargopts}[hvilpwMXbntLPTZCkOSA])
return
;;
- --format | -!(-*)f)
- COMPREPLY=($(compgen -W 'k m g K M G' -- "$cur"))
+ --format | -${noargopts}f)
+ local formats=$(
+ "$1" --help 2>&1 |
+ command sed -ne 's/^.*--format .*\[\([a-zA-Z]\{1,\}\)\].*/\1/p' |
+ command sed -e 's/./& /g'
+ )
+ _comp_compgen -- -W '$formats'
return
;;
- --output | --fileinput | -!(-*)[oF])
- _filedir
+ --pidfile | -${noargopts}I)
+ _comp_compgen_filedir pid
return
;;
- --bind | -!(-*)B)
- _available_interfaces -a
- _ip_addresses -a
- __ltrim_colon_completions "$cur"
+ --output | --fileinput | --authorized-users-path | -${noargopts}[oF])
+ _comp_compgen_filedir
return
;;
- --client | -!(-*)c)
- _known_hosts_real -- "$cur"
+ --bind | -${noargopts}B)
+ _comp_compgen_available_interfaces -a
+ _comp_compgen -a ip_addresses -a
return
;;
- --reportexclude | -!(-*)x)
- COMPREPLY=($(compgen -W 'C D M S V' -- "$cur"))
+ --bind-dev)
+ _comp_compgen_available_interfaces -a
return
;;
- --reportstyle | -!(-*)y)
- COMPREPLY=($(compgen -W 'C' -- "$cur"))
+ --client | -${noargopts}c)
+ _comp_compgen_known_hosts -- "$cur"
+ return
+ ;;
+ --reportexclude | -${noargopts}x)
+ _comp_compgen -- -W 'C D M S V'
+ return
+ ;;
+ --reportstyle | -${noargopts}y)
+ _comp_compgen -- -W 'C'
return
;;
--logfile)
- _filedir log
+ _comp_compgen_filedir log
+ return
+ ;;
+ --rsa-private-key-path | --rsa-public-key-path)
+ _comp_compgen_filedir pem
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
# Filter mode specific options
- local i filter=cat
+ local -a filter=(cat)
+ local i
for i in "${words[@]}"; do
case $i in
-s | --server)
- filter='command sed -e /^Client.specific/,/^\(Server.specific.*\)\?$/d'
+ filter=(command sed -e '/^Client.specific/,/^\(Server.specific.*\)\{0,1\}$/d')
;;
-c | --client)
- filter='command sed -e /^Server.specific/,/^\(Client.specific.*\)\?$/d'
+ filter=(command sed -e '/^Server.specific/,/^\(Client.specific.*\)\{0,1\}$/d')
;;
esac
done
- [[ $filter != cat ]] && filter+=' -e /--client/d -e /--server/d'
+ [[ $filter != cat ]] && filter+=(-e '/--client/d' -e '/--server/d')
- COMPREPLY=($(compgen -W \
- '$("$1" --help 2>&1 | $filter | _parse_help -)' -- "$cur"))
+ _comp_compgen_help - <<<"$("$1" --help 2>&1 | "${filter[@]}")"
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
} &&
- complete -F _iperf iperf iperf3
+ complete -F _comp_cmd_iperf iperf iperf3
# ex: filetype=sh
diff --git a/completions/ipmitool b/completions/ipmitool
index 920287d..5d6c212 100644
--- a/completions/ipmitool
+++ b/completions/ipmitool
@@ -1,65 +1,61 @@
# bash completion for ipmitool -*- shell-script -*-
-_ipmitool_singleline_help()
+_comp_cmd_ipmitool__singleline_help()
{
- COMPREPLY=($(compgen -W "$($1 $2 2>&1 |
- command sed -ne 's/[,\r]//g' -e 's/^.*[Cc]ommands://p')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" "$2" 2>&1 |
+ command sed -ne 's/[,\r]//g' -e 's/^.*[Cc]ommands://p')"
}
-_ipmitool()
+_comp_cmd_ipmitool()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*[hVpUekyPmbtBTl])
return
;;
-*d)
- COMPREPLY=($(compgen -W "$(
- command ls -d /dev/ipmi* /dev/ipmi/* /dev/ipmidev/* \
- 2>/dev/null | command sed -ne 's/^[^0-9]*\([0-9]\{1,\}\)/\1/p'
- )" \
- -- "$cur"))
+ local -a files
+ _comp_expand_glob files '/dev/ipmi* /dev/ipmi/* /dev/ipmidev/*' &&
+ _comp_compgen -- -W '"${files[@]##*([^0-9])}"' -X '![0-9]*'
return
;;
-*I)
- COMPREPLY=($(compgen -W "$($1 -h 2>&1 |
+ _comp_compgen_split -- "$("$1" -h 2>&1 |
command sed -e '/^Interfaces:/,/^[[:space:]]*$/!d' \
- -ne 's/^[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*/\1/p')" \
- -- "$cur"))
+ -ne 's/^[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*/\1/p')"
return
;;
-*H)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-*[fSO])
- _filedir
+ _comp_compgen_filedir
return
;;
-*C)
- COMPREPLY=($(compgen -W '{0..14}' -- "$cur"))
+ _comp_compgen -- -W '{0..14}'
return
;;
-*L)
- COMPREPLY=($(compgen -W 'CALLBACK USER OPERATOR ADMINISTRATOR' \
- -- "$cur"))
+ _comp_compgen -- -W 'CALLBACK USER OPERATOR ADMINISTRATOR'
return
;;
-*A)
- COMPREPLY=($(compgen -W 'NONE PASSWORD MD2 MD5 OEM' -- "$cur"))
+ _comp_compgen -- -W 'NONE PASSWORD MD2 MD5 OEM'
return
;;
-*o)
- COMPREPLY=($(compgen -W "$($1 -o list 2>&1 |
- awk '/^[ \t]+/ { print $1 }') list" -- "$cur"))
+ _comp_compgen_split -- "$("$1" -o list 2>&1 |
+ _comp_awk '/^[ \t]+/ { print $1 }') list"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ _comp_compgen_help -- -h
return
fi
@@ -68,16 +64,16 @@ _ipmitool()
local cmds=(raw i2c spd lan chassis power event mc sdr sensor fru gendev
sel pef sol tsol isol user channel session sunoem kontronoem picmg fwum
firewall shell exec set hpm ekanalyzer)
- local i c cmd subcmd
- for ((i = 1; i < ${#words[@]} - 1; i++)); do
- [[ -v cmd ]] && subcmd=${words[i]} && break
+ local i c cmd="" has_cmd="" subcmd
+ for ((i = 1; i < cword; i++)); do
+ [[ $has_cmd ]] && subcmd=${words[i]} && break
for c in "${cmds[@]}"; do
- [[ ${words[i]} == "$c" ]] && cmd=$c && break
+ [[ ${words[i]} == "$c" ]] && cmd=$c has_cmd=set && break
done
done
- if [[ ! -v cmd ]]; then
- COMPREPLY=($(compgen -W '${cmds[@]}' -- "$cur"))
+ if [[ ! $has_cmd ]]; then
+ _comp_compgen -- -W '"${cmds[@]}"'
return
fi
@@ -87,13 +83,12 @@ _ipmitool()
shell) ;;
- \
- exec)
- _filedir
+ exec)
+ _comp_compgen_filedir
;;
chassis | power | kontronoem | fwum)
- _ipmitool_singleline_help $1 $cmd
+ _comp_cmd_ipmitool__singleline_help "$1" "$cmd"
;;
lan)
@@ -102,15 +97,14 @@ _ipmitool()
alert)
[[ $prev == alert ]] &&
- COMPREPLY=($(compgen -W 'print set' -- "$cur"))
+ _comp_compgen -- -W 'print set'
;;
stats)
[[ $prev == stats ]] &&
- COMPREPLY=($(compgen -W 'print set' -- "$cur"))
+ _comp_compgen -- -W 'print set'
;;
*)
- COMPREPLY=($(compgen -W 'print set alert stats' \
- -- "$cur"))
+ _comp_compgen -- -W 'print set alert stats'
;;
esac
;;
@@ -120,25 +114,25 @@ _ipmitool()
get | info | type | list | entity) ;;
elist)
- COMPREPLY=($(compgen -W 'all full compact event mclog fru
- generic' -- "$cur"))
+ _comp_compgen -- -W 'all full compact event mclog fru
+ generic'
;;
dump)
- _filedir
+ _comp_compgen_filedir
;;
fill)
case $prev in
fill)
- COMPREPLY=($(compgen -W 'sensors file' -- "$cur"))
+ _comp_compgen -- -W 'sensors file'
;;
file)
- _filedir
+ _comp_compgen_filedir
;;
esac
;;
*)
- COMPREPLY=($(compgen -W 'get info type list elist entity
- dump fill' -- "$cur"))
+ _comp_compgen -- -W 'get info type list elist entity dump
+ fill'
;;
esac
;;
@@ -148,7 +142,7 @@ _ipmitool()
list | get | thresh) ;;
*)
- COMPREPLY=($(compgen -W 'list get thresh' -- "$cur"))
+ _comp_compgen -- -W 'list get thresh'
;;
esac
;;
@@ -158,15 +152,15 @@ _ipmitool()
info | clear | list | elist | delete) ;;
add | save | writeraw | readraw)
- _filedir
+ _comp_compgen_filedir
;;
time)
[[ $prev == time ]] &&
- COMPREPLY=($(compgen -W 'get set' -- "$cur"))
+ _comp_compgen -- -W 'get set'
;;
*)
- COMPREPLY=($(compgen -W 'info clear list elist delete add
- get save writeraw readraw time' -- "$cur"))
+ _comp_compgen -- -W 'info clear list elist delete add get
+ save writeraw readraw time'
;;
esac
;;
@@ -177,23 +171,23 @@ _ipmitool()
set)
[[ $prev == set ]] &&
- COMPREPLY=($(compgen -W 'name password' -- "$cur"))
+ _comp_compgen -- -W 'name password'
;;
*)
- COMPREPLY=($(compgen -W 'summary list set disable enable
- priv test' -- "$cur"))
+ _comp_compgen -- -W 'summary list set disable enable priv
+ test'
;;
esac
;;
set)
[[ $prev == set ]] &&
- COMPREPLY=($(compgen -W 'hostname username password privlvl
- authtype localaddr targetaddr port csv verbose' -- "$cur"))
+ _comp_compgen -- -W 'hostname username password privlvl
+ authtype localaddr targetaddr port csv verbose'
;;
esac
} &&
- complete -F _ipmitool ipmitool
+ complete -F _comp_cmd_ipmitool ipmitool
# ex: filetype=sh
diff --git a/completions/ipsec b/completions/ipsec
index 4bc8cdf..6bd4ebf 100644
--- a/completions/ipsec
+++ b/completions/ipsec
@@ -3,87 +3,86 @@
# Complete ipsec.conf conn entries.
#
# Reads a file from stdin in the ipsec.conf(5) format.
-_ipsec_connections()
+_comp_cmd_ipsec__connections()
{
local keyword name
while read -r keyword name; do
if [[ $keyword == [#]* ]]; then continue; fi
[[ $keyword == conn && $name != '%default' ]] && COMPREPLY+=("$name")
done
- COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur"))
+ ((${#COMPREPLY[@]})) &&
+ _comp_compgen -- -W '"${COMPREPLY[@]}"'
}
-_ipsec_freeswan()
+_comp_cmd_ipsec__freeswan()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if ((cword == 1)); then
- COMPREPLY=($(compgen -W 'auto barf eroute klipsdebug look manual
- pluto ranbits rsasigkey setup showdefaults showhostkey spi spigrp
- tncfg whack' -- "$cur"))
+ _comp_compgen -- -W 'auto barf eroute klipsdebug look manual pluto
+ ranbits rsasigkey setup showdefaults showhostkey spi spigrp tncfg
+ whack'
return
fi
case ${words[1]} in
auto)
- COMPREPLY=($(compgen -W '--asynchronous --up --add --delete
- --replace --down --route --unroute --ready --status
- --rereadsecrets' -- "$cur"))
+ _comp_compgen -- -W '--asynchronous --up --add --delete --replace
+ --down --route --unroute --ready --status --rereadsecrets'
;;
manual)
- COMPREPLY=($(compgen -W '--up --down --route --unroute --union' \
- -- "$cur"))
+ _comp_compgen -- -W '--up --down --route --unroute --union'
;;
ranbits)
- COMPREPLY=($(compgen -W '--quick --continuous --bytes' -- "$cur"))
+ _comp_compgen -- -W '--quick --continuous --bytes'
;;
setup)
- COMPREPLY=($(compgen -W '--start --stop --restart' -- "$cur"))
+ _comp_compgen -- -W '--start --stop --restart'
;;
*) ;;
esac
}
-_ipsec_strongswan()
+_comp_cmd_ipsec__strongswan()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if ((cword == 1)); then
- COMPREPLY=($(compgen -W 'down irdumm leases listaacerts listacerts
- listalgs listall listcacerts listcainfos listcards listcerts
- listcrls listgroups listocsp listocspcerts listpubkeys openac pki
- pluto pool purgecerts purgecrls purgeike purgeocsp ready reload
- rereadaacerts rereadacerts rereadall rereadcacerts rereadcrls
- rereadgroups rereadocspcerts rereadsecrets restart route scdecrypt
- scencrypt scepclient secrets start starter status statusall stop
- stroke unroute uci up update version whack --confdir --copyright
- --directory --help --version --versioncode' -- "$cur"))
+ _comp_compgen -- -W 'down irdumm leases listaacerts listacerts listalgs
+ listall listcacerts listcainfos listcards listcerts listcrls
+ listgroups listocsp listocspcerts listpubkeys openac pki pluto pool
+ purgecerts purgecrls purgeike purgeocsp ready reload rereadaacerts
+ rereadacerts rereadall rereadcacerts rereadcrls rereadgroups
+ rereadocspcerts rereadsecrets restart route scdecrypt scencrypt
+ scepclient secrets start starter status statusall stop stroke
+ unroute uci up update version whack --confdir --copyright
+ --directory --help --version --versioncode'
return
fi
case ${words[1]} in
down | route | status | statusall | unroute | up)
local confdir=$(ipsec --confdir)
- _ipsec_connections <"$confdir/ipsec.conf"
+ _comp_cmd_ipsec__connections <"$confdir/ipsec.conf"
;;
list*)
- COMPREPLY=($(compgen -W '--utc' -- "$cur"))
+ _comp_compgen -- -W '--utc'
;;
restart | start)
- COMPREPLY=($(compgen -W '--attach-gdb --auto-update --debug
- --debug-all --debug-more --nofork' -- "$cur"))
+ _comp_compgen -- -W '--attach-gdb --auto-update --debug --debug-all
+ --debug-more --nofork'
;;
pki)
- COMPREPLY=($(compgen -W '--gen --issue --keyid --print --pub
- --req --self --signcrl --verify' -- "$cur"))
+ _comp_compgen -- -W '--gen --issue --keyid --print --pub --req
+ --self --signcrl --verify'
;;
pool) ;;
irdumm)
- _filedir 'rb'
+ _comp_compgen_filedir 'rb'
;;
*) ;;
@@ -92,10 +91,10 @@ _ipsec_strongswan()
case "$(ipsec --version 2>/dev/null)" in
*strongSwan*)
- complete -F _ipsec_strongswan ipsec
+ complete -F _comp_cmd_ipsec__strongswan ipsec
;;
*)
- complete -F _ipsec_freeswan ipsec
+ complete -F _comp_cmd_ipsec__freeswan ipsec
;;
esac
diff --git a/completions/iptables b/completions/iptables
index ffb905b..d0c0ec1 100644
--- a/completions/iptables
+++ b/completions/iptables
@@ -1,51 +1,55 @@
# bash completion for iptables -*- shell-script -*-
-_iptables()
+_comp_cmd_iptables()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
- local table chain='s/^Chain \([^ ]\{1,\}\).*$/\1/p'
+ local table="" chain='s/^Chain \([^ ]\{1,\}\).*$/\1/p'
+ local targets='ACCEPT DROP LOG ULOG REJECT'
+ local IFS=$' \t\n' # for ${table:+-t "$table"}
[[ ${words[*]} =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] &&
- table="-t ${BASH_REMATCH[2]}"
+ table=${BASH_REMATCH[2]}
case $prev in
-*[AIDRPFXLZ])
- COMPREPLY=($(compgen -W '`"$1" $table -nL 2>/dev/null | \
- command sed -ne "s/^Chain \([^ ]\{1,\}\).*$/\1/p"`' -- "$cur"))
+ _comp_compgen_split -- "$(
+ "$1" ${table:+-t "$table"} -nL 2>/dev/null |
+ command sed -ne 's/^Chain \([^ ]\{1,\}\).*$/\1/p'
+ )"
;;
-*t)
- COMPREPLY=($(compgen -W 'nat filter mangle' -- "$cur"))
+ _comp_compgen -- -W 'nat filter mangle'
;;
-j)
- if [[ $table == "-t filter" || -z $table ]]; then
- COMPREPLY=($(compgen -W 'ACCEPT DROP LOG ULOG REJECT
- `"$1" $table -nL 2>/dev/null | command sed -ne "$chain" \
- -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
- "$cur"))
- elif [[ $table == "-t nat" ]]; then
- COMPREPLY=($(compgen -W 'ACCEPT DROP LOG ULOG REJECT MIRROR SNAT
- DNAT MASQUERADE `"$1" $table -nL 2>/dev/null | \
- command sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \
- -- "$cur"))
- elif [[ $table == "-t mangle" ]]; then
- COMPREPLY=($(compgen -W 'ACCEPT DROP LOG ULOG REJECT MARK TOS
- `"$1" $table -nL 2>/dev/null | command sed -ne "$chain" \
- -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
- "$cur"))
+ if [[ $table == "filter" || ! $table ]]; then
+ _comp_compgen -- -W '$targets'
+ _comp_compgen -a split -- "$("$1" ${table:+-t "$table"} -nL \
+ 2>/dev/null | command sed -ne "$chain" \
+ -e 's/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//')"
+ elif [[ $table == "nat" ]]; then
+ _comp_compgen -- -W '$targets MIRROR SNAT DNAT MASQUERADE'
+ _comp_compgen -a split -- "$("$1" -t "$table" -nL 2>/dev/null |
+ command sed -ne "$chain" \
+ -e 's/OUTPUT|PREROUTING|POSTROUTING//')"
+ elif [[ $table == "mangle" ]]; then
+ _comp_compgen -- -W '$targets MARK TOS'
+ _comp_compgen -a split -- "$("$1" -t "$table" -nL 2>/dev/null |
+ command sed -ne "$chain" \
+ -e 's/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//')"
fi
;;
*)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$("$1" --help 2>&1 |
- command sed -e "s/^\[\!\]//" | _parse_help -)' -- "$cur"))
+ _comp_compgen_help - <<<"$("$1" --help 2>&1 |
+ command sed -e "s/^\[\!\]//")"
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
;;
esac
} &&
- complete -F _iptables iptables
+ complete -F _comp_cmd_iptables iptables
# ex: filetype=sh
diff --git a/completions/ipv6calc b/completions/ipv6calc
index c452c15..7cf7d82 100644
--- a/completions/ipv6calc
+++ b/completions/ipv6calc
@@ -1,23 +1,24 @@
# ipv6calc completion -*- shell-script -*-
-_ipv6calc()
+_comp_cmd_ipv6calc()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[dIOA]*)'
+ # shellcheck disable=SC2254
case "$prev" in
- --debug | -!(-*)d)
+ --debug | -${noargopts}d)
return
;;
- --in | --out | --action | -!(-*)[IOA])
+ --in | --out | --action | -${noargopts}[IOA])
# With ipv6calc < 0.73.0, -m does nothing here, so use sed instead.
- COMPREPLY=($(compgen -W "$($1 "$prev" -h 2>&1 |
- command sed -ne 's/^[[:space:]]\{1,\}\([^[:space:]:]\{1,\}\)[[:space:]]*:.*/\1/p')" \
- -- "$cur"))
+ _comp_compgen_split -- "$("$1" "$prev" -h 2>&1 |
+ command sed -ne 's/^[[:space:]]\{1,\}\([^[:space:]:]\{1,\}\)[[:space:]]*:.*/\1/p')"
return
;;
--db-geoip | --db-ip2location-ipv4 | --db-ip2location-ipv6)
- _filedir
+ _comp_compgen_filedir
return
;;
--printstart | --printend)
@@ -25,14 +26,14 @@ _ipv6calc()
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$("$1" -h 2>&1 |
- command sed -e "s/[][]//g" | _parse_help -)' -- "$cur"))
+ _comp_compgen_help - <<<"$("$1" -h 2>&1 |
+ command sed -e "s/[][]//g")"
fi
} &&
- complete -F _ipv6calc ipv6calc
+ complete -F _comp_cmd_ipv6calc ipv6calc
# ex: filetype=sh
diff --git a/completions/iscsiadm b/completions/iscsiadm
index 7786ddc..84cc817 100644
--- a/completions/iscsiadm
+++ b/completions/iscsiadm
@@ -1,31 +1,32 @@
# iscsiadm(1) completion -*- shell-script -*-
-_iscsiadm()
+_comp_cmd_iscsiadm()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[motLU]*)'
+ # shellcheck disable=SC2254
case $prev in
- --mode | -!(-*)m)
- COMPREPLY=($(compgen -W 'discovery node session iface fw host' \
- -- "$cur"))
+ --mode | -${noargopts}m)
+ _comp_compgen -- -W 'discovery node session iface fw host'
return
;;
- --op | -!(-*)o)
- COMPREPLY=($(compgen -W 'new delete update show' -- "$cur"))
+ --op | -${noargopts}o)
+ _comp_compgen -- -W 'new delete update show'
return
;;
- --type | -!(-*)t)
- COMPREPLY=($(compgen -W 'sendtargets st slp isns fw' -- "$cur"))
+ --type | -${noargopts}t)
+ _comp_compgen -- -W 'sendtargets st slp isns fw'
return
;;
- --loginall | --logoutall | -!(-*)[LU])
- COMPREPLY=($(compgen -W 'all manual automatic' -- "$cur"))
+ --loginall | --logoutall | -${noargopts}[LU])
+ _comp_compgen -- -W 'all manual automatic'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
local options
if ((cword > 1)); then
@@ -59,8 +60,8 @@ _iscsiadm()
options='--mode'
fi
- COMPREPLY=($(compgen -W "$options" -- "$cur"))
+ _comp_compgen -- -W "$options"
} &&
- complete -F _iscsiadm iscsiadm
+ complete -F _comp_cmd_iscsiadm iscsiadm
# ex: filetype=sh
diff --git a/completions/isort b/completions/isort
index 2a84e25..a5c6dff 100644
--- a/completions/isort
+++ b/completions/isort
@@ -1,9 +1,9 @@
# isort completion -*- shell-script -*-
-_isort()
+_comp_cmd_isort()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--help | --add-import | --builtin | --future | --from-first | -ff | \
@@ -15,27 +15,29 @@ _isort()
return
;;
--jobs | -j)
- COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur"))
+ local REPLY
+ _comp_get_ncpus
+ _comp_compgen -- -W "{1..$REPLY}"
return
;;
--multi-line | -m)
- COMPREPLY=($(compgen -W '{0..5}' -- "$cur"))
+ _comp_compgen -- -W '{0..5}'
return
;;
--section-default | -sd)
- COMPREPLY=($(compgen -W 'FUTURE STDLIB THIRDPARTY FIRSTPARTY
- LOCALFOLDER' -- "$cur"))
+ _comp_compgen -- -W 'FUTURE STDLIB THIRDPARTY FIRSTPARTY
+ LOCALFOLDER'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- _filedir '@(py|pyi)'
+ _comp_compgen_filedir '@(py|pyi)'
} &&
- complete -F _isort isort
+ complete -F _comp_cmd_isort isort
# ex: filetype=sh
diff --git a/completions/isql b/completions/isql
index 4258c51..11dd654 100644
--- a/completions/isql
+++ b/completions/isql
@@ -1,14 +1,16 @@
# isql completion -*- shell-script -*-
# by Victor Bogado da Silva Lins <victor@bogado.net>
-_isql()
+_comp_cmd_isql()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- [[ -f $ODBCINI ]] &&
- COMPREPLY=($(command grep "\[$cur" "$ODBCINI" | tr -d \[\]))
+ [[ -f ${ODBCINI-} ]] &&
+ _comp_compgen_split -l -- "$(
+ command sed -n 's/\]//g;s/^\[//gp' "$ODBCINI"
+ )"
} &&
- complete -F _isql isql
+ complete -F _comp_cmd_isql isql
# ex: filetype=sh
diff --git a/completions/iwconfig b/completions/iwconfig
index aa8fbf3..7fbc985 100644
--- a/completions/iwconfig
+++ b/completions/iwconfig
@@ -1,90 +1,90 @@
# iwconfig completion -*- shell-script -*-
-_iwconfig()
+_comp_deprecate_var 2.12 \
+ COMP_IWLIST_SCAN BASH_COMPLETION_CMD_IWCONFIG_SCAN
+
+_comp_cmd_iwconfig()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
mode)
- COMPREPLY=($(compgen -W 'managed ad-hoc master repeater secondary
- monitor' -- "$cur"))
+ _comp_compgen -- -W 'managed ad-hoc master repeater secondary
+ monitor'
return
;;
essid)
- COMPREPLY=($(compgen -W 'on off any' -- "$cur"))
- if [[ -n ${COMP_IWLIST_SCAN:-} ]]; then
- COMPREPLY+=($(compgen -W \
- "$(iwlist ${words[1]} scan |
- awk -F'\"' '/ESSID/ {print $2}')" -- "$cur"))
+ _comp_compgen -- -W 'on off any'
+ if [[ ${BASH_COMPLETION_CMD_IWCONFIG_SCAN-} ]]; then
+ _comp_compgen -a split -- "$(iwlist "${words[1]}" scan |
+ _comp_awk -F '\"' '/ESSID/ {print $2}')"
fi
return
;;
nwid)
- COMPREPLY=($(compgen -W 'on off' -- "$cur"))
+ _comp_compgen -- -W 'on off'
return
;;
channel)
- COMPREPLY=($(compgen -W "$(iwlist ${words[1]} channel |
- awk '/^[ \t]*Channel/ {print $2}')" -- "$cur"))
+ _comp_compgen_split -- "$(iwlist "${words[1]}" channel |
+ _comp_awk '/^[ \t]*Channel/ {print $2}')"
return
;;
freq)
- COMPREPLY=($(compgen -W "$(iwlist ${words[1]} channel |
- awk '/^[ \t]*Channel/ {print $4"G"}')" -- "$cur"))
+ _comp_compgen_split -- "$(iwlist "${words[1]}" channel |
+ _comp_awk '/^[ \t]*Channel/ {print $4"G"}')"
return
;;
ap)
- COMPREPLY=($(compgen -W 'on off any' -- "$cur"))
- if [[ -n ${COMP_IWLIST_SCAN:-} ]]; then
- COMPREPLY+=($(compgen -W \
- "$(iwlist ${words[1]} scan |
- awk -F ': ' '/Address/ {print $2}')" -- "$cur"))
+ _comp_compgen -- -W 'on off any'
+ if [[ ${BASH_COMPLETION_CMD_IWCONFIG_SCAN-} ]]; then
+ _comp_compgen -a split -- "$(iwlist "${words[1]}" scan |
+ _comp_awk -F ': ' '/Address/ {print $2}')"
fi
return
;;
rate)
- COMPREPLY=($(compgen -W 'auto fixed' -- "$cur"))
- COMPREPLY+=($(compgen -W \
- "$(iwlist ${words[1]} rate |
- awk '/^[ \t]*[0-9]/ {print $1"M"}')" -- "$cur"))
+ _comp_compgen -- -W 'auto fixed'
+ _comp_compgen -a split -- "$(iwlist "${words[1]}" rate |
+ _comp_awk '/^[ \t]*[0-9]/ {print $1"M"}')"
return
;;
rts | frag)
- COMPREPLY=($(compgen -W 'auto fixed off' -- "$cur"))
+ _comp_compgen -- -W 'auto fixed off'
return
;;
key | enc)
- COMPREPLY=($(compgen -W 'off on open restricted' -- "$cur"))
+ _comp_compgen -- -W 'off on open restricted'
return
;;
power)
- COMPREPLY=($(compgen -W 'period timeout off on' -- "$cur"))
+ _comp_compgen -- -W 'period timeout off on'
return
;;
txpower)
- COMPREPLY=($(compgen -W 'off on auto' -- "$cur"))
+ _comp_compgen -- -W 'off on auto'
return
;;
retry)
- COMPREPLY=($(compgen -W 'limit lifetime' -- "$cur"))
+ _comp_compgen -- -W 'limit lifetime'
return
;;
esac
if ((cword == 1)); then
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--help --version' -- "$cur"))
+ _comp_compgen -- -W '--help --version'
else
- _available_interfaces -w
+ _comp_compgen_available_interfaces -w
fi
else
- COMPREPLY=($(compgen -W 'essid nwid mode freq channel sens mode ap
- nick rate rts frag enc key power txpower commit' -- "$cur"))
+ _comp_compgen -- -W 'essid nwid mode freq channel sens mode ap nick
+ rate rts frag enc key power txpower commit'
fi
} &&
- complete -F _iwconfig iwconfig
+ complete -F _comp_cmd_iwconfig iwconfig
# ex: filetype=sh
diff --git a/completions/iwlist b/completions/iwlist
index 16aa39c..efac3e6 100644
--- a/completions/iwlist
+++ b/completions/iwlist
@@ -1,22 +1,22 @@
# iwlist completion -*- shell-script -*-
-_iwlist()
+_comp_cmd_iwlist()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if ((cword == 1)); then
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--help --version' -- "$cur"))
+ _comp_compgen -- -W '--help --version'
else
- _available_interfaces -w
+ _comp_compgen_available_interfaces -w
fi
else
- COMPREPLY=($(compgen -W 'scan scanning freq frequency channel rate
- bit bitrate key enc encryption power txpower retry ap accesspoint
- peers event' -- "$cur"))
+ _comp_compgen -- -W 'scan scanning freq frequency channel rate bit
+ bitrate key enc encryption power txpower retry ap accesspoint peers
+ event'
fi
} &&
- complete -F _iwlist iwlist
+ complete -F _comp_cmd_iwlist iwlist
# ex: filetype=sh
diff --git a/completions/iwpriv b/completions/iwpriv
index 4e38246..518a22a 100644
--- a/completions/iwpriv
+++ b/completions/iwpriv
@@ -1,31 +1,31 @@
# iwpriv completion -*- shell-script -*-
-_iwpriv()
+_comp_cmd_iwpriv()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
roam)
- COMPREPLY=($(compgen -W 'on off' -- "$cur"))
+ _comp_compgen -- -W 'on off'
return
;;
port)
- COMPREPLY=($(compgen -W 'ad-hoc managed' -- "$cur"))
+ _comp_compgen -- -W 'ad-hoc managed'
return
;;
esac
if ((cword == 1)); then
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--help --version' -- "$cur"))
+ _comp_compgen -- -W '--help --version'
else
- _available_interfaces -w
+ _comp_compgen_available_interfaces -w
fi
else
- COMPREPLY=($(compgen -W '--all roam port' -- "$cur"))
+ _comp_compgen -- -W '--all roam port'
fi
} &&
- complete -F _iwpriv iwpriv
+ complete -F _comp_cmd_iwpriv iwpriv
# ex: filetype=sh
diff --git a/completions/iwspy b/completions/iwspy
index 38b7868..e097d95 100644
--- a/completions/iwspy
+++ b/completions/iwspy
@@ -1,20 +1,20 @@
# iwspy completion -*- shell-script -*-
-_iwspy()
+_comp_cmd_iwspy()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if ((cword == 1)); then
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--help --version' -- "$cur"))
+ _comp_compgen -- -W '--help --version'
else
- _available_interfaces -w
+ _comp_compgen_available_interfaces -w
fi
else
- COMPREPLY=($(compgen -W 'setthr getthr off' -- "$cur"))
+ _comp_compgen -- -W 'setthr getthr off'
fi
} &&
- complete -F _iwspy iwspy
+ complete -F _comp_cmd_iwspy iwspy
# ex: filetype=sh
diff --git a/completions/jar b/completions/jar
index 2289491..d01a8a4 100644
--- a/completions/jar
+++ b/completions/jar
@@ -1,27 +1,27 @@
# jar(1) completion -*- shell-script -*-
-_jar()
+_comp_cmd_jar()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if ((cword == 1)); then
- COMPREPLY=($(compgen -W 'c t x u' -- "$cur"))
+ _comp_compgen -- -W 'c t x u'
return
fi
case ${words[1]} in
*c*f)
- _filedir
+ _comp_compgen_filedir
;;
*f)
- _filedir_xspec unzip
+ _comp_compgen_filedir_xspec unzip
;;
*)
- _filedir
+ _comp_compgen_filedir
;;
esac
} &&
- complete -F _jar jar
+ complete -F _comp_cmd_jar jar
# ex: filetype=sh
diff --git a/completions/jarsigner b/completions/jarsigner
index 1f26c9c..ebc6cf8 100644
--- a/completions/jarsigner
+++ b/completions/jarsigner
@@ -1,14 +1,14 @@
# jarsigner(1) completion -*- shell-script -*-
-_jarsigner()
+_comp_cmd_jarsigner()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-keystore)
- COMPREPLY=($(compgen -W 'NONE' -- "$cur"))
- _filedir '@(jks|ks|p12|pfx)'
+ _comp_compgen -- -W 'NONE'
+ _comp_compgen -a filedir '@(jks|ks|p12|pfx)'
return
;;
-storepass | -keypass | -sigfile | -digestalg | -sigalg | -tsacert | -tsapolicyid | \
@@ -17,41 +17,40 @@ _jarsigner()
return
;;
-certchain | -tsa)
- _filedir
+ _comp_compgen_filedir
return
;;
-storetype)
- COMPREPLY=($(compgen -W 'JKS PKCS11 PKCS12' -- "$cur"))
+ _comp_compgen -- -W 'JKS PKCS11 PKCS12'
return
;;
-signedjar)
- _filedir '@(jar|apk)'
+ _comp_compgen_filedir '@(jar|apk)'
return
;;
esac
# Check if a jar was already given.
- local i jar=false
- for ((i = 1; i < ${#words[@]} - 1; i++)); do
- if [[ ${words[i]} == *.@(jar|apk) && \
+ local i jar=""
+ for ((i = 1; i < cword; i++)); do
+ if [[ ${words[i]} == *.@(jar|apk) &&
${words[i - 1]} != -signedjar ]]; then
- jar=true
+ jar=set
break
fi
done
- if ! $jar; then
+ if [[ ! $jar ]]; then
if [[ $cur == -* ]]; then
# Documented as "should not be used": -internalsf, -sectionsonly
- COMPREPLY=($(compgen -W '-keystore -storepass -storetype
- -keypass -sigfile -signedjar -digestalg -sigalg -verify
- -verbose -certs -tsa -tsacert -altsigner -altsignerpath
- -protected -providerName -providerClass -providerArg' \
- -- "$cur"))
+ _comp_compgen -- -W '-keystore -storepass -storetype -keypass
+ -sigfile -signedjar -digestalg -sigalg -verify -verbose -certs
+ -tsa -tsacert -altsigner -altsignerpath -protected
+ -providerName -providerClass -providerArg'
fi
- _filedir '@(jar|apk)'
+ _comp_compgen -a filedir '@(jar|apk)'
fi
} &&
- complete -F _jarsigner jarsigner
+ complete -F _comp_cmd_jarsigner jarsigner
# ex: filetype=sh
diff --git a/completions/java b/completions/java
index d0f70ae..8ddcfaf 100644
--- a/completions/java
+++ b/completions/java
@@ -1,86 +1,93 @@
# bash completion for java, javac and javadoc -*- shell-script -*-
# available path elements completion
-_java_path()
+_comp_cmd_java__classpath()
{
- cur=${cur##*:}
- _filedir '@(jar|zip)'
+ _comp_compgen -c "${cur##*:}" filedir '@(jar|zip)'
}
# exact classpath determination
-_java_find_classpath()
+# @var[out] REPLY Array to store classpaths
+# @return 0 if at least one element is generated, or otherwise 1
+_comp_cmd_java__find_classpath()
{
local i
+ REPLY=
+
# search first in current options
for ((i = 1; i < cword; i++)); do
if [[ ${words[i]} == -@(cp|classpath) ]]; then
- classpath=${words[i + 1]}
+ REPLY=${words[i + 1]}
break
fi
done
- # default to environment
- [[ ! -v classpath ]] && classpath=${CLASSPATH-}
-
- # default to current directory
- [[ -z $classpath ]] && classpath=.
+ # fall back to environment, followed by current directory
+ _comp_split -F : REPLY "${REPLY:-${CLASSPATH:-.}}"
}
# exact sourcepath determination
-_java_find_sourcepath()
+# @var[out] REPLY Array to store sourcepaths
+# @return 0 if at least one element is generated, or otherwise 1
+_comp_cmd_java__find_sourcepath()
{
local i
+ REPLY=
+
# search first in current options
for ((i = 1; i < cword; i++)); do
if [[ ${words[i]} == -sourcepath ]]; then
- sourcepath=${words[i + 1]}
+ REPLY=${words[i + 1]}
break
fi
done
- # default to classpath
- if [[ ! -v sourcepath ]]; then
- local classpath
- _java_find_classpath
- sourcepath=$classpath
+ # fall back to classpath
+ if [[ ! $REPLY ]]; then
+ _comp_cmd_java__find_classpath
+ return
fi
+
+ _comp_split -F : REPLY "$REPLY"
}
# available classes completion
-_java_classes()
+_comp_cmd_java__classes()
{
- local classpath i
+ local REPLY i
# find which classpath to use
- _java_find_classpath
+ _comp_cmd_java__find_classpath
+ local -a classpaths=("${REPLY[@]}")
+ local -a classes=()
# convert package syntax to path syntax
- cur=${cur//.//}
+ local cur=${cur//.//}
# parse each classpath element for classes
- for i in ${classpath//:/ }; do
+ for i in "${classpaths[@]}"; do
if [[ $i == *.@(jar|zip) && -r $i ]]; then
if type zipinfo &>/dev/null; then
- COMPREPLY+=($(zipinfo -1 "$i" "$cur*" 2>/dev/null |
- command grep '^[^$]*\.class$'))
+ _comp_split -a classes "$(zipinfo -1 "$i" "$cur*" 2>/dev/null |
+ command grep '^[^$]*\.class$')"
elif type unzip &>/dev/null; then
# Last column, between entries consisting entirely of dashes
- COMPREPLY+=($(unzip -lq "$i" "$cur*" 2>/dev/null |
- awk '$NF ~ /^-+$/ { flag=!flag; next };
- flag && $NF ~ /^[^$]*\.class/ { print $NF }'))
+ _comp_split -a classes "$(unzip -lq "$i" "$cur*" 2>/dev/null |
+ _comp_awk '$NF ~ /^-+$/ { flag=!flag; next };
+ flag && $NF ~ /^[^$]*\.class/ { print $NF }')"
elif type jar &>/dev/null; then
- COMPREPLY+=($(jar tf "$i" "$cur" |
- command grep '^[^$]*\.class$'))
+ _comp_split -a classes "$(jar tf "$i" "$cur" |
+ command grep '^[^$]*\.class$')"
fi
elif [[ -d $i ]]; then
- COMPREPLY+=(
- $(compgen -d -- "$i/$cur" | command sed -e "s|^$i/\(.*\)|\1.|")
- $(compgen -f -X '!*.class' -- "$i/$cur" |
- command sed -e '/\$/d' -e "s|^$i/||")
- )
- [[ ${COMPREPLY-} == *.class ]] || compopt -o nospace
+ local tmp
+ _comp_compgen -v tmp -c "$i/$cur" -- -d -S .
+ _comp_compgen -av tmp -c "$i/$cur" -- -f -X '!*.class'
+ ((${#tmp[@]})) &&
+ _comp_compgen -av classes -- -X '*\$*' -W '"${tmp[@]#$i/}"'
+ [[ ${classes-} == *.class ]] || compopt -o nospace
# FIXME: if we have foo.class and foo/, the completion
# returns "foo/"... how to give precedence to files
@@ -88,47 +95,50 @@ _java_classes()
fi
done
- if ((${#COMPREPLY[@]} != 0)); then
+ if ((${#classes[@]} != 0)); then
# remove class extension
- COMPREPLY=(${COMPREPLY[@]%.class})
+ classes=("${classes[@]%.class}")
# convert path syntax to package syntax
- COMPREPLY=(${COMPREPLY[@]//\//.})
+ classes=("${classes[@]//\//.}")
+ _comp_compgen -U classes -- -W '"${classes[@]}"'
fi
}
# available packages completion
-_java_packages()
+_comp_cmd_java__packages()
{
- local sourcepath i
+ local REPLY i files
# find which sourcepath to use
- _java_find_sourcepath
+ _comp_cmd_java__find_sourcepath || return 0
+ local -a sourcepaths=("${REPLY[@]}")
# convert package syntax to path syntax
- cur=${cur//.//}
+ local cur=${cur//.//}
# parse each sourcepath element for packages
- for i in ${sourcepath//:/ }; do
+ for i in "${sourcepaths[@]}"; do
if [[ -d $i ]]; then
- COMPREPLY+=($(command ls -F -d $i/$cur* 2>/dev/null |
- command sed -e 's|^'$i'/||'))
+ _comp_expand_glob files '"$i/$cur"*' || continue
+ _comp_split -la COMPREPLY "$(
+ command ls -F -d "${files[@]}" 2>/dev/null |
+ command sed -e 's|^'"$i"'/||'
+ )"
fi
done
if ((${#COMPREPLY[@]} != 0)); then
- # keep only packages
- COMPREPLY=($(tr " " "\n" <<<"${COMPREPLY[@]}" | command grep "/$"))
- # remove packages extension
- COMPREPLY=(${COMPREPLY[@]%/})
+ # keep only packages with the package suffix `/` being removed
+ _comp_split -l COMPREPLY "$(printf '%s\n' "${COMPREPLY[@]}" | command sed -n 's,/$,,p')"
# convert path syntax to package syntax
- cur="${COMPREPLY[*]//\//.}"
+ ((${#COMPREPLY[@]})) && COMPREPLY=("${COMPREPLY[@]//\//.}")
fi
}
# java completion
#
-_java()
+_comp_cmd_java()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
local i
@@ -142,7 +152,7 @@ _java()
;;
*)
# once we've seen a class, just do filename completion
- _filedir
+ _comp_compgen_filedir
return
;;
esac
@@ -151,59 +161,55 @@ _java()
case $cur in
# standard option completions
-verbose:*)
- COMPREPLY=($(compgen -W 'class gc jni' -- "${cur#*:}"))
+ _comp_compgen -c "${cur#*:}" -- -W 'class gc jni'
return
;;
-javaagent:*)
- cur=${cur#*:}
- _filedir '@(jar|zip)'
+ _comp_compgen -c "${cur#*:}" filedir '@(jar|zip)'
return
;;
-agentpath:*)
- cur=${cur#*:}
- _filedir so
+ _comp_compgen -c "${cur#*:}" filedir so
return
;;
# various non-standard option completions
-splash:*)
- cur=${cur#*:}
- _filedir '@(gif|jp?(e)g|png)'
+ _comp_compgen -c "${cur#*:}" filedir '@(gif|jp?(e)g|png)'
return
;;
-Xbootclasspath*:*)
- _java_path
+ _comp_cmd_java__classpath
return
;;
-Xcheck:*)
- COMPREPLY=($(compgen -W 'jni' -- "${cur#*:}"))
+ _comp_compgen -c "${cur#*:}" -- -W 'jni'
return
;;
-Xgc:*)
- COMPREPLY=($(compgen -W 'singlecon gencon singlepar genpar' \
- -- "${cur#*:}"))
+ _comp_compgen -c "${cur#*:}" -- -W 'singlecon gencon singlepar
+ genpar'
return
;;
-Xgcprio:*)
- COMPREPLY=($(compgen -W 'throughput pausetime deterministic' \
- -- "${cur#*:}"))
+ _comp_compgen -c "${cur#*:}" -- -W 'throughput pausetime
+ deterministic'
return
;;
-Xloggc:* | -Xverboselog:*)
- cur=${cur#*:}
- _filedir
+ _comp_compgen -c "${cur#*:}" filedir
return
;;
-Xshare:*)
- COMPREPLY=($(compgen -W 'auto off on' -- "${cur#*:}"))
+ _comp_compgen -c "${cur#*:}" -- -W 'auto off on'
return
;;
-Xverbose:*)
- COMPREPLY=($(compgen -W 'memory load jni cpuinfo codegen opt
- gcpause gcreport' -- "${cur#*:}"))
+ _comp_compgen -c "${cur#*:}" -- -W 'memory load jni cpuinfo codegen
+ opt gcpause gcreport'
return
;;
-Xverify:*)
- COMPREPLY=($(compgen -W 'all none remote' -- "${cur#*:}"))
+ _comp_compgen -c "${cur#*:}" -- -W 'all none remote'
return
;;
# the rest that we have no completions for
@@ -214,39 +220,39 @@ _java()
case $prev in
-cp | -classpath)
- _java_path
+ _comp_cmd_java__classpath
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
[[ $cur == -X* ]] &&
- COMPREPLY+=($(compgen -W '$(_parse_help "$1" -X)' -- "$cur"))
+ _comp_compgen -a help -- -X
else
if [[ $prev == -jar ]]; then
# jar file completion
- _filedir '[jw]ar'
+ _comp_compgen_filedir '[jw]ar'
else
# classes completion
- _java_classes
+ _comp_cmd_java__classes
fi
fi
[[ ${COMPREPLY-} == -*[:=] ]] && compopt -o nospace
- __ltrim_colon_completions "$cur"
+ _comp_ltrim_colon_completions "$cur"
} &&
- complete -F _java java
+ complete -F _comp_cmd_java java
-_javadoc()
+_comp_cmd_javadoc()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-overview | -helpfile)
- _filedir '?(x)htm?(l)'
+ _comp_compgen_filedir '?(x)htm?(l)'
return
;;
-doclet | -exclude | -subpackages | -source | -locale | -encoding | -windowtitle | \
@@ -255,49 +261,49 @@ _javadoc()
return
;;
-stylesheetfile)
- _filedir css
+ _comp_compgen_filedir css
return
;;
-d | -link | -linkoffline)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-classpath | -cp | -bootclasspath | -docletpath | -sourcepath | -extdirs | \
-excludedocfilessubdir)
- _java_path
+ _comp_cmd_java__classpath
return
;;
esac
# -linkoffline takes two arguments
if [[ $cword -gt 2 && ${words[cword - 2]} == -linkoffline ]]; then
- _filedir -d
+ _comp_compgen_filedir -d
return
fi
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
else
# source files completion
- _filedir java
+ _comp_compgen_filedir java
# packages completion
- _java_packages
+ _comp_cmd_java__packages
fi
} &&
- complete -F _javadoc javadoc
+ complete -F _comp_cmd_javadoc javadoc
-_javac()
+_comp_cmd_javac()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
case $prev in
-d)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-cp | -classpath | -bootclasspath | -sourcepath | -extdirs)
- _java_path
+ _comp_cmd_java__classpath
return
;;
esac
@@ -311,23 +317,23 @@ _javac()
# the others.
local opts=$("$1" $helpopt 2>&1 | command sed -e 's/-g:none/-g:{none}/' -ne \
"s/^[[:space:]]*${cur%%:*}:{\([^}]\{1,\}\)}.*/\1/p")
- COMPREPLY=($(compgen -W "${opts//,/ }" -- "${cur#*:}"))
+ _comp_compgen -c "${cur#*:}" -- -W "${opts//,/ }"
return
fi
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
[[ $cur == -X* ]] &&
- COMPREPLY+=($(compgen -W '$(_parse_help "$1" -X)' -- "$cur"))
+ _comp_compgen -a help -- -X
else
# source files completion
- _filedir java
+ _comp_compgen_filedir java
fi
[[ ${COMPREPLY-} == -*[:=] ]] && compopt -o nospace
- __ltrim_colon_completions "$cur"
+ _comp_ltrim_colon_completions "$cur"
} &&
- complete -F _javac javac
+ complete -F _comp_cmd_javac javac
# ex: filetype=sh
diff --git a/completions/javaws b/completions/javaws
index f42a1e5..cd6c848 100644
--- a/completions/javaws
+++ b/completions/javaws
@@ -1,20 +1,20 @@
# javaws(1) completion -*- shell-script -*-
-_javaws()
+_comp_cmd_javaws()
{
- local cur prev words cword
- _init_completion -n = || return
+ local cur prev words cword comp_args
+ _comp_initialize -n = -- "$@" || return
case $prev in
-help | -license | -about | -viewer | -arg | -param | -property | -update | -umask)
return
;;
-basedir | -codebase)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-uninstall | -import)
- _filedir jnlp
+ _comp_compgen_filedir jnlp
return
;;
esac
@@ -22,13 +22,13 @@ _javaws()
if [[ $cur == *= ]]; then
return
elif [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W "$(_parse_help "$1" -help) " -- "$cur"))
+ _comp_compgen_help -- -help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir jnlp
+ _comp_compgen_filedir jnlp
} &&
- complete -F _javaws javaws
+ complete -F _comp_cmd_javaws javaws
# ex: filetype=sh
diff --git a/completions/jpegoptim b/completions/jpegoptim
index c366972..7409854 100644
--- a/completions/jpegoptim
+++ b/completions/jpegoptim
@@ -1,38 +1,40 @@
# jpegoptim(1) completion -*- shell-script -*-
-_jpegoptim()
+_comp_cmd_jpegoptim()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[dmTS]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | -!(-*)[hV]*)
+ --help | --version | -${noargopts}[hV]*)
return
;;
- --dest | -!(-*)d)
- _filedir -d
+ --dest | -${noargopts}d)
+ _comp_compgen_filedir -d
return
;;
- --max | --threshold | -!(-*)[mT])
- COMPREPLY=($(compgen -W '{0..100}' -- "$cur"))
+ --max | --threshold | -${noargopts}[mT])
+ _comp_compgen -- -W '{0..100}'
return
;;
- --size | -!(-*)S)
- COMPREPLY=($(compgen -W '{1..99}%' -- "$cur"))
+ --size | -${noargopts}S)
+ _comp_compgen -- -W '{1..99}%'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir 'jp?(e)g'
+ _comp_compgen_filedir 'jp?(e)g'
} &&
- complete -F _jpegoptim jpegoptim
+ complete -F _comp_cmd_jpegoptim jpegoptim
# ex: filetype=sh
diff --git a/completions/jps b/completions/jps
index a451eec..324ba0e 100644
--- a/completions/jps
+++ b/completions/jps
@@ -1,9 +1,9 @@
# jps(1) completion -*- shell-script -*-
-_jps()
+_comp_cmd_jps()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-J* | -help)
@@ -12,14 +12,14 @@ _jps()
esac
if [[ $cur == -* ]]; then
- # Not using _parse_usage because output has [-help] which does not
- # mean -h, -e, -l, -p...
- COMPREPLY=($(compgen -W "-q -m -l -v -V -J -help" -- "$cur"))
+ # Not using _comp_compgen_usage because output has [-help] which does
+ # not mean -h, -e, -l, -p...
+ _comp_compgen -- -W "-q -m -l -v -V -J -help"
[[ ${COMPREPLY-} == -J* ]] && compopt -o nospace
else
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
fi
} &&
- complete -F _jps jps
+ complete -F _comp_cmd_jps jps
# ex: filetype=sh
diff --git a/completions/jq b/completions/jq
index 2d99c39..7021d2a 100644
--- a/completions/jq
+++ b/completions/jq
@@ -1,24 +1,26 @@
# jq(1) completion -*- shell-script -*-
-_jq()
+_comp_cmd_jq()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[fL]*)'
+ # shellcheck disable=SC2254
case $prev in
--help | --version | --arg | --argjson | --slurpfile | --argfile)
return
;;
--indent)
- COMPREPLY=($(compgen -W '{1..8}' -- "$cur"))
+ _comp_compgen -- -W '{1..8}'
return
;;
- --from-file | --run-tests | -!(-*)f)
- _filedir
+ --from-file | --run-tests | -${noargopts}f)
+ _comp_compgen_filedir
return
;;
- -!(-*)L)
- _filedir -d
+ -${noargopts}L)
+ _comp_compgen_filedir -d
return
;;
esac
@@ -29,26 +31,49 @@ _jq()
return
;;
--slurpfile | --argfile)
- _filedir json
+ _comp_compgen_filedir 'json?(l)'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ # Get jq's --help output and see whether it mentions --help
+ # jq's --help only shows some of its command-line options; some are not
+ # even listed in the man page!
+ local help_output=$("$1" --help 2>/dev/null)
+
+ if [[ $help_output == *--help* ]]; then
+ # If the output of --help seems complete, use it
+ _comp_compgen_help - <<<"$help_output"
+ else
+ # Otherwise, use a hard-coded list of known flags, some of which do
+ # not appear in the output of --help as of jq 1.6.
+ _comp_compgen -- -W '--version --seq --stream --slurp --raw-input
+ --null-input --compact-output --tab --indent --color-output
+ -monochrome-output --ascii-output --unbuffered --sort-keys
+ --raw-output --join-output --from-file --exit-status --arg
+ --argjson --slurpfile --rawfile --argfile --args --jsonargs
+ --run-tests --help'
+ fi
return
fi
- local args
+ local word
+ for word in "${words[@]}"; do
+ [[ $word != --?(json)args ]] || return
+ done
+
+ local REPLY
# TODO: DTRT with args taking 2 options
- _count_args "" "@(--arg|--arg?(json|file)|--?(slurp|from-)file|--indent|--run-tests|-!(-*)[fL])"
+ # -f|--from-file are not counted here because they supply the filter
+ _comp_count_args -a "@(--arg|--arg?(json|file)|--slurpfile|--indent|--run-tests|-${noargopts}L)"
# 1st arg is filter
- ((args == 1)) && return
+ ((REPLY == 1)) && return
# 2... are input files
- _filedir json
+ _comp_compgen_filedir 'json?(l)'
} &&
- complete -F _jq jq
+ complete -F _comp_cmd_jq jq
# ex: filetype=sh
diff --git a/completions/jshint b/completions/jshint
index 3622cec..27a529e 100644
--- a/completions/jshint
+++ b/completions/jshint
@@ -1,38 +1,38 @@
# bash completion for jshint -*- shell-script -*-
-_jshint()
+_comp_cmd_jshint()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-v | --version | -h | --help | --exclude | --filename | -e | --extra-ext)
return
;;
-c | --config)
- _filedir
+ _comp_compgen_filedir
return
;;
--reporter)
- COMPREPLY=($(compgen -W "jslint checkstyle unix" -- "$cur"))
+ _comp_compgen -- -W "jslint checkstyle unix"
return
;;
--extract)
- COMPREPLY=($(compgen -W "auto always never" -- "$cur"))
+ _comp_compgen -- -W "auto always never"
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir js
+ _comp_compgen_filedir js
} &&
- complete -F _jshint jshint
+ complete -F _comp_cmd_jshint jshint
# ex: filetype=sh
diff --git a/completions/json_xs b/completions/json_xs
index c93ba86..d894526 100644
--- a/completions/json_xs
+++ b/completions/json_xs
@@ -1,21 +1,20 @@
# json_xs completion -*- shell-script -*-
-_json_xs()
+_comp_cmd_json_xs()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*f)
- COMPREPLY=($(compgen -W 'json cbor storable storable-file bencode
- clzf eval yaml string none' -- "$cur"))
+ _comp_compgen -- -W 'json cbor storable storable-file bencode clzf
+ eval yaml string none'
return
;;
-*t)
- COMPREPLY=($(compgen -W 'json json-utf-8 json-pretty
- json-utf-16le json-utf-16be json-utf-32le json-utf-32be
- cbor storable storable-file bencode clzf yaml dump dumper
- string none' -- "$cur"))
+ _comp_compgen -- -W 'json json-utf-8 json-pretty json-utf-16le
+ json-utf-16be json-utf-32le json-utf-32be cbor storable
+ storable-file bencode clzf yaml dump dumper string none'
return
;;
-*e)
@@ -23,9 +22,11 @@ _json_xs()
;;
esac
- [[ $cur == -* ]] &&
- COMPREPLY=($(compgen -W '$(_parse_usage "$1") -f' -- "$cur"))
+ if [[ $cur == -* ]]; then
+ _comp_compgen_usage
+ _comp_compgen -a -- -W '-f'
+ fi
} &&
- complete -F _json_xs json_xs
+ complete -F _comp_cmd_json_xs json_xs
# ex: filetype=sh
diff --git a/completions/jsonschema b/completions/jsonschema
index 8a36ed3..19a4439 100644
--- a/completions/jsonschema
+++ b/completions/jsonschema
@@ -1,30 +1,30 @@
# bash completion for jsonschema -*- shell-script -*-
-_jsonschema()
+_comp_cmd_jsonschema()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--help | --error-format | --validator | -[hFV])
return
;;
--instance | -i)
- _filedir json
+ _comp_compgen_filedir json
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- local args
- _count_args "" "-*"
- ((args == 1)) || return
- _filedir '@(json|schema)'
+ local REPLY
+ _comp_count_args -a "-*"
+ ((REPLY == 1)) || return
+ _comp_compgen_filedir '@(json|schema)'
} &&
- complete -F _jsonschema jsonschema
+ complete -F _comp_cmd_jsonschema jsonschema
# ex: filetype=sh
diff --git a/completions/k3b b/completions/k3b
index 87d26cd..960e046 100644
--- a/completions/k3b
+++ b/completions/k3b
@@ -1,48 +1,48 @@
# bash completion for k3b -*- shell-script -*-
-_k3b()
+_comp_cmd_k3b()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--help* | --author | -v | --version | --license | --lang)
return
;;
--datacd | --audiocd | --videocd | --mixedcd | --emovixcd | --videodvd)
- _filedir
+ _comp_compgen_filedir
return
;;
--copydvd | --formatdvd | --videodvdrip)
- _dvd_devices
+ _comp_compgen_dvd_devices
return
;;
--copycd | --erasecd | --cddarip | --videocdrip)
- _cd_devices
- _dvd_devices
+ _comp_compgen_cd_devices
+ _comp_compgen -a dvd_devices
return
;;
--cdimage | --image)
- _filedir '@(cue|iso|toc)'
+ _comp_compgen_filedir '@(cue|iso|toc)'
return
;;
--dvdimage)
- _filedir iso
+ _comp_compgen_filedir iso
return
;;
--ao)
- COMPREPLY=($(compgen -W 'alsa arts' -- "$cur"))
+ _comp_compgen -- -W 'alsa arts'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W "$(_parse_help "$1")" -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _k3b k3b
+ complete -F _comp_cmd_k3b k3b
# ex: filetype=sh
diff --git a/completions/kcov b/completions/kcov
index 672967a..20a62f2 100644
--- a/completions/kcov
+++ b/completions/kcov
@@ -1,30 +1,28 @@
# kcov(1) completion -*- shell-script -*-
-_kcov()
+_comp_cmd_kcov()
{
- local cur prev words cword split
- _init_completion -s -n : || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -n : -- "$@" || return
case "$prev" in
--pid | -p)
- _pids
+ _comp_compgen_pids
return
;;
--sort-type | -s)
- COMPREPLY=($(compgen -W 'filename percent reverse lines
- uncovered' -- "$cur"))
+ _comp_compgen -- -W 'filename percent reverse lines uncovered'
return
;;
--include-path | --exclude-path)
- _filedir
+ _comp_compgen_filedir
return
;;
--replace-src-path)
if [[ $cur == ?*:* ]]; then
- cur="${cur##*:}"
- _filedir
+ _comp_compgen -c "${cur##*:}" filedir
else
- _filedir
+ _comp_compgen_filedir
compopt -o nospace
fi
return
@@ -33,12 +31,12 @@ _kcov()
if [[ $cur == ?*,* ]]; then
prev="${cur%,*}"
cur="${cur##*,}"
- COMPREPLY=($(compgen -W "{0..100}" -- "$cur"))
+ _comp_compgen -- -W "{0..100}"
((${#COMPREPLY[@]} == 1)) &&
- COMPREPLY=(${COMPREPLY/#/$prev,})
+ _comp_compgen -Rv COMPREPLY -- -P "$prev," -W '"$COMPREPLY"'
else
- COMPREPLY=($(compgen -W "{0..100}" -- "$cur"))
- ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/%/,})
+ _comp_compgen -- -W "{0..100}"
+ ((${#COMPREPLY[@]} == 1)) && COMPREPLY=("${COMPREPLY/%/,}")
compopt -o nospace
fi
return
@@ -49,16 +47,16 @@ _kcov()
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _kcov kcov
+ complete -F _comp_cmd_kcov kcov
# ex: filetype=sh
diff --git a/completions/kill b/completions/kill
index 25cddba..266ea13 100644
--- a/completions/kill
+++ b/completions/kill
@@ -1,29 +1,30 @@
# kill(1) completion -*- shell-script -*-
-_kill()
+_comp_cmd_kill()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-s)
- _signals
+ _comp_compgen_signals
return
;;
- -l)
+ -l | -n)
return
;;
esac
if [[ $cword -eq 1 && $cur == -* ]]; then
# return list of available signals
- _signals -
- COMPREPLY+=($(compgen -W "-s -l" -- "$cur"))
+ _comp_compgen_signals -
+ _comp_compgen -a help -c help "$1"
else
- # return list of available PIDs
- _pids
+ # return list of available PIDs and jobs
+ _comp_compgen_pids
+ _comp_compgen -ac "${cur#%}" -- -j -P %
fi
} &&
- complete -F _kill kill
+ complete -F _comp_cmd_kill kill
# ex: filetype=sh
diff --git a/completions/killall b/completions/killall
index c7c0b0f..76f8759 100644
--- a/completions/killall
+++ b/completions/killall
@@ -2,35 +2,37 @@
[[ $OSTYPE == *@(linux|freebsd|darwin)* ]] || return 1
-_killall()
+_comp_cmd_killall()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[Zoysu]*)'
+ # shellcheck disable=SC2254
case $prev in
- --context | --older-than | --younger-than | --version | -!(-*)@([Zoy]|V*))
+ --context | --older-than | --younger-than | --version | -${noargopts}@([Zoy]|V*))
return
;;
- --signal | -!(-*)s)
- _signals
+ --signal | -${noargopts}s)
+ _comp_compgen_signals
return
;;
- --user | -!(-*)u)
- _allowed_users
+ --user | -${noargopts}u)
+ _comp_compgen_allowed_users
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
- ((cword == 1)) && _signals -
+ _comp_compgen_help
+ ((cword == 1)) && _comp_compgen -a signals -
return
fi
- _pnames
+ _comp_compgen_pnames
} &&
- complete -F _killall killall
+ complete -F _comp_cmd_killall killall
# ex: filetype=sh
diff --git a/completions/kldload b/completions/kldload
index f511158..3c2396d 100644
--- a/completions/kldload
+++ b/completions/kldload
@@ -2,20 +2,31 @@
[[ $OSTYPE == *freebsd* ]] || return 1
-_kldload()
+_comp_cmd_kldload()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- local moddir=/modules/
- [[ -d $moddir ]] || moddir=/boot/kernel/
+ if _comp_looks_like_path "$cur"; then
+ _comp_compgen_filedir ko
+ return
+ fi
- compopt -o filenames
- COMPREPLY=($(compgen -f "$moddir$cur"))
- COMPREPLY=(${COMPREPLY[@]#$moddir})
- COMPREPLY=(${COMPREPLY[@]%.ko})
+ local moddirs modules i
+ if _comp_split -F ";" moddirs "$(kldconfig -r 2>/dev/null)"; then
+ compopt -o filenames
+ for i in "${moddirs[@]}"; do
+ _comp_compgen -v modules -c "$i/$cur" -- -f &&
+ COMPREPLY+=("${modules[@]#$i/}")
+ done
+ ((${#COMPREPLY[@]})) &&
+ COMPREPLY=("${COMPREPLY[@]%.ko}")
+ fi
+
+ # also add dirs in current dir
+ _comp_compgen -a filedir -d
} &&
- complete -F _kldload kldload
+ complete -F _comp_cmd_kldload kldload
# ex: filetype=sh
diff --git a/completions/kldunload b/completions/kldunload
index 2e12282..180af36 100644
--- a/completions/kldunload
+++ b/completions/kldunload
@@ -2,14 +2,14 @@
[[ $OSTYPE == *freebsd* ]] || return 1
-_kldunload()
+_comp_cmd_kldunload()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- COMPREPLY=($(compgen -W '$(kldstat)' -X 'kernel' -X '!*.ko' -- "$cur"))
- COMPREPLY=(${COMPREPLY[@]%.ko})
+ _comp_compgen_split -X '!*.ko' -- "$(kldstat)" &&
+ COMPREPLY=("${COMPREPLY[@]%.ko}")
} &&
- complete -F _kldunload kldunload
+ complete -F _comp_cmd_kldunload kldunload
# ex: filetype=sh
diff --git a/completions/koji b/completions/koji
index 8efef9a..8ee4390 100644
--- a/completions/koji
+++ b/completions/koji
@@ -1,74 +1,76 @@
# koji completion -*- shell-script -*-
-_koji_search()
+_comp_cmd_koji__search()
{
- COMPREPLY+=($(compgen -W \
- '$("$1" -q search $2 "$cur*" 2>/dev/null)' -- "$cur"))
+ _comp_compgen -a split -- "$("$1" -q search "$2" "$cur*" 2>/dev/null)"
}
-_koji_build()
+_comp_cmd_koji__build()
{
- _koji_search "$1" build
+ _comp_cmd_koji__search "$1" build
}
-_koji_package()
+_comp_cmd_koji__package()
{
- _koji_search "$1" package
+ _comp_cmd_koji__search "$1" package
}
-_koji_user()
+_comp_cmd_koji__user()
{
- _koji_search "$1" user
+ _comp_cmd_koji__search "$1" user
}
-_koji_tag()
+_comp_cmd_koji__tag()
{
- COMPREPLY+=($(compgen -W '$("$1" -q list-tags 2>/dev/null)' -- "$cur"))
+ _comp_compgen -a split -- "$("$1" -q list-tags 2>/dev/null)"
}
-_koji_target()
+_comp_cmd_koji__target()
{
- COMPREPLY+=($(compgen -W '$("$1" -q list-targets 2>/dev/null |
- awk "{ print \$1 }")' -- "$cur"))
+ _comp_compgen -a split -- "$("$1" -q list-targets 2>/dev/null |
+ _comp_awk '{ print $1 }')"
}
-_koji()
+_comp_cmd_koji()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
- local commandix command
+ local commandix command="" has_command=""
for ((commandix = 1; commandix < cword; commandix++)); do
if [[ ${words[commandix]} != -* ]]; then
command=${words[commandix]}
+ has_command=set
break
fi
done
+ local noargopts='!(-*|*[co]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --help-commands | -!(-*)h*)
+ --help | --help-commands | -${noargopts}h*)
return
;;
- --config | --keytab | -!(-*)[co])
- _filedir
+ --config | --keytab | -${noargopts}[co])
+ _comp_compgen_filedir
return
;;
--runas | --user | --editor | --by)
- _koji_user "$1"
+ _comp_cmd_koji__user "$1"
return
;;
--authtype)
- COMPREPLY=($(compgen -W 'noauth ssl password kerberos' -- "$cur"))
+ _comp_compgen -- -W 'noauth ssl password kerberos'
return
;;
--topdir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
--type)
case ${command-} in
latest-pkg | list-tagged)
- COMPREPLY=($(compgen -W 'maven' -- "$cur"))
+ _comp_compgen -- -W 'maven'
;;
esac
return
@@ -76,39 +78,38 @@ _koji()
--name)
case ${command-} in
list-targets)
- _koji_target "$1"
+ _comp_cmd_koji__target "$1"
;;
esac
return
;;
--owner)
- _koji_user "$1"
+ _comp_cmd_koji__user "$1"
return
;;
--tag | --latestfrom)
- _koji_tag "$1"
+ _comp_cmd_koji__tag "$1"
return
;;
--package)
- _koji_package "$1"
+ _comp_cmd_koji__package "$1"
return
;;
--build)
- _koji_build "$1"
+ _comp_cmd_koji__build "$1"
return
;;
--build-target)
- _koji_target "$1"
+ _comp_cmd_koji__target "$1"
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
- if [[ -v command ]]; then
+ if [[ $has_command ]]; then
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W \
- '$(_parse_help "$1" "$command --help")' -- "$cur"))
+ _comp_compgen_help -- "$command" --help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
@@ -123,108 +124,108 @@ _koji()
build | maven-build | win-build)
case $nth in
1)
- _koji_target "$1"
+ _comp_cmd_koji__target "$1"
;;
2)
- _filedir src.rpm
+ _comp_compgen_filedir src.rpm
;;
esac
;;
cancel)
- _koji_build "$1"
+ _comp_cmd_koji__build "$1"
;;
chain-build)
case $nth in
1)
- _koji_target "$1"
+ _comp_cmd_koji__target "$1"
;;
esac
;;
download-build)
case $nth in
1)
- _koji_build "$1"
+ _comp_cmd_koji__build "$1"
;;
esac
;;
import-comps)
case $nth in
1)
- _filedir xml
+ _comp_compgen_filedir xml
;;
2)
- _koji_tag "$1"
+ _comp_cmd_koji__tag "$1"
;;
esac
;;
latest-by-tag)
- _koji_package "$1"
+ _comp_cmd_koji__package "$1"
;;
latest-pkg | list-groups | list-tag-inheritance | show-groups)
case $nth in
1)
- _koji_tag "$1"
+ _comp_cmd_koji__tag "$1"
;;
esac
;;
list-tagged)
case $nth in
1)
- _koji_tag "$1"
+ _comp_cmd_koji__tag "$1"
;;
2)
- _koji_package "$1"
+ _comp_cmd_koji__package "$1"
;;
esac
;;
list-untagged)
case $nth in
1)
- _koji_package "$1"
+ _comp_cmd_koji__package "$1"
;;
esac
;;
move-pkg)
case $nth in
1 | 2)
- _koji_tag "$1"
+ _comp_cmd_koji__tag "$1"
;;
*)
- _koji_package "$1"
+ _comp_cmd_koji__package "$1"
;;
esac
;;
search)
case $nth in
1)
- COMPREPLY=($(compgen -W 'package build tag target
- user host rpm' -- "$cur"))
+ _comp_compgen -- -W 'package build tag target user host
+ rpm'
;;
esac
;;
tag-pkg | untag-pkg)
case $nth in
1)
- _koji_tag "$1"
+ _comp_cmd_koji__tag "$1"
;;
*)
- _koji_package "$1"
+ _comp_cmd_koji__package "$1"
;;
esac
;;
taginfo)
- _koji_tag "$1"
+ _comp_cmd_koji__tag "$1"
;;
wait-repo)
case $nth in
1)
for ((i = commandix + 1; i < cword; i++)); do
if [[ ${words[i]} == --target ]]; then
- _koji_target "$1"
+ _comp_cmd_koji__target "$1"
return
fi
done
- _koji_tag "$1"
+ _comp_cmd_koji__tag "$1"
;;
esac
;;
@@ -233,13 +234,13 @@ _koji()
fi
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
- elif [[ ! -v command ]]; then
- COMPREPLY=($(compgen -W '$("$1" --help-commands 2>/dev/null | \
- awk "/^( +|\t)/ { print \$1 }")' -- "$cur"))
+ elif [[ ! $has_command ]]; then
+ _comp_compgen_split -- "$("$1" --help-commands 2>/dev/null |
+ _comp_awk '/^( +|\t)/ { print $1 }')"
fi
} &&
- complete -F _koji koji arm-koji ppc-koji s390-koji sparc-koji
+ complete -F _comp_cmd_koji koji arm-koji ppc-koji s390-koji sparc-koji
# ex: filetype=sh
diff --git a/completions/ktutil b/completions/ktutil
index 6030a47..d25dafc 100644
--- a/completions/ktutil
+++ b/completions/ktutil
@@ -1,55 +1,54 @@
# ktutil completion -*- shell-script -*-
-_heimdal_principals()
+_comp_cmd_ktutil__heimdal_principals()
{
- COMPREPLY=($(compgen -W "$(kadmin -l dump 2>/dev/null |
- awk '{print $1}')" -- "$cur"))
+ _comp_compgen_split -- "$(kadmin -l dump 2>/dev/null |
+ _comp_awk '{print $1}')"
}
-_heimdal_realms()
+_comp_cmd_ktutil__heimdal_realms()
{
- COMPREPLY=($(compgen -W "$(kadmin -l dump 2>/dev/null |
- awk '{print $1}' | awk -F@ '{print $2}')" -- "$cur"))
+ _comp_compgen_split -- "$(kadmin -l dump 2>/dev/null |
+ _comp_awk '{print $1}' | _comp_awk -F @ '{print $2}')"
}
-_heimdal_encodings()
+_comp_cmd_ktutil__heimdal_encodings()
{
- COMPREPLY=($(compgen -W 'des-cbc-mcrc des-cbc-md4 des-cbc-md5
- des3-cbc-sha1 arcfour-hmac-md5 aes128-cts-hmac-sha1-96
- aes256-cts-hmac-sha1-96' -- "$cur"))
+ _comp_compgen -- -W 'des-cbc-mcrc des-cbc-md4 des-cbc-md5 des3-cbc-sha1
+ arcfour-hmac-md5 aes128-cts-hmac-sha1-96 aes256-cts-hmac-sha1-96'
}
-_ktutil()
+_comp_cmd_ktutil()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
local command commands i options
case $prev in
-p | --principal)
- _heimdal_principals
+ _comp_cmd_ktutil__heimdal_principals
return
;;
-e | --enctype)
- _heimdal_encodings
+ _comp_cmd_ktutil__heimdal_encodings
return
;;
-a | --admin-server)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-r | --realm)
- _heimdal_realms
+ _comp_cmd_ktutil__heimdal_realms
return
;;
-s | -k | --srvtab | --keytab)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
commands='add change copy get list remove rename purge srvconvert
srv2keytab srvcreate key2srvtab'
@@ -97,24 +96,24 @@ _ktutil()
options='-k --keytab -v --verbose --version -v --help'
;;
esac
- COMPREPLY=($(compgen -W "$options" -- "$cur"))
+ _comp_compgen -- -W "$options"
else
case ${command-} in
copy)
- _filedir
+ _comp_compgen_filedir
;;
get)
- _heimdal_principals
+ _comp_cmd_ktutil__heimdal_principals
;;
rename)
- _heimdal_principals
+ _comp_cmd_ktutil__heimdal_principals
;;
*)
- COMPREPLY=($(compgen -W "$commands" -- "$cur"))
+ _comp_compgen -- -W "$commands"
;;
esac
fi
} &&
- complete -F _ktutil ktutil
+ complete -F _comp_cmd_ktutil ktutil
# ex: filetype=sh
diff --git a/completions/larch b/completions/larch
index 7ed9ca2..0df7537 100644
--- a/completions/larch
+++ b/completions/larch
@@ -1,13 +1,13 @@
# larch(1) completion -*- shell-script -*-
# by Alex Shinn <foof@synthcode.com>
-_larch()
+_comp_cmd_larch()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cword -eq 1 || $prev == -* ]]; then
- COMPREPLY=($(compgen -W ' \
+ _comp_compgen -- -W ' \
my-id my-default-archive register-archive whereis-archive archives \
init-tree tree-root tree-version set-tree-version inventory \
tagging-method tree-lint missing-tags add delete \
@@ -29,11 +29,10 @@ _larch()
touched-files-prereqs patch-set-web update-distributions \
distribution-name notify my-notifier mail-new-categories \
mail-new-branches mail-new-versions mail-new-revisions \
- notify-library notify-browser push-new-revisions sendmail-mailx' \
- "$cur"))
+ notify-library notify-browser push-new-revisions sendmail-mailx'
fi
} &&
- complete -F _larch -o default larch
+ complete -F _comp_cmd_larch -o default larch
# ex: filetype=sh
diff --git a/completions/lastlog b/completions/lastlog
index 214a174..8faf82b 100644
--- a/completions/lastlog
+++ b/completions/lastlog
@@ -1,25 +1,27 @@
# lastlog(8) completion -*- shell-script -*-
-_lastlog()
+_comp_cmd_lastlog()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[btu]*)'
+ # shellcheck disable=SC2254
case $prev in
- --before | --help | --time | -!(-*)@([bt]|h*))
+ --before | --help | --time | -${noargopts}@([bt]|h*))
return
;;
- --user | -!(-*)u)
- COMPREPLY=($(compgen -u -- "$cur"))
+ --user | -${noargopts}u)
+ _comp_compgen -- -u
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
} &&
- complete -F _lastlog lastlog
+ complete -F _comp_cmd_lastlog lastlog
# ex: filetype=sh
diff --git a/completions/ldapsearch b/completions/ldapsearch
index 6dc415e..71c728e 100644
--- a/completions/ldapsearch
+++ b/completions/ldapsearch
@@ -1,231 +1,238 @@
# bash completion for openldap -*- shell-script -*-
-_ldap_uris()
+_comp_cmd_ldapsearch__ldap_uris()
{
- COMPREPLY=($(compgen -W 'ldap:// ldaps://' -- "$cur"))
+ _comp_compgen -- -W 'ldap:// ldaps://'
}
-_ldap_protocols()
+_comp_cmd_ldapsearch__ldap_protocols()
{
- COMPREPLY=($(compgen -W '2 3' -- "$cur"))
+ _comp_compgen -- -W '2 3'
}
-_ldapsearch()
+_comp_cmd_ldapsearch()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*h)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-*H)
- _ldap_uris
+ _comp_cmd_ldapsearch__ldap_uris
return
;;
-*T)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-*[fy])
- _filedir
+ _comp_compgen_filedir
return
;;
-*s)
- COMPREPLY=($(compgen -W 'base one sub children' -- "$cur"))
+ _comp_compgen -- -W 'base one sub children'
return
;;
-*a)
- COMPREPLY=($(compgen -W 'never always search find' -- "$cur"))
+ _comp_compgen -- -W 'never always search find'
return
;;
-*P)
- _ldap_protocols
+ _comp_cmd_ldapsearch__ldap_protocols
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur"))
+ _comp_compgen_help
+ _comp_compgen -a -- -W '-MM -ZZ'
fi
} &&
- complete -F _ldapsearch ldapsearch
+ complete -F _comp_cmd_ldapsearch ldapsearch
-_ldapaddmodify()
+_comp_cmd_ldapadd()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*h)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-*H)
- _ldap_uris
+ _comp_cmd_ldapsearch__ldap_uris
return
;;
-*[Sfy])
- _filedir
+ _comp_compgen_filedir
return
;;
-*P)
- _ldap_protocols
+ _comp_cmd_ldapsearch__ldap_protocols
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur"))
+ _comp_compgen_help
+ _comp_compgen -a -- -W '-MM -ZZ'
fi
} &&
- complete -F _ldapaddmodify ldapadd ldapmodify
+ complete -F _comp_cmd_ldapadd ldapadd ldapmodify
-_ldapdelete()
+_comp_cmd_ldapdelete()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*h)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-*H)
- _ldap_uris
+ _comp_cmd_ldapsearch__ldap_uris
return
;;
-*[fy])
- _filedir
+ _comp_compgen_filedir
return
;;
-*P)
- _ldap_protocols
+ _comp_cmd_ldapsearch__ldap_protocols
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur"))
+ _comp_compgen_help
+ _comp_compgen -a -- -W '-MM -ZZ'
fi
} &&
- complete -F _ldapdelete ldapdelete
+ complete -F _comp_cmd_ldapdelete ldapdelete
-_ldapcompare()
+_comp_cmd_ldapcompare()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*h)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-*H)
- _ldap_uris
+ _comp_cmd_ldapsearch__ldap_uris
return
;;
-*y)
- _filedir
+ _comp_compgen_filedir
return
;;
-*P)
- _ldap_protocols
+ _comp_cmd_ldapsearch__ldap_protocols
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur"))
+ _comp_compgen_help
+ _comp_compgen -a -- -W '-MM -ZZ'
fi
} &&
- complete -F _ldapcompare ldapcompare
+ complete -F _comp_cmd_ldapcompare ldapcompare
-_ldapmodrdn()
+_comp_cmd_ldapmodrdn()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*h)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-*H)
- _ldap_uris
+ _comp_cmd_ldapsearch__ldap_uris
return
;;
-*[fy])
- _filedir
+ _comp_compgen_filedir
return
;;
-*P)
- _ldap_protocols
+ _comp_cmd_ldapsearch__ldap_protocols
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1") -ZZ -MM' -- "$cur"))
+ _comp_compgen_help
+ _comp_compgen -a -- -W '-ZZ -MM'
fi
} &&
- complete -F _ldapmodrdn ldapmodrdn
+ complete -F _comp_cmd_ldapmodrdn ldapmodrdn
-_ldapwhoami()
+_comp_cmd_ldapwhoami()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*h)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-*H)
- _ldap_uris
+ _comp_cmd_ldapsearch__ldap_uris
return
;;
-*[fy])
- _filedir
+ _comp_compgen_filedir
return
;;
-*P)
- _ldap_protocols
+ _comp_cmd_ldapsearch__ldap_protocols
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur"))
+ _comp_compgen_help
+ _comp_compgen -a -- -W '-MM -ZZ'
fi
} &&
- complete -F _ldapwhoami ldapwhoami
+ complete -F _comp_cmd_ldapwhoami ldapwhoami
-_ldappasswd()
+_comp_cmd_ldappasswd()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*h)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-*H)
- _ldap_uris
+ _comp_cmd_ldapsearch__ldap_uris
return
;;
-*[tTy])
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur"))
+ _comp_compgen_help
+ _comp_compgen -a -- -W '-MM -ZZ'
fi
} &&
- complete -F _ldappasswd ldappasswd
+ complete -F _comp_cmd_ldappasswd ldappasswd
# ex: filetype=sh
diff --git a/completions/ldapvi b/completions/ldapvi
index cb01ac8..d86cf55 100644
--- a/completions/ldapvi
+++ b/completions/ldapvi
@@ -1,51 +1,52 @@
# bash completion for ldapvi -*- shell-script -*-
-_ldapvi()
+_comp_cmd_ldapvi()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[Y]*)'
+ # shellcheck disable=SC2254
case $prev in
- --host | -!(-*)h)
- _known_hosts_real -- "$cur"
+ --host | -${noargopts}h)
+ _comp_compgen_known_hosts -- "$cur"
return
;;
- --sasl-mech | -!(-*)Y)
- COMPREPLY=($(compgen -W 'EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5
- PLAIN ANONYMOUS' -- "$cur"))
+ --sasl-mech | -${noargopts}Y)
+ _comp_compgen -- -W 'EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 PLAIN
+ ANONYMOUS'
return
;;
--bind)
- COMPREPLY=($(compgen -W 'simple sasl' -- "$cur"))
+ _comp_compgen -- -W 'simple sasl'
return
;;
--bind-dialog)
- COMPREPLY=($(compgen -W 'never auto always' -- "$cur"))
+ _comp_compgen -- -W 'never auto always'
return
;;
--scope)
- COMPREPLY=($(compgen -W 'base one sub' -- "$cur"))
+ _comp_compgen -- -W 'base one sub'
return
;;
--deref)
- COMPREPLY=($(compgen -W 'never searching finding always' \
- -- "$cur"))
+ _comp_compgen -- -W 'never searching finding always'
return
;;
--encoding)
- COMPREPLY=($(compgen -W 'ASCII UTF-8 binary' -- "$cur"))
+ _comp_compgen -- -W 'ASCII UTF-8 binary'
return
;;
--tls)
- COMPREPLY=($(compgen -W 'never allow try strict' -- "$cur"))
+ _comp_compgen -- -W 'never allow try strict'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
fi
} &&
- complete -F _ldapvi ldapvi
+ complete -F _comp_cmd_ldapvi ldapvi
# ex: filetype=sh
diff --git a/completions/lftp b/completions/lftp
index 72dedb4..16264cf 100644
--- a/completions/lftp
+++ b/completions/lftp
@@ -1,28 +1,30 @@
# lftp(1) completion -*- shell-script -*-
-_lftp()
+_comp_cmd_lftp()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[fceups]*)'
+ # shellcheck disable=SC2254
case $prev in
- -!(-*)f)
- _filedir
+ -${noargopts}f)
+ _comp_compgen_filedir
return
;;
- --help | --version | -!(-*)[chveups])
+ --help | --version | -${noargopts}[chveups])
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- COMPREPLY=($(compgen -W '$("$1" -c "bookmark list" 2>/dev/null)' -- "$cur"))
- _known_hosts_real -- "$cur"
+ _comp_compgen_split -- "$("$1" -c "bookmark list" 2>/dev/null)"
+ _comp_compgen -a known_hosts -- "$cur"
} &&
- complete -F _lftp lftp
+ complete -F _comp_cmd_lftp lftp
# ex: filetype=sh
diff --git a/completions/lftpget b/completions/lftpget
index d21622e..a41ad0c 100644
--- a/completions/lftpget
+++ b/completions/lftpget
@@ -1,14 +1,14 @@
# lftpget(1) completion -*- shell-script -*-
-_lftpget()
+_comp_cmd_lftpget()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-c -d -v' -- "$cur"))
+ _comp_compgen -- -W '-c -d -v'
fi
} &&
- complete -F _lftpget lftpget
+ complete -F _comp_cmd_lftpget lftpget
# ex: filetype=sh
diff --git a/completions/lilo b/completions/lilo
index af8539a..6df8566 100644
--- a/completions/lilo
+++ b/completions/lilo
@@ -1,66 +1,63 @@
# bash completion for lilo(8) -*- shell-script -*-
-_lilo_labels()
+_comp_cmd_lilo__labels()
{
- COMPREPLY=($(compgen -W "$(awk -F= '$1 ~ /^[ \t]*label$/ {print $2}' \
- ${1:-/etc/lilo.conf} 2>/dev/null | command sed -e 's/\"//g')" \
- -- "$cur"))
+ _comp_compgen_split -- "$(_comp_awk -F = '$1 ~ /^[ \t]*label$/ {print $2}' \
+ "${1:-/etc/lilo.conf}" 2>/dev/null | command sed -e 's/\"//g')"
}
-_lilo()
+_comp_cmd_lilo()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-C | -i | -m | -s | -S)
- _filedir
+ _comp_compgen_filedir
return
;;
-r)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-I | -D | -R)
# label completion
- local i conf
+ local i conf=""
for i in "${!words[@]}"; do
if [[ ${words[i]} == -C ]]; then
- conf=${words[i + 1]}
+ conf=${words[i + 1]-}
break
fi
done
- _lilo_labels $conf
+ _comp_cmd_lilo__labels "$conf"
return
;;
-A | -b | -M | -u | -U)
# device completion
- cur=${cur:=/dev/}
- _filedir
+ _comp_compgen -c "${cur:-/dev/}" filedir
return
;;
-T)
# topic completion
- COMPREPLY=($(compgen -W 'help ChRul EBDA geom geom= table=
- video' -- "$cur"))
+ _comp_compgen -- -W 'help ChRul EBDA geom geom= table= video'
return
;;
-B)
- _filedir bmp
+ _comp_compgen_filedir bmp
return
;;
-E)
- _filedir '@(bmp|dat)'
+ _comp_compgen_filedir '@(bmp|dat)'
return
;;
esac
if [[ $cur == -* ]]; then
# relevant options completion
- COMPREPLY=($(compgen -W '-A -B -b -c -C -d -E -f -g -i -I -l -L -m -M
- -p -P -q -r -R -s -S -t -T -u -U -v -V -w -x -z' -- "$cur"))
+ _comp_compgen -- -W '-A -B -b -c -C -d -E -f -g -i -I -l -L -m -M -p -P
+ -q -r -R -s -S -t -T -u -U -v -V -w -x -z'
fi
} &&
- complete -F _lilo lilo
+ complete -F _comp_cmd_lilo lilo
# ex: filetype=sh
diff --git a/completions/links b/completions/links
index e0c28e2..989e9e0 100644
--- a/completions/links
+++ b/completions/links
@@ -1,17 +1,17 @@
# bash completion for links -*- shell-script -*-
-_links()
+_comp_cmd_links()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
case $prev in
-html-t-text-color | -html-t-link-color)
- COMPREPLY=($(compgen -W '{0..15}' -- "$cur"))
+ _comp_compgen -- -W '{0..15}'
return
;;
-http.fake-firefox | -html-[gt]-ignore-document-color)
- COMPREPLY=($(compgen -W '0 1' -- "$cur"))
+ _comp_compgen -- -W '0 1'
return
;;
--help | -help | -mode | -display | -source | -dump | -width | -max-connections | \
@@ -23,78 +23,78 @@ _links()
return
;;
-lookup)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-driver)
local drivers=$("$1" -driver foo 2>&1 |
command sed -ne '$!d' -e '/^[a-z0-9, ]\{1,\}$/s/,/ /gp')
[[ $drivers ]] || drivers='x svgalib fb directfb pmshell atheos'
- COMPREPLY=($(compgen -W "$drivers" -- "$cur"))
+ _comp_compgen -- -W "$drivers"
return
;;
-codepage | -bookmarks-codepage | -http-assume-codepage)
- _xfunc iconv _iconv_charsets
+ _comp_compgen -x iconv charsets
return
;;
-download-dir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-bind-address)
- _ip_addresses
+ _comp_compgen_ip_addresses
return
;;
-bind-address-ipv6)
- _ip_addresses -6
- __ltrim_colon_completions "$cur"
+ _comp_compgen_ip_addresses -6
return
;;
-async-dns | -download-utime | -aggressive-cache | -only-proxies | \
-http-bugs.* | -http.do-not-track | -ftp.use-* | -ftp.fast | -ftp.set-iptos | \
-smb.allow-hyperlinks-to-smb | -save-url-history | -dither-letters | \
-dither-images | -overwrite-instead-of-scroll | -html-*)
- COMPREPLY=($(compgen -W '0 1' -- "$cur"))
+ _comp_compgen -- -W '0 1'
return
;;
-address-preference | -http.referer)
- COMPREPLY=($(compgen -W '{0..4}' -- "$cur"))
+ _comp_compgen -- -W '{0..4}'
return
;;
-ssl-certificates | -display-optimize | -gamma-correction)
- COMPREPLY=($(compgen -W '{0..2}' -- "$cur"))
+ _comp_compgen -- -W '{0..2}'
return
;;
-ssl.client-cert-key)
- _filedir '@(key|pem)'
+ _comp_compgen_filedir '@(key|pem)'
return
;;
-ssl.client-cert-crt)
- _filedir '@(c?(e)rt|cer|pem|der)'
+ _comp_compgen_filedir '@(c?(e)rt|cer|pem|der)'
return
;;
-bookmarks-file)
- _filedir html
+ _comp_compgen_filedir html
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" |
- command grep -vF -- "->")' -- "$cur"))
+ _comp_compgen -R help
+ ((${#COMPREPLY[@]})) &&
+ _comp_compgen -- -W '"${COMPREPLY[@]}"' -X "->"
return
fi
local dir
for dir in .links .links2; do
if [[ -r ~/$dir/links.his ]]; then
- COMPREPLY+=($(compgen -W '$(cat ~/$dir/links.his)' -- "$cur"))
- __ltrim_colon_completions "$cur"
+ _comp_compgen -a split -- "$(cat ~/$dir/links.his)"
+ _comp_ltrim_colon_completions "$cur"
fi
done
- _filedir '@(htm|html)'
+ _comp_compgen -a filedir '@(htm|html)'
} &&
- complete -F _links links links2
+ complete -F _comp_cmd_links links links2
# ex: filetype=sh
diff --git a/completions/lintian b/completions/lintian
index 9343832..51402b2 100644
--- a/completions/lintian
+++ b/completions/lintian
@@ -1,74 +1,73 @@
# bash completion for lintian(1) and lintian-info(1) -*- shell-script -*-
-_lintian_tags()
+_comp_cmd_lintian__tags()
{
- local match search tags
+ local search tags check_files
+ _comp_expand_glob check_files '/usr/share/lintian/checks/*.desc' || return 0
- tags=$(awk '/^Tag/ { print $2 }' /usr/share/lintian/checks/*.desc)
+ tags=$(_comp_awk '/^Tag/ { print $2 }' "${check_files[@]}")
if [[ $cur == *, ]]; then
search=${cur//,/ }
for item in $search; do
- match=$(command grep -nE "^Tag: $item$" \
- /usr/share/lintian/checks/*.desc | cut -d: -f1)
- tags=$(command sed -e "s/\<$item\>//g" <<<$tags)
+ tags=$(command sed -e "s/\<$item\>//g" <<<"$tags")
done
- COMPREPLY+=($(compgen -W "$tags"))
+ _comp_compgen -aR -- -W "$tags"
elif [[ $cur == *,* ]]; then
- COMPREPLY+=($(compgen -P "${cur%,*}," -W "$tags" -- "${cur##*,}"))
+ _comp_compgen -ac "${cur##*,}" -- -P "${cur%,*}," -W "$tags"
else
- COMPREPLY+=($(compgen -W "$tags" -- "$cur"))
+ _comp_compgen -a -- -W "$tags"
fi
}
-_lintian_checks()
+_comp_cmd_lintian__checks()
{
- local match search todisable checks
+ local match search todisable checks check_files
+ _comp_expand_glob check_files '/usr/share/lintian/checks/*.desc' || return 0
- checks=$(awk '/^(Check-Script|Abbrev)/ { print $2 }' \
- /usr/share/lintian/checks/*.desc)
+ checks=$(_comp_awk '/^(Check-Script|Abbrev)/ { print $2 }' \
+ "${check_files[@]}")
if [[ $cur == *, ]]; then
search=${cur//,/ }
for item in $search; do
match=$(command grep -nE "^(Check-Script|Abbrev): $item$" \
- /usr/share/lintian/checks/*.desc | cut -d: -f1)
- todisable=$(awk '/^(Check-Script|Abbrev)/ { print $2 }' $match)
+ "${check_files[@]}" | cut -d: -f1)
+ todisable=$(_comp_awk '/^(Check-Script|Abbrev)/ { print $2 }' "$match")
for name in $todisable; do
- checks=$(command sed -e "s/\<$name\>//g" <<<$checks)
+ checks=$(command sed -e "s/\<$name\>//g" <<<"$checks")
done
done
- COMPREPLY+=($(compgen -W "$checks"))
+ _comp_compgen -aR -- -W "$checks"
elif [[ $cur == *,* ]]; then
- COMPREPLY+=($(compgen -P "${cur%,*}," -W "$checks" -- "${cur##*,}"))
+ _comp_compgen -ac "${cur##*,}" -- -P "${cur%,*}," -W "$checks"
else
- COMPREPLY+=($(compgen -W "$checks" -- "$cur"))
+ _comp_compgen -a -- -W "$checks"
fi
}
-_lintian_infos()
+_comp_cmd_lintian__infos()
{
- local match search infos
+ local search infos collection_files
+ _comp_expand_glob collection_files '/usr/share/lintian/collection/*.desc' || return 0
- infos=$(awk '/^Collector/ { print $2 }' \
- /usr/share/lintian/collection/*.desc)
+ infos=$(_comp_awk '/^Collector/ { print $2 }' \
+ "${collection_files[@]}")
if [[ $cur == *, ]]; then
search=${cur//,/ }
for item in $search; do
- match=$(command grep -nE "^Collector: $item$" \
- /usr/share/lintian/collection/*.desc | cut -d: -f1)
- infos=$(command sed -e "s/\<$item\>//g" <<<$infos)
+ infos=$(command sed -e "s/\<$item\>//g" <<<"$infos")
done
- COMPREPLY+=($(compgen -W "$infos"))
+ _comp_compgen -aR -- -W "$infos"
elif [[ $cur == *,* ]]; then
- COMPREPLY+=($(compgen -P "${cur%,*}," -W "$infos" -- "${cur##*,}"))
+ _comp_compgen -ac "${cur##*,}" -- -P "${cur%,*}," -W "$infos"
else
- COMPREPLY+=($(compgen -W "$infos" -- "$cur"))
+ _comp_compgen -a -- -W "$infos"
fi
}
-_lintian()
+_comp_cmd_lintian()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local lint_actions general_opts behaviour_opts configuration_opts
@@ -86,36 +85,44 @@ _lintian()
if [[ $prev == -* ]]; then
case $prev in
-C | --check-part | -X | --dont-check-part)
- _lintian_checks
+ _comp_cmd_lintian__checks
+ return
;;
-T | --tags | --suppress-tags)
- _lintian_tags
+ _comp_cmd_lintian__tags
+ return
;;
--tags-from-file | --suppress-tags-from-file | --cfg | -p | \
--packages-file)
- _filedir
+ _comp_compgen_filedir
+ return
;;
--lab | --archivedir | --dist | --root)
- _filedir -d
+ _comp_compgen_filedir -d
+ return
;;
--color)
- COMPREPLY=($(compgen -W "never always auto html" -- "$cur"))
+ _comp_compgen -- -W "never always auto html"
+ return
;;
-U | --unpack-info)
- _lintian_infos
+ _comp_cmd_lintian__infos
+ return
;;
--area | --section)
- COMPREPLY=($(compgen -W "main contrib non-free" -- "$cur"))
+ _comp_compgen -- -W "main contrib non-free"
+ return
+ ;;
+ --arch)
+ return
;;
- --arch) ;;
-
esac
fi
case "$cur" in
--*)
- COMPREPLY=($(compgen -W "$lint_actions $general_opts
- $behaviour_opts $configuration_opts" -- "$cur"))
+ _comp_compgen -- -W "$lint_actions $general_opts $behaviour_opts
+ $configuration_opts"
;;
*,)
# If we're here, the user is trying to complete on
@@ -123,54 +130,54 @@ _lintian()
# Only few actions permit that, re-complete them now.
case "$prev" in
-C | --check-part | -X | --dont-check-part)
- _lintian_checks
+ _comp_cmd_lintian__checks
;;
-T | --tags | --suppress-tags)
- _lintian_tags
+ _comp_cmd_lintian__tags
;;
-U | --unpack-info)
- _lintian_infos
+ _comp_cmd_lintian__infos
;;
esac
;;
*)
# in Ubuntu, dbgsym packages end in .ddeb, lintian >= 2.57.0 groks
- _filedir '@(?(u|d)deb|changes|dsc|buildinfo)'
+ _comp_compgen_filedir '@(?(u|d)deb|changes|dsc|buildinfo)'
;;
esac
return 0
} &&
- complete -F _lintian lintian
+ complete -F _comp_cmd_lintian lintian
-_lintian_info()
+_comp_cmd_lintian_info()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case "$prev" in
--help | --profile)
return
;;
-t | --tags)
- _lintian_tags
+ _comp_cmd_lintian__tags
return
;;
--include-dir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
case "$cur" in
--*)
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
;;
*)
- _filedir
+ _comp_compgen_filedir
;;
esac
return 0
} &&
- complete -F _lintian_info lintian-info
+ complete -F _comp_cmd_lintian_info lintian-info
# ex: filetype=sh
diff --git a/completions/lisp b/completions/lisp
index 098567b..c236092 100644
--- a/completions/lisp
+++ b/completions/lisp
@@ -2,21 +2,20 @@
# bash programmable completion for various Common Lisp implementations by
# Nikodemus Siivola <nikodemus@random-state.net>
-_lisp()
+_comp_cmd_lisp()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
# completing an option (may or may not be separated by a space)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-core -lib -batch -quit -edit -eval -init
- -dynamic-space-size -hinit -noinit -nositeinit -load -slave' \
- -- "$cur"))
+ _comp_compgen -- -W '-core -lib -batch -quit -edit -eval -init
+ -dynamic-space-size -hinit -noinit -nositeinit -load -slave'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _lisp -o default lisp
+ complete -F _comp_cmd_lisp -o default lisp
# ex: filetype=sh
diff --git a/completions/list_admins b/completions/list_admins
index 5708179..98452eb 100644
--- a/completions/list_admins
+++ b/completions/list_admins
@@ -1,17 +1,20 @@
# mailman list_admins completion -*- shell-script -*-
-_list_admins()
+_comp_cmd_list_admins()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--all-vhost --all --help' -- "$cur"))
+ _comp_compgen -- -W '--all-vhost --all --help'
else
- _xfunc list_lists _mailman_lists
+ # Prefer `list_lists` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -x list_lists mailman_lists
fi
} &&
- complete -F _list_admins list_admins
+ complete -F _comp_cmd_list_admins list_admins
# ex: filetype=sh
diff --git a/completions/list_lists b/completions/list_lists
index c5b9ba7..0ae00af 100644
--- a/completions/list_lists
+++ b/completions/list_lists
@@ -1,21 +1,25 @@
# mailman list_lists completion -*- shell-script -*-
-_mailman_lists()
+# @since 2.12
+_comp_xfunc_list_lists_compgen_mailman_lists()
{
- COMPREPLY=($(compgen -W '$(list_lists -b 2>/dev/null)' -- "$cur"))
+ _comp_compgen_split -- "$(list_lists -b 2>/dev/null)"
}
-_list_lists()
+_comp_deprecate_func 2.12 _mailman_lists \
+ _comp_xfunc_list_lists_compgen_mailman_lists
+
+_comp_cmd_list_lists()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--advertised --virtual-host-overview --bare
- --help' -- "$cur"))
+ _comp_compgen -- -W '--advertised --virtual-host-overview --bare
+ --help'
fi
} &&
- complete -F _list_lists list_lists
+ complete -F _comp_cmd_list_lists list_lists
# ex: filetype=sh
diff --git a/completions/list_members b/completions/list_members
index 639344c..a15a2cc 100644
--- a/completions/list_members
+++ b/completions/list_members
@@ -1,36 +1,38 @@
# mailman list_members completion -*- shell-script -*-
-_list_members()
+_comp_cmd_list_members()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-o | --output)
- _filedir
+ _comp_compgen_filedir
return
;;
-d | --digest)
- COMPREPLY=($(compgen -W 'mime plain' -- "$cur"))
+ _comp_compgen -- -W 'mime plain'
return
;;
-n | --nomail)
- COMPREPLY=($(compgen -W 'byadmin byuser bybounce unknown' \
- -- "$cur"))
+ _comp_compgen -- -W 'byadmin byuser bybounce unknown'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--output --regular --digest --nomail
- --fullnames --preserve --help' -- "$cur"))
+ _comp_compgen -- -W '--output --regular --digest --nomail --fullnames
+ --preserve --help'
else
- _xfunc list_lists _mailman_lists
+ # Prefer `list_lists` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -x list_lists mailman_lists
fi
} &&
- complete -F _list_members list_members
+ complete -F _comp_cmd_list_members list_members
# ex: filetype=sh
diff --git a/completions/list_owners b/completions/list_owners
index 445be0b..6179176 100644
--- a/completions/list_owners
+++ b/completions/list_owners
@@ -1,18 +1,20 @@
# mailman list_owners completion -*- shell-script -*-
-_list_owners()
+_comp_cmd_list_owners()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--with-listnames --moderators --help' \
- -- "$cur"))
+ _comp_compgen -- -W '--with-listnames --moderators --help'
else
- _xfunc list_lists _mailman_lists
+ # Prefer `list_lists` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -x list_lists mailman_lists
fi
} &&
- complete -F _list_owners list_owners
+ complete -F _comp_cmd_list_owners list_owners
# ex: filetype=sh
diff --git a/completions/locale-gen b/completions/locale-gen
index 4068201..0ac8598 100644
--- a/completions/locale-gen
+++ b/completions/locale-gen
@@ -1,32 +1,32 @@
# locale-gen(8) completion -*- shell-script -*-
-_locale_gen()
+_comp_cmd_locale_gen()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
--help | -h)
return
;;
--aliases)
- _filedir alias
+ _comp_compgen_filedir alias
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- COMPREPLY=($(compgen -W \
- '$(awk "{ print \$1 }" /usr/share/i18n/SUPPORTED 2>/dev/null)' \
- -- "$cur"))
+ _comp_compgen_split -- "$(
+ _comp_awk '{ print $1 }' /usr/share/i18n/SUPPORTED 2>/dev/null
+ )"
} &&
- complete -F _locale_gen locale-gen
+ complete -F _comp_cmd_locale_gen locale-gen
# ex: filetype=sh
diff --git a/completions/lpq b/completions/lpq
index 36729d2..d9c29bb 100644
--- a/completions/lpq
+++ b/completions/lpq
@@ -1,28 +1,28 @@
# lpq(1) completion -*- shell-script -*-
-_lpq()
+_comp_cmd_lpq()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-P)
- COMPREPLY=($(compgen -W "$(lpstat -a 2>/dev/null | cut -d' ' -f1)" -- "$cur"))
+ _comp_compgen_split -- "$(lpstat -a 2>/dev/null | cut -d' ' -f1)"
return
;;
-U)
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
return
;;
esac
if [[ $cur == - ]]; then
- COMPREPLY=($(compgen -W '-E -P -U -a -h -l' -- "$cur"))
+ _comp_compgen -- -W '-E -P -U -a -h -l'
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _lpq lpq
+ complete -F _comp_cmd_lpq lpq
# ex: filetype=sh
diff --git a/completions/lpr b/completions/lpr
index 554f053..746df28 100644
--- a/completions/lpr
+++ b/completions/lpr
@@ -1,33 +1,33 @@
# lpr(1) completion -*- shell-script -*-
-_lpr()
+_comp_cmd_lpr()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-P)
- COMPREPLY=($(compgen -W "$(lpstat -a 2>/dev/null | cut -d' ' -f1)" -- "$cur"))
+ _comp_compgen_split -- "$(lpstat -a 2>/dev/null | cut -d' ' -f1)"
return
;;
-U)
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
return
;;
-o)
- COMPREPLY=($(compgen -W "media= landscape orientation-requested= sides= fitplot number-up= scaling= cpi= lpi= page-bottom= page-top= page-left= page-right=" -- "$cur"))
+ _comp_compgen -- -W "media= landscape orientation-requested= sides= fitplot number-up= scaling= cpi= lpi= page-bottom= page-top= page-left= page-right="
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
;;
esac
if [[ $cur == - ]]; then
- COMPREPLY=($(compgen -W '-E -H -C -J -T -P -U -h -l -m -o -p -q -r' -- "$cur"))
+ _comp_compgen -- -W '-E -H -C -J -T -P -U -h -l -m -o -p -q -r'
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _lpr lpr
+ complete -F _comp_cmd_lpr lpr
# ex: filetype=sh
diff --git a/completions/lrzip b/completions/lrzip
index eb2904c..6f40be7 100644
--- a/completions/lrzip
+++ b/completions/lrzip
@@ -1,52 +1,56 @@
# lrzip(1) completion -*- shell-script -*-
-_lrzip()
+_comp_cmd_lrzip()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local xspec="*.lrz"
+ local noargopts='!(-*|*[SmwdoOLNp]*)'
+ # shellcheck disable=SC2254
case $prev in
- -*@([wSm]|[Vh?]*))
+ --help | --version | --suffix | --maxram | --window | \
+ -${noargopts}@([Smw]|[h?V]*))
return
;;
- -*d)
+ --decompress | -${noargopts}d)
xspec="!"$xspec
;;
- -*o)
- _filedir
+ --outfile | -${noargopts}o)
+ _comp_compgen_filedir
return
;;
- -*O)
- _filedir -d
+ --outdir | -${noargopts}O)
+ _comp_compgen_filedir -d
return
;;
- -*L)
- COMPREPLY=($(compgen -W '{1..9}' -- "$cur"))
+ --level | -${noargopts}L)
+ _comp_compgen -- -W '{1..9}'
return
;;
- -*N)
- COMPREPLY=($(compgen -W '{-20..19}' -- "$cur"))
+ --nice-level | -${noargopts}N)
+ _comp_compgen -- -W '{-20..19}'
return
;;
- -*p)
- COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur"))
+ --threads | -${noargopts}p)
+ local REPLY
+ _comp_get_ncpus
+ _comp_compgen -- -W "{1..$REPLY}"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- _tilde "$cur" || return
+ _comp_compgen_tilde && return
- local IFS=$'\n'
compopt -o filenames
- COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur"))
+ _comp_compgen -- -f -X "$xspec" -o plusdirs
} &&
- complete -F _lrzip lrzip
+ complete -F _comp_cmd_lrzip lrzip
# ex: filetype=sh
diff --git a/completions/lsof b/completions/lsof
index eb1e967..07559b3 100644
--- a/completions/lsof
+++ b/completions/lsof
@@ -1,56 +1,56 @@
# lsof(8) completion -*- shell-script -*-
-_lsof()
+_comp_cmd_lsof()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-'?' | -h | +c | -c | -d | -F | -i | +r | -r | -s | -S | -T)
return
;;
-A | -k | -m | +m | -o)
- _filedir
+ _comp_compgen_filedir
return
;;
+d | +D)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-D)
- COMPREPLY=($(compgen -W '? b i r u' -- "$cur"))
+ _comp_compgen -- -W '? b i r u'
return
;;
-f)
- COMPREPLY=($(compgen -W 'c f g G n' -- "$cur"))
+ _comp_compgen -- -W 'c f g G n'
return
;;
-g)
# TODO: handle ^foo exclusions, comma separated lists
- _pgids
+ _comp_compgen_pgids
return
;;
-p)
# TODO: handle ^foo exclusions, comma separated lists
- _pids
+ _comp_compgen_pids
return
;;
-u)
# TODO: handle ^foo exclusions, comma separated lists
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
return
;;
esac
if [[ $cur == [-+]* ]]; then
- COMPREPLY=($(compgen -W '-h -a -A -b -c +c -C +d -d +D -D +f -f -F -g
- -i -k -l +L -L +m -m +M -M -n -N -o -O -p -P +r -r -R -s -S -T -t
- -u -U -v -V +w -w -x -X -z -Z' -- "$cur"))
+ _comp_compgen -- -W '-h -a -A -b -c +c -C +d -d +D -D +f -f -F -g -i -k
+ -l +L -L +m -m +M -M -n -N -o -O -p -P +r -r -R -s -S -T -t -u -U
+ -v -V +w -w -x -X -z -Z'
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _lsof lsof
+ complete -F _comp_cmd_lsof lsof
# ex: filetype=sh
diff --git a/completions/lspci b/completions/lspci
index d50783c..16d6195 100644
--- a/completions/lspci
+++ b/completions/lspci
@@ -1,41 +1,40 @@
# lspci(8) completion -*- shell-script -*-
-_lspci()
+_comp_cmd_lspci()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*[sDO])
return
;;
-*i)
- _filedir ids
+ _comp_compgen_filedir ids
return
;;
-*p)
- _filedir pcimap
+ _comp_compgen_filedir pcimap
return
;;
-*A)
- COMPREPLY+=($(compgen -W '$($1 -A help | command grep -vF :)' \
- -- "$cur"))
+ _comp_compgen_split -- "$("$1" -A help | command grep -vF :)"
return
;;
-*H)
- COMPREPLY+=($(compgen -W "1 2" -- "$cur"))
+ _comp_compgen -- -W "1 2"
return
;;
-*F)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
fi
} &&
- complete -F _lspci lspci
+ complete -F _comp_cmd_lspci lspci
# ex: filetype=sh
diff --git a/completions/lsscsi b/completions/lsscsi
index bcbc430..6f417f5 100644
--- a/completions/lsscsi
+++ b/completions/lsscsi
@@ -1,27 +1,29 @@
# lsscsi(8) completion -*- shell-script -*-
-_lsscsi()
+_comp_cmd_lsscsi()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[y]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | -!(-*)[hV]*)
+ --help | --version | -${noargopts}[hV]*)
return
;;
- --sysfsroot | -!(-*)y)
- _filedir -d
+ --sysfsroot | -${noargopts}y)
+ _comp_compgen_filedir -d
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _lsscsi lsscsi
+ complete -F _comp_cmd_lsscsi lsscsi
# ex: filetype=sh
diff --git a/completions/lsusb b/completions/lsusb
index 63cff54..44c2625 100644
--- a/completions/lsusb
+++ b/completions/lsusb
@@ -1,20 +1,22 @@
# lsusb(8) completion -*- shell-script -*-
-_lsusb()
+_comp_cmd_lsusb()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[sD]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | -!(-*)@([sD]|[hV]*))
+ --help | --version | -${noargopts}@([sD]|[hV]*))
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
fi
} &&
- complete -F _lsusb lsusb
+ complete -F _comp_cmd_lsusb lsusb
# ex: filetype=sh
diff --git a/completions/lua b/completions/lua
index 3c4df90..a8904e0 100644
--- a/completions/lua
+++ b/completions/lua
@@ -1,9 +1,9 @@
# lua(1) completion -*- shell-script -*-
-_lua()
+_comp_cmd_lua()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-e | -l | -v | -)
@@ -12,12 +12,12 @@ _lua()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W "$(_parse_help "$1")" -- "$cur"))
+ _comp_compgen_help
return
fi
- _filedir 'l@(ua|?(ua)c)'
+ _comp_compgen_filedir 'l@(ua|?(ua)c)'
} &&
- complete -F _lua lua
+ complete -F _comp_cmd_lua lua{,5{,.}{0..4}}
# ex: filetype=sh
diff --git a/completions/luac b/completions/luac
index c763deb..3fef4be 100644
--- a/completions/luac
+++ b/completions/luac
@@ -1,27 +1,27 @@
# luac(1) completion -*- shell-script -*-
-_luac()
+_comp_cmd_luac()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-v | -)
return
;;
-o)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W "$(_parse_help "$1")" -- "$cur"))
+ _comp_compgen_help
return
fi
- _filedir lua
+ _comp_compgen_filedir lua
} &&
- complete -F _luac luac
+ complete -F _comp_cmd_luac luac{,5{,.}{0..4}}
# ex: filetype=sh
diff --git a/completions/luseradd b/completions/luseradd
index 4d66385..255bc91 100644
--- a/completions/luseradd
+++ b/completions/luseradd
@@ -1,40 +1,42 @@
# luseradd(1) and lusermod(1) completion -*- shell-script -*-
-_luseradd()
+_comp_cmd_luseradd()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[culPpdksg]*)'
+ # shellcheck disable=SC2254
case $prev in
--help | --usage | --gecos | --uid | --login | --plainpassword | --password | \
--commonname | --givenname | --surname | --roomnumber | --telephonenumber | \
- --homephone | -!(-*)@([culPp]|[?]*))
+ --homephone | -${noargopts}@([culPp]|[?]*))
return
;;
- --directory | --skeleton | -!(-*)[dk])
- _filedir -d
+ --directory | --skeleton | -${noargopts}[dk])
+ _comp_compgen_filedir -d
return
;;
- --shell | -!(-*)s)
- _shells
+ --shell | -${noargopts}s)
+ _comp_compgen_shells
return
;;
- --gid | -!(-*)g)
- _gids
+ --gid | -${noargopts}g)
+ _comp_compgen_gids
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- [[ ${1##*/} == luseradd ]] || COMPREPLY=($(compgen -u -- "$cur"))
+ [[ ${1##*/} == luseradd ]] || _comp_compgen -- -u
} &&
- complete -F _luseradd luseradd lusermod
+ complete -F _comp_cmd_luseradd luseradd lusermod
# ex: filetype=sh
diff --git a/completions/luserdel b/completions/luserdel
index e36bda9..d36b256 100644
--- a/completions/luserdel
+++ b/completions/luserdel
@@ -1,9 +1,9 @@
# luserdel(1) completion -*- shell-script -*-
-_luserdel()
+_comp_cmd_luserdel()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--help | --usage | -!(-*)[?]*)
@@ -12,12 +12,12 @@ _luserdel()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
} &&
- complete -F _luserdel luserdel
+ complete -F _comp_cmd_luserdel luserdel
# ex: filetype=sh
diff --git a/completions/lvm b/completions/lvm
index e70ecc3..70581a7 100644
--- a/completions/lvm
+++ b/completions/lvm
@@ -1,56 +1,55 @@
# bash completion for lvm -*- shell-script -*-
-_lvm_filedir()
+_comp_cmd_lvm__filedir()
{
- cur=${cur:-/dev/}
- _filedir
+ _comp_compgen -c "${cur:-/dev/}" filedir
}
-_lvm_volumegroups()
+_comp_cmd_lvm__volumegroups()
{
- COMPREPLY=($(compgen -W "$(vgscan 2>/dev/null |
- command sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p')" -- "$cur"))
+ _comp_compgen_split -- "$(vgscan 2>/dev/null |
+ command sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p')"
}
-_lvm_physicalvolumes_all()
+_comp_cmd_lvm__physicalvolumes_all()
{
- COMPREPLY=($(compgen -W "$(pvscan 2>/dev/null |
- command sed -n -e 's|^.*PV \([^ ]*\) .*|\1|p')" -- "$cur"))
+ _comp_compgen_split -- "$(pvscan 2>/dev/null |
+ command sed -n -e 's|^.*PV \([^ ]*\) .*|\1|p')"
}
-_lvm_physicalvolumes()
+_comp_cmd_lvm__physicalvolumes()
{
- COMPREPLY=($(compgen -W "$(pvscan 2>/dev/null |
- command sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p')" -- "$cur"))
+ _comp_compgen_split -- "$(pvscan 2>/dev/null |
+ command sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p')"
}
-_lvm_logicalvolumes()
+_comp_cmd_lvm__logicalvolumes()
{
- COMPREPLY=($(compgen -W "$(lvscan 2>/dev/null |
- command sed -n -e "s|^.*'\(.*\)'.*$|\1|p")" -- "$cur"))
+ _comp_compgen_split -- "$(lvscan 2>/dev/null |
+ command sed -n -e "s|^.*'\(.*\)'.*$|\1|p")"
if [[ $cur == /dev/mapper/* ]]; then
- _filedir
+ _comp_compgen -a filedir
local i
for i in "${!COMPREPLY[@]}"; do
- [[ ${COMPREPLY[i]} == */control ]] && unset 'COMPREPLY[i]'
+ [[ ${COMPREPLY[i]} == */control ]] && unset -v 'COMPREPLY[i]'
done
fi
}
-_lvm_units()
+_comp_cmd_lvm__units()
{
- COMPREPLY=($(compgen -W 'h s b k m g t H K M G T' -- "$cur"))
+ _comp_compgen -- -W 'h s b k m g t H K M G T'
}
-_lvm_sizes()
+_comp_cmd_lvm__sizes()
{
- COMPREPLY=($(compgen -W 'k K m M g G t T' -- "$cur"))
+ _comp_compgen -- -W 'k K m M g G t T'
}
# @param $1 glob matching args known to take an argument
-_lvm_count_args()
+_comp_cmd_lvm__count_args()
{
- args=0
+ REPLY=0
local offset=1
if [[ ${words[0]} == lvm ]]; then
offset=2
@@ -59,791 +58,836 @@ _lvm_count_args()
for ((i = offset; i < cword; i++)); do
# shellcheck disable=SC2053
if [[ ${words[i]} != -* && $prev != $1 ]]; then
- ((args++))
+ ((REPLY++))
fi
prev=${words[i]}
done
}
-_lvmdiskscan()
+_comp_cmd_lvmdiskscan()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
fi
} &&
- complete -F _lvmdiskscan lvmdiskscan
+ complete -F _comp_cmd_lvmdiskscan lvmdiskscan
-_pvscan()
+_comp_cmd_pvscan()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
fi
} &&
- complete -F _pvscan pvscan
+ complete -F _comp_cmd_pvscan pvscan
-_pvs()
+_comp_cmd_pvs()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[oO]*)'
+ # shellcheck disable=SC2254
case $prev in
- --options | --sort | -!(-*)[oO])
- COMPREPLY=($(compgen -W 'pv_fmt pv_uuid pv_size pv_free pv_used
- pv_name pv_attr pv_pe_count pv_pe_alloc_count' -- "$cur"))
+ --options | --sort | -${noargopts}[oO])
+ _comp_compgen -- -W 'pv_fmt pv_uuid pv_size pv_free pv_used pv_name
+ pv_attr pv_pe_count pv_pe_alloc_count'
return
;;
--units)
- _lvm_units
+ _comp_cmd_lvm__units
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_physicalvolumes_all
+ _comp_cmd_lvm__physicalvolumes_all
fi
} &&
- complete -F _pvs pvs
+ complete -F _comp_cmd_pvs pvs
-_pvdisplay()
+_comp_cmd_pvdisplay()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--units)
- _lvm_units
+ _comp_cmd_lvm__units
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_physicalvolumes_all
+ _comp_cmd_lvm__physicalvolumes_all
fi
} &&
- complete -F _pvdisplay pvdisplay
+ complete -F _comp_cmd_pvdisplay pvdisplay
-_pvchange()
+_comp_cmd_pvchange()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[Ax]*)'
+ # shellcheck disable=SC2254
case $prev in
- --autobackup | --allocatable | -!(-*)[Ax])
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ --autobackup | --allocatable | -${noargopts}[Ax])
+ _comp_compgen -- -W 'y n'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_physicalvolumes_all
+ _comp_cmd_lvm__physicalvolumes_all
fi
} &&
- complete -F _pvchange pvchange
+ complete -F _comp_cmd_pvchange pvchange
-_pvcreate()
+_comp_cmd_pvcreate()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[M]*)'
+ # shellcheck disable=SC2254
case $prev in
--restorefile)
- _filedir
+ _comp_compgen_filedir
return
;;
- --metadatatype | -!(-*)M)
- COMPREPLY=($(compgen -W '1 2' -- "$cur"))
+ --metadatatype | -${noargopts}M)
+ _comp_compgen -- -W '1 2'
return
;;
--metadatacopies)
- COMPREPLY=($(compgen -W '0 1 2' -- "$cur"))
+ _comp_compgen -- -W '0 1 2'
return
;;
--metadatasize | --setphysicalvolumesize)
- _lvm_sizes
+ _comp_cmd_lvm__sizes
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_filedir
+ _comp_cmd_lvm__filedir
fi
} &&
- complete -F _pvcreate pvcreate
+ complete -F _comp_cmd_pvcreate pvcreate
-_pvmove()
+_comp_cmd_pvmove()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[An]*)'
+ # shellcheck disable=SC2254
case $prev in
- --autobackup | -!(-*)A)
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ --autobackup | -${noargopts}A)
+ _comp_compgen -- -W 'y n'
return
;;
- --name | -!(-*)n)
- _lvm_logicalvolumes
+ --name | -${noargopts}n)
+ _comp_cmd_lvm__logicalvolumes
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_physicalvolumes
+ _comp_cmd_lvm__physicalvolumes
fi
} &&
- complete -F _pvmove pvmove
+ complete -F _comp_cmd_pvmove pvmove
-_pvremove()
+_comp_cmd_pvremove()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_physicalvolumes_all
+ _comp_cmd_lvm__physicalvolumes_all
fi
} &&
- complete -F _pvremove pvremove
+ complete -F _comp_cmd_pvremove pvremove
-_vgscan()
+_comp_cmd_vgscan()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
fi
} &&
- complete -F _vgscan vgscan
+ complete -F _comp_cmd_vgscan vgscan
-_vgs()
+_comp_cmd_vgs()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[oO]*)'
+ # shellcheck disable=SC2254
case $prev in
- --options | --sort | -!(-*)[oO])
- COMPREPLY=($(compgen -W 'vg_fmt vg_uuid vg_name vg_attr vg_size
- vg_free vg_sysid vg_extent_size vg_extent_count vg_free_count
- max_lv max_pv pv_count lv_count snap_count vg_seqno' \
- -- "$cur"))
+ --options | --sort | -${noargopts}[oO])
+ _comp_compgen -- -W 'vg_fmt vg_uuid vg_name vg_attr vg_size vg_free
+ vg_sysid vg_extent_size vg_extent_count vg_free_count max_lv
+ max_pv pv_count lv_count snap_count vg_seqno'
return
;;
--units)
- _lvm_units
+ _comp_cmd_lvm__units
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_volumegroups
+ _comp_cmd_lvm__volumegroups
fi
} &&
- complete -F _vgs vgs
+ complete -F _comp_cmd_vgs vgs
-_vgdisplay()
+_comp_cmd_vgdisplay()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--units)
- _lvm_units
+ _comp_cmd_lvm__units
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_volumegroups
+ _comp_cmd_lvm__volumegroups
fi
} &&
- complete -F _vgdisplay vgdisplay
+ complete -F _comp_cmd_vgdisplay vgdisplay
-_vgchange()
+_comp_cmd_vgchange()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[aAx]*)'
+ # shellcheck disable=SC2254
case $prev in
- --available | --autobackup | --resizeable | -!(-*)[aAx])
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ --available | --autobackup | --resizeable | -${noargopts}[aAx])
+ _comp_compgen -- -W 'y n'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_volumegroups
+ _comp_cmd_lvm__volumegroups
fi
} &&
- complete -F _vgchange vgchange
+ complete -F _comp_cmd_vgchange vgchange
-_vgcreate()
+_comp_cmd_vgcreate()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[AMs]*)'
+ # shellcheck disable=SC2254
case $prev in
- --autobackup | -!(-*)A)
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ --autobackup | -${noargopts}A)
+ _comp_compgen -- -W 'y n'
return
;;
- --metadatatype | -!(-*)M)
- COMPREPLY=($(compgen -W '1 2' -- "$cur"))
+ --metadatatype | -${noargopts}M)
+ _comp_compgen -- -W '1 2'
return
;;
- --physicalextentsize | -!(-*)s)
- _lvm_sizes
+ --physicalextentsize | -${noargopts}s)
+ _comp_cmd_lvm__sizes
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- local args
- _lvm_count_args '@(-A|--autobackup|-M|--metadatatype|-s|--physicalextentsize)'
- if ((args == 0)); then
- _lvm_volumegroups
+ local REPLY
+ _comp_cmd_lvm__count_args '@(-A|--autobackup|-M|--metadatatype|-s|--physicalextentsize)'
+ if ((REPLY == 0)); then
+ _comp_cmd_lvm__volumegroups
else
- _lvm_physicalvolumes_all
+ _comp_cmd_lvm__physicalvolumes_all
fi
fi
} &&
- complete -F _vgcreate vgcreate
+ complete -F _comp_cmd_vgcreate vgcreate
-_vgremove()
+_comp_cmd_vgremove()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_volumegroups
+ _comp_cmd_lvm__volumegroups
fi
} &&
- complete -F _vgremove vgremove
+ complete -F _comp_cmd_vgremove vgremove
-_vgrename()
+_comp_cmd_vgrename()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[A]*)'
+ # shellcheck disable=SC2254
case $prev in
- --autobackup | -!(-*)A)
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ --autobackup | -${noargopts}A)
+ _comp_compgen -- -W 'y n'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_volumegroups
+ _comp_cmd_lvm__volumegroups
fi
} &&
- complete -F _vgrename vgrename
+ complete -F _comp_cmd_vgrename vgrename
-_vgreduce()
+_comp_cmd_vgreduce()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[A]*)'
+ # shellcheck disable=SC2254
case $prev in
- --autobackup | -!(-*)A)
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ --autobackup | -${noargopts}A)
+ _comp_compgen -- -W 'y n'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- local args
- _lvm_count_args '@(-A|--autobackup)'
- if ((args == 0)); then
- _lvm_volumegroups
+ local REPLY
+ _comp_cmd_lvm__count_args '@(-A|--autobackup)'
+ if ((REPLY == 0)); then
+ _comp_cmd_lvm__volumegroups
else
- _lvm_physicalvolumes
+ _comp_cmd_lvm__physicalvolumes
fi
fi
} &&
- complete -F _vgreduce vgreduce
+ complete -F _comp_cmd_vgreduce vgreduce
-_vgextend()
+_comp_cmd_vgextend()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[AL]*)'
+ # shellcheck disable=SC2254
case $prev in
- --autobackup | -!(-*)A)
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ --autobackup | -${noargopts}A)
+ _comp_compgen -- -W 'y n'
return
;;
- --size | -!(-*)L)
- _lvm_sizes
+ --size | -${noargopts}L)
+ _comp_cmd_lvm__sizes
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- local args
- _lvm_count_args '@(-A|--autobackup|-L|--size)'
- if ((args == 0)); then
- _lvm_volumegroups
+ local REPLY
+ _comp_cmd_lvm__count_args '@(-A|--autobackup|-L|--size)'
+ if ((REPLY == 0)); then
+ _comp_cmd_lvm__volumegroups
else
- _lvm_physicalvolumes_all
+ _comp_cmd_lvm__physicalvolumes_all
fi
fi
} &&
- complete -F _vgextend vgextend
+ complete -F _comp_cmd_vgextend vgextend
-_vgport()
+_comp_cmd_vgport()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_volumegroups
+ _comp_cmd_lvm__volumegroups
fi
} &&
- complete -F _vgport vgimport vgexport
+ complete -F _comp_cmd_vgport vgimport vgexport
-_vgck()
+_comp_cmd_vgck()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_volumegroups
+ _comp_cmd_lvm__volumegroups
fi
} &&
- complete -F _vgck vgck
+ complete -F _comp_cmd_vgck vgck
-_vgconvert()
+_comp_cmd_vgconvert()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[M]*)'
+ # shellcheck disable=SC2254
case $prev in
- --metadatatype | -!(-*)M)
- COMPREPLY=($(compgen -W '1 2' -- "$cur"))
+ --metadatatype | -${noargopts}M)
+ _comp_compgen -- -W '1 2'
return
;;
--metadatacopies)
- COMPREPLY=($(compgen -W '0 1 2' -- "$cur"))
+ _comp_compgen -- -W '0 1 2'
return
;;
--metadatasize)
- _lvm_sizes
+ _comp_cmd_lvm__sizes
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_volumegroups
+ _comp_cmd_lvm__volumegroups
fi
} &&
- complete -F _vgconvert vgconvert
+ complete -F _comp_cmd_vgconvert vgconvert
-_vgcfgbackup()
+_comp_cmd_vgcfgbackup()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[f]*)'
+ # shellcheck disable=SC2254
case $prev in
- --file | -!(-*)f)
- _filedir
+ --file | -${noargopts}f)
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_volumegroups
+ _comp_cmd_lvm__volumegroups
fi
} &&
- complete -F _vgcfgbackup vgcfgbackup
+ complete -F _comp_cmd_vgcfgbackup vgcfgbackup
-_vgcfgrestore()
+_comp_cmd_vgcfgrestore()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[fMn]*)'
+ # shellcheck disable=SC2254
case $prev in
- --file | -!(-*)f)
- _filedir
+ --file | -${noargopts}f)
+ _comp_compgen_filedir
return
;;
- --metadatatype | -!(-*)M)
- COMPREPLY=($(compgen -W '1 2' -- "$cur"))
+ --metadatatype | -${noargopts}M)
+ _comp_compgen -- -W '1 2'
return
;;
- --name | -!(-*)n)
- _lvm_volumegroups
+ --name | -${noargopts}n)
+ _comp_cmd_lvm__volumegroups
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_volumegroups
+ _comp_cmd_lvm__volumegroups
fi
} &&
- complete -F _vgcfgrestore vgcfgrestore
+ complete -F _comp_cmd_vgcfgrestore vgcfgrestore
-_vgmerge()
+_comp_cmd_vgmerge()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[A]*)'
+ # shellcheck disable=SC2254
case $prev in
- --autobackup | -!(-*)A)
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ --autobackup | -${noargopts}A)
+ _comp_compgen -- -W 'y n'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_volumegroups
+ _comp_cmd_lvm__volumegroups
fi
} &&
- complete -F _vgmerge vgmerge
+ complete -F _comp_cmd_vgmerge vgmerge
-_vgsplit()
+_comp_cmd_vgsplit()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[AM]*)'
+ # shellcheck disable=SC2254
case $prev in
- --autobackup | -!(-*)A)
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ --autobackup | -${noargopts}A)
+ _comp_compgen -- -W 'y n'
return
;;
- --metadatatype | -!(-*)M)
- COMPREPLY=($(compgen -W '1 2' -- "$cur"))
+ --metadatatype | -${noargopts}M)
+ _comp_compgen -- -W '1 2'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- local args
- _lvm_count_args '@(-A|--autobackup|-M|--metadatatype)'
- if ((args == 0 || args == 1)); then
- _lvm_volumegroups
+ local REPLY
+ _comp_cmd_lvm__count_args '@(-A|--autobackup|-M|--metadatatype)'
+ if ((REPLY < 2)); then
+ _comp_cmd_lvm__volumegroups
else
- _lvm_physicalvolumes
+ _comp_cmd_lvm__physicalvolumes
fi
fi
} &&
- complete -F _vgsplit vgsplit
+ complete -F _comp_cmd_vgsplit vgsplit
-_vgmknodes()
+_comp_cmd_vgmknodes()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_volumegroups
+ _comp_cmd_lvm__volumegroups
fi
} &&
- complete -F _vgmknodes vgmknodes
+ complete -F _comp_cmd_vgmknodes vgmknodes
-_lvscan()
+_comp_cmd_lvscan()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
fi
} &&
- complete -F _lvscan lvscan
+ complete -F _comp_cmd_lvscan lvscan
-_lvs()
+_comp_cmd_lvs()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[oO]*)'
+ # shellcheck disable=SC2254
case $prev in
- --options | --sort | -!(-*)[oO])
- COMPREPLY=($(compgen -W 'lv_uuid lv_name lv_attr lv_minor lv_size
+ --options | --sort | -${noargopts}[oO])
+ _comp_compgen -- -W 'lv_uuid lv_name lv_attr lv_minor lv_size
seg_count origin snap_percent segtype stripes stripesize
- chunksize seg_start seg_size' -- "$cur"))
+ chunksize seg_start seg_size'
return
;;
--units)
- _lvm_units
+ _comp_cmd_lvm__units
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_logicalvolumes
+ _comp_cmd_lvm__logicalvolumes
fi
} &&
- complete -F _lvs lvs
+ complete -F _comp_cmd_lvs lvs
-_lvdisplay()
+_comp_cmd_lvdisplay()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--units)
- _lvm_units
+ _comp_cmd_lvm__units
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_logicalvolumes
+ _comp_cmd_lvm__logicalvolumes
fi
} &&
- complete -F _lvdisplay lvdisplay
+ complete -F _comp_cmd_lvdisplay lvdisplay
-_lvchange()
+_comp_cmd_lvchange()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[aACMp]*)'
+ # shellcheck disable=SC2254
case $prev in
- --available | --autobackup | --contiguous | --persistent | -!(-*)[aACM])
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ --available | --autobackup | --contiguous | --persistent | -${noargopts}[aACM])
+ _comp_compgen -- -W 'y n'
return
;;
- --permission | -!(-*)p)
- COMPREPLY=($(compgen -W 'r rw' -- "$cur"))
+ --permission | -${noargopts}p)
+ _comp_compgen -- -W 'r rw'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_logicalvolumes
+ _comp_cmd_lvm__logicalvolumes
fi
} &&
- complete -F _lvchange lvchange
+ complete -F _comp_cmd_lvchange lvchange
-_lvcreate()
+_comp_cmd_lvcreate()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[ACMZLpn]*)'
+ # shellcheck disable=SC2254
case $prev in
- --autobackup | --contiguous | --persistent | --zero | -!(-*)[ACMZ])
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ --autobackup | --contiguous | --persistent | --zero | -${noargopts}[ACMZ])
+ _comp_compgen -- -W 'y n'
return
;;
- --size | -!(-*)L)
- _lvm_sizes
+ --size | -${noargopts}L)
+ _comp_cmd_lvm__sizes
return
;;
- --permission | -!(-*)p)
- COMPREPLY=($(compgen -W 'r rw' -- "$cur"))
+ --permission | -${noargopts}p)
+ _comp_compgen -- -W 'r rw'
return
;;
- --name | -!(-*)n)
- _lvm_logicalvolumes
+ --name | -${noargopts}n)
+ _comp_cmd_lvm__logicalvolumes
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- local args
- _lvm_count_args '@(-A|-C|-M|-Z|--autobackup|--contiguous|--persistent|--zero|-L|--size|-p|--permission|-n|--name)'
- if ((args == 0)); then
- _lvm_volumegroups
+ local REPLY
+ _comp_cmd_lvm__count_args '@(-A|-C|-M|-Z|--autobackup|--contiguous|--persistent|--zero|-L|--size|-p|--permission|-n|--name)'
+ if ((REPLY == 0)); then
+ _comp_cmd_lvm__volumegroups
else
- _lvm_physicalvolumes
+ _comp_cmd_lvm__physicalvolumes
fi
fi
} &&
- complete -F _lvcreate lvcreate
+ complete -F _comp_cmd_lvcreate lvcreate
-_lvremove()
+_comp_cmd_lvremove()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[A]*)'
+ # shellcheck disable=SC2254
case $prev in
- --autobackup | -!(-*)A)
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ --autobackup | -${noargopts}A)
+ _comp_compgen -- -W 'y n'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_logicalvolumes
+ _comp_cmd_lvm__logicalvolumes
fi
} &&
- complete -F _lvremove lvremove
+ complete -F _comp_cmd_lvremove lvremove
-_lvrename()
+_comp_cmd_lvrename()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[A]*)'
+ # shellcheck disable=SC2254
case $prev in
- --autobackup | -!(-*)A)
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ --autobackup | -${noargopts}A)
+ _comp_compgen -- -W 'y n'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_logicalvolumes
+ _comp_cmd_lvm__logicalvolumes
fi
} &&
- complete -F _lvrename lvrename
+ complete -F _comp_cmd_lvrename lvrename
-_lvreduce()
+_comp_cmd_lvreduce()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[AL]*)'
+ # shellcheck disable=SC2254
case $prev in
- --autobackup | -!(-*)A)
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ --autobackup | -${noargopts}A)
+ _comp_compgen -- -W 'y n'
return
;;
- --size | -!(-*)L)
- _lvm_sizes
+ --size | -${noargopts}L)
+ _comp_cmd_lvm__sizes
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _lvm_logicalvolumes
+ _comp_cmd_lvm__logicalvolumes
fi
} &&
- complete -F _lvreduce lvreduce
+ complete -F _comp_cmd_lvreduce lvreduce
-_lvresize()
+_comp_cmd_lvresize()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[AL]*)'
+ # shellcheck disable=SC2254
case $prev in
- --autobackup | -!(-*)A)
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ --autobackup | -${noargopts}A)
+ _comp_compgen -- -W 'y n'
return
;;
- --size | -!(-*)L)
- _lvm_sizes
+ --size | -${noargopts}L)
+ _comp_cmd_lvm__sizes
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- local args
- _lvm_count_args '@(-A|--autobackup|-L|--size)'
- if ((args == 0)); then
- _lvm_logicalvolumes
+ local REPLY
+ _comp_cmd_lvm__count_args '@(-A|--autobackup|-L|--size)'
+ if ((REPLY == 0)); then
+ _comp_cmd_lvm__logicalvolumes
else
- _lvm_physicalvolumes
+ _comp_cmd_lvm__physicalvolumes
fi
fi
} &&
- complete -F _lvresize lvresize
+ complete -F _comp_cmd_lvresize lvresize
-_lvextend()
+_comp_cmd_lvextend()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[AL]*)'
+ # shellcheck disable=SC2254
case $prev in
- --autobackup | -!(-*)A)
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ --autobackup | -${noargopts}A)
+ _comp_compgen -- -W 'y n'
return
;;
- --size | -!(-*)L)
- _lvm_sizes
+ --size | -${noargopts}L)
+ _comp_cmd_lvm__sizes
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- local args
- _lvm_count_args '@(-A|--autobackup|-L|--size)'
- if ((args == 0)); then
- _lvm_logicalvolumes
+ local REPLY
+ _comp_cmd_lvm__count_args '@(-A|--autobackup|-L|--size)'
+ if ((REPLY == 0)); then
+ _comp_cmd_lvm__logicalvolumes
else
- _lvm_physicalvolumes
+ _comp_cmd_lvm__physicalvolumes
fi
fi
} &&
- complete -F _lvextend lvextend
+ complete -F _comp_cmd_lvextend lvextend
-_lvm()
+_comp_cmd_lvm()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if ((cword == 1)); then
- COMPREPLY=($(compgen -W 'dumpconfig help lvchange lvcreate lvdisplay
+ _comp_compgen -- -W 'dumpconfig help lvchange lvcreate lvdisplay
lvextend lvmchange lvmdiskscan lvmsadc lvmsar lvreduce lvremove
lvrename lvresize lvs lvscan pvchange pvcreate pvdata pvdisplay
pvmove pvremove pvresize pvs pvscan vgcfgbackup vgcfgrestore
vgchange vgck vgconvert vgcreate vgdisplay vgexport vgextend
vgimport vgmerge vgmknodes vgreduce vgremove vgrename vgs vgscan
- vgsplit version' -- "$cur"))
+ vgsplit version'
else
case "${words[1]}" in
pvchange | pvcreate | pvdisplay | pvmove | pvremove | pvresize | pvs | pvscan | \
@@ -851,11 +895,11 @@ _lvm()
vgdisplay | vgexport | vgextend | vgimport | vgmerge | vgmknodes | vgreduce | \
vgremove | vgrename | vgs | vgscan | vgsplit | lvchange | lvcreate | lvdisplay | \
lvextend | lvreduce | lvremove | lvrename | lvresize | lvscan)
- _${words[1]}
+ _comp_command_offset 1
;;
esac
fi
} &&
- complete -F _lvm lvm
+ complete -F _comp_cmd_lvm lvm
# ex: filetype=sh
diff --git a/completions/lz4 b/completions/lz4
index f297b5d..8e2a777 100644
--- a/completions/lz4
+++ b/completions/lz4
@@ -1,25 +1,27 @@
# lz4 completion -*- shell-script -*-
-_lz4()
+_comp_cmd_lz4()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-b)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -X '-*#*' -W \
- '$(_parse_help "$1" -h) -B{4..7} -i{1..9}' -- "$cur"))
+ _comp_compgen -R help -- -h
+ _comp_compgen -- -X '-*#*' -W \
+ '${COMPREPLY+"${COMPREPLY[@]}"} -B{4..7} -i{1..9}'
return
fi
- local args word xspec="*.?(t)lz4"
- _count_args
+ local REPLY word xspec="*.?(t)lz4"
+ _comp_count_args
+ local args=$REPLY
((args > 2)) && return
for word in "${words[@]}"; do
@@ -41,12 +43,11 @@ _lz4()
esac
done
- _tilde "$cur" || return
+ _comp_compgen_tilde && return
- local IFS=$'\n'
compopt -o filenames
- COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur"))
+ _comp_compgen -- -f -X "$xspec" -o plusdirs
} &&
- complete -F _lz4 lz4 lz4c
+ complete -F _comp_cmd_lz4 lz4 lz4c
# ex: filetype=sh
diff --git a/completions/lzip b/completions/lzip
index 05f169c..cd33f60 100644
--- a/completions/lzip
+++ b/completions/lzip
@@ -1,47 +1,51 @@
# lzip(1) completion -*- shell-script -*-
-_lzip()
+_comp_cmd_lzip()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
- local decompress=false
+ local decompress=""
+ local noargopts='!(-*|*[bmsSBdno]*)'
+ # shellcheck disable=SC2254
case $prev in
--help | --version | --member-size | --match-length | --dictionary-size | \
- --volume-size | --data-size | -!(-*)@([bmsSB]|[hV]*))
+ --volume-size | --data-size | -${noargopts}@([bmsSB]|[hV]*))
return
;;
- --decompress-!(-*)d)
- decompress=true
+ --decompress | -${noargopts}d)
+ decompress=set
;;
- --threads-!(-*)n)
- COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur"))
+ --threads | -${noargopts}n)
+ local REPLY
+ _comp_get_ncpus
+ _comp_compgen -- -W "{1..$REPLY}"
return
;;
- --output-!(-*)o)
- _filedir
+ --output | -${noargopts}o)
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1") {-1..-9}' -- "$cur"))
+ _comp_compgen_help
+ _comp_compgen -a -- -W '-{1..9}'
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- if $decompress; then
- _filedir lz
+ if [[ $decompress ]]; then
+ _comp_compgen_filedir lz
return
fi
- local IFS=$'\n'
compopt -o filenames
- COMPREPLY=($(compgen -f -X "*.lz" -- "$cur") $(compgen -d -- "$cur"))
+ _comp_compgen -- -f -X "*.lz" -o plusdirs
} &&
- complete -F _lzip clzip lzip pdlzip plzip
+ complete -F _comp_cmd_lzip clzip lzip pdlzip plzip
# ex: filetype=sh
diff --git a/completions/lzma b/completions/lzma
index 34fba89..c1ae07d 100644
--- a/completions/lzma
+++ b/completions/lzma
@@ -1,20 +1,21 @@
# lzma(1) completion -*- shell-script -*-
# by Per Øyvind Karlsen <peroyvind@mandriva.org>
-_lzma()
+_comp_cmd_lzma()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1") -{1..9}' -- "$cur"))
+ _comp_compgen_help
+ _comp_compgen -a -- -W '-{1..9}'
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- local IFS=$'\n' xspec="*.@(lzma|tlz)"
+ local xspec="*.@(lzma|tlz)"
if [[ $prev == --* ]]; then
[[ $prev == --@(decompress|list|test) ]] && xspec="!"$xspec
@@ -24,11 +25,11 @@ _lzma()
[[ $prev == -*z* ]] && xspec=
fi
- _tilde "$cur" || return
+ _comp_compgen_tilde && return
compopt -o filenames
- COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur"))
+ _comp_compgen -- -f -X "$xspec" -o plusdirs
} &&
- complete -F _lzma lzma
+ complete -F _comp_cmd_lzma lzma
# ex: filetype=sh
diff --git a/completions/lzop b/completions/lzop
index 2642742..5cbd51f 100644
--- a/completions/lzop
+++ b/completions/lzop
@@ -1,32 +1,33 @@
# lzop(1) completion -*- shell-script -*-
-_lzop()
+_comp_cmd_lzop()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[oS]*)'
+ # shellcheck disable=SC2254
case $prev in
- --output | -!(-*)o)
- _filedir
+ --output | -${noargopts}o)
+ _comp_compgen_filedir
return
;;
--path)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
- --suffix | -!(-*)S)
+ --suffix | -${noargopts}S)
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-1 -2 -3 -4 -5 -6 -7 -8 -9 -P
+ _comp_compgen -- -W '-{1..9} -P
--fast --best --decompress --extract --test --list --ls --info
--sysinfo --license --help --version --stdout --output --path
--force --no-checksum --no-name --name --no-mode --no-time --suffix
--keep --delete --crc32 --no-warn --ignore-warn --quiet --verbose
- --no-stdin --filter --checksum --no-color --mono --color' \
- -- "$cur"))
+ --no-stdin --filter --checksum --no-color --mono --color'
return
fi
@@ -48,12 +49,11 @@ _lzop()
;;
esac
- _tilde "$cur" || return
+ _comp_compgen_tilde && return
- local IFS=$'\n'
compopt -o filenames
- COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur"))
+ _comp_compgen -- -f -X "$xspec" -o plusdirs
} &&
- complete -F _lzop lzop
+ complete -F _comp_cmd_lzop lzop
# ex: filetype=sh
diff --git a/completions/macof b/completions/macof
index ad29f58..408e446 100644
--- a/completions/macof
+++ b/completions/macof
@@ -1,22 +1,22 @@
# macof completion -*- shell-script -*-
-_macof()
+_comp_cmd_macof()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-i)
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
fi
} &&
- complete -F _macof macof
+ complete -F _comp_cmd_macof macof
# ex: filetype=sh
diff --git a/completions/mailmanctl b/completions/mailmanctl
index 3bbc2f2..b29487a 100644
--- a/completions/mailmanctl
+++ b/completions/mailmanctl
@@ -1,18 +1,18 @@
# mailmanctl completion -*- shell-script -*-
-_mailmanctl()
+_comp_cmd_mailmanctl()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--no-restart --run-as-user
- --stale-lock-cleanup --quiet --help' -- "$cur"))
+ _comp_compgen -- -W '--no-restart --run-as-user --stale-lock-cleanup
+ --quiet --help'
else
- COMPREPLY=($(compgen -W 'start stop restart reopen' -- "$cur"))
+ _comp_compgen -- -W 'start stop restart reopen'
fi
} &&
- complete -F _mailmanctl mailmanctl
+ complete -F _comp_cmd_mailmanctl mailmanctl
# ex: filetype=sh
diff --git a/completions/make b/completions/make
index 96517c2..94e2b73 100644
--- a/completions/make
+++ b/completions/make
@@ -1,135 +1,128 @@
# bash completion for GNU make -*- shell-script -*-
-_make_target_extract_script()
+# Extract the valid target names starting with PREFIX from the output of
+# `make -npq'
+# @param mode If this is `-d', the directory names already specified in
+# PREFIX are omitted in the output
+# @param prefix Prefix of the target names
+_comp_cmd_make__extract_targets()
{
- local mode="$1"
- shift
+ local mode=$1
+ local -x prefix=$2
- local prefix="$1"
- local prefix_pat=$(command sed 's/[][\,.*^$(){}?+|/]/\\&/g' <<<"$prefix")
- local basename=${prefix##*/}
- local dirname_len=$((${#prefix} - ${#basename}))
+ # display mode, only output current path component to the next slash
+ local -x prefix_replace=$prefix
+ [[ $mode == -d && $prefix == */* ]] &&
+ prefix_replace=${prefix##*/}
- if [[ $mode == -d ]]; then
- # display mode, only output current path component to the next slash
- local output="\2"
- else
- # completion mode, output full path to the next slash
- local output="\1\2"
- fi
-
- cat <<EOF
- 1,/^# * Make data base/ d; # skip any makefile output
- /^# * Finished Make data base/,/^# * Make data base/{
- d; # skip any makefile output
- }
- /^# * Variables/,/^# * Files/ d; # skip until files section
- /^# * Not a target/,/^$/ d; # skip not target blocks
- /^${prefix_pat}/,/^$/! d; # skip anything user dont want
-
- # The stuff above here describes lines that are not
- # explicit targets or not targets other than special ones
- # The stuff below here decides whether an explicit target
- # should be output.
-
- /^# * File is an intermediate prerequisite/ {
- s/^.*$//;x; # unhold target
- d; # delete line
- }
-
- /^$/ { # end of target block
- x; # unhold target
- /^$/d; # dont print blanks
- s|^\(.\{${dirname_len}\}\)\(.\{${#basename}\}[^:/]*/\{0,1\}\)[^:]*:.*$|${output}|p;
- d; # hide any bugs
- }
-
- # This pattern includes a literal tab character as \t is not a portable
- # representation and fails with BSD sed
- /^[^# :%]\{1,\}:/ { # found target block
- /^\.PHONY:/ d; # special target
- /^\.SUFFIXES:/ d; # special target
- /^\.DEFAULT:/ d; # special target
- /^\.PRECIOUS:/ d; # special target
- /^\.INTERMEDIATE:/ d; # special target
- /^\.SECONDARY:/ d; # special target
- /^\.SECONDEXPANSION:/ d; # special target
- /^\.DELETE_ON_ERROR:/ d; # special target
- /^\.IGNORE:/ d; # special target
- /^\.LOW_RESOLUTION_TIME:/ d; # special target
- /^\.SILENT:/ d; # special target
- /^\.EXPORT_ALL_VARIABLES:/ d; # special target
- /^\.NOTPARALLEL:/ d; # special target
- /^\.ONESHELL:/ d; # special target
- /^\.POSIX:/ d; # special target
- /^\.NOEXPORT:/ d; # special target
- /^\.MAKE:/ d; # special target
-EOF
-
- # don't complete with hidden targets unless we are doing a partial completion
- if [[ -z ${prefix_pat} || ${prefix_pat} == */ ]]; then
- cat <<EOF
- /^${prefix_pat}[^a-zA-Z0-9]/d; # convention for hidden tgt
-EOF
- fi
+ _comp_awk -f "${BASH_SOURCE[0]%/*}/../helpers/make-extract-targets.awk"
+}
- cat <<EOF
- h; # hold target
- d; # delete line
- }
+# Truncate the non-unique filepaths in COMPREPLY to only generate unique
+# directories or files. This function discards the files under subdirectories
+# unless the path is unique under each subdirectory and instead generate the
+# subdirectory path. For example, when there are two candidates, "abc/def" and
+# "abc/xyz", we generate "abc/" instead of generating both candidates directly.
+# When there is only one candidate "abc/def", we generate the full path
+# "abc/def".
+#
+# @var[in] cur
+# @var[in] mode
+# @var[in,out] COMPREPLY
+_comp_cmd_make__truncate_non_unique_paths()
+{
+ local prefix=$cur
+ [[ $mode == -d ]] && prefix=
+ if ((${#COMPREPLY[@]} > 0)); then
+ # collect the possible completions including the directory names in
+ # `paths' and count the number of children of each subdirectory in
+ # `nchild'.
+ local -A paths nchild
+ local target
+ for target in "${COMPREPLY[@]}"; do
+ local path=${target%/}
+ while [[ ! ${paths[$path]+set} ]] &&
+ paths[$path]=set &&
+ [[ $path == "$prefix"*/* ]]; do
+ path=${path%/*}
+ nchild[$path]=$((${nchild[$path]-0} + 1))
+ done
+ done
-EOF
+ COMPREPLY=()
+ local nreply=0
+ for target in "${!paths[@]}"; do
+ # generate only the paths that do not have a unique child and whose
+ # all parent and ancestor directories have a unique child.
+ ((${nchild[$target]-0} == 1)) && continue
+ local path=$target
+ while [[ $path == "$prefix"*/* ]]; do
+ path=${path%/*}
+ ((${nchild[$path]-0} == 1)) || continue 2
+ done
+
+ # suffix `/' when the target path is a subdiretory, which has
+ # at least one child.
+ COMPREPLY[nreply++]=$target${nchild[$target]+/}
+ done
+ fi
}
-_make()
+_comp_cmd_make()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
local makef makef_dir=("-C" ".") i
+ local noargopts='!(-*|*[foWICmEDVxj]*)'
+ # shellcheck disable=SC2254
case $prev in
--file | --makefile | --old-file | --assume-old | --what-if | --new-file | \
- --assume-new | -!(-*)[foW])
- _filedir
+ --assume-new | -${noargopts}[foW])
+ _comp_compgen_filedir
return
;;
- --include-dir | --directory | -!(-*)[ICm])
- _filedir -d
+ --include-dir | --directory | -${noargopts}[ICm])
+ _comp_compgen_filedir -d
return
;;
- -!(-*)E)
- COMPREPLY=($(compgen -v -- "$cur"))
+ -${noargopts}E)
+ _comp_compgen -- -v
return
;;
- --eval | -!(-*)[DVx])
+ --eval | -${noargopts}[DVx])
return
;;
- --jobs | -!(-*)j)
- COMPREPLY=($(compgen -W "{1..$(($(_ncpus) * 2))}" -- "$cur"))
+ --jobs | -${noargopts}j)
+ local REPLY
+ _comp_get_ncpus
+ _comp_compgen -- -W "{1..$((REPLY * 2))}"
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- local opts="$(_parse_help "$1")"
- COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
elif [[ $cur == *=* ]]; then
prev=${cur%%=*}
cur=${cur#*=}
local diropt
[[ ${prev,,} == *dir?(ectory) ]] && diropt=-d
- _filedir $diropt
+ _comp_compgen_filedir $diropt
else
# before we check for makefiles, see if a path was specified
# with -C/--directory
for ((i = 1; i < ${#words[@]}; i++)); do
- if [[ ${words[i]} == -@(C|-directory) ]]; then
- # eval for tilde expansion
- eval "makef_dir=( -C \"${words[i + 1]}\" )"
+ if [[ ${words[i]} == @(-${noargopts}C|--directory) ]]; then
+ # Expand tilde expansion
+ local REPLY
+ _comp_dequote "${words[i + 1]-}" &&
+ [[ -d ${REPLY-} ]] &&
+ makef_dir=(-C "$REPLY")
break
fi
done
@@ -137,25 +130,36 @@ _make()
# before we scan for targets, see if a Makefile name was
# specified with -f/--file/--makefile
for ((i = 1; i < ${#words[@]}; i++)); do
- if [[ ${words[i]} == -@(f|-?(make)file) ]]; then
- # eval for tilde expansion
- eval "makef=( -f \"${words[i + 1]}\" )"
+ if [[ ${words[i]} == @(-${noargopts}f|--?(make)file) ]]; then
+ # Expand tilde expansion
+ local REPLY
+ _comp_dequote "${words[i + 1]-}" &&
+ [[ -f ${REPLY-} ]] &&
+ makef=(-f "$REPLY")
break
fi
done
- # recognise that possible completions are only going to be displayed
- # so only the base name is shown
+ # recognise that possible completions are only going to be displayed so
+ # only the base name is shown.
+ #
+ # Note: This is currently turned off because the test suite of
+ # bash-completion conflicts with it; it uses "set show-all-if-ambiguous
+ # on" (causing COMP_TYPE == 37) to retrieve the action completion
+ # results, and also the compact form with only the basenames is not
+ # essentially needed. To re-enable it, please uncomment the following
+ # if-statement.
local mode=--
- if ((COMP_TYPE != 9)); then
- mode=-d # display-only mode
- fi
+ # if ((COMP_TYPE != 9 && COMP_TYPE != 37 && COMP_TYPE != 42)); then
+ # mode=-d # display-only mode
+ # fi
- local IFS=$' \t\n' script=$(_make_target_extract_script $mode "$cur")
- COMPREPLY=($(LC_ALL=C \
+ _comp_split COMPREPLY "$(LC_ALL=C \
$1 -npq __BASH_MAKE_COMPLETION__=1 \
${makef+"${makef[@]}"} "${makef_dir[@]}" .DEFAULT 2>/dev/null |
- command sed -ne "$script"))
+ _comp_cmd_make__extract_targets "$mode" "$cur")"
+
+ _comp_cmd_make__truncate_non_unique_paths
if [[ $mode != -d ]]; then
# Completion will occur if there is only one suggestion
@@ -165,6 +169,6 @@ _make()
fi
} &&
- complete -F _make make gmake gnumake pmake colormake bmake
+ complete -F _comp_cmd_make make gmake gnumake pmake colormake bmake
# ex: filetype=sh
diff --git a/completions/makepkg b/completions/makepkg
index 23ac784..f6bdc65 100644
--- a/completions/makepkg
+++ b/completions/makepkg
@@ -1,29 +1,27 @@
# makepkg completion -*- shell-script -*-
# Slackware Linux variant
-_makepkg_slackware()
+_comp_cmd_makepkg__slackware()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case "$prev" in
-l | --linkadd | -c | --chown)
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ _comp_compgen -- -W 'y n'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W \
- '$($1 | command sed -e "s/^options://" | _parse_help -)' \
- -- "$cur"))
+ _comp_compgen_help - <<<"$("$1" | command sed -e "s/^options://")"
return
fi
- _filedir
+ _comp_compgen_filedir
}
-_makepkg_bootstrap()
+_comp_cmd_makepkg__bootstrap()
{
local fname help
@@ -32,17 +30,17 @@ _makepkg_bootstrap()
help=$("$1" --help 2>&1)
case ${help,,} in
*slackware*)
- fname=_makepkg_slackware
+ fname=_comp_cmd_makepkg__slackware
;;
*)
- fname=_minimal
+ fname=_comp_complete_minimal
;;
esac
- unset -f _makepkg_bootstrap
+ unset -f "$FUNCNAME"
complete -F $fname makepkg
- $fname
+ $fname "$@"
} &&
- complete -F _makepkg_bootstrap makepkg
+ complete -F _comp_cmd_makepkg__bootstrap makepkg
# ex: filetype=sh
diff --git a/completions/man b/completions/man
index 81d06f5..b405f08 100644
--- a/completions/man
+++ b/completions/man
@@ -1,86 +1,95 @@
# man(1) completion -*- shell-script -*-
-_man()
+_comp_cmd_man()
{
- local cur prev words cword split
- _init_completion -s -n : || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -n : -- "$@" || return
- local comprsuffix=".@([glx]z|bz2|lzma|Z)"
- local manext="@([0-9lnp]|[0-9][px]|man|3?(gl|pm))?($comprsuffix)"
- local mansect="@([0-9lnp]|[0-9][px]|3?(gl|pm))"
+ local comprsuffix=".@([glx]z|bz2|lzma|Z|zst)"
+ local manext="@([0-9]*([a-z])|[lnp]|man)?($comprsuffix)"
+ local mansect="@([0-9]*([a-z])|[lnp])"
+ local noargopts='!(-*|*[ClMSsPpLmerRE]*)'
+ # shellcheck disable=SC2254
case $prev in
- --config-file | -!(-*)C)
- _filedir conf
+ --config-file | -${noargopts}C)
+ _comp_compgen_filedir conf
return
;;
- --local-file | -!(-*)l)
- _filedir "$manext"
+ --local-file | -${noargopts}l)
+ _comp_compgen_filedir "$manext"
return
;;
- --manpath | -!(-*)M)
- _filedir -d
+ --manpath | -${noargopts}M)
+ _comp_compgen_filedir -d
return
;;
- --pager | -!(-*)P)
- compopt -o filenames
- COMPREPLY=($(compgen -c -- "$cur"))
+ --sections | -${noargopts}[Ss])
+ _comp_delimited : -W '{1..9}'
return
;;
- --preprocessor | -!(-*)p)
- COMPREPLY=($(compgen -W 'e p t g r v' -- "$cur"))
+ --pager | -${noargopts}P)
+ _comp_compgen_commands
+ return
+ ;;
+ --preprocessor | -${noargopts}p)
+ _comp_compgen -- -W 'e p t g r v'
return
;;
--locale | --systems | --extension | --prompt | --recode | --encoding | \
- -!(-*)[LmerRE])
+ -${noargopts}[LmerRE])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- local opts=$(_parse_help "$1" -h)
- COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ _comp_compgen_help -- -h || _comp_compgen_usage
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
# file based completion if parameter looks like a path
- if [[ $cur == @(*/|[.~])* ]]; then
- _filedir "$manext"
+ if _comp_looks_like_path "$cur"; then
+ _comp_compgen_filedir "$manext"
return
fi
local manpath=$(manpath 2>/dev/null || command man -w 2>/dev/null)
- [[ -z $manpath ]] && manpath="/usr/share/man:/usr/local/share/man"
+ if [[ ! $manpath ]]; then
+ # Note: Both "manpath" and "man -w" may be unavailable, in
+ # which case we determine the man paths based on the
+ # environment variable MANPATH.
+ manpath=:${MANPATH-}:
+ # Note: An empty path (represented by two consecutive colons
+ # or a preceding/trailing colon) represents the system man
+ # paths.
+ manpath=${manpath//::/':/usr/share/man:/usr/local/share/man:'}
+ manpath=${manpath:1:-1}
+ fi
# determine manual section to search
local sect
# shellcheck disable=SC2053
[[ $prev == $mansect ]] && sect=$prev || sect='*'
- _expand || return
-
- manpath=$manpath:
- if [[ -n $cur ]]; then
- manpath="${manpath//://*man$sect/$cur* } ${manpath//://*cat$sect/$cur* }"
- else
- manpath="${manpath//://*man$sect/ } ${manpath//://*cat$sect/ }"
- fi
-
- local IFS=$' \t\n' reset=$(shopt -p failglob)
- shopt -u failglob
- # redirect stderr for when path doesn't exist
- COMPREPLY=($(eval command ls "$manpath" 2>/dev/null))
- $reset
+ _comp_split -F : manpath "$manpath"
+ if ((${#manpath[@]})); then
+ local manfiles
+ _comp_compgen -Rv manfiles -- -S "/*man$sect/$cur*" -W '"${manpath[@]}"'
+ _comp_compgen -aRv manfiles -- -S "/*cat$sect/$cur*" -W '"${manpath[@]}"'
- if ((${#COMPREPLY[@]} != 0)); then
- # weed out directory path names and paths to man pages
- COMPREPLY=(${COMPREPLY[@]##*/?(:)})
- # strip suffix from man pages
- COMPREPLY=(${COMPREPLY[@]%$comprsuffix})
- COMPREPLY=($(compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}"))
+ local IFS=
+ if _comp_expand_glob COMPREPLY '${manfiles[@]}'; then
+ # weed out directory path names and paths to man pages (empty
+ # elements will be removed by the later `compgen -X ''`)
+ COMPREPLY=("${COMPREPLY[@]##*/?(:)}")
+ # strip suffix from man pages
+ COMPREPLY=("${COMPREPLY[@]%$comprsuffix}")
+ _comp_compgen -c "${cur//\\\\/}" -- -W '"${COMPREPLY[@]%.*}"' -X ''
+ fi
+ _comp_unlocal IFS
fi
# shellcheck disable=SC2053
@@ -88,14 +97,14 @@ _man()
# File based completion for the rest, prepending ./ if needed
# (man 1.6f needs that for man pages in current dir)
local i start=${#COMPREPLY[@]}
- _filedir "$manext"
+ _comp_compgen -a filedir "$manext"
for ((i = start; i < ${#COMPREPLY[@]}; i++)); do
[[ ${COMPREPLY[i]} == */* ]] || COMPREPLY[i]=./${COMPREPLY[i]}
done
fi
- __ltrim_colon_completions "$cur"
+ _comp_ltrim_colon_completions "$cur"
} &&
- complete -F _man man apropos whatis
+ complete -F _comp_cmd_man man apropos whatis
# ex: filetype=sh
diff --git a/completions/mc b/completions/mc
index cf38821..5ea2423 100644
--- a/completions/mc
+++ b/completions/mc
@@ -1,29 +1,31 @@
# bash completion for mc -*- shell-script -*-
-_mc()
+_comp_cmd_mc()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[evlPCD]*)'
+ # shellcheck disable=SC2254
case $prev in
- --edit | --view | --ftplog | --printwd | -!(-*)[evlP])
- _filedir
+ --edit | --view | --ftplog | --printwd | -${noargopts}[evlP])
+ _comp_compgen_filedir
return
;;
- --help | --help-* | --version | --colors | --debuglevel | -!(-*)[hVCD])
+ --help | --help-* | --version | --colors | --debuglevel | -${noargopts}[hVCD])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur"))
+ _comp_compgen_help -- --help-all
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- _filedir -d
+ _comp_compgen_filedir -d
fi
} &&
- complete -F _mc mc
+ complete -F _comp_cmd_mc mc
# ex: filetype=sh
diff --git a/completions/mcrypt b/completions/mcrypt
index 0c3ab5e..3135244 100644
--- a/completions/mcrypt
+++ b/completions/mcrypt
@@ -1,67 +1,65 @@
# mcrypt(1) completion -*- shell-script -*-
# by Ariel Fermani <the_end@bbs.frc.utn.edu.ar>
-_mcrypt()
+_comp_cmd_mcrypt()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-g | --openpgp-z)
- COMPREPLY=($(compgen -W '{0..9}' -- "$cur"))
+ _comp_compgen -- -W '{0..9}'
return
;;
-o | --keymode)
- COMPREPLY=($(compgen -W '$($1 --list-keymodes 2>/dev/null )' \
- -- "$cur"))
+ _comp_compgen_split -- "$("$1" --list-keymodes 2>/dev/null)"
return
;;
-m | --mode)
- COMPREPLY=($(compgen -W "$($1 --list 2>/dev/null | cut -d: -f2-)" \
- -- "$cur"))
+ _comp_compgen_split -- "$("$1" --list 2>/dev/null | cut -d: -f2-)"
return
;;
-a | --algorithm)
- COMPREPLY=($(compgen -W "$($1 --list 2>/dev/null |
- awk '{print $1}')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" --list 2>/dev/null |
+ _comp_awk '{print $1}')"
return
;;
-h | --hash)
- COMPREPLY=($(compgen -W '$($1 --list-hash 2>/dev/null | \
- command sed -e 1d)' -- "$cur"))
+ _comp_compgen_split -- "$("$1" --list-hash 2>/dev/null |
+ command sed -e 1d)"
return
;;
-k | -s | --key | --keysize)
return
;;
-f | -c | --keyfile | --config)
- _filedir
+ _comp_compgen_filedir
return
;;
--algorithms-directory | --modes-directory)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
elif [[ ${words[0]} == mdecrypt ]]; then
- _filedir nc
+ _comp_compgen_filedir nc
else
- local i decrypt=0
- for ((i = 1; i < ${#words[@]} - 1; i++)); do
+ local i decrypt=""
+ for ((i = 1; i < cword; i++)); do
if [[ ${words[i]} == -@(d|-decrypt) ]]; then
- _filedir nc
- decrypt=1
+ _comp_compgen_filedir nc
+ decrypt=set
break
fi
done
- if ((decrypt == 0)); then
- _filedir
+ if [[ ! $decrypt ]]; then
+ _comp_compgen_filedir
fi
fi
} &&
- complete -F _mcrypt mcrypt mdecrypt
+ complete -F _comp_cmd_mcrypt mcrypt mdecrypt
# ex: filetype=sh
diff --git a/completions/mdadm b/completions/mdadm
index 37effd9..e67558d 100644
--- a/completions/mdadm
+++ b/completions/mdadm
@@ -1,16 +1,18 @@
# bash completion for mdadm -*- shell-script -*-
-_mdadm_raid_level()
+_comp_cmd_mdadm__raid_level()
{
- local mode
+ local mode=""
+ local i noargopts='!(-*|*[CB]*)'
for ((i = 1; i < cword; i++)); do
+ # shellcheck disable=SC2254
case ${words[i]} in
- -!(-*)C* | --create)
+ -${noargopts}C* | --create)
mode=create
break
;;
- -!(-*)B* | --build)
+ -${noargopts}B* | --build)
mode=build
break
;;
@@ -19,20 +21,19 @@ _mdadm_raid_level()
case $mode in
create)
- COMPREPLY=($(compgen -W 'linear raid0 0 stripe raid1 1 mirror
- raid4 4 raid5 5 raid6 6 raid10 10 multipath mp faulty' \
- -- "$cur"))
+ _comp_compgen -- -W 'linear raid0 0 stripe raid1 1 mirror raid4 4
+ raid5 5 raid6 6 raid10 10 multipath mp faulty'
;;
build)
- COMPREPLY=($(compgen -W 'linear stripe raid0 0 raid1 multipath mp
- faulty' -- "$cur"))
+ _comp_compgen -- -W 'linear stripe raid0 0 raid1 multipath mp
+ faulty'
;;
esac
}
-_mdadm_raid_layout()
+_comp_cmd_mdadm__raid_layout()
{
- local level
+ local i level=""
for ((i = 1; i < cword; i++)); do
if [[ ${words[i]} == -@(l|-level) ]]; then
level=${words[i + 1]}
@@ -42,108 +43,107 @@ _mdadm_raid_layout()
case $level in
raid5)
- COMPREPLY=($(compgen -W 'left-asymmetric left-symmetric
- right-asymmetric right-symmetric la ra ls rs' -- "$cur"))
+ _comp_compgen -- -W 'left-asymmetric left-symmetric
+ right-asymmetric right-symmetric la ra ls rs'
;;
raid10)
- COMPREPLY=($(compgen -W 'n o p' -- "$cur"))
+ _comp_compgen -- -W 'n o p'
;;
faulty)
- COMPREPLY=($(compgen -W 'write-transient wt read-transient rt
+ _comp_compgen -- -W 'write-transient wt read-transient rt
write-persistent wp read-persistent rp write-all read-fixable
- rf clear flush none' -- "$cur"))
+ rf clear flush none'
;;
esac
}
-_mdadm_auto_flag()
+_comp_cmd_mdadm__auto_flag()
{
- COMPREPLY=($(compgen -W 'no yes md mdp part p' -- "$cur"))
+ _comp_compgen -- -W 'no yes md mdp part p'
}
-_mdadm_update_flag()
+_comp_cmd_mdadm__update_flag()
{
- COMPREPLY=($(compgen -W 'sparc2.2 summaries uuid name homehost resync
- byteorder super-minor' -- "$cur"))
+ _comp_compgen -- -W 'sparc2.2 summaries uuid name homehost resync byteorder
+ super-minor'
}
-_mdadm()
+_comp_cmd_mdadm()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[cblpaU]*)'
+ # shellcheck disable=SC2254
case $prev in
- --config | --bitmap | --backup-file | -!(-*)[cb])
- _filedir
+ --config | --bitmap | --backup-file | -${noargopts}[cb])
+ _comp_compgen_filedir
return
;;
- --level | -!(-*)l)
- _mdadm_raid_level
+ --level | -${noargopts}l)
+ _comp_cmd_mdadm__raid_level
return
;;
- --layout | --parity | -!(-*)p)
- _mdadm_raid_layout
+ --layout | --parity | -${noargopts}p)
+ _comp_cmd_mdadm__raid_layout
return
;;
- --auto | -!(-*)a)
- _mdadm_auto_flag
+ --auto | -${noargopts}a)
+ _comp_cmd_mdadm__auto_flag
return
;;
- --update | -!(-*)U)
- _mdadm_update_flag
+ --update | -${noargopts}U)
+ _comp_cmd_mdadm__update_flag
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
local options='--help --help-options --version --verbose --quiet --brief
--force --config= --scan --metadata= --homehost='
if [[ $cur == -* ]]; then
if ((cword == 1)); then
- COMPREPLY=($(compgen -W "$options --assemble --build --create
- --monitor --grow" -- "$cur"))
+ _comp_compgen -- -W "$options --assemble --build --create --monitor
+ --grow"
else
+ # shellcheck disable=SC2254
case ${words[cword - 1]} in
- --assemble | -!(-*)A*)
- COMPREPLY=($(compgen -W "$options --uuid= --super-minor=
+ --assemble | -${noargopts}A*)
+ _comp_compgen -- -W "$options --uuid= --super-minor=
--name= --force --run --no-degraded --auto= --bitmap=
- --backup-file= --update= --auto-update-homehost" \
- -- "$cur"))
+ --backup-file= --update= --auto-update-homehost"
;;
- --build | --create | --grow | -!(-*)[BCG]*)
- COMPREPLY=($(compgen -W "$options --raid-devices=
+ --build | --create | --grow | -${noargopts}[BCG]*)
+ _comp_compgen -- -W "$options --raid-devices=
--spare-devices= --size= --chunk= --rounding= --level=
--layout= --parity= --bitmap= --bitmap-chunk=
--write-mostly --write-behind= --assume-clean
- --backup-file= --name= --run --force --auto=" \
- -- "$cur"))
+ --backup-file= --name= --run --force --auto="
;;
- --follow | --monitor | -!(-*)F)
- COMPREPLY=($(compgen -W "$options --mail --program
- --alert --syslog --delay --daemonise --pid-file
- --oneshot --test" -- "$cur"))
+ --follow | --monitor | -${noargopts}F)
+ _comp_compgen -- -W "$options --mail --program --alert
+ --syslog --delay --daemonise --pid-file --oneshot
+ --test"
;;
/dev/* | --add | --fail | --remove)
- COMPREPLY=($(compgen -W "$options --add --re-add
- --remove --fail --set-faulty" -- "$cur"))
+ _comp_compgen -- -W "$options --add --re-add --remove
+ --fail --set-faulty"
;;
*)
- COMPREPLY=($(compgen -W "$options --query --detail
- --examine --sparc2.2 --examine-bitmap --run --stop
- --readonly --readwrite --zero-superblock --test" \
- -- "$cur"))
+ _comp_compgen -- -W "$options --query --detail --examine
+ --sparc2.2 --examine-bitmap --run --stop --readonly
+ --readwrite --zero-superblock --test"
;;
esac
fi
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- cur=${cur:=/dev/}
- _filedir
+ _comp_compgen -c "${cur:-/dev/}" filedir
fi
} &&
- complete -F _mdadm mdadm
+ complete -F _comp_cmd_mdadm mdadm
# ex: filetype=sh
diff --git a/completions/mdtool b/completions/mdtool
index 428e33b..cd179e5 100644
--- a/completions/mdtool
+++ b/completions/mdtool
@@ -1,32 +1,30 @@
# mdtool completion -*- shell-script -*-
-_mdtool()
+_comp_cmd_mdtool()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- local command i
-
- for ((i = 1; i < ${#words[@]} - 1; i++)); do
+ local command="" i
+ for ((i = 1; i < cword; i++)); do
if [[ ${words[i]} == @(build|generate-makefiles|setup) ]]; then
command=${words[i]}
break
fi
done
- if [[ -v command ]]; then
+ if [[ $command ]]; then
case $command in
"build")
- COMPREPLY=($(compgen -W '--f --buildfile --p --project' \
- -S":" -- "$cur"))
+ _comp_compgen -- -W '--f --buildfile --p --project' -S":"
# TODO: This does not work :(
#if [[ "$prev" == *: ]]; then
# case $prev in
# @(--p:|--project:))
- # COMPREPLY=( $(compgen -f -G "*.mdp" -- "$cur") )
+ # _comp_compgen -- -f -G "*.mdp"
# ;;
# @(--f:|--buildfile:))
- # COMPREPLY=( $(compgen -f -G "*.mdp" -G "*.mds" -- "$cur") )
+ # _comp_compgen -- -f -G "*.mdp" -G "*.mds"
# ;;
# esac
#fi
@@ -34,29 +32,27 @@ _mdtool()
;;
"generate-makefiles")
compopt -o filenames
- COMPREPLY=($(compgen -o filenames -G"*.mds" -- "$cur"))
+ _comp_compgen -- -o filenames -G"*.mds"
if [[ $prev == *mds ]]; then
- COMPREPLY=($(compgen -W '--simple-makefiles --s --d:' \
- -- "$cur"))
+ _comp_compgen -- -W '--simple-makefiles --s --d:'
fi
return
;;
"setup")
# TODO: at least return filenames after these options.
- COMPREPLY=($(compgen -W 'install i uninstall u check-install
- ci update up list l list-av la list-update lu rep-add ra
+ _comp_compgen -- -W 'install i uninstall u check-install ci
+ update up list l list-av la list-update lu rep-add ra
rep-remove rr rep-update ru rep-list rl reg-update
- reg-build rgu info rep-build rb pack p help h dump-file' \
- -- "$cur"))
+ reg-build rgu info rep-build rb pack p help h dump-file'
return
;;
esac
fi
- COMPREPLY=($(compgen -W 'gsetup build dbgen project-export
- generate-makefiles gettext-update setup -q' -- "$cur"))
+ _comp_compgen -- -W 'gsetup build dbgen project-export generate-makefiles
+ gettext-update setup -q'
} &&
- complete -F _mdtool mdtool
+ complete -F _comp_cmd_mdtool mdtool
# ex: filetype=sh
diff --git a/completions/medusa b/completions/medusa
index 4512987..347879a 100644
--- a/completions/medusa
+++ b/completions/medusa
@@ -1,30 +1,30 @@
# bash completion for medusa -*- shell-script -*-
-_medusa()
+_comp_cmd_medusa()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*h)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-*[HUPCO])
- _filedir
+ _comp_compgen_filedir
return
;;
-*M)
- COMPREPLY=($(compgen -W "$($1 -d | awk '/^ +\+/ {print $2}' |
- command sed -e 's/\.mod$//')"))
+ _comp_compgen_split -- "$("$1" -d | _comp_awk '/^ +\+/ {print $2}' |
+ command sed -e 's/\.mod$//')"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
fi
} &&
- complete -F _medusa medusa
+ complete -F _comp_cmd_medusa medusa
# ex: filetype=sh
diff --git a/completions/mii-diag b/completions/mii-diag
index c433a7a..bf4938b 100644
--- a/completions/mii-diag
+++ b/completions/mii-diag
@@ -1,26 +1,26 @@
# mii-diag(8) completion -*- shell-script -*-
-_mii_diag()
+_comp_cmd_mii_diag()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-F | -A | --advertise | --fixed-speed)
- COMPREPLY=($(compgen -W '100baseT4 100baseTx 100baseTx-FD
- 100baseTx-HD 10baseT 10baseT-FD 10baseT-HD' -- "$cur"))
+ _comp_compgen -- -W '100baseT4 100baseTx 100baseTx-FD 100baseTx-HD
+ 10baseT 10baseT-FD 10baseT-HD'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
else
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
fi
} &&
- complete -F _mii_diag -o default mii-diag
+ complete -F _comp_cmd_mii_diag -o default mii-diag
# ex: filetype=sh
diff --git a/completions/mii-tool b/completions/mii-tool
index 1b80202..b3e15ad 100644
--- a/completions/mii-tool
+++ b/completions/mii-tool
@@ -1,32 +1,34 @@
# mii-tool(8) completion -*- shell-script -*-
-_mii_tool()
+_comp_cmd_mii_tool()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[FA]*)'
+ # shellcheck disable=SC2254
case $prev in
- --force | -!(-*)F)
- COMPREPLY=($(compgen -W '100baseTx-FD 100baseTx-HD 10baseT-FD
- 10baseT-HD' -- "$cur"))
+ --force | -${noargopts}F)
+ _comp_compgen -- -W '100baseTx-FD 100baseTx-HD 10baseT-FD
+ 10baseT-HD'
return
;;
- --advertise | -!(-*)A)
- COMPREPLY=($(compgen -W '100baseT4 100baseTx-FD 100baseTx-HD
- 10baseT-FD 10baseT-HD' -- "$cur"))
+ --advertise | -${noargopts}A)
+ _comp_compgen -- -W '100baseT4 100baseTx-FD 100baseTx-HD 10baseT-FD
+ 10baseT-HD'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
fi
} &&
- complete -F _mii_tool -o default mii-tool
+ complete -F _comp_cmd_mii_tool -o default mii-tool
# ex: filetype=sh
diff --git a/completions/minicom b/completions/minicom
index 57510e9..752c22e 100644
--- a/completions/minicom
+++ b/completions/minicom
@@ -1,40 +1,40 @@
# bash completion for minicom -*- shell-script -*-
-_minicom()
+_comp_cmd_minicom()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[acSCp]*)'
+ # shellcheck disable=SC2254
case $prev in
- --attrib | --color | -!(-*)[ac])
- COMPREPLY=($(compgen -W 'on off' -- "$cur"))
+ --attrib | --color | -${noargopts}[ac])
+ _comp_compgen -- -W 'on off'
return
;;
- --script | --capturefile | -!(-*)[SC])
- _filedir
+ --script | --capturefile | -${noargopts}[SC])
+ _comp_compgen_filedir
return
;;
- --ptty | -!(-*)p)
- COMPREPLY=($(printf '%s\n' /dev/tty*))
- COMPREPLY=($(compgen -W '${COMPREPLY[@]} ${COMPREPLY[@]#/dev/}' \
- -- "$cur"))
+ --ptty | -${noargopts}p)
+ _comp_expand_glob COMPREPLY '/dev/tty*' &&
+ _comp_compgen -- -W '"${COMPREPLY[@]}" "${COMPREPLY[@]#/dev/}"'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- COMPREPLY=(
- $(printf '%s\n' /etc/minirc.* /etc/minicom/minirc.* ~/.minirc.* |
- command sed -e '/\*$/d' -e 's/^.*minirc\.//' |
- command grep "^${cur}"))
+ local -a files
+ _comp_expand_glob files '{/etc/,/etc/minicom/,~/.}minirc.?*' &&
+ _comp_compgen -- -W '"${files[@]##*minirc.}"'
} &&
- complete -F _minicom -o default minicom
+ complete -F _comp_cmd_minicom -o default minicom
# ex: filetype=sh
diff --git a/completions/mkinitrd b/completions/mkinitrd
index bcb7e07..4e11b0b 100644
--- a/completions/mkinitrd
+++ b/completions/mkinitrd
@@ -1,50 +1,49 @@
# bash completion for mkinitrd -*- shell-script -*-
-_mkinitrd()
+_comp_cmd_mkinitrd()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
--preload | --with | --builtin)
- _modules
+ _comp_compgen_kernel_modules
return
;;
--fstab | --dsdt)
- _filedir
+ _comp_compgen_filedir
return
;;
--net-dev)
- _available_interfaces
+ _comp_compgen_available_interfaces
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--version --help -v -f --preload \
- --force-scsi-probe --omit-scsi-modules \
- --omit-ide-modules --image-version --force-raid-probe \
- --omit-raid-modules --with= --force-lvm-probe \
- --omit-lvm-modules --builtin --omit-dmraid --net-dev \
- --fstab --nocompress --dsdt --bootchart' -- "$cur"))
+ _comp_compgen -- -W '--version --help -v -f --preload
+ --force-scsi-probe --omit-scsi-modules --omit-ide-modules
+ --image-version --force-raid-probe --omit-raid-modules --with=
+ --force-lvm-probe --omit-lvm-modules --builtin --omit-dmraid
+ --net-dev --fstab --nocompress --dsdt --bootchart'
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- local args
- _count_args
+ local REPLY
+ _comp_count_args
- case $args in
+ case $REPLY in
1)
- _filedir
+ _comp_compgen_filedir
;;
2)
- _kernel_versions
+ _comp_compgen_kernel_versions
;;
esac
fi
} &&
- complete -F _mkinitrd mkinitrd
+ complete -F _comp_cmd_mkinitrd mkinitrd
# ex: filetype=sh
diff --git a/completions/mktemp b/completions/mktemp
index e063810..a13542a 100644
--- a/completions/mktemp
+++ b/completions/mktemp
@@ -1,29 +1,30 @@
# mktemp(1) completion -*- shell-script -*-
-_mktemp()
+_comp_cmd_mktemp()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[p]*)'
+ # shellcheck disable=SC2254
case "$prev" in
--help | --version | --suffix)
return
;;
- --tmpdir | -!(-*)p)
- _filedir -d
+ --tmpdir | -${noargopts}p)
+ _comp_compgen_filedir -d
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- local opts=$(_parse_help "$1")
- [[ $opts ]] || opts="-d -u -q -p -t" # non-GNU fallback
- COMPREPLY=($(compgen -W "$opts" -- "$cur"))
+ _comp_compgen_help ||
+ _comp_compgen -- -W '-d -u -q -p -t' # non-GNU fallback
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _mktemp mktemp
+ complete -F _comp_cmd_mktemp mktemp
# ex: filetype=sh
diff --git a/completions/mmsitepass b/completions/mmsitepass
index 49daae6..dcf38c7 100644
--- a/completions/mmsitepass
+++ b/completions/mmsitepass
@@ -1,15 +1,15 @@
# mailman mmsitepass completion -*- shell-script -*-
-_mmsitepass()
+_comp_cmd_mmsitepass()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--listcreator --help' -- "$cur"))
+ _comp_compgen -- -W '--listcreator --help'
fi
} &&
- complete -F _mmsitepass mmsitepass
+ complete -F _comp_cmd_mmsitepass mmsitepass
# ex: filetype=sh
diff --git a/completions/modinfo b/completions/modinfo
index 009bcf3..5c8d416 100644
--- a/completions/modinfo
+++ b/completions/modinfo
@@ -1,35 +1,41 @@
# Linux modinfo(8) completion -*- shell-script -*-
-_modinfo()
+_comp_cmd_modinfo()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[Fkb]*)'
+ # shellcheck disable=SC2254
case "$prev" in
- --field | -!(-*)F)
- COMPREPLY=($(compgen -W 'alias author depends description
- filename firmware license parm srcversion staging vermagic
- version' -- "${cur,,}"))
+ --field | -${noargopts}F)
+ _comp_compgen -c "${cur,,}" -- -W 'alias author depends description
+ filename firmware intree license name parm release_date
+ retpoline sig_hashalgo sig_key signat signer softdep srcversion
+ staging vermagic version'
return
;;
- --set-version | -!(-*)k)
- _kernel_versions
+ --set-version | -${noargopts}k)
+ _comp_compgen_kernel_versions
+ return
+ ;;
+ --basedir | -${noargopts}b)
+ _comp_compgen_filedir -d
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- local opts=$(_parse_help "$1")
- COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
local i version=$(uname -r)
for ((i = ${#words[@]} - 1; i > 0; i--)); do
- if [[ ${words[i]} == -@(!(-*)k*|-set-version) ]]; then
+ if [[ ${words[i]} == -@(${noargopts}k*|-set-version) ]]; then
version=${words[i + 1]}
break
fi
@@ -37,11 +43,11 @@ _modinfo()
# do filename completion if we're giving a path to a module
if [[ $cur == @(*/|[.~])* ]]; then
- _filedir '@(?(k)o?(.[gx]z))'
+ _comp_compgen_filedir '@(?(k)o?(.[gx]z|.zst))'
else
- _modules $version
+ _comp_compgen_kernel_modules "$version"
fi
} &&
- complete -F _modinfo modinfo
+ complete -F _comp_cmd_modinfo modinfo
# ex: filetype=sh
diff --git a/completions/modprobe b/completions/modprobe
index 36cb588..242a282 100644
--- a/completions/modprobe
+++ b/completions/modprobe
@@ -1,40 +1,42 @@
# Linux modprobe(8) completion -*- shell-script -*-
-_modprobe()
+_comp_cmd_modprobe()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[CdtS]*)'
+ # shellcheck disable=SC2254
case "$prev" in
- --help | --version | -!(-*)[hV])
+ --help | --version | -${noargopts}[hV])
return
;;
- --config | -!(-*)C)
- _filedir
+ --config | -${noargopts}C)
+ _comp_compgen_filedir
return
;;
- --dirname | --type | -!(-*)[dt])
- _filedir -d
+ --dirname | --type | -${noargopts}[dt])
+ _comp_compgen_filedir -d
return
;;
- --set-version | -!(-*)S)
- _kernel_versions
+ --set-version | -${noargopts}S)
+ _comp_compgen_kernel_versions
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
if [[ ! ${COMPREPLY-} ]]; then
- COMPREPLY=($(compgen -W '-a --all -b --use-blacklist -C --config
+ _comp_compgen -- -W '-a --all -b --use-blacklist -C --config
-c --showconfig --dump-modversions -d --dirname --first-time
--force-vermagic --force-modversion -f --force -i
--ignore-install --ignore-remove -l --list -n --dry-run -q
--quiet -R --resolve-alias -r --remove -S --set-version
--show-depends -s --syslog -t --type -V --version -v
- --verbose' -- "$cur"))
+ --verbose'
fi
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
@@ -42,46 +44,47 @@ _modprobe()
local i mode=insert module="" version=$(uname -r)
for ((i = 1; i < cword; i++)); do
+ # shellcheck disable=SC2254
case "${words[i]}" in
- --remove | -!(-*)r*)
+ --remove | -${noargopts}r*)
mode=remove
;;
- --list | -!(-*)l*)
+ --list | -${noargopts}l*)
mode=list
;;
--dump-modversions)
mode="file"
;;
- --set-version | -!(-*)S)
+ --set-version | -${noargopts}S)
version=${words[i + 1]} # -S is not $prev and not $cur
;;
- --config | --dirname | --type | -!(-*)[Cdt])
+ --config | --dirname | --type | -${noargopts}[Cdt])
((i++)) # skip option and its argument
;;
-*)
# skip all other options
;;
*)
- [[ -z $module ]] && module=${words[i]}
+ [[ ! $module ]] && module=${words[i]}
;;
esac
done
case $mode in
remove)
- _installed_modules "$cur"
+ _comp_compgen_inserted_kernel_modules
;;
list)
# no completion available
;;
file)
- _filedir
+ _comp_compgen_filedir
;;
insert)
# do filename completion if we're giving a path to a module
if [[ $cur == @(*/|[.~])* ]]; then
- _filedir '@(?(k)o?(.[gx]z))'
- elif [[ -n $module ]]; then
+ _comp_compgen_filedir '@(?(k)o?(.[gx]z|.zst))'
+ elif [[ $module ]]; then
# do module parameter completion
if [[ $cur == *=* ]]; then
prev=${cur%%=*}
@@ -90,24 +93,24 @@ _modprobe()
command grep -q "^$prev:.*(bool)"; then
local choices="on off"
[[ $cur ]] && choices="1 0 y Y n N on off"
- COMPREPLY=($(compgen -W "$choices" -- "$cur"))
+ _comp_compgen -- -W "$choices"
fi
else
- COMPREPLY=($(compgen -S = -W "$(PATH="$PATH:/sbin" \
+ _comp_compgen_split -S = -- "$(PATH="$PATH:/sbin" \
modinfo -p "$module" 2>/dev/null |
- awk -F: '!/^[ \t]/ { print $1 }')" -- "$cur"))
+ _comp_awk -F : '!/^[ \t]/ { print $1 }')"
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
else
- _modules $version
+ _comp_compgen_kernel_modules "$version"
if [[ ${COMPREPLY-} ]]; then
# filter out already installed modules
local -a mods=("${COMPREPLY[@]}")
- _installed_modules "$cur"
+ _comp_compgen_inserted_kernel_modules
for i in "${!mods[@]}"; do
for module in "${COMPREPLY[@]}"; do
if [[ ${mods[i]} == "$module" ]]; then
- unset 'mods[i]'
+ unset -v 'mods[i]'
break
fi
done
@@ -118,6 +121,6 @@ _modprobe()
;;
esac
} &&
- complete -F _modprobe modprobe
+ complete -F _comp_cmd_modprobe modprobe
# ex: filetype=sh
diff --git a/completions/monodevelop b/completions/monodevelop
index 1c5b5ba..6e60bfe 100644
--- a/completions/monodevelop
+++ b/completions/monodevelop
@@ -1,19 +1,19 @@
# monodevelop completion -*- shell-script -*-
-_monodevelop()
+_comp_cmd_monodevelop()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ _comp_compgen_help -- -h
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _monodevelop monodevelop
+ complete -F _comp_cmd_monodevelop monodevelop
# ex: filetype=sh
diff --git a/completions/mplayer b/completions/mplayer
index d71ebb8..7ab096a 100644
--- a/completions/mplayer
+++ b/completions/mplayer
@@ -1,120 +1,120 @@
# mplayer(1) completion -*- shell-script -*-
-_mplayer_options_list()
+_comp_cmd_mplayer__options()
{
cur=${cur%\\}
- COMPREPLY=($(compgen -W "$($1 -noconfig all $2 help 2>/dev/null |
- command sed -e '/^Available/,/^$/!d' -e '/^Available/d' | awk '{print $1}' |
- command sed -e 's/:$//' -e 's/^'${2#-}'$//' -e 's/<.*//')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" -noconfig all "$2" help 2>/dev/null |
+ command sed -e '/^Available/,/^$/!d' -e '/^Available/d' | _comp_awk '{print $1}' |
+ command sed -e 's/:$//' -e 's/^'"${2#-}"'$//' -e 's/<.*//')"
}
-_mplayer()
+_comp_cmd_mplayer()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
local cmd=${words[0]} i j k=0
case $prev in
-[av][cfo] | -[av]fm | -vop | -fstype | -demuxer | -o[av]c | -of | -profile | \
-audio-demuxer | -sub-demuxer)
- _mplayer_options_list $cmd $prev
+ _comp_cmd_mplayer__options "$cmd" "$prev"
return
;;
-show-profile)
- _mplayer_options_list $cmd -profile
+ _comp_cmd_mplayer__options "$cmd" -profile
return
;;
-audiofile | -audio-file)
- _filedir '@(mp3|mpg|og[ag]|w?(a)v|mid|flac|mka|ac3|ape)'
+ _comp_compgen_filedir '@(mp3|mpg|og[ag]|w?(a)v|mid|flac|mka|ac3|ape)'
return
;;
-font | -subfont)
if [[ $prev == -font ]]; then
- _filedir '@(desc|ttf)'
+ _comp_compgen_filedir '@(desc|ttf)'
else
- _filedir ttf
+ _comp_compgen_filedir ttf
fi
- local IFS=$'\n'
- COMPREPLY+=($(compgen -W '$(fc-list 2>/dev/null)' -- "$cur"))
+ _comp_compgen -a split -l -- "$(fc-list 2>/dev/null)"
return
;;
-sub | -sub-file)
- _filedir '@(srt|sub|txt|utf|rar|mpsub|smi|js|ssa|ass)'
+ _comp_compgen_filedir '@(srt|sub|txt|utf|rar|mpsub|smi|js|ssa|ass)'
return
;;
-vobsub)
- _filedir '@(idx|ifo|sub)'
- local IFS=$'\n'
- COMPREPLY=($(for i in "${COMPREPLY[@]}"; do
- if [[ -f $i && -r $i ]]; then
- printf '%s\n' ${i%.*}
- else
- printf '%s\n' $i
- fi
- done))
+ if _comp_compgen_filedir '@(idx|ifo|sub)'; then
+ for i in "${!COMPREPLY[@]}"; do
+ if [[ -f ${COMPREPLY[i]} && -r ${COMPREPLY[i]} ]]; then
+ COMPREPLY[i]=${COMPREPLY[i]%.*}
+ fi
+ done
+ fi
return
;;
-subcp | -msgcharset)
local cp
- cp=($(iconv --list 2>/dev/null | command sed -e "s@//@@;" 2>/dev/null))
- if [[ $cur == "${cur,,}" ]]; then
- COMPREPLY=($(compgen -W '${cp[@],,}' -- "$cur"))
- else
- COMPREPLY=($(compgen -W '${cp[@]^^}' -- "$cur"))
+ if _comp_split cp "$(iconv --list 2>/dev/null | command sed -e "s@//@@;" 2>/dev/null)"; then
+ if [[ $cur == "${cur,,}" ]]; then
+ _comp_compgen -- -W '"${cp[@],,}"'
+ else
+ _comp_compgen -- -W '"${cp[@]^^}"'
+ fi
fi
return
;;
-ifo)
- _filedir ifo
+ _comp_compgen_filedir ifo
return
;;
-cuefile)
- _filedir '@(bin|cue)'
+ _comp_compgen_filedir '@(bin|cue)'
return
;;
-skin)
# if you don't have installed mplayer in /usr you
# may want to set the MPLAYER_SKINS_DIR global variable
local -a dirs
- if [[ -n $MPLAYER_SKINS_DIR ]]; then
- dirs=($MPLAYER_SKINS_DIR)
+ if [[ $MPLAYER_SKINS_DIR ]]; then
+ _comp_split dirs "$MPLAYER_SKINS_DIR"
else
dirs=(/usr/share/mplayer/skins /usr/local/share/mplayer/skins)
fi
- local IFS=$'\n'
- for i in ~/.mplayer/skins "${dirs[@]}"; do
- if [[ -d $i && -r $i ]]; then
- for j in $(compgen -d -- $i/$cur); do
- COMPREPLY[k++]=${j#$i/}
- done
- fi
- done
+ if ((${#dirs[@]})); then
+ local -a subdirs
+ for i in ~/.mplayer/skins "${dirs[@]}"; do
+ if [[ -d $i && -r $i ]]; then
+ _comp_compgen -v subdirs -c "$i/$cur" -- -d
+ for j in "${subdirs[@]}"; do
+ COMPREPLY[k++]=${j#"$i/"}
+ done
+ fi
+ done
+ fi
return
;;
-cdrom-device)
- _cd_devices
- _dvd_devices
+ _comp_compgen_cd_devices
+ _comp_compgen -a dvd_devices
return
;;
-dvd-device)
- _dvd_devices
- _filedir iso
+ _comp_compgen_dvd_devices
+ _comp_compgen -a filedir iso
return
;;
-bluray-device)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-mixer | -dvdauth | -fb | -zrdev)
- cur=${cur:=/dev/}
- _filedir
+ _comp_compgen -c "${cur:-/dev/}" filedir
return
;;
-edl | -edlout | -lircconf | -menu-cfg | -playlist | -csslib | -dumpfile | \
-subfile | -aofile | -fbmodeconfig | -include | -o | -dvdkey | -passlogfile)
- _filedir
+ _comp_compgen_filedir
return
;;
-autoq | -autosync | -loop | -menu-root | -speed | -sstep | -aid | -alang | \
@@ -136,124 +136,119 @@ _mplayer()
return
;;
-channels)
- COMPREPLY=($(compgen -W '2 4 6 8' -- "$cur"))
+ _comp_compgen -- -W '2 4 6 8'
return
;;
-aspect | -monitoraspect)
- COMPREPLY=($(compgen -W '1:1 3:2 4:3 5:4 14:9 14:10 16:9 16:10
- 2.35:1' -- "$cur"))
- __ltrim_colon_completions "$cur"
+ _comp_compgen -- -W '1:1 3:2 4:3 5:4 14:9 14:10 16:9 16:10 2.35:1'
+ _comp_ltrim_colon_completions "$cur"
return
;;
-lavdopts)
- COMPREPLY=($(compgen -W 'bitexact bug= debug= ec= er= fast gray
- idct= lowres= sb= st= skiploopfilter= skipidct= skipframe=
- threads= vismv= vstats' -- "$cur"))
+ _comp_compgen -- -W 'bitexact bug= debug= ec= er= fast gray idct=
+ lowres= sb= st= skiploopfilter= skipidct= skipframe= threads=
+ vismv= vstats'
return
;;
-lavcopts)
- COMPREPLY=($(compgen -W 'vcodec= vqmin= vqscale= vqmax= mbqmin=
- mbqmax= vqdiff= vmax_b_frames= vme= vhq v4mv keyint=
- vb_strategy= vpass= aspect= vbitrate= vratetol= vrc_maxrate=
- vrc_minrate= vrc_buf_size= vb_qfactor= vi_qfactor= vb_qoffset=
- vi_qoffset= vqblur= vqcomp= vrc_eq= vrc_override=
- vrc_init_cplx= vqsquish= vlelim= vcelim= vstrict= vdpart
- vpsize= gray vfdct= idct= lumi_mask= dark_mask= tcplx_mask=
- scplx_mask= naq ildct format= pred qpel precmp= cmp= subcmp=
- predia= dia= trell last_pred= preme= subq= psnr mpeg_quant aic
- umv' -- "$cur"))
+ _comp_compgen -- -W 'vcodec= vqmin= vqscale= vqmax= mbqmin= mbqmax=
+ vqdiff= vmax_b_frames= vme= vhq v4mv keyint= vb_strategy=
+ vpass= aspect= vbitrate= vratetol= vrc_maxrate= vrc_minrate=
+ vrc_buf_size= vb_qfactor= vi_qfactor= vb_qoffset= vi_qoffset=
+ vqblur= vqcomp= vrc_eq= vrc_override= vrc_init_cplx= vqsquish=
+ vlelim= vcelim= vstrict= vdpart vpsize= gray vfdct= idct=
+ lumi_mask= dark_mask= tcplx_mask= scplx_mask= naq ildct format=
+ pred qpel precmp= cmp= subcmp= predia= dia= trell last_pred=
+ preme= subq= psnr mpeg_quant aic umv'
return
;;
-ssf)
- COMPREPLY=($(compgen -W 'lgb= cgb= ls= cs= chs= cvs=' -- "$cur"))
+ _comp_compgen -- -W 'lgb= cgb= ls= cs= chs= cvs='
return
;;
-jpeg)
- COMPREPLY=($(compgen -W 'noprogressive progressive nobaseline
- baseline optimize= smooth= quality= outdir=' -- "$cur"))
+ _comp_compgen -- -W 'noprogressive progressive nobaseline baseline
+ optimize= smooth= quality= outdir='
return
;;
-xvidopts)
- COMPREPLY=($(compgen -W 'dr2 nodr2' -- "$cur"))
+ _comp_compgen -- -W 'dr2 nodr2'
return
;;
-xvidencopts)
- COMPREPLY=($(compgen -W 'pass= bitrate= fixed_quant= me_quality=
- 4mv rc_reaction_delay_factor= rc_averaging_period= rc_buffer=
+ _comp_compgen -- -W 'pass= bitrate= fixed_quant= me_quality= 4mv
+ rc_reaction_delay_factor= rc_averaging_period= rc_buffer=
quant_range= min_key_interval= max_key_interval= mpeg_quant
mod_quant lumi_mask hintedme hintfile debug keyframe_boost=
- kfthreshold= kfreduction=' -- "$cur"))
+ kfthreshold= kfreduction='
return
;;
-divx4opts)
- COMPREPLY=($(compgen -W 'br= key= deinterlace q= min_quant=
- max_quant= rc_period= rc_reaction_period= crispness=
- rc_reaction_ratio= pass= vbrpass= help' -- "$cur"))
+ _comp_compgen -- -W 'br= key= deinterlace q= min_quant= max_quant=
+ rc_period= rc_reaction_period= crispness= rc_reaction_ratio=
+ pass= vbrpass= help'
return
;;
-info)
- COMPREPLY=($(compgen -W 'name= artist= genre= subject=
- copyright= srcform= comment= help' -- "$cur"))
+ _comp_compgen -- -W 'name= artist= genre= subject= copyright=
+ srcform= comment= help'
return
;;
-lameopts)
- COMPREPLY=($(compgen -W 'vbr= abr cbr br= q= aq= ratio= vol=
- mode= padding= fast preset= help' -- "$cur"))
+ _comp_compgen -- -W 'vbr= abr cbr br= q= aq= ratio= vol= mode=
+ padding= fast preset= help'
return
;;
-rawaudio)
- COMPREPLY=($(compgen -W 'on channels= rate= samplesize= format=' \
- -- "$cur"))
+ _comp_compgen -- -W 'on channels= rate= samplesize= format='
return
;;
-rawvideo)
- COMPREPLY=($(compgen -W 'on fps= sqcif qcif cif 4cif pal ntsc w=
- h= y420 yv12 yuy2 y8 format= size=' -- "$cur"))
+ _comp_compgen -- -W 'on fps= sqcif qcif cif 4cif pal ntsc w= h=
+ y420 yv12 yuy2 y8 format= size='
return
;;
-aop)
- COMPREPLY=($(compgen -W 'list= delay= format= fout= volume= mul=
- softclip' -- "$cur"))
+ _comp_compgen -- -W 'list= delay= format= fout= volume= mul=
+ softclip'
return
;;
-dxr2)
- COMPREPLY=($(compgen -W 'ar-mode= iec958-encoded iec958-decoded
- mute ucode= 75ire bw color interlaced macrovision= norm=
+ _comp_compgen -- -W 'ar-mode= iec958-encoded iec958-decoded mute
+ ucode= 75ire bw color interlaced macrovision= norm=
square-pixel ccir601-pixel cr-left= cr-right= cr-top= cr-bot=
ck-rmin= ck-gmin= ck-bmin= ck-rmax= ck-gmax= ck-bmax= ck-r=
ck-g= ck-b= ignore-cache= ol-osd= olh-cor= olw-cor= olx-cor=
- oly-cor= overlay overlay-ratio= update-cache' -- "$cur"))
+ oly-cor= overlay overlay-ratio= update-cache'
return
;;
-tv)
- COMPREPLY=($(compgen -W 'on noaudio driver= device= input= freq=
+ _comp_compgen -- -W 'on noaudio driver= device= input= freq=
outfmt= width= height= buffersize= norm= channel= chanlist=
audiorate= forceaudio alsa amode= forcechan= adevice= audioid=
- volume= bass= treble= balance= fps= channels= immediatemode=' \
- -- "$cur"))
+ volume= bass= treble= balance= fps= channels= immediatemode='
return
;;
-mf)
- COMPREPLY=($(compgen -W 'on w= h= fps= type=' -- "$cur"))
+ _comp_compgen -- -W 'on w= h= fps= type='
return
;;
-cdda)
- COMPREPLY=($(compgen -W 'speed= paranoia= generic-dev=
- sector-size= overlap= toc-bias toc-offset= skip noskip' \
- -- "$cur"))
+ _comp_compgen -- -W 'speed= paranoia= generic-dev= sector-size=
+ overlap= toc-bias toc-offset= skip noskip'
return
;;
-input)
- COMPREPLY=($(compgen -W 'conf= ar-delay ar-rate keylist cmdlist
- js-dev file' -- "$cur"))
+ _comp_compgen -- -W 'conf= ar-delay ar-rate keylist cmdlist js-dev
+ file'
return
;;
-af-adv)
- COMPREPLY=($(compgen -W 'force= list=' -- "$cur"))
+ _comp_compgen -- -W 'force= list='
return
;;
-noconfig)
- COMPREPLY=($(compgen -W 'all gui system user' -- "$cur"))
+ _comp_compgen -- -W 'all gui system user'
return
;;
-*)
@@ -271,17 +266,17 @@ _mplayer()
case $cur in
-*)
- COMPREPLY=($(compgen -W '$($cmd -noconfig all -list-options 2>/dev/null | \
+ _comp_compgen_split -- "$("$cmd" -noconfig all -list-options 2>/dev/null |
command sed -ne "1,/^[[:space:]]*Name/d" \
-e "s/^[[:space:]]*/-/" -e "s/[[:space:]:].*//" \
- -e "/^-\(Total\|.*\*\)\{0,1\}$/!p")' -- "$cur"))
+ -e "/^-\(Total\|.*\*\)\{0,1\}$/!p")"
;;
*)
- _filedir '@(m?(j)p?(e)g|M?(J)P?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|vob|VOB|bin|BIN|dat|DAT|vcd|VCD|ps|PS|pes|PES|fl[iv]|FL[IV]|fxm|FXM|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|og[gmavx]|OG[GMAVX]|w?(a)v|W?(A)V|dump|DUMP|mk[av]|MK[AV]|aac|AAC|m2v|M2V|dv|DV|rmvb|RMVB|mid|MID|t[ps]|T[PS]|3g[p2]|3gpp?(2)|mpc|MPC|flac|FLAC|vro|VRO|divx|DIVX|aif?(f)|AIF?(F)|m2t?(s)|M2T?(S)|mts|MTS|vdr|VDR|xvid|XVID|ape|APE|gif|GIF|nut|NUT|bik|BIK|web[am]|WEB[AM]|amr|AMR|awb|AWB|iso|ISO|opus|OPUS|m[eo]d|M[EO]D|xm|XM|it|IT|s[t3]m|S[T3]M|mtm|MTM|w64|W64)?(.@(crdownload|part))'
+ _comp_compgen_filedir '@(m?(j)p?(e)g|M?(J)P?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|vob|VOB|bin|BIN|dat|DAT|vcd|VCD|ps|PS|pes|PES|fl[iv]|FL[IV]|fxm|FXM|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|og[gmavx]|OG[GMAVX]|w?(a)v|W?(A)V|dump|DUMP|mk[av]|MK[AV]|aac|AAC|m2v|M2V|dv|DV|rmvb|RMVB|mid|MID|t[ps]|T[PS]|3g[p2]|3gpp?(2)|mpc|MPC|flac|FLAC|vro|VRO|divx|DIVX|aif?(f)|AIF?(F)|m2t?(s)|M2T?(S)|mts|MTS|vdr|VDR|xvid|XVID|ape|APE|gif|GIF|nut|NUT|bik|BIK|web[am]|WEB[AM]|amr|AMR|awb|AWB|iso|ISO|opus|OPUS|m[eo]d|M[EO]D|xm|XM|it|IT|s[t3]m|S[T3]M|mtm|MTM|w64|W64)?(.@(crdownload|part))'
;;
esac
} &&
- complete -F _mplayer mplayer mplayer2 mencoder gmplayer kplayer
+ complete -F _comp_cmd_mplayer mplayer mplayer2 mencoder gmplayer kplayer
# ex: filetype=sh
diff --git a/completions/mr b/completions/mr
index 930e3c9..660dfd8 100644
--- a/completions/mr
+++ b/completions/mr
@@ -1,59 +1,66 @@
# mr completion -*- shell-script -*-
-_mr()
+_comp_cmd_mr()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local help commands options
help="$(PERLDOC_PAGER=cat PERLDOC=-otext "${1}" help 2>/dev/null)"
commands="$(
+ # shellcheck disable=SC2030
printf %s "$help" | while read -r _ options cmd _; do
[[ $options != "[options]" ]] || printf "%s\n" "$cmd"
done
)"
# Split [online|offline] and remove `action` placeholder.
- commands="${commands//@(action|[\[\|\]])/$'\n'}"
+ commands="${commands//@(action|[\[\|\]])/ }"
# Add standard aliases.
commands="${commands} ci co ls"
+ _comp_split commands "$commands"
+ local IFS='|'
+ local glob_commands="@(${commands[*]})"
+ _comp_unlocal IFS
# Determine if user has entered an `mr` command. Used to block top-level
# (option and command) completions.
- local cmd i
- for ((i = 1; i < ${#words[@]} - 1; i++)); do
- if [[ $commands == *"${words[i]}"* ]]; then
+ local cmd has_cmd="" i
+ for ((i = 1; i < cword; i++)); do
+ # shellcheck disable=SC2053
+ if [[ ${words[i]} == $glob_commands ]]; then
cmd="${words[i]}"
+ has_cmd=set
break
fi
done
# Complete options for specific commands.
- if [[ -v cmd ]]; then
+ if [[ $has_cmd ]]; then
case $cmd in
bootstrap)
- _filedir
+ _comp_compgen_filedir
# Also complete stdin (-) as a potential bootstrap source.
- if [[ -z ${cur} || $cur == - ]] && [[ $prev != - ]]; then
+ if [[ ! ${cur} || $cur == - ]] && [[ $prev != - ]]; then
COMPREPLY+=(-)
fi
return
;;
clean)
if [[ ${cur} == -* ]]; then
- COMPREPLY=($(compgen -W '-f' -- "${cur}"))
+ _comp_compgen -- -W '-f'
fi
return
;;
commit | ci | record)
if [[ ${cur} == -* ]]; then
- COMPREPLY=($(compgen -W '-m' -- "${cur}"))
+ _comp_compgen -- -W '-m'
fi
return
;;
run)
- COMPREPLY=($(compgen -c -- "${cur}"))
+ _comp_compgen_commands
return
;;
*)
@@ -64,28 +71,28 @@ _mr()
fi
# Complete top-level options and commands.
+ local noargopts='!(-*|*[cd]*)'
+ # shellcheck disable=SC2254
case $prev in
- --config | -!(-*)c)
- _filedir
+ --config | -${noargopts}c)
+ _comp_compgen_filedir
return
;;
- --directory | -!(-*)d)
- _filedir -d
+ --directory | -${noargopts}d)
+ _comp_compgen_filedir -d
return
;;
esac
if [[ $cur == -* ]]; then
- options="$(printf '%s\n' "$help" | _parse_help -)"
- # Remove short options (all have compatible long options).
- options="${options//-[a-z]$'\n'/}"
- # Remove deprecated options.
- options="${options//--path/}"
- COMPREPLY=($(compgen -W "${options}" -- "${cur}"))
+ _comp_compgen -Rv options help - <<<"$help"
+ # -X '-[a-z]': Remove short options (all have compatible long options).
+ # -X '--path': Remove deprecated options.
+ _comp_compgen -- -W '"${options[@]}"' -X '@(-[a-z]|--path)'
else
- COMPREPLY=($(compgen -W "${commands}" -- "${cur}"))
+ _comp_compgen -- -W '"${commands[@]}"'
fi
} &&
- complete -F _mr mr
+ complete -F _comp_cmd_mr mr
# ex: filetype=sh
diff --git a/completions/msynctool b/completions/msynctool
index 4de37f5..0348170 100644
--- a/completions/msynctool
+++ b/completions/msynctool
@@ -1,42 +1,38 @@
# bash completion for msynctool -*- shell-script -*-
-_msynctool()
+_comp_cmd_msynctool()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $words in
--configure)
- COMPREPLY=($(compgen -W "$($1 --showgroup \
- $prev | awk '/^Member/ {print $2}' | command sed \
- -e 's/:$//')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" --showgroup "$prev" |
+ _comp_awk '/^Member/ {print $2}' | command sed -e 's/:$//')"
return
;;
--addmember)
- COMPREPLY=($(compgen -W '$($1 --listplugins \
- | command sed -e 1d)' -- "$cur"))
+ _comp_compgen_split -- "$("$1" --listplugins | command sed -e 1d)"
return
;;
esac
case $prev in
--configure | --addgroup | --delgroup | --showgroup | --sync | --addmember)
- COMPREPLY=($(compgen -W '$($1 --listgroups \
- | command sed -e 1d)' -- "$cur"))
+ _comp_compgen_split -- "$("$1" --listgroups | command sed -e 1d)"
return
;;
--showformats | --filter-objtype | --slow-sync)
- COMPREPLY=($(compgen -W '$($1 --listobjects \
- | command sed -e 1d)' -- "$cur"))
+ _comp_compgen_split -- "$("$1" --listobjects | command sed -e 1d)"
return
;;
esac
- COMPREPLY=($(compgen -W '--listgroups --listplugins --listobjects
- --showformats --showgroup --sync --filter-objtype --slow-sync --wait
- --multi --addgroup --delgroup --addmember --configure --manual
- --configdir --conflict' -- "$cur"))
+ _comp_compgen -- -W '--listgroups --listplugins --listobjects --showformats
+ --showgroup --sync --filter-objtype --slow-sync --wait --multi
+ --addgroup --delgroup --addmember --configure --manual --configdir
+ --conflict'
} &&
- complete -F _msynctool msynctool
+ complete -F _comp_cmd_msynctool msynctool
# ex: filetype=sh
diff --git a/completions/mtx b/completions/mtx
index b5c270b..d04a0c1 100644
--- a/completions/mtx
+++ b/completions/mtx
@@ -1,10 +1,10 @@
# mtx completion -*- shell-script -*-
# by Jon Middleton <jjm@ixtab.org.uk>
-_mtx()
+_comp_cmd_mtx()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local options tapes drives
@@ -12,21 +12,21 @@ _mtx()
inventory status load unload eepos first last next"
tapes=$(mtx status 2>/dev/null |
- awk '/Storage Element [0-9]+:Full/ { printf "%s ", $3 }')
+ _comp_awk '/Storage Element [0-9]+:Full/ { printf "%s ", $3 }')
tapes=${tapes//:Full/}
drives=$(mtx status 2>/dev/null |
- awk '/Data Transfer Element [0-9]+:(Full|Empty)/ { printf "%s ", $4 }')
+ _comp_awk '/Data Transfer Element [0-9]+:(Full|Empty)/ { printf "%s ", $4 }')
drives=${drives//:Full/}
drives=${drives//:Empty/}
if ((cword > 1)); then
case $prev in
load)
- COMPREPLY=($(compgen -W "$tapes" -- "$cur"))
+ _comp_compgen -- -W "$tapes"
;;
unload | first | last | next)
- COMPREPLY=($(compgen -W "$drives" -- "$cur"))
+ _comp_compgen -- -W "$drives"
;;
-f)
true
@@ -36,9 +36,9 @@ _mtx()
;;
esac
else
- COMPREPLY=($(compgen -W "$options" -- "$cur"))
+ _comp_compgen -- -W "$options"
fi
} &&
- complete -F _mtx mtx
+ complete -F _comp_cmd_mtx mtx
# ex: filetype=sh
diff --git a/completions/munin-node-configure b/completions/munin-node-configure
index 39d8d64..edfb4b9 100644
--- a/completions/munin-node-configure
+++ b/completions/munin-node-configure
@@ -1,33 +1,33 @@
# munin-node-configure completion -*- shell-script -*-
-_munin_node_configure()
+_comp_cmd_munin_node_configure()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--config)
- _filedir
+ _comp_compgen_filedir
return
;;
--servicedir | --libdir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
--snmp)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
--snmpversion)
- COMPREPLY=($(compgen -W '1 2c 3' -- "$cur"))
+ _comp_compgen -- -W '1 2c 3'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
fi
} &&
- complete -F _munin_node_configure munin-node-configure
+ complete -F _comp_cmd_munin_node_configure munin-node-configure
# ex: filetype=sh
diff --git a/completions/munin-run b/completions/munin-run
index 97e526a..c514a01 100644
--- a/completions/munin-run
+++ b/completions/munin-run
@@ -1,28 +1,27 @@
# munin-run completion -*- shell-script -*-
-_munin_run()
+_comp_cmd_munin_run()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--config | --sconffile)
- _filedir
+ _comp_compgen_filedir
return
;;
--servicedir | --sconfdir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
else
- COMPREPLY=($(compgen -W \
- '$(command ls /etc/munin/plugins 2>/dev/null)' -- "$cur"))
+ _comp_compgen_split -- "$(command ls /etc/munin/plugins 2>/dev/null)"
fi
} &&
- complete -F _munin_run munin-run
+ complete -F _comp_cmd_munin_run munin-run
# ex: filetype=sh
diff --git a/completions/munin-update b/completions/munin-update
index 8766eae..8ed8a1f 100644
--- a/completions/munin-update
+++ b/completions/munin-update
@@ -1,27 +1,27 @@
# munin-update completion -*- shell-script -*-
-_munin_update()
+_comp_cmd_munin_update()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--config)
- _filedir
+ _comp_compgen_filedir
return
;;
--host)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--force-root --noforce-root --service --host
+ _comp_compgen -- -W '--force-root --noforce-root --service --host
--config --help --debug --nodebug --fork --nofork --stdout
- --nostdout --timeout' -- "$cur"))
+ --nostdout --timeout'
fi
} &&
- complete -F _munin_update munin-update
+ complete -F _comp_cmd_munin_update munin-update
# ex: filetype=sh
diff --git a/completions/munindoc b/completions/munindoc
index 5c7644a..4a1b4c6 100644
--- a/completions/munindoc
+++ b/completions/munindoc
@@ -1,13 +1,12 @@
# munindoc completion -*- shell-script -*-
-_munindoc()
+_comp_cmd_munindoc()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- COMPREPLY=($(compgen -W \
- '$(command ls /usr/share/munin/plugins 2>/dev/null)' -- "$cur"))
+ _comp_compgen_split -- "$(command ls /usr/share/munin/plugins 2>/dev/null)"
} &&
- complete -F _munindoc munindoc
+ complete -F _comp_cmd_munindoc munindoc
# ex: filetype=sh
diff --git a/completions/mussh b/completions/mussh
index c2f7a52..e36affe 100644
--- a/completions/mussh
+++ b/completions/mussh
@@ -1,52 +1,52 @@
# mussh(1) completion -*- shell-script -*-
-_mussh()
+_comp_cmd_mussh()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--help | -V | -m | -t)
return
;;
-d)
- COMPREPLY=($(compgen -W '{0..2}' -- "$cur"))
+ _comp_compgen -- -W '{0..2}'
return
;;
-v)
- COMPREPLY=($(compgen -W '{0..3}' -- "$cur"))
+ _comp_compgen -- -W '{0..3}'
return
;;
-i | -H | -C)
- _filedir
+ _comp_compgen_filedir
return
;;
-o | -po)
- _xfunc ssh _ssh_options
+ _comp_compgen -x ssh options
return
;;
-l | -L)
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
return
;;
-s)
- _shells
+ _comp_compgen_shells
return
;;
-p | -h)
- [[ $cur == *@* ]] && _user_at_host || _known_hosts_real -a -- "$cur"
+ [[ $cur == *@* ]] && _comp_complete_user_at_host "$@" || _comp_compgen_known_hosts -a -- "$cur"
return
;;
-c)
compopt -o filenames
- COMPREPLY+=($(compgen -c -- "$cur"))
+ _comp_compgen_commands
return
;;
esac
[[ $cur != -* ]] ||
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
} &&
- complete -F _mussh mussh
+ complete -F _comp_cmd_mussh mussh
# ex: filetype=sh
diff --git a/completions/mutt b/completions/mutt
index 1161487..5ebf65a 100644
--- a/completions/mutt
+++ b/completions/mutt
@@ -4,157 +4,174 @@
# a "query" function to retrieve addresses, so that's what we use here.
# @param $1 (cur) Current word to complete
-_muttaddr()
+_comp_cmd_mutt__addresses()
{
- _muttaliases "$1"
- _muttquery "$1"
+ _comp_cmd_mutt__aliases "$1"
+ _comp_cmd_mutt__query "$1"
- COMPREPLY+=($(compgen -u -- "$1"))
+ _comp_compgen -ac "$1" -- -u
}
# Find muttrc to use
-# @output muttrc filename
-_muttrc()
+# @var[out] REPLY muttrc filename
+_comp_cmd_mutt__get_muttrc()
{
+ REPLY=
# Search COMP_WORDS for '-F muttrc' or '-Fmuttrc' argument
set -- "${words[@]}"
while (($# > 0)); do
if [[ $1 == -F* ]]; then
if ((${#1} > 2)); then
- muttrc="$(dequote "${1:2}")"
+ _comp_dequote "${1:2}"
else
shift
- [[ $1 ]] && muttrc="$(dequote "$1")"
+ [[ ${1-} ]] && _comp_dequote "$1"
fi
break
fi
shift
done
- if [[ ! -v muttrc ]]; then
+ if [[ ! $REPLY ]]; then
if [[ -f ~/.${muttcmd}rc ]]; then
- muttrc=\~/.${muttcmd}rc
+ REPLY=\~/.${muttcmd}rc
elif [[ -f ~/.${muttcmd}/${muttcmd}rc ]]; then
- muttrc=\~/.${muttcmd}/${muttcmd}rc
+ REPLY=\~/.${muttcmd}/${muttcmd}rc
fi
fi
- printf "%s" "${muttrc-}"
}
# Recursively build list of sourced config files
-# @param $1 List of config files found so far
-# @param $2 Config file to process
-# @output List of config files
-_muttconffiles()
+# @param $1... Config file to process
+# @var[out] REPLY List of config files
+# @return 0 if any conffiles are generated, 1 if none is generated.
+_comp_cmd_mutt__get_conffiles()
{
- local file sofar
+ local -a conffiles=()
+ local -A visited=()
+ local file
+ for file; do
+ _comp_dequote "$file"
+ _comp_cmd_mutt__get_conffiles__visit "$REPLY"
+ done
+ ((${#conffiles[@]})) || return 1
+ REPLY=("${conffiles[@]}")
+}
+# Recursion function for _comp_cmd_mutt__get_conffiles
+# @var[ref] conffiles List of config files found so far
+# @var[ref] visited Dictionary of config files already visited
+_comp_cmd_mutt__get_conffiles__visit()
+{
+ [[ -f $1 && ${visited[$1]-} != set ]] || return 0
+ visited[$1]=set
+ conffiles+=("$1")
+
local -a newconffiles
+ _comp_split newconffiles "$(command sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' "$1")" ||
+ return 0
- sofar=" $1 "
- shift
- while [[ ${1-} ]]; do
- newconffiles=($(command sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' "$(eval printf %s $1)"))
- for file in ${newconffiles+"${newconffiles[@]}"}; do
- __expand_tilde_by_ref file
- [[ ! -f $file || $sofar == *\ $file\ * ]] && continue
- sofar+=" $file"
- sofar=" $(eval _muttconffiles \"$sofar\" $file) "
- done
- shift
+ local file REPLY
+ for file in "${newconffiles[@]}"; do
+ _comp_expand_tilde "$file"
+ _comp_cmd_mutt__get_conffiles__visit "$REPLY"
done
- printf '%s\n' $sofar
}
# @param $1 (cur) Current word to complete
-_muttaliases()
+_comp_cmd_mutt__aliases()
{
- local cur=$1 muttrc muttcmd=${words[0]}
+ local cur=$1 muttrc muttcmd=${words[0]} REPLY
local -a conffiles aliases
- muttrc=$(_muttrc)
- [[ -z $muttrc ]] && return
+ _comp_cmd_mutt__get_muttrc
+ muttrc=$REPLY
+ [[ ! $muttrc ]] && return
- conffiles=($(eval _muttconffiles $muttrc $muttrc))
- # shellcheck disable=SC2046
- aliases=("$(command sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' \
- $(eval echo "${conffiles[@]}"))")
- COMPREPLY+=($(compgen -W "${aliases[*]}" -- "$cur"))
+ local REPLY
+ _comp_cmd_mutt__get_conffiles "$muttrc" || return 0
+ conffiles=("${REPLY[@]}")
+ _comp_compgen -a split -- "$(command sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' \
+ "${conffiles[@]}")"
}
# @param $1 (cur) Current word to complete
-_muttquery()
+_comp_cmd_mutt__query()
{
- local cur=$1 querycmd muttcmd=${words[0]}
- local -a queryresults
-
- querycmd="$($muttcmd -Q query_command 2>/dev/null | command sed -e 's|^query_command=\"\(.*\)\"$|\1|' -e 's|%s|'$cur'|')"
- if [[ -z $cur || -z $querycmd ]]; then
- queryresults=()
- else
- __expand_tilde_by_ref querycmd
- queryresults=($($querycmd |
- command sed -n '2,$s|^\([^[:space:]]\{1,\}\).*|\1|p'))
+ local cur=$1
+ [[ $cur ]] || return 0
+ local muttcmd=${words[0]}
+
+ local querycmd="$("$muttcmd" -Q query_command 2>/dev/null | command sed -e 's|^query_command=\"\(.*\)\"$|\1|' -e 's|%s|'"$cur"'|')"
+ if [[ $querycmd ]]; then
+ local REPLY
+ _comp_expand_tilde "$querycmd"
+ querycmd=$REPLY
+ # generate queryresults:
+ # $querycmd is expected to be a command with arguments
+ _comp_compgen -a split -- "$($querycmd |
+ command sed -n '2,$s|^\([^[:space:]]\{1,\}\).*|\1|p')"
fi
-
- COMPREPLY+=($(compgen -W "${queryresults[*]}" -- "$cur"))
}
# @param $1 (cur) Current word to complete
-_muttfiledir()
+_comp_cmd_mutt__filedir()
{
- local cur=$1 folder muttrc spoolfile muttcmd=${words[0]}
-
- muttrc=$(_muttrc)
+ local cur=$1 folder muttrc spoolfile muttcmd=${words[0]} REPLY
+ _comp_cmd_mutt__get_muttrc
+ muttrc=$REPLY
if [[ $cur == [=+]* ]]; then
- folder="$($muttcmd -F "$muttrc" -Q folder 2>/dev/null | command sed -e 's|^folder=\"\(.*\)\"$|\1|')"
- : folder:=~/Mail
+ folder="$("$muttcmd" -F "$muttrc" -Q folder 2>/dev/null | command sed -e 's|^folder=\"\(.*\)\"$|\1|')"
+ [[ $folder ]] || folder=~/Mail
# Match any file in $folder beginning with $cur
# (minus the leading '=' sign).
compopt -o filenames
- COMPREPLY=($(compgen -f -- "$folder/${cur:1}"))
- COMPREPLY=(${COMPREPLY[@]#$folder/})
+ _comp_compgen -c "$folder/${cur:1}" -- -f
+ COMPREPLY=("${COMPREPLY[@]#"$folder"/}")
return
elif [[ $cur == !* ]]; then
- spoolfile="$($muttcmd -F "$muttrc" -Q spoolfile 2>/dev/null |
+ spoolfile="$("$muttcmd" -F "$muttrc" -Q spoolfile 2>/dev/null |
command sed -e 's|^spoolfile=\"\(.*\)\"$|\1|')"
- [[ -n $spoolfile ]] && eval cur="${cur/^!/$spoolfile}"
+ if [[ $spoolfile ]]; then
+ _comp_dequote "\"$spoolfile\"" && spoolfile=$REPLY
+ cur=$spoolfile${cur:1}
+ fi
fi
- _filedir
+ _comp_compgen -c "$cur" filedir
}
-_mutt()
+_comp_cmd_mutt()
{
- local cur prev words cword
- _init_completion -n =+! || return
+ local cur prev words cword comp_args
+ _comp_initialize -n =+! -- "$@" || return
case $cur in
-*)
- COMPREPLY=($(compgen -W '-A -a -b -c -e -f -F -H -i -m -n -p -Q -R -s
- -v -x -y -z -Z -h' -- "$cur"))
+ _comp_compgen -- -W '-A -a -b -c -e -f -F -H -i -m -n -p -Q -R -s
+ -v -x -y -z -Z -h'
return
;;
*)
case $prev in
-*[afFHi])
- _muttfiledir "$cur"
+ _comp_cmd_mutt__filedir "$cur"
return
;;
-*A)
- _muttaliases "$cur"
+ _comp_cmd_mutt__aliases "$cur"
return
;;
-*[emQshpRvyzZ])
return
;;
*)
- _muttaddr "$cur"
+ _comp_cmd_mutt__addresses "$cur"
return
;;
esac
;;
esac
} &&
- complete -F _mutt -o default mutt muttng
+ complete -F _comp_cmd_mutt -o default mutt muttng neomutt
# ex: filetype=sh
diff --git a/completions/mypy b/completions/mypy
index 534d575..1c01ad4 100644
--- a/completions/mypy
+++ b/completions/mypy
@@ -1,57 +1,60 @@
# mypy completion -*- shell-script -*-
-_mypy()
+_comp_cmd_mypy()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
[[ $cword -gt 2 && ${words[cword - 2]} == --shadow-file ]] &&
prev=--shadow-file # hack; takes two args
+ local noargopts='!(-*|*[pcm]*)'
+ # shellcheck disable=SC2254
case $prev in
--help | --version | --python-version | --platform | --always-true | \
- --always-false | --find-occurrences | --package | --command | -!(-*)[hVpc])
+ --always-false | --@(dis|en)able-error-code | --find-occurrences | \
+ --exclude | --package | --command | -${noargopts}[hVpc])
return
;;
--config-file)
- _filedir
+ _comp_compgen_filedir
return
;;
--follow-imports)
- COMPREPLY=($(compgen -W 'normal silent skip error' -- "$cur"))
+ _comp_compgen -- -W 'normal silent skip error'
return
;;
--python-executable)
- COMPREPLY=($(compgen -c -- "${cur:-py}"))
+ _comp_compgen -c "${cur:-py}" commands
return
;;
--*-dir | --*-report)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
- --custom-typing | --module | -!(-*)m)
- _xfunc python _python_modules
+ --custom-typing-module | --module | -${noargopts}m)
+ _comp_compgen -x python modules
return
;;
--shadow-file)
- _filedir '@(py|pyi)'
+ _comp_compgen_filedir '@(py|pyi)'
return
;;
--junit-xml)
- _filedir xml
+ _comp_compgen_filedir xml
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- _filedir '@(py|pyi)'
+ _comp_compgen_filedir '@(py|pyi)'
} &&
- complete -F _mypy mypy
+ complete -F _comp_cmd_mypy mypy
# ex: filetype=sh
diff --git a/completions/mysql b/completions/mysql
index 9363133..4ba049f 100644
--- a/completions/mysql
+++ b/completions/mysql
@@ -1,83 +1,94 @@
# mysql(1) completion -*- shell-script -*-
-_mysql_character_sets()
+# @since 2.12
+_comp_xfunc_mysql_compgen_character_sets()
{
- local IFS=$' \t\n' reset=$(shopt -p failglob)
- shopt -u failglob
- local -a charsets=(/usr/share/m{ariadb,ysql}/charsets/*.xml)
- $reset
+ local -a charsets
+ _comp_expand_glob charsets '/usr/share/m{ariadb,ysql}/charsets/!(Index).xml'
+ charsets+=(utf8)
charsets=("${charsets[@]##*/}")
- charsets=("${charsets[@]%%?(Index|\*).xml}" utf8)
- COMPREPLY+=($(compgen -W '${charsets[@]}' -- "$cur"))
+ charsets=("${charsets[@]%.xml}")
+ _comp_compgen -U charsets -- -W '"${charsets[@]}"' -X ''
}
-_mysql()
+# @deprecated 2.12
+_mysql_character_sets()
{
- local cur prev words cword split
- _init_completion -s || return
+ _comp_compgen -ax mysql character_sets "$@"
+}
+_comp_cmd_mysql()
+{
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+
+ # Prefer `mysqlshow` in the same dir as the command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+
+ local noargopts='!(-*|*[uDhSPeI]*)'
+ # shellcheck disable=SC2254
case $prev in
- --user | -!(-*)u)
- COMPREPLY=($(compgen -u -- "$cur"))
+ --user | -${noargopts}u)
+ _comp_compgen -- -u
return
;;
- --database | -!(-*)D)
- COMPREPLY=($(compgen -W "$(mysqlshow 2>/dev/null | command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" -- "$cur"))
+ --database | -${noargopts}D)
+ _comp_compgen_split -- "$(mysqlshow 2>/dev/null |
+ command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')"
return
;;
- --host | -!(-*)h)
- _known_hosts_real -- "$cur"
+ --host | -${noargopts}h)
+ _comp_compgen_known_hosts -- "$cur"
return
;;
--default-character-set)
- _mysql_character_sets
+ _comp_xfunc_mysql_compgen_character_sets
return
;;
--character-sets-dir | --ssl-capath)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
- --socket | -!(-*)S)
- _filedir sock
+ --socket | -${noargopts}S)
+ _comp_compgen_filedir sock
return
;;
--protocol)
- COMPREPLY=($(compgen -W 'tcp socket pipe memory' -- "$cur"))
+ _comp_compgen -- -W 'tcp socket pipe memory'
return
;;
--defaults-file | --defaults-extra-file | --tee)
- _filedir
+ _comp_compgen_filedir
return
;;
--ssl-ca | --ssl-cert)
- _filedir '@(pem|cer|c?(e)rt)'
+ _comp_compgen_filedir '@(pem|cer|c?(e)rt)'
return
;;
--ssl-key)
- _filedir '@(pem|key)'
+ _comp_compgen_filedir '@(pem|key)'
return
;;
--port | --set-variable | --ssl-cipher | --connect_timeout | \
--max_allowed_packet | --prompt | --net_buffer_length | --select_limit | \
--max_join_size | --server-arg | --debug | --delimiter | --execute | --pager | \
- -!(-*)[Pe])
+ -${noargopts}[Pe])
return
;;
- --help | --version | -!(-*)[?IV])
+ --help | --version | -${noargopts}[?IV])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
case $cur in
--*)
- local help=$(_parse_help "$1")
- help+=" --skip-comments --skip-ssl"
-
- COMPREPLY=($(compgen -W "$help" -- "$cur"))
+ _comp_compgen_help
+ _comp_compgen -a -- -W '--skip-comments --skip-ssl'
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
;;
@@ -90,10 +101,9 @@ _mysql()
;;
esac
- COMPREPLY=($(compgen -W \
- "$(mysqlshow 2>/dev/null | command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" \
- -- "$cur"))
+ _comp_compgen_split -- "$(mysqlshow 2>/dev/null |
+ command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')"
} &&
- complete -F _mysql mysql
+ complete -F _comp_cmd_mysql mysql
# ex: filetype=sh
diff --git a/completions/mysqladmin b/completions/mysqladmin
index 5329534..af7d50f 100644
--- a/completions/mysqladmin
+++ b/completions/mysqladmin
@@ -1,63 +1,65 @@
# bash completion for mysqladmin -*- shell-script -*-
-_mysqladmin()
+_comp_cmd_mysqladmin()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[uhScPOiw]*)'
+ # shellcheck disable=SC2254
case $prev in
- --user | -!(-*)u)
- COMPREPLY=($(compgen -u -- "$cur"))
+ --user | -${noargopts}u)
+ _comp_compgen -- -u
return
;;
- --host | -!(-*)h)
- _known_hosts_real -- "$cur"
+ --host | -${noargopts}h)
+ _comp_compgen_known_hosts -- "$cur"
return
;;
--character-sets-dir | --ssl-capath)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
--default-character-set)
- _xfunc mysql _mysql_character_sets
+ _comp_compgen -x mysql character_sets
return
;;
- --socket | -!(-*)S)
- _filedir sock
+ --socket | -${noargopts}S)
+ _comp_compgen_filedir sock
return
;;
--defaults-file | --defaults-extra-file)
- _filedir
+ _comp_compgen_filedir
return
;;
--ssl-ca | --ssl-cert)
- _filedir '@(pem|cer|c?(e)rt)'
+ _comp_compgen_filedir '@(pem|cer|c?(e)rt)'
return
;;
--ssl-key)
- _filedir '@(pem|key)'
+ _comp_compgen_filedir '@(pem|key)'
return
;;
--count | --port | --set-variable | --sleep | --ssl-cipher | --wait | \
- --connect_timeout | --shutdown_timeout | -!(-*)[cPOiw])
+ --connect_timeout | --shutdown_timeout | -${noargopts}[cPOiw])
return
;;
- --help | --version | -!(-*)[?V])
+ --help | --version | -${noargopts}[?V])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
- COMPREPLY+=($(compgen -W 'create debug drop extended-status flush-hosts
+ _comp_compgen -a -- -W 'create debug drop extended-status flush-hosts
flush-logs flush-status flush-tables flush-threads flush-privileges
kill password old-password ping processlist reload refresh shutdown
- status start-slave stop-slave variables version' -- "$cur"))
+ status start-slave stop-slave variables version'
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
} &&
- complete -F _mysqladmin mysqladmin
+ complete -F _comp_cmd_mysqladmin mysqladmin
# ex: filetype=sh
diff --git a/completions/nc b/completions/nc
index 6fb0994..22e297c 100644
--- a/completions/nc
+++ b/completions/nc
@@ -1,9 +1,9 @@
# nc(1) completion -*- shell-script -*-
-_nc()
+_comp_cmd_nc()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
case $prev in
-*[hIiMmOPpqVWw])
@@ -11,41 +11,39 @@ _nc()
;;
-*s)
if [[ ${words[*]} == *-6* ]]; then
- _ip_addresses -6
- __ltrim_colon_completions "$cur"
+ _comp_compgen_ip_addresses -6
else
- _ip_addresses
+ _comp_compgen_ip_addresses
fi
return
;;
-*T)
- COMPREPLY=($(compgen -W 'critical inetcontrol lowcost lowdelay
- netcontrol throughput reliability ef af{11..43} cs{0..7}' \
- -- "$cur"))
+ _comp_compgen -- -W 'critical inetcontrol lowcost lowdelay
+ netcontrol throughput reliability ef af{11..43} cs{0..7}'
return
;;
-*X)
- COMPREPLY=($(compgen -W '4 5 connect' -- "$cur"))
+ _comp_compgen -- -W '4 5 connect'
return
;;
-*x)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ _comp_compgen_help -- -h
return
fi
# Complete 1st non-option arg only
- local args
- _count_args "" "-*[IiMmOPpqsTVWwXx]"
- ((args == 1)) || return
+ local REPLY
+ _comp_count_args -n "" -a "-*[IiMmOPpqsTVWwXx]"
+ ((REPLY == 1)) || return
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
} &&
- complete -F _nc nc
+ complete -F _comp_cmd_nc nc
# ex: filetype=sh
diff --git a/completions/ncftp b/completions/ncftp
index c3f2cf1..60218c1 100644
--- a/completions/ncftp
+++ b/completions/ncftp
@@ -1,9 +1,9 @@
# bash completion for ncftp -*- shell-script -*-
-_ncftp()
+_comp_cmd_ncftp()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-u | -p | -P | -j | -F)
@@ -12,16 +12,16 @@ _ncftp()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ _comp_compgen_help -- -h
return
fi
if [[ $cword -eq 1 && -f ~/.ncftp/bookmarks ]]; then
- COMPREPLY=($(compgen -W '$(command sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \
- ~/.ncftp/bookmarks)' -- "$cur"))
+ _comp_compgen_split -- "$(command sed -ne \
+ 's/^\([^,]\{1,\}\),.*$/\1/p' ~/.ncftp/bookmarks)"
fi
} &&
- complete -F _ncftp -o default ncftp
+ complete -F _comp_cmd_ncftp -o default ncftp
# ex: filetype=sh
diff --git a/completions/nethogs b/completions/nethogs
index 5cd3650..c39a707 100644
--- a/completions/nethogs
+++ b/completions/nethogs
@@ -1,26 +1,26 @@
# bash completion for nethogs(8) -*- shell-script -*-
-_nethogs()
+_comp_cmd_nethogs()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case "$prev" in
-d)
# expect integer value
- COMPREPLY+=($(compgen -W '{0..9}'))
+ _comp_compgen -aR -- -W '{0..9}'
compopt -o nospace
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" -h)' -- "$cur"))
+ _comp_compgen_usage -- -h
return
fi
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
} &&
- complete -F _nethogs nethogs
+ complete -F _comp_cmd_nethogs nethogs
# ex: filetype=sh
diff --git a/completions/newlist b/completions/newlist
index f1f6cf8..b4e6060 100644
--- a/completions/newlist
+++ b/completions/newlist
@@ -1,9 +1,9 @@
# mailman newlist completion -*- shell-script -*-
-_newlist()
+_comp_cmd_newlist()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-l | --language | -u | --urlhost | -e | --emailhost | --help)
@@ -11,15 +11,18 @@ _newlist()
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- _xfunc list_lists _mailman_lists
+ # Prefer `list_lists` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -x list_lists mailman_lists
fi
} &&
- complete -F _newlist newlist
+ complete -F _comp_cmd_newlist newlist
# ex: filetype=sh
diff --git a/completions/newusers b/completions/newusers
index 890a5fc..28282f6 100644
--- a/completions/newusers
+++ b/completions/newusers
@@ -1,13 +1,13 @@
# newusers(8) completion -*- shell-script -*-
-_newusers()
+_comp_cmd_newusers()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-c | --crypt)
- COMPREPLY=($(compgen -W 'DES MD5 NONE SHA256 SHA512' -- "$cur"))
+ _comp_compgen -- -W 'DES MD5 NONE SHA256 SHA512'
return
;;
-s | --sha-rounds)
@@ -15,16 +15,16 @@ _newusers()
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _newusers newusers
+ complete -F _comp_cmd_newusers newusers
# ex: filetype=sh
diff --git a/completions/ngrep b/completions/ngrep
index 7d16c8d..14f39a9 100644
--- a/completions/ngrep
+++ b/completions/ngrep
@@ -1,38 +1,38 @@
# ngrep(8) completion -*- shell-script -*-
-_ngrep()
+_comp_cmd_ngrep()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-h | -V | -n | -A | -s | -S | -c | -P)
return
;;
-I | -O)
- _filedir 'pcap?(ng)'
+ _comp_compgen_filedir 'pcap?(ng)'
return
;;
-d)
- _available_interfaces -a
- COMPREPLY+=($(compgen -W 'any' -- "$cur"))
+ _comp_compgen_available_interfaces -a
+ _comp_compgen -a -- -W 'any'
return
;;
-W)
- COMPREPLY=($(compgen -W 'normal byline single none' -- "$cur"))
+ _comp_compgen -- -W 'normal byline single none'
return
;;
-F)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ _comp_compgen_help -- -h
return
fi
} &&
- complete -F _ngrep ngrep
+ complete -F _comp_cmd_ngrep ngrep
# ex: filetype=sh
diff --git a/completions/nmap b/completions/nmap
index 482148e..a3e691b 100644
--- a/completions/nmap
+++ b/completions/nmap
@@ -1,30 +1,30 @@
# bash completion for nmap -*- shell-script -*-
-_nmap()
+_comp_cmd_nmap()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-iL | -oN | -oX | -oS | -oG | ---excludefile | --resume | --stylesheet)
- _filedir
+ _comp_compgen_filedir
return
;;
-oA | --datadir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-e)
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
return
;;
-b | --dns-servers)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
# strip everything following a :, inclusive
@@ -35,7 +35,7 @@ _nmap()
# expand --foo/bar to --foo --bar
# strip everything following a non-option name or = char
# TODO: should expand -T<0-5> to -T0 ... -T5
- COMPREPLY=($(compgen -W "$(
+ _comp_compgen_split -- "$(
"$1" --help 2>&1 | command sed \
-e "s/:.*$//" \
-e "s/=.*$/=/" \
@@ -44,13 +44,12 @@ _nmap()
-e "/^[[:space:]]*-[^-]/s/\/\([^-]\)/ -\1/g" \
-e "/^[[:space:]]*--/s/\/\([^-]\)/ --\1/g" \
-e "s/[^[:space:]a-zA-Z0-9=-].*$//"
- )" \
- -- "$cur"))
+ )"
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
fi
} &&
- complete -F _nmap nmap
+ complete -F _comp_cmd_nmap nmap
# ex: filetype=sh
diff --git a/completions/nproc b/completions/nproc
index 50273f0..dc38944 100644
--- a/completions/nproc
+++ b/completions/nproc
@@ -1,9 +1,9 @@
# nproc(1) completion -*- shell-script -*-
-_nproc()
+_comp_cmd_nproc()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
--help | --version | --ignore)
@@ -11,13 +11,13 @@ _nproc()
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _nproc nproc
+ complete -F _comp_cmd_nproc nproc
# ex: filetype=sh
diff --git a/completions/nslookup b/completions/nslookup
index 3341b1f..b04b03a 100644
--- a/completions/nslookup
+++ b/completions/nslookup
@@ -1,32 +1,42 @@
# bash completion for nslookup -*- shell-script -*-
-_bind_queryclass()
+_comp_cmd_nslookup__queryclass()
{
- COMPREPLY+=($(compgen -W 'IN CH HS ANY' -- "$cur"))
+ _comp_compgen -a -- -W 'IN CH HS ANY'
}
-_bind_querytype()
+_comp_cmd_nslookup__querytype()
{
# https://en.wikipedia.org/wiki/List_of_DNS_record_types
- COMPREPLY+=($(compgen -W 'A AAAA AFSDB APL CERT CNAME DHCID DLV DNAME
- DNSKEY DS HIP IPSECKEY KEY KX LOC MX NAPTR NS NSEC NSEC3 NSEC3PARAM PTR
- RRSIG RP SIG SOA SPF SRV SSHFP TXT' -- "$cur"))
+ # Resource records
+ local -a types=(
+ A AAAA AFSDB APL CAA CDNSKEY CDS CERT CNAME CSYNC DHCID DLV DNAME
+ DNSKEY DS EUI48 EUI64 HINFO HIP IPSECKEY KEY KX LOC MX NAPTR NS NSEC
+ NSEC3 NSEC3PARAM OPENPGPKEY PTR RRSIG RP SIG SMIMEA SOA SRV SSHFP TA
+ TKEY TLSA TSIG TXT URI ZONEMD SVCB HTTPS
+ )
+ # Other types/pseudo record types
+ types+=(AXFR IXFR OPT)
+ # Selected obsolete record types
+ types+=(SPF)
+
+ _comp_compgen -a -- -W '"${types[@]}"'
}
-_nslookup()
+_comp_cmd_nslookup()
{
- local cur prev words cword
- _init_completion -n = || return
+ local cur prev words cword comp_args
+ _comp_initialize -n = -- "$@" || return
case $cur in
-class=* | -cl=*)
cur=${cur#*=}
- _bind_queryclass
+ _comp_cmd_nslookup__queryclass
return
;;
-querytype=* | -type=* | -q=* | -ty=*)
cur=${cur#*=}
- _bind_querytype
+ _comp_cmd_nslookup__querytype
return
;;
-?*=*)
@@ -35,38 +45,38 @@ _nslookup()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-all -class= -debug -nodebug -d2 -nod2
- -domain= -search -nosearch -port= -querytype= -recurse -norecurse
- -retry= -timeout= -vc -novc -fail -nofail' -- "$cur"))
+ _comp_compgen -- -W '-all -class= -debug -nodebug -d2 -nod2 -domain=
+ -search -nosearch -port= -querytype= -recurse -norecurse -retry=
+ -timeout= -vc -novc -fail -nofail'
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- local args
- _count_args =
- if ((args <= 2)); then
- _known_hosts_real -- "$cur"
- [[ $args -eq 1 && $cur == @(|-) ]] && COMPREPLY+=(-)
+ local REPLY
+ _comp_count_args
+ if ((REPLY <= 2)); then
+ _comp_compgen_known_hosts -- "$cur"
+ [[ $REPLY -eq 1 && $cur == @(|-) ]] && COMPREPLY+=(-)
fi
} &&
- complete -F _nslookup nslookup
+ complete -F _comp_cmd_nslookup nslookup
-_host()
+_comp_cmd_host()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-c)
- _bind_queryclass
+ _comp_cmd_nslookup__queryclass
return
;;
-t)
- _bind_querytype
+ _comp_cmd_nslookup__querytype
return
;;
-m)
- COMPREPLY=($(compgen -W 'trace record usage' -- "$cur"))
+ _comp_compgen -- -W 'trace record usage'
return
;;
-N | -R | -W)
@@ -75,12 +85,21 @@ _host()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
return
fi
- _known_hosts_real -- "$cur"
+ local REPLY
+ _comp_count_args -a "-*[ctmNRW]"
+ if ((REPLY == 1)); then
+ _comp_compgen_known_hosts -- "$cur"
+ elif ((REPLY == 2)); then
+ local ipvx
+ [[ ${words[*]} =~ \ -[^\ ]*([46]) ]] && ipvx=-${BASH_REMATCH[1]}
+ # shellcheck disable=SC2086
+ _comp_compgen_known_hosts ${ipvx-} -- "$cur"
+ fi
} &&
- complete -F _host host
+ complete -F _comp_cmd_host host
# ex: filetype=sh
diff --git a/completions/nsupdate b/completions/nsupdate
index 68df333..854e33c 100644
--- a/completions/nsupdate
+++ b/completions/nsupdate
@@ -1,27 +1,25 @@
# bash completion for nsupdate(1) -*- shell-script -*-
-_nsupdate()
+_comp_cmd_nsupdate()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*[VLprtu])
return
;;
-*k)
- _filedir key
+ _comp_compgen_filedir key
return
;;
-*R)
- cur=${cur:=/dev/}
- _filedir
+ _comp_compgen -c "${cur:-/dev/}" filedir
return
;;
-*y)
if [[ $cur == h* ]]; then
- COMPREPLY=($(compgen -W "hmac-{md5,sha{1,224,256,384,512}}" \
- -S : -- "$cur"))
+ _comp_comtpen -- -W "hmac-{md5,sha{1,224,256,384,512}}" -S :
[[ ${COMPREPLY-} == *: ]] && compopt -o nospace
fi
return
@@ -29,12 +27,12 @@ _nsupdate()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _nsupdate nsupdate
+ complete -F _comp_cmd_nsupdate nsupdate
# ex: filetype=sh
diff --git a/completions/ntpdate b/completions/ntpdate
index f6ee8f5..5dab0a7 100644
--- a/completions/ntpdate
+++ b/completions/ntpdate
@@ -1,21 +1,21 @@
# bash completion for ntpdate -*- shell-script -*-
-_ntpdate()
+_comp_cmd_ntpdate()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*k)
- _filedir
+ _comp_compgen_filedir
return
;;
-*U)
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
return
;;
-*p)
- COMPREPLY=($(compgen -W '{1..8}' -- "$cur"))
+ _comp_compgen -- -W '{1..8}'
return
;;
@@ -25,11 +25,11 @@ _ntpdate()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_help -- -h || _comp_compgen_usage
else
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
fi
} &&
- complete -F _ntpdate ntpdate
+ complete -F _comp_cmd_ntpdate ntpdate
# ex: filetype=sh
diff --git a/completions/oggdec b/completions/oggdec
index 97bde20..a76ba49 100644
--- a/completions/oggdec
+++ b/completions/oggdec
@@ -1,38 +1,40 @@
# bash completion for oggdec(1) -*- shell-script -*-
-_oggdec()
+_comp_cmd_oggdec()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[beso]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | -!(-*)[hV]*)
+ --help | --version | -${noargopts}[hV]*)
return
;;
- --bits | -!(-*)b)
- COMPREPLY=($(compgen -W "8 16" -- "$cur"))
+ --bits | -${noargopts}b)
+ _comp_compgen -- -W "8 16"
return
;;
- --endianness | --sign | -!(-*)[es])
- COMPREPLY=($(compgen -W "0 1" -- "$cur"))
+ --endianness | --sign | -${noargopts}[es])
+ _comp_compgen -- -W "0 1"
return
;;
- --output | -!(-*)o)
- _filedir wav
+ --output | -${noargopts}o)
+ _comp_compgen_filedir wav
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir ogg
+ _comp_compgen_filedir ogg
} &&
- complete -F _oggdec oggdec
+ complete -F _comp_cmd_oggdec oggdec
# ex: filetype=sh
diff --git a/completions/op b/completions/op
deleted file mode 100644
index 31d6475..0000000
--- a/completions/op
+++ /dev/null
@@ -1,59 +0,0 @@
-# op (1Password CLI) completion -*- shell-script -*-
-
-_op_commands()
-{
- "$@" --help 2>/dev/null |
- awk '/^(Available |Sub)commands/{flag=1;next}/^ /&&flag{print $1}'
-}
-
-_op_command_options()
-{
- case $cur in
- -*)
- for i in "${!words[@]}"; do
- [[ ${words[i]} == -* || $i -eq 0 ]] && unset "words[i]"
- done
- COMPREPLY=($(compgen -W \
- '$(_parse_usage "$1" "${words[*]} --help") --help' -- "$cur"))
- [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
- return 0
- ;;
- esac
- return 1
-}
-
-_op()
-{
- local cur prev words cword split
- _init_completion -s || return
-
- local command i
- for ((i = 1; i < cword; i++)); do
- case ${words[i]} in
- --help | --version) return ;;
- -*) ;;
- *)
- command=${words[i]}
- break
- ;;
- esac
- done
-
- if [[ ! -v command && $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
- [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
- return
- fi
-
- [[ -v command ]] && _op_command_options "$1" && return
-
- if [[ ! -v command || $command == "$prev" ]]; then
- COMPREPLY=($(compgen -W '$(_op_commands "$1" ${command-})' -- "$cur"))
- [[ ${COMPREPLY-} ]] && return
- fi
-
- # TODO specific command and subcommand completions
-} &&
- complete -F _op op
-
-# ex: filetype=sh
diff --git a/completions/openssl b/completions/openssl
index dd77092..9dad715 100644
--- a/completions/openssl
+++ b/completions/openssl
@@ -1,52 +1,54 @@
# bash completion for openssl -*- shell-script -*-
-_openssl_sections()
+_comp_cmd_openssl__compgen_sections()
{
- local config f
+ local config="" _i _file
# check if a specific configuration file is used
- for ((i = 2; i < cword; i++)); do
- if [[ ${words[i]} == -config ]]; then
- config=${words[i + 1]}
+ for ((_i = 2; _i < cword; _i++)); do
+ if [[ ${words[_i]} == -config ]]; then
+ config=${words[_i + 1]}
break
fi
done
# if no config given, check some usual default locations
- if [[ -z $config ]]; then
- for f in /etc/ssl/openssl.cnf /etc/pki/tls/openssl.cnf \
+ if [[ ! $config ]]; then
+ for _file in /etc/ssl/openssl.cnf /etc/pki/tls/openssl.cnf \
/usr/share/ssl/openssl.cnf; do
- [[ -f $f ]] && config=$f && break
+ [[ -f $_file ]] && config=$_file && break
done
fi
[[ ! -f $config ]] && return
- COMPREPLY=($(compgen -W "$(awk '/\[.*\]/ {print $2}' $config)" -- "$cur"))
+ _comp_compgen -U config split -- "$(_comp_awk '/\[.*\]/ {print $2}' "$config")"
}
-_openssl_digests()
+_comp_cmd_openssl__compgen_digests()
{
- "$1" dgst -h 2>&1 |
- awk '/^-.*[ \t]to use the .* message digest algorithm/ { print $1 }'
- local -a digests=($("$1" help 2>&1 |
+ [[ $cur == -* ]] || return
+ _comp_compgen_split -- "$(
+ "$1" dgst -h 2>&1 |
+ _comp_awk '/^-.*[ \t]to use the .* message digest algorithm/ { print $1 }'
+ )"
+ _comp_compgen -ac "${cur#-}" split -P "-" -- "$("$1" help 2>&1 |
command sed -ne '/^Message Digest commands/,/^[[:space:]]*$/p' |
- command sed -e 1d))
- printf "%s\n" "${digests[@]/#/-}"
+ command sed -e 1d)"
}
-_openssl()
+_comp_cmd_openssl()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- local commands command options formats
+ local commands command formats
commands='asn1parse ca ciphers crl crl2pkcs7 dgst dh dhparam dsa dsaparam
ec ecparam enc engine errstr gendh gendsa genrsa nseq ocsp passwd
pkcs12 pkcs7 pkcs8 prime rand req rsa rsautl s_client s_server s_time
- sess_id smime speed spkac verify version x509 md2 md4 md5 rmd160 sha
- sha1 aes-128-cbc aes-128-ecb aes-192-cbc aes-192-ecb aes-256-cbc
+ sess_id smime speed spkac storeutl verify version x509 md2 md4 md5 rmd160
+ sha sha1 aes-128-cbc aes-128-ecb aes-192-cbc aes-192-ecb aes-256-cbc
aes-256-ecb base64 bf bf-cbc bf-cfb bf-ecb bf-ofb camellia-128-cbc
camellia-128-ecb camellia-192-cbc camellia-192-ecb camellia-256-cbc
camellia-256-ecb cast cast-cbc cast5-cbc cast5-cfb cast5-ecb cast5-ofb
@@ -56,7 +58,7 @@ _openssl()
sha224 sha256 sha384 sha512 genpkey pkey pkeyparam pkeyutl'
if ((cword == 1)); then
- COMPREPLY=($(compgen -W "$commands" -- "$cur"))
+ _comp_compgen -- -W "$commands"
else
command=${words[1]}
case $prev in
@@ -65,15 +67,15 @@ _openssl()
-out | -oid | -paramfile | -peerkey | -prvrify | -rand | -recip | -revoke | \
-sess_in | -sess_out | -spkac | -sigfile | -sign | -signkey | -signer | \
-signature | -ss_cert | -untrusted | -verify | -writerand)
- _filedir
+ _comp_compgen_filedir
return
;;
-outdir | -CApath)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-name | -crlexts | -extensions)
- _openssl_sections
+ _comp_cmd_openssl__compgen_sections
return
;;
-inform | -outform | -keyform | -certform | -CAform | -CAkeyform | -dkeyform | \
@@ -90,49 +92,48 @@ _openssl()
formats+=" ENGINE"
;;
esac
- COMPREPLY=($(compgen -W "$formats" -- "$cur"))
+ _comp_compgen -- -W "$formats"
return
;;
-connect)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-starttls)
- COMPREPLY=($(compgen -W '
- smtp pop3 imap ftp xmpp xmpp-server telnet irc mysql
- postgres lmtp nntp sieve ldap
- ' -- "$cur"))
+ _comp_compgen -- -W ' smtp pop3 imap ftp xmpp xmpp-server
+ telnet irc mysql postgres lmtp nntp sieve ldap'
return
;;
-cipher)
- COMPREPLY=($(IFS=: compgen -W "$($1 ciphers)" -- "$cur"))
+ _comp_compgen_split -F : -- "$("$1" ciphers)"
return
;;
-kdf)
- COMPREPLY=($(compgen -W 'TLS1-PRF HKDF' -- "$cur"))
+ _comp_compgen -- -W 'TLS1-PRF HKDF'
return
;;
esac
if [[ $cur == -* ]]; then
# possible options for the command
- options=$(_parse_help "$1" "$command -help" 2>/dev/null)
+ _comp_compgen_help -- "$command" -help
case $command in
- dgst | req | x509) options+=" $(_openssl_digests $1)" ;;
+ dgst | req | x509)
+ _comp_compgen -a -i openssl digests "$1"
+ ;;
esac
- COMPREPLY=($(compgen -W "$options" -- "$cur"))
else
if [[ $command == speed ]]; then
- COMPREPLY=($(compgen -W 'md2 mdc2 md5 hmac sha1 rmd160
- idea-cbc rc2-cbc rc5-cbc bf-cbc des-cbc des-ede3 rc4
- rsa512 rsa1024 rsa2048 rsa4096 dsa512 dsa1024 dsa2048 idea
- rc2 des rsa blowfish' -- "$cur"))
+ _comp_compgen -- -W 'md2 mdc2 md5 hmac sha1 rmd160 idea-cbc
+ rc2-cbc rc5-cbc bf-cbc des-cbc des-ede3 rc4 rsa512 rsa1024
+ rsa2048 rsa4096 dsa512 dsa1024 dsa2048 idea rc2 des rsa
+ blowfish'
else
- _filedir
+ _comp_compgen_filedir
fi
fi
fi
} &&
- complete -F _openssl -o default openssl
+ complete -F _comp_cmd_openssl -o default openssl
# ex: filetype=sh
diff --git a/completions/opera b/completions/opera
index f2bc8c3..c9245e4 100644
--- a/completions/opera
+++ b/completions/opera
@@ -1,29 +1,28 @@
# opera(1) completion -*- shell-script -*-
-_opera()
+_comp_cmd_opera()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case "$prev" in
?(-)-widget | ?(-)-urllist | ?(-)-uiparserlog | ?(-)-uiwidgetsparserlog | \
?(-)-profilinglog)
- _filedir
+ _comp_compgen_filedir
return
;;
?(-)-[psb]d)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
?(-)-remote)
- COMPREPLY=($(compgen -W 'openURL\\( openFile\\( openM2\\(
- openComposer\\( addBookmark\\( raise\\(\\) lower\\(\\)' \
- -- "$cur"))
+ _comp_compgen -- -W 'openURL\\( openFile\\( openM2\\(
+ openComposer\\( addBookmark\\( raise\\(\\) lower\\(\\)'
[[ ${COMPREPLY-} == *\( ]] && compopt -o nospace
return
;;
?(-)-windowname)
- COMPREPLY=($(compgen -W 'first last opera{1..9}' -- "$cur"))
+ _comp_compgen -- -W 'first last opera{1..9}'
return
;;
?(-)-geometry | ?(-)-window | ?(-)-display | ?(-)-urllistloadtimeout | \
@@ -35,13 +34,13 @@ _opera()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir '@(?([xX]|[sS])[hH][tT][mM]?([lL]))'
+ _comp_compgen_filedir '@(?([xX]|[sS])[hH][tT][mM]?([lL]))'
} &&
- complete -F _opera opera
+ complete -F _comp_cmd_opera opera
# ex: filetype=sh
diff --git a/completions/optipng b/completions/optipng
index 0f6b40e..a81ffa2 100644
--- a/completions/optipng
+++ b/completions/optipng
@@ -1,52 +1,51 @@
# optipng(1) completion -*- shell-script -*-
-_optipng()
+_comp_cmd_optipng()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-'?' | -h | --help | -f)
return
;;
-o)
- COMPREPLY=($(compgen -W '{0..7}' -- "$cur"))
+ _comp_compgen -- -W '{0..7}'
return
;;
-out | -log)
- _filedir
+ _comp_compgen_filedir
return
;;
-dir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-i)
- COMPREPLY=($(compgen -W '0 1' -- "$cur"))
+ _comp_compgen -- -W '0 1'
return
;;
-zc | -zm)
- COMPREPLY=($(compgen -W '{1..9}' -- "$cur"))
+ _comp_compgen -- -W '{1..9}'
return
;;
-zw)
- COMPREPLY=($(compgen -W '256 512 1k 2k 4k 8k 16k 32k' \
- -- "$cur"))
+ _comp_compgen -- -W '256 512 1k 2k 4k 8k 16k 32k'
return
;;
-strip)
- COMPREPLY=($(compgen -W 'all' -- "$cur"))
+ _comp_compgen -- -W 'all'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- _filedir '@(png|bmp|gif|pnm|tif?(f))'
+ _comp_compgen_filedir '@(png|bmp|gif|pnm|tif?(f))'
} &&
- complete -F _optipng optipng
+ complete -F _comp_cmd_optipng optipng
# ex: filetype=sh
diff --git a/completions/p4 b/completions/p4
index ed5f20c..5bcadf6 100644
--- a/completions/p4
+++ b/completions/p4
@@ -1,30 +1,29 @@
# Perforce completion -*- shell-script -*-
# by Frank Cusack <frank@google.com>
-_p4()
+_comp_cmd_p4()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local p4commands p4filetypes
# rename isn't really a command
- p4commands="$(p4 help commands 2>/dev/null | awk 'NF>3 {print $1}')"
+ p4commands="$(p4 help commands 2>/dev/null | _comp_awk 'NF>3 {print $1}')"
p4filetypes="ctext cxtext ktext kxtext ltext tempobj ubinary \
uresource uxbinary xbinary xltext xtempobj xtext \
text binary resource"
if ((cword == 1)); then
- COMPREPLY=($(compgen -W "$p4commands" -- "$cur"))
+ _comp_compgen -- -W "$p4commands"
elif ((cword == 2)); then
case $prev in
help)
- COMPREPLY=($(compgen -W "simple commands environment
- filetypes jobview revisions usage views $p4commands" \
- -- "$cur"))
+ _comp_compgen -- -W "simple commands environment filetypes
+ jobview revisions usage views $p4commands"
;;
admin)
- COMPREPLY=($(compgen -W "checkpoint stop" -- "$cur"))
+ _comp_compgen -- -W "checkpoint stop"
;;
*) ;;
@@ -34,7 +33,7 @@ _p4()
-t)
case ${words[cword - 2]} in
add | edit | reopen)
- COMPREPLY=($(compgen -W "$p4filetypes" -- "$cur"))
+ _comp_compgen -- -W "$p4filetypes"
;;
*) ;;
@@ -46,6 +45,6 @@ _p4()
fi
} &&
- complete -F _p4 -o default p4 g4
+ complete -F _comp_cmd_p4 -o default p4 g4
# ex: filetype=sh
diff --git a/completions/pack200 b/completions/pack200
index 1a6ded7..a4abe92 100644
--- a/completions/pack200
+++ b/completions/pack200
@@ -1,74 +1,74 @@
# pack200(1) completion -*- shell-script -*-
-_pack200()
+_comp_cmd_pack200()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-S | --segment-limit | -P | --pass-file | -C | --class-attribute | \
- -F | --field-attribute | -M | --method-attribute | -D | --code-attribute | \
- '-?' | -h | --help | -V | --version | -J)
+ -F | --field-attribute | -M | --method-attribute | -D | \
+ --code-attribute | '-?' | -h | --help | -V | --version | -J)
return
;;
-E | --effort)
- COMPREPLY=($(compgen -W '{0..9}' -- "$cur"))
+ _comp_compgen -- -W '{0..9}'
return
;;
-H | --deflate-hint)
- COMPREPLY=($(compgen -W 'true false keep' -- "$cur"))
+ _comp_compgen -- -W 'true false keep'
return
;;
-m | --modification-time)
- COMPREPLY=($(compgen -W 'latest keep' -- "$cur"))
+ _comp_compgen -- -W 'latest keep'
return
;;
-U | --unknown-attribute)
- COMPREPLY=($(compgen -W 'error strip pass' -- "$cur"))
+ _comp_compgen -- -W 'error strip pass'
return
;;
-f | --config-file)
- _filedir properties
+ _comp_compgen_filedir properties
return
;;
-l | --log-file)
- COMPREPLY=($(compgen -W '-' -- "$cur"))
- _filedir log
+ _comp_compgen -- -W '-'
+ _comp_compgen -a filedir log
return
;;
-r | --repack)
- _filedir jar
+ _comp_compgen_filedir jar
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
# Check if a pack or a jar was already given.
- local i pack=false jar=false
- for ((i = 1; i < ${#words[@]} - 1; i++)); do
+ local i pack="" jar=""
+ for ((i = 1; i < cword; i++)); do
case ${words[i]} in
- *.pack | *.pack.gz) pack=true ;;
- *.jar) jar=true ;;
+ *.pack | *.pack.gz) pack=set ;;
+ *.jar) jar=set ;;
esac
done
- if ! $pack; then
+ if [[ ! $pack ]]; then
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--no-gzip --gzip --strip-debug
+ _comp_compgen -- -W '--no-gzip --gzip --strip-debug
--no-keep-file-order --segment-limit= --effort= --deflate-hint=
--modification-time= --pass-file= --unknown-attribute=
--class-attribute= --field-attribute= --method-attribute=
--code-attribute= --config-file= --verbose --quiet --log-file=
- --help --version -J --repack' -- "$cur"))
+ --help --version -J --repack'
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- _filedir 'pack?(.gz)'
+ _comp_compgen_filedir 'pack?(.gz)'
fi
- elif ! $jar; then
- _filedir jar
+ elif [[ ! $jar ]]; then
+ _comp_compgen_filedir jar
fi
} &&
- complete -F _pack200 pack200
+ complete -F _comp_cmd_pack200 pack200
# ex: filetype=sh
diff --git a/completions/passwd b/completions/passwd
index 652a41e..b34a1e7 100644
--- a/completions/passwd
+++ b/completions/passwd
@@ -1,24 +1,26 @@
# passwd(1) completion -*- shell-script -*-
-_passwd()
+_comp_cmd_passwd()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[nxwi]*)'
+ # shellcheck disable=SC2254
case $prev in
- --minimum | --maximum | --warning | --inactive | --help | --usage | -!(-*)[nxwi?])
+ --minimum | --maximum | --warning | --inactive | --help | --usage | \
+ -${noargopts}[nxwi?])
return
;;
esac
if [[ $cur == -* ]]; then
- local opts=$(_parse_help "$1")
- COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
return
fi
- _allowed_users
+ _comp_compgen_allowed_users
} &&
- complete -F _passwd passwd
+ complete -F _comp_cmd_passwd passwd
# ex: filetype=sh
diff --git a/completions/patch b/completions/patch
index e883d9c..bba184c 100644
--- a/completions/patch
+++ b/completions/patch
@@ -1,70 +1,71 @@
# patch(1) completion -*- shell-script -*-
-_patch()
+_comp_cmd_patch()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[pDBYzgFiorVd]*)'
+ # shellcheck disable=SC2254
case $prev in
--strip | --ifdef | --prefix | --basename-prefix | --suffix | --get | \
- -!(-*)[pDBYzg])
+ -${noargopts}[pDBYzg])
return
;;
- --fuzz | -!(-*)F)
- COMPREPLY=($(compgen -W '{0..3}' -- "$cur"))
+ --fuzz | -${noargopts}F)
+ _comp_compgen -- -W '{0..3}'
return
;;
- --input | -!(-*)i)
- _filedir '@(?(d)patch|dif?(f))'
+ --input | -${noargopts}i)
+ _comp_compgen_filedir '@(?(d)patch|dif?(f))'
return
;;
- --output | --reject-file | -!(-*)[or])
+ --output | --reject-file | -${noargopts}[or])
[[ ! $cur || $cur == - ]] && COMPREPLY=(-)
- _filedir
+ _comp_compgen -a filedir
return
;;
--quoting-style)
- COMPREPLY=($(compgen -W 'literal shell shell-always c escape' \
- -- "$cur"))
+ _comp_compgen -- -W 'literal shell shell-always c escape'
return
;;
- --version-control | -!(-*)V)
- COMPREPLY=($(compgen -W 'simple numbered existing' -- "$cur"))
+ --version-control | -${noargopts}V)
+ _comp_compgen -- -W 'simple numbered existing'
return
;;
- --directory | -!(-*)d)
- _filedir -d
+ --directory | -${noargopts}d)
+ _comp_compgen_filedir -d
return
;;
--reject-format)
- COMPREPLY=($(compgen -W 'context unified' -- "$cur"))
+ _comp_compgen -- -W 'context unified'
return
;;
--read-only)
- COMPREPLY=($(compgen -W 'ignore warn fail' -- "$cur"))
+ _comp_compgen -- -W 'ignore warn fail'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- local args
- _count_args
- case $args in
+ local REPLY
+ _comp_count_args
+ case $REPLY in
1)
- _filedir
+ _comp_compgen_filedir
;;
2)
- _filedir '@(?(d)patch|dif?(f))'
+ _comp_compgen_filedir '@(?(d)patch|dif?(f))'
;;
esac
} &&
- complete -F _patch patch
+ complete -F _comp_cmd_patch patch
# ex: filetype=sh
diff --git a/completions/pdftoppm b/completions/pdftoppm
new file mode 100644
index 0000000..ac97b41
--- /dev/null
+++ b/completions/pdftoppm
@@ -0,0 +1,35 @@
+# bash completion for pdftoppm(1) -*- shell-script -*-
+
+_comp_cmd_pdftoppm()
+{
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+
+ case $prev in
+ -[flrxyWH] | -r[xy] | -scale?(-to-[xy]) | -jpegopt | -[ou]pw)
+ return
+ ;;
+ -tiffcompression)
+ _comp_compgen -- -W 'none packbits jpeg lzw deflate'
+ return
+ ;;
+ -freetype | -aa | -aaVector)
+ _comp_compgen -- -W 'yes no'
+ return
+ ;;
+ -thinlinemode)
+ _comp_compgen -- -W 'none solid shape'
+ return
+ ;;
+ esac
+
+ if [[ $cur == -* ]]; then
+ _comp_compgen_help
+ return
+ fi
+
+ [[ $prev == *.pdf ]] || _comp_compgen_filedir pdf
+} &&
+ complete -F _comp_cmd_pdftoppm pdftoppm
+
+# ex: filetype=sh
diff --git a/completions/pdftotext b/completions/pdftotext
index a3501ba..a99fd40 100644
--- a/completions/pdftotext
+++ b/completions/pdftotext
@@ -1,39 +1,40 @@
# bash completion for pdftotext(1) -*- shell-script -*-
-_pdftotext()
+_comp_cmd_pdftotext()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
- -h | -help | --help | -'?' | -f | -l | -r | -x | -y | -W | -H | -fixed | -opw | -upw)
+ -h | -help | --help | -'?' | -f | -l | -r | -x | -y | -W | -H | \
+ -fixed | -opw | -upw)
return
;;
-enc)
- COMPREPLY=($(compgen -W '$("$1" -listenc 2>/dev/null |
- command sed -e 1d)' -- "$cur"))
+ _comp_compgen_split -- "$("$1" -listenc 2>/dev/null |
+ command sed -e 1d)"
return
;;
-eol)
- COMPREPLY=($(compgen -W "unix dos mac" -- "$cur"))
+ _comp_compgen -- -W "unix dos mac"
return
;;
esac
if [[ $cur == -* && ${prev,,} != *.pdf ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
case ${prev,,} in
- | *.txt) ;;
*.pdf)
- COMPREPLY=($(compgen -W '-' -- "$cur"))
- _filedir txt
+ _comp_compgen -- -W '-'
+ _comp_compgen -a filedir txt
;;
- *) _filedir pdf ;;
+ *) _comp_compgen_filedir pdf ;;
esac
} &&
- complete -F _pdftotext pdftotext
+ complete -F _comp_cmd_pdftotext pdftotext
# ex: filetype=sh
diff --git a/completions/perl b/completions/perl
index 9823d73..9b82777 100644
--- a/completions/perl
+++ b/completions/perl
@@ -1,17 +1,16 @@
# bash completion for perl -*- shell-script -*-
-_perl_helper()
+_comp_cmd_perl__helper()
{
- COMPREPLY=($(compgen -P "$prefix" -W \
- "$(${2:-perl} ${BASH_SOURCE[0]%/*}/../helpers/perl $1 $cur)" \
- -- "$cur"))
- [[ $1 == functions ]] || __ltrim_colon_completions "$prefix$cur"
+ _comp_compgen_split -P "$prefix" -- "$("${1:-perl}" \
+ "${BASH_SOURCE[0]%/*}/../helpers/perl" "$2" "$cur")"
+ [[ $2 == functions ]] || _comp_ltrim_colon_completions "$prefix$cur"
}
-_perl()
+_comp_cmd_perl()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
local prefix="" temp optPrefix optSuffix
@@ -33,36 +32,35 @@ _perl()
return
;;
-*[Ix])
- local IFS=$'\n'
compopt -o filenames
- COMPREPLY=($(compgen -d $optPrefix $optSuffix -- "$cur"))
+ _comp_compgen -- -d "$optPrefix" $optSuffix
return
;;
-*[mM])
temp="${cur#-}"
- prefix+="${cur%$temp}"
+ prefix+=${cur%"$temp"}
cur="$temp"
- _perl_helper modules $1
+ _comp_cmd_perl__helper "$1" modules
return
;;
-*V)
if [[ $cur == :* ]]; then
temp="${cur##+(:)}"
- prefix+="${cur%$temp}"
- local IFS=$'\n'
- COMPREPLY=($(compgen -P "$prefix" -W \
- '$($1 -MConfig -e "print join \"\\n\",
- keys %Config::Config" 2>/dev/null)' -- "$temp"))
- __ltrim_colon_completions "$prefix$temp"
+ prefix+=${cur%"$temp"}
+ _comp_compgen -c "$temp" split -lP "$prefix" -- "$(
+ "$1" -MConfig -e 'print join "\n",
+ keys %Config::Config' 2>/dev/null
+ )"
+ _comp_ltrim_colon_completions "$prefix$temp"
fi
return
;;
-*d | -*dt)
if [[ $cur == :* ]]; then
temp="${cur#:}"
- prefix="$prefix${cur%$temp}"
+ prefix=$prefix${cur%"$temp"}
cur="Devel::$temp"
- _perl_helper modules $1
+ _comp_cmd_perl__helper "$1" modules
fi
;;
esac
@@ -71,31 +69,31 @@ _perl()
# `-E' options and their arguments, e.g. `perl -e "exit 2"', is
# valid syntax. However, the argument is neither a filename nor a
# directory, but one line of perl program, thus do not suggest
- # _filedir completion.
+ # _comp_compgen_filedir completion.
elif [[ $prev == -e ]] || [[ $prev == -E ]]; then
return
# Likewise, `-I' also accepts a space between option and argument
# and it takes a directory as value.
elif [[ $prev == -I ]]; then
- local IFS=$'\n'
compopt -o filenames
- COMPREPLY=($(compgen -d ${optPrefix-} ${optSuffix-} -- "$cur"))
+ # shellcheck disable=SC2086
+ _comp_compgen -- -d ${optPrefix-} ${optSuffix-}
return
elif [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p
- -n -a -F -l -0 -I -m -M -P -S -x -i -e' -- "$cur"))
+ _comp_compgen -- -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p -n -a
+ -F -l -0 -I -m -M -P -S -x -i -e'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _perl perl
+ complete -F _comp_cmd_perl perl
-_perldoc()
+_comp_cmd_perldoc()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
local prefix="" temp
@@ -107,40 +105,39 @@ _perldoc()
prefix=$prev
fi
- local perl="${1%doc}"
- [[ $perl == "$1" ]] || ! type $perl &>/dev/null && perl=
+ # Prefer `perl` in the same dir in utility functions
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
case $prev in
-*[hVnoMwL])
return
;;
-*d)
- _filedir
+ _comp_compgen_filedir
return
;;
-*f)
- _perl_helper functions $perl
+ _comp_cmd_perl__helper "" functions
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ _comp_compgen_help -- -h
else
# return available modules (unless it is clearly a file)
if [[ $cur != @(*/|[.~])* ]]; then
- _perl_helper perldocs $perl
+ _comp_cmd_perl__helper "" perldocs
if [[ $cur == p* ]]; then
- COMPREPLY+=($(compgen -W \
- '$(PERLDOC_PAGER=cat "$1" -u perl | \
- command sed -ne "/perl.*Perl overview/,/perlwin32/p" | \
- awk "\$NF=2 && \$1 ~ /^perl/ { print \$1 }")' \
- -- "$cur"))
+ _comp_compgen -a split -- "$(PERLDOC_PAGER=cat "$1" -u perl |
+ command sed -ne '/perl.*Perl overview/,/perlwin32/p' |
+ _comp_awk 'NF >= 2 && $1 ~ /^perl/ { print $1 }')"
fi
fi
- _filedir 'p@([lm]|od)'
+ _comp_compgen -a filedir 'p@([lm]|od)'
fi
} &&
- complete -F _perldoc -o bashdefault perldoc
+ complete -F _comp_cmd_perldoc -o bashdefault perldoc
# ex: filetype=sh
diff --git a/completions/perlcritic b/completions/perlcritic
index 7843549..d368203 100644
--- a/completions/perlcritic
+++ b/completions/perlcritic
@@ -1,9 +1,9 @@
# perlcritic(1) completion -*- shell-script -*-
-_perlcritic()
+_comp_cmd_perlcritic()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--help | --version | --top | --include | --exclude | --single-policy | \
@@ -11,41 +11,38 @@ _perlcritic()
return
;;
--severity)
- COMPREPLY=($(compgen -W "{1..5} brutal cruel harsh stern gentle" \
- -- "$cur"))
+ _comp_compgen -- -W '{1..5} brutal cruel harsh stern gentle'
return
;;
--profile | -p)
- _filedir perlcriticrc
+ _comp_compgen_filedir perlcriticrc
return
;;
--theme)
- COMPREPLY=($(compgen -W '$("$1" --list-themes 2>/dev/null)' \
- -- "$cur"))
+ _comp_compgen_split -- "$("$1" --list-themes 2>/dev/null)"
return
;;
--profile-strictness)
- COMPREPLY=($(compgen -W 'warn fatal quiet' -- "$cur"))
+ _comp_compgen -- -W 'warn fatal quiet'
return
;;
--verbose)
- COMPREPLY=($(compgen -W '{1..11}' -- "$cur"))
+ _comp_compgen -- -W '{1..11}'
return
;;
--pager)
- compopt -o filenames
- COMPREPLY=($(compgen -c -- "$cur"))
+ _comp_compgen_commands
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
return
fi
- _filedir 'p[lm]'
+ _comp_compgen_filedir 'p[lm]'
} &&
- complete -F _perlcritic perlcritic
+ complete -F _comp_cmd_perlcritic perlcritic
# ex: filetype=sh
diff --git a/completions/perltidy b/completions/perltidy
index 4404cf8..5be5281 100644
--- a/completions/perltidy
+++ b/completions/perltidy
@@ -1,41 +1,49 @@
# perltidy(1) completion -*- shell-script -*-
-_perltidy()
+_comp_cmd_perltidy()
{
- local cur prev words cword
- _init_completion -n = || return
+ local cur prev words cword comp_args
+ _comp_initialize -n = -- "$@" || return
case $prev in
-h | --help)
return
;;
-o)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
case $cur in
- -pro=*)
- cur="${cur#*=}"
- _filedir
+ -pro=* | --profile=*)
+ _comp_compgen -c "${cur#*=}" filedir
return
;;
- -ole=*)
- COMPREPLY=($(compgen -W 'dos win mac unix' -- "${cur#*=}"))
+ -ole=* | --output-line-ending=*)
+ _comp_compgen -c "${cur#*=}" -- -W 'dos win mac unix'
return
;;
- -bt=* | -pt=* | -sbt=* | -bvt=* | -pvt=* | -sbvt=* | -bvtc=* | -pvtc=* | -sbvtc=* | \
- -cti=* | -kbl=* | -vt=*)
- COMPREPLY=($(compgen -W '0 1 2' -- "${cur#*=}"))
+ -bt=* | --brace-tightness=* | -pt=* | --paren-tightness=* | \
+ -sbt=* | --square-bracket-tightness=* | \
+ -bvt=* | --brace-vertical-tightness=* | \
+ -pvt=* | --paren-vertical-tightness=* | \
+ -sbvt=* | --square-bracket-vertical-tightness=* | \
+ -bvtc=* | --brace-vertical-tightness-closing=* | \
+ -pvtc=* | --paren-vertical-tightness-closing=* | \
+ -sbvtc=* | --square-bracket-vertical-tightness-closing=* | \
+ -cti=* | --closing-token-indentation=* | \
+ -kbl=* | --keep-old-blank-lines=* | \
+ -vt=* | --vertical-tightness=*)
+ _comp_compgen -c "${cur#*=}" -- -W '0 1 2'
return
;;
- -vtc=*)
- COMPREPLY=($(compgen -W '0 1' -- "${cur#*=}"))
+ -vtc=* | --vertical-tightness-closing=*)
+ _comp_compgen -c "${cur#*=}" -- -W '0 1'
return
;;
- -cab=*)
- COMPREPLY=($(compgen -W '0 1 2 3' -- "${cur#*=}"))
+ -cab=* | --comma-arrow-breakpoints=*)
+ _comp_compgen -c "${cur#*=}" -- -W '0 1 2 3'
return
;;
-*=)
@@ -44,12 +52,12 @@ _perltidy()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- _filedir 'p[lm]|t'
+ _comp_compgen_filedir 'p[lm]|t'
fi
} &&
- complete -F _perltidy perltidy
+ complete -F _comp_cmd_perltidy perltidy
# ex: filetype=sh
diff --git a/completions/pgrep b/completions/pgrep
index 62dbb65..d4402f5 100644
--- a/completions/pgrep
+++ b/completions/pgrep
@@ -1,62 +1,60 @@
# pgrep(1) and pkill(1) completion -*- shell-script -*-
-_pgrep()
+_comp_cmd_pgrep()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[cdgJMNstTzFGPuU]*)'
+ # shellcheck disable=SC2254
case $prev in
- --delimiter | --pgroup | --session | --terminal | -!(-*)[cdgJMNstTz])
+ --delimiter | --pgroup | --session | --terminal | -${noargopts}[cdgJMNstTz])
return
;;
--signal)
- _signals
+ _comp_compgen_signals
return
;;
- --pidfile | -!(-*)F)
- _filedir
+ --pidfile | -${noargopts}F)
+ _comp_compgen_filedir
return
;;
- --group | -!(-*)G)
- _gids
+ --group | -${noargopts}G)
+ _comp_compgen_gids
return
;;
-j)
- COMPREPLY=($(compgen -W 'any none' -- "$cur"))
+ _comp_compgen -- -W 'any none'
return
;;
- --parent | --ns | -!(-*)P)
- _pids
+ --parent | --ns | -${noargopts}P)
+ _comp_compgen_pids
return
;;
- --euid | --uid | -!(-*)[uU])
- _uids
+ --euid | --uid | -${noargopts}[uU])
+ _comp_compgen_uids
return
;;
--nslist)
- local prefix=
- [[ $cur == *,* ]] && prefix="${cur%,*},"
- COMPREPLY=(
- $(IFS="$IFS," compgen -W '$($1 --help 2>&1 |
- command sed -ne "s/^[[:space:]]*Available namespaces://p")' \
- -- "${cur##*,}"))
- ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
+ _comp_compgen -c "${cur##*,}" split -F $' \t\n,' -- "$(
+ "$1" --help 2>&1 |
+ command sed -ne 's/^[[:space:]]*Available namespaces://p'
+ )" &&
+ _comp_delimited , -W '"${COMPREPLY[@]}"'
return
;;
esac
if [[ $cur == -* ]]; then
- local help=$(_parse_help "$1")
- [[ $help ]] || help='$("$1" --usage 2>&1 |
- command sed -e "s/\[-signal\]//" -e "s/\[-SIGNAL\]//" |
- _parse_usage -)'
- COMPREPLY=($(compgen -W "$help" -- "$cur"))
- [[ $cword -eq 1 && $1 == *pkill ]] && _signals -
+ _comp_compgen_help ||
+ _comp_compgen_usage - <<<"$("$1" --usage 2>&1 |
+ command sed -e "s/\[-signal\]//" -e "s/\[-SIGNAL\]//")"
+ [[ $cword -eq 1 && $1 == *pkill ]] && _comp_compgen -a signals -
return
fi
- _pnames -s
+ _comp_compgen_pnames -s
} &&
- complete -F _pgrep pgrep pkill
+ complete -F _comp_cmd_pgrep pgrep pkill
# ex: filetype=sh
diff --git a/completions/pidof b/completions/pidof
index a11b432..d413d6f 100644
--- a/completions/pidof
+++ b/completions/pidof
@@ -1,27 +1,29 @@
# pidof(8) completion -*- shell-script -*-
-_pidof()
+_comp_cmd_pidof()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[o]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | -V | --version | -!(-*)[hV]*)
+ --help | -V | --version | -${noargopts}[hV]*)
return
;;
- --omit-pid | -!(-*)o)
- _pids
+ --omit-pid | -${noargopts}o)
+ _comp_compgen_pids
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- _pnames
+ _comp_compgen_pnames
} &&
- complete -F _pidof pidof
+ complete -F _comp_cmd_pidof pidof
# ex: filetype=sh
diff --git a/completions/pine b/completions/pine
index 319c8d5..6844db0 100644
--- a/completions/pine
+++ b/completions/pine
@@ -1,32 +1,32 @@
# pine/alpine completion -*- shell-script -*-
-_pine()
+_comp_cmd_pine()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-help | -d | -f | -c | -I | -n | -url | -copy_pinerc | -copy_abook)
return
;;
- -attach | -attachlist | -attach_and_delete | -p | -P | -pinerc | -passfile | -x)
- _filedir
+ -attach | -attachlist | -attach_and_delete | -p | -P | -pinerc | \
+ -passfile | -x)
+ _comp_compgen_filedir
return
;;
-sort)
- COMPREPLY=($(compgen -W 'arrival subject threaded orderedsubject
- date from size score to cc' -- "$cur"))
+ _comp_compgen -- -W 'arrival subject threaded orderedsubject date
+ from size score to cc'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ _comp_compgen_help -- -h
else
- COMPREPLY=($(compgen -W '$(awk "{print \$1}" ~/.addressbook \
- 2>/dev/null)' -- "$cur"))
+ _comp_compgen_split -- "$(_comp_awk '{print $1}' ~/.addressbook 2>/dev/null)"
fi
} &&
- complete -F _pine pine alpine
+ complete -F _comp_cmd_pine pine alpine
# ex: filetype=sh
diff --git a/completions/ping b/completions/ping
index 446f026..44c0888 100644
--- a/completions/ping
+++ b/completions/ping
@@ -1,9 +1,9 @@
# ping(8) completion -*- shell-script -*-
-_ping()
+_comp_cmd_ping()
{
- local cur prev words cword
- _init_completion -n = || return
+ local cur prev words cword comp_args
+ _comp_initialize -n = -- "$@" || return
local ipvx
@@ -12,21 +12,21 @@ _ping()
return
;;
-*I)
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
return
;;
-*M)
# Path MTU strategy in Linux, mask|time in FreeBSD
local opts="do want dont"
[[ $OSTYPE == *bsd* ]] && opts="mask time"
- COMPREPLY=($(compgen -W '$opts' -- "$cur"))
+ _comp_compgen -- -W '$opts'
return
;;
-*N)
if [[ $cur != *= ]]; then
- COMPREPLY=($(compgen -W 'name ipv6 ipv6-global ipv6-sitelocal
+ _comp_compgen -- -W 'name ipv6 ipv6-global ipv6-sitelocal
ipv6-linklocal ipv6-all ipv4 ipv4-all subject-ipv6=
- subject-ipv4= subject-name= subject-fqdn=' -- "$cur"))
+ subject-ipv4= subject-name= subject-fqdn='
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
return
@@ -34,19 +34,19 @@ _ping()
-*Q)
# TOS in Linux, "somewhat quiet" (no args) in FreeBSD
if [[ $OSTYPE != *bsd* ]]; then
- COMPREPLY=($(compgen -W '{0..7}' -- "$cur"))
+ _comp_compgen -- -W '{0..7}'
return
fi
;;
-*S)
# Socket sndbuf in Linux, source IP in FreeBSD
- [[ $OSTYPE == *bsd* ]] && _ip_addresses
+ [[ $OSTYPE == *bsd* ]] && _comp_compgen_ip_addresses
return
;;
-*T)
# Timestamp option in Linux, TTL in FreeBSD
[[ $OSTYPE == *bsd* ]] ||
- COMPREPLY=($(compgen -W 'tsonly tsandaddr' -- "$cur"))
+ _comp_compgen -- -W 'tsonly tsandaddr'
return
;;
-*4*)
@@ -58,14 +58,14 @@ _ping()
esac
if [[ $cur == -* ]]; then
- local opts=$(_parse_help "$1")
- COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
return
fi
[[ $1 == *6 ]] && ipvx=-6
- _known_hosts_real ${ipvx-} -- "$cur"
+ [[ $1 == *4 ]] && ipvx=-4
+ _comp_compgen_known_hosts ${ipvx-} -- "$cur"
} &&
- complete -F _ping ping ping6
+ complete -F _comp_cmd_ping ping ping4 ping6
# ex: filetype=sh
diff --git a/completions/pkg-config b/completions/pkg-config
index b9db167..489f477 100644
--- a/completions/pkg-config
+++ b/completions/pkg-config
@@ -1,9 +1,9 @@
# bash completion for pkgconfig -*- shell-script -*-
-_pkg_config()
+_comp_cmd_pkg_config()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
--define-variable | --atleast-version | --atleast-pkgconfig-version | \
@@ -15,9 +15,9 @@ _pkg_config()
local word
for word in "${words[@]:1}"; do
if [[ $word != -* ]]; then
- COMPREPLY=($(compgen -W \
- '$("$1" $word --print-variables 2>/dev/null)' \
- -- "$cur"))
+ _comp_compgen_split -- "$(
+ "$1" "$word" --print-variables 2>/dev/null
+ )"
break
fi
done
@@ -29,17 +29,17 @@ _pkg_config()
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- COMPREPLY=($(compgen -W "$($1 --list-all \
- 2>/dev/null | awk '{print $1}')" -- "$cur"))
- _filedir pc
+ _comp_compgen_split -- "$("$1" --list-all 2>/dev/null |
+ _comp_awk '{print $1}')"
+ _comp_compgen -a filedir pc
fi
} &&
- complete -F _pkg_config pkg-config
+ complete -F _comp_cmd_pkg_config pkg-config pkgconf
# ex: filetype=sh
diff --git a/completions/pkg-get b/completions/pkg-get
index 72bd0a0..a8ec1a8 100644
--- a/completions/pkg-get
+++ b/completions/pkg-get
@@ -2,10 +2,10 @@
#
# Copyright 2006 Yann Rouillard <yann@opencsw.org>
-_pkg_get_get_catalog_file()
+_comp_cmd_pkg_get__catalog_file()
{
local url="$1"
- local catalog_file i conffile
+ local i conffile
for file in /etc/opt/csw/pkg-get.conf /opt/csw/etc/pkg-get.conf /etc/pkg-get.conf; do
if [[ -f $file ]]; then
@@ -15,19 +15,17 @@ _pkg_get_get_catalog_file()
done
conffile="${conffile:-/opt/csw/etc/pkg-get.conf}"
- if [[ -z $url ]]; then
- url=$(awk -F= ' $1=="url" { print $2 }' $conffile)
+ if [[ ! $url ]]; then
+ url=$(_comp_awk -F = ' $1=="url" { print $2 }' "$conffile")
fi
- catalog_file="${url##*//}"
- catalog_file="${catalog_file%%/*}"
- catalog_file="/var/pkg-get/catalog-$catalog_file"
-
- echo "$catalog_file"
+ REPLY="${url##*//}"
+ REPLY="${REPLY%%/*}"
+ REPLY="/var/pkg-get/catalog-$REPLY"
} &&
- _pkg_get()
+ _comp_cmd_pkg_get()
{
- local cur prev file catalog_file url command
+ local cur prev file url command=""
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
@@ -46,27 +44,29 @@ _pkg_get_get_catalog_file()
fi
done
- if [[ -v command ]]; then
+ if [[ $command ]]; then
if [[ $command == @(-[Ddi]|describe|download|install) ]]; then
- catalog_file=$(_pkg_get_get_catalog_file "$url")
- if [[ -f $catalog_file ]]; then
- local packages_list=$(awk ' $0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' $catalog_file)
- COMPREPLY=($(compgen -W "${packages_list}" -- ${cur}))
+ local REPLY
+ _comp_cmd_pkg_get__catalog_file "$url"
+ if [[ -f $REPLY ]]; then
+ local packages_list=$(_comp_awk '$0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' "$REPLY")
+ _comp_compgen -- -W "${packages_list}"
fi
fi
return
fi
if [[ ${cur} == -* ]]; then
- local opts="-c -d -D -f -i -l -s -S -u -U -v"
- COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+ local -a opts=(-c -d -D -f -i -l -s -S -u -U -v)
+ _comp_compgen -- -W '"${opts[@]}"'
return
fi
- local commands="available describe download install list \
- updatecatalog upgrade"
- COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
+ local -a commands=(
+ available describe download install list updatecatalog upgrade
+ )
+ _comp_compgen -- -W '"${commands[@]}"'
} &&
- complete -F _pkg_get pkg-get
+ complete -F _comp_cmd_pkg_get pkg-get
# ex: filetype=sh
diff --git a/completions/pkg_delete b/completions/pkg_delete
index 2abb671..aecc8e8 100644
--- a/completions/pkg_delete
+++ b/completions/pkg_delete
@@ -1,18 +1,19 @@
# bash completion for *BSD package management tools -*- shell-script -*-
-_pkg_delete()
+_comp_cmd_pkg_delete()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local pkgdir=${PKG_DBDIR:-/var/db/pkg}/
[[ $prev == -o || $prev == -p || $prev == -W ]] && return
- COMPREPLY=($(compgen -d -- "$pkgdir$cur"))
- ((${#COMPREPLY[@]} == 0)) || COMPREPLY=(${COMPREPLY[@]#$pkgdir})
+ _comp_compgen -c "$pkgdir$cur" -- -d
+ ((${#COMPREPLY[@]} == 0)) || COMPREPLY=("${COMPREPLY[@]#"$pkgdir"}")
} &&
- complete -F _pkg_delete -o dirnames pkg_delete pkg_info pkg_deinstall
+ complete -F _comp_cmd_pkg_delete -o dirnames \
+ pkg_delete pkg_info pkg_deinstall
# ex: filetype=sh
diff --git a/completions/pkgadd b/completions/pkgadd
index 3f5b6a1..bdb9c42 100644
--- a/completions/pkgadd
+++ b/completions/pkgadd
@@ -2,10 +2,10 @@
#
# Copyright 2006 Yann Rouillard <yann@opencsw.org>
-_pkgadd()
+_comp_cmd_pkgadd()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
# if a device directory was given
# we must complete with the package
@@ -23,40 +23,39 @@ _pkgadd()
case $prev in
-d)
- _filedir pkg
- _filedir -d
+ _comp_compgen_filedir pkg
;;
-a | -r | -V)
- _filedir
+ _comp_compgen_filedir
;;
-k | -s | -R)
- _filedir -d
+ _comp_compgen_filedir -d
;;
-P | -x) ;;
*)
if [[ ${cur} == -* ]]; then
- local opts="-a -A -d -k -n -M -P -r -R -s -v -V -x"
- COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+ local -a opts=(-a -A -d -k -n -M -P -r -R -s -v -V -x)
+ _comp_compgen -- -W '"${opts[@]}"'
else
- local pkginst_list
+ local -a pkginst_list
if [[ -d $device ]]; then
- local -a tmplist
- for filedir in $(/bin/ls -1 $device); do
- if [[ -d "$device/$filedir" ]] && [[ -f "$device/$filedir/pkginfo" ]]; then
- tmplist+=(${tmplist[@]:-} "$filedir")
- fi
- done
- pkginst_list="${tmplist[*]}"
+ if _comp_expand_glob pkginst_list '"$device"/*/pkginfo'; then
+ pkginst_list=("${pkginst_list[@]#"$device/"}")
+ pkginst_list=("${pkginst_list[@]%/pkginfo}")
+ fi
else
- pkginst_list="$(strings "$(dequote $device)" |
- command grep ^PKG= | sort -u | cut -d= -f2)"
+ local REPLY
+ _comp_dequote "$device"
+ _comp_split -l pkginst_list "$(strings "${REPLY-}" |
+ command sed -n 's/^PKG=//p' | sort -u)"
fi
- COMPREPLY=($(compgen -W "$pkginst_list" -- ${cur}))
+ ((${#pkginst_list[@]})) &&
+ _comp_compgen -- -W '"${pkginst_list[@]}"'
fi
;;
esac
} &&
- complete -F _pkgadd pkgadd
+ complete -F _comp_cmd_pkgadd pkgadd
# ex: filetype=sh
diff --git a/completions/pkgrm b/completions/pkgrm
index 2449d34..bb5327e 100644
--- a/completions/pkgrm
+++ b/completions/pkgrm
@@ -1,11 +1,11 @@
-# pkgrm completion -*- shell-script -*-
+# pkgrm completion -*- shell-script -*-
#
# Copyright 2006 Yann Rouillard <yann@opencsw.org>
-_pkgrm()
+_comp_cmd_pkgrm()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
# if a spool directory was given
# we must complete with the package
@@ -24,23 +24,23 @@ _pkgrm()
case $prev in
-a | -V)
- _filedir
+ _comp_compgen_filedir
;;
-s | -R)
- _filedir -d
+ _comp_compgen_filedir -d
;;
-Y) ;;
*)
if [[ ${cur} == -* ]]; then
local opts="-a -A -n -M -R -s -v -V -Y"
- COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+ _comp_compgen -- -W "${opts}"
else
- COMPREPLY=($(compgen -W "$(/bin/ls -1 $spool)" -- ${cur}))
+ _comp_compgen_split -- "$(/bin/ls -1 "$spool")"
fi
;;
esac
} &&
- complete -F _pkgrm pkgrm
+ complete -F _comp_cmd_pkgrm pkgrm
# ex: filetype=sh
diff --git a/completions/pkgtool b/completions/pkgtool
index 951bae4..faf0130 100644
--- a/completions/pkgtool
+++ b/completions/pkgtool
@@ -1,13 +1,13 @@
# Slackware Linux pkgtool completion -*- shell-script -*-
-_pkgtool()
+_comp_cmd_pkgtool()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case "$prev" in
--source_dir | --target_dir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
--sets)
@@ -15,21 +15,20 @@ _pkgtool()
return
;;
--source_device)
- COMPREPLY=($(compgen -f -d -- "${cur:-/dev/}"))
+ _comp_compgen -c "${cur:-/dev/}" -- -f -d
return
;;
--tagfile)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--sets --ignore-tagfiles --tagfile
- --source-mounted --source_dir --target_dir --source_device' \
- -- "$cur"))
+ _comp_compgen -- -W '--sets --ignore-tagfiles --tagfile
+ --source-mounted --source_dir --target_dir --source_device'
fi
} &&
- complete -F _pkgtool pkgtool
+ complete -F _comp_cmd_pkgtool pkgtool
# ex: filetype=sh
diff --git a/completions/pkgutil b/completions/pkgutil
index 91d8748..63dc400 100644
--- a/completions/pkgutil
+++ b/completions/pkgutil
@@ -1,7 +1,7 @@
-# pkgutil completion -*- shell-script -*-
+# pkgutil completion -*- shell-script -*-
# Copyright 2006 Yann Rouillard <yann@opencsw.org>
-_pkgutil_url2catalog()
+_comp_cmd_pkgutil__url2catalog()
{
local filename="$1"
@@ -9,44 +9,50 @@ _pkgutil_url2catalog()
filename="${filename//\//_}"
filename="/var/opt/csw/pkgutil/catalog.${filename}_$(uname -p)_$(uname -r)"
- echo "$filename"
+ REPLY=$filename
}
-_pkgutil()
+_comp_cmd_pkgutil()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
- local command catalog_files configuration_files
- declare -a configuration_files=("/opt/csw/etc/pkgutil.conf" "/etc/opt/csw/pkgutil.conf")
- declare -a catalog_files=()
+ local command="" catalog_files configuration_files
+ local -a configuration_files=(
+ "/opt/csw/etc/pkgutil.conf" "/etc/opt/csw/pkgutil.conf")
+ local -a catalog_files=()
- local i=$cword
+ local i=$cword REPLY
while ((i-- > 1)); do
if [[ ${words[i]} == -@(t|-temp) ]]; then
local url="${words[i + 1]}"
- local catalog=$(_pkgutil_url2catalog "$url")
- catalog_files=("$catalog")
+ _comp_cmd_pkgutil__url2catalog "$url"
+ catalog_files=("$REPLY")
elif [[ ${words[i]} == --config ]]; then
- configuration_files=("$(dequote ${words[i + 1]})")
+ local REPLY
+ _comp_dequote "${words[i + 1]}"
+ [[ ${REPLY-} ]] && configuration_files=("$REPLY")
elif [[ ${words[i]} == -@([iurdacUS]|-install|-upgrade|-remove|-download|-available|-compare|-catalog|-stream) ]]; then
command="${words[i]}"
fi
done
if [[ $prev == -@([WPR]|-workdir|-pkgdir|-rootpath) ]]; then
- _filedir -d
+ _comp_compgen_filedir -d
return
fi
if [[ $prev == -@(o|-output|-config) ]]; then
- _filedir
+ _comp_compgen_filedir
return
fi
if [[ $prev == -@(p|-param) ]]; then
compopt -o nospace
- COMPREPLY=($(compgen -W "mirror: pkgaddopts: pkgrmopts: wgetopts: use_gpg: use_md5: pkgliststyle: maxpkglist: noncsw: stop_on_hook_soft_error: exclude_pattern: gpg_homedir: root_path: deptree_filter_common: show_current: catalog_not_cached: catalog_update:" -- $cur))
+ _comp_compgen -- -W 'mirror: pkgaddopts: pkgrmopts: wgetopts: use_gpg:
+ use_md5: pkgliststyle: maxpkglist: noncsw: stop_on_hook_soft_error:
+ exclude_pattern: gpg_homedir: root_path: deptree_filter_common:
+ show_current: catalog_not_cached: catalog_update:'
return
fi
@@ -55,7 +61,8 @@ _pkgutil()
# as a separator, borrowed from maven completion code which borrowed
# it from darcs completion code :)
local colonprefixes=${cur%"${cur##*:}"}
- COMPREPLY=($(compgen -W "sparc:5.9 sparc:5.10 sparc:5.11 i386:5.9 i386:5.10 i386:5.11" -- $cur))
+ _comp_compgen -- -W 'sparc:5.9 sparc:5.10 sparc:5.11 i386:5.9 i386:5.10
+ i386:5.11'
local i=${#COMPREPLY[*]}
while ((i-- > 0)); do
COMPREPLY[i]=${COMPREPLY[i]#"$colonprefixes"}
@@ -63,33 +70,42 @@ _pkgutil()
return
fi
- if [[ -v command && $cur != -* ]]; then
+ if [[ $command && $cur != -* ]]; then
local mirrors mirror_url
- mirrors=$(awk -F= ' $1 ~ /^ *mirror *$/ { print $2 }' "${configuration_files[@]}")
+ mirrors=$(_comp_awk -F = ' $1 ~ /^ *mirror *$/ { print $2 }' "${configuration_files[@]}")
mirrors=${mirrors:-http://mirror.opencsw.org/opencsw/testing}
for mirror_url in $mirrors; do
- local catalog=$(_pkgutil_url2catalog "$mirror_url")
- catalog_files=("${catalog_files[@]}" "$catalog")
+ _comp_cmd_pkgutil__url2catalog "$mirror_url"
+ catalog_files+=("$REPLY")
done
if [[ $command == -@([dius]|-download|-install|-upgrade|-stream) ]]; then
- local packages_list=$(awk ' $0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' "${catalog_files[@]}")
- COMPREPLY=($(compgen -W "${packages_list}" -- $cur))
+ local packages_list=$(_comp_awk ' $0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' "${catalog_files[@]}")
+ _comp_compgen -- -W "${packages_list}"
elif [[ $command == @(-r|--remove) ]]; then
- local packages_list=$(pkginfo | awk ' $2 ~ /^CSW/ { printf ("%s|",$2) }')
+ local packages_list=$(
+ pkginfo | _comp_awk ' $2 ~ /^CSW/ { printf ("%s|",$2) }'
+ )
packages_list=${packages_list%|}
packages_list=$(nawk " \$3 ~ /^$packages_list\$/ { print \$1 }" "${catalog_files[@]}")
- COMPREPLY=($(compgen -W "${packages_list}" -- $cur))
+ _comp_compgen -- -W "${packages_list}"
fi
return
fi
- local commands="-i --install -u --upgrade -r --remove -d --download -U --catalog -a --available --describe -c --compare -C --compare-diff -A --compare-avail -e --email -t --temp -x --exclude -W --workdir -P --pkgdir -R --rootpath --config -y --yes -f --force -n --nomod -N --nodeps -D --debug --trace -h --help -v --version -V --syscheck -l --list -L --listfile -F --findfile --deptree --extract -s --stream -o --output -T --target --single -p --param --parse --cleanup --catinfo"
- COMPREPLY=($(compgen -W "${commands}" -- $cur))
+ local -a commands=(
+ --install --upgrade --remove --download --catalog --available
+ --describe --compare --compare-diff --compare-avail --email --temp
+ --exclude --workdir --pkgdir --rootpath --config --yes --force --nomod
+ --nodeps --debug --trace --help --version --syscheck --list --listfile
+ --findfile --deptree --extract --stream --output --target --single
+ --param --parse --cleanup --catinfo
+ )
+ _comp_compgen -- -W '"${commands[@]}"'
} &&
- complete -F _pkgutil pkgutil
+ complete -F _comp_cmd_pkgutil pkgutil
# ex: filetype=sh
diff --git a/completions/plague-client b/completions/plague-client
index 4e98206..cec0b6c 100644
--- a/completions/plague-client
+++ b/completions/plague-client
@@ -1,14 +1,14 @@
# bash completion for plague-client -*- shell-script -*-
-_plague_client()
+_comp_cmd_plague_client()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
((cword == 1)) &&
- COMPREPLY=($(compgen -W 'build detail finish help is_paused kill list
- list_builders pause requeue unpause update_builders' -- "$cur"))
+ _comp_compgen -- -W 'build detail finish help is_paused kill list
+ list_builders pause requeue unpause update_builders'
} &&
- complete -F _plague_client plague-client
+ complete -F _comp_cmd_plague_client plague-client
# ex: filetype=sh
diff --git a/completions/pm-hibernate b/completions/pm-hibernate
index ea3b0aa..26c304b 100644
--- a/completions/pm-hibernate
+++ b/completions/pm-hibernate
@@ -1,12 +1,13 @@
# bash completion for pm-utils -*- shell-script -*-
-_pm_action()
+_comp_cmd_pm_hibernate()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- COMPREPLY=($(compgen -W "--help $(_parse_help "$1")" -- "$cur"))
+ _comp_compgen_help
+ _comp_compgen -a -- -W '--help'
} &&
- complete -F _pm_action pm-hibernate pm-suspend pm-suspend-hybrid
+ complete -F _comp_cmd_pm_hibernate pm-hibernate pm-suspend pm-suspend-hybrid
# ex: filetype=sh
diff --git a/completions/pm-is-supported b/completions/pm-is-supported
index adc7fde..f909fe4 100644
--- a/completions/pm-is-supported
+++ b/completions/pm-is-supported
@@ -1,13 +1,12 @@
# pm-is-supported(1) completion -*- shell-script -*-
-_pm_is_supported()
+_comp_cmd_pm_is_supported()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- COMPREPLY=($(compgen -W '--help --suspend --hibernate --suspend-hybrid' \
- -- "$cur"))
+ _comp_compgen -- -W '--help --suspend --hibernate --suspend-hybrid'
} &&
- complete -F _pm_is_supported pm-is-supported
+ complete -F _comp_cmd_pm_is_supported pm-is-supported
# ex: filetype=sh
diff --git a/completions/pm-powersave b/completions/pm-powersave
index affb195..0db0ddc 100644
--- a/completions/pm-powersave
+++ b/completions/pm-powersave
@@ -1,12 +1,12 @@
# pm-powersave(8) completion -*- shell-script -*-
-_pm_powersave()
+_comp_cmd_pm_powersave()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- COMPREPLY=($(compgen -W "true false" -- "$cur"))
+ _comp_compgen -- -W "true false"
} &&
- complete -F _pm_powersave pm-powersave
+ complete -F _comp_cmd_pm_powersave pm-powersave
# ex: filetype=sh
diff --git a/completions/pngfix b/completions/pngfix
index 64b5481..d77d80b 100644
--- a/completions/pngfix
+++ b/completions/pngfix
@@ -1,36 +1,35 @@
# pngfix completion -*- shell-script -*-
-_pngfix()
+_comp_cmd_pngfix()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
--suffix | --prefix)
return
;;
--output)
- _filedir
+ _comp_compgen_filedir
return
;;
--strip)
- COMPREPLY=($(IFS='|' compgen -W '$("$1" --help 2>&1 |
- command sed -ne "s/.*--strip=\[\([^]]*\)\].*/\1/p")' \
- -- "$cur"))
+ _comp_compgen_split -F '|' -- "$("$1" --help 2>&1 |
+ command sed -ne 's/.*--strip=\[\([^]]*\)\].*/\1/p')"
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir png
+ _comp_compgen_filedir png
} &&
- complete -F _pngfix pngfix
+ complete -F _comp_cmd_pngfix pngfix
# ex: filetype=sh
diff --git a/completions/portinstall b/completions/portinstall
index 8033740..dc1a933 100644
--- a/completions/portinstall
+++ b/completions/portinstall
@@ -1,31 +1,28 @@
# bash completion for FreeBSD portinstall -*- shell-script -*-
-_portinstall()
+_comp_cmd_portinstall()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- local portsdir indexfile
- local -a COMPREPLY2
+ [[ $prev == -l || $prev == -L || $prev == -o ]] && return
- portsdir=${PORTSDIR:-/usr/ports}/
+ local -x portsdir=${PORTSDIR:-/usr/ports}/
# First try INDEX-5
- indexfile=$portsdir/INDEX-5
+ local indexfile=$portsdir/INDEX-5
# Then INDEX if INDEX-5 does not exist or system is not FreeBSD 5.x
[[ ${OSTYPE%.*} == freebsd5 && -f $indexfile ]] ||
indexfile=$portsdir/INDEX
+ [[ -f $indexfile && -r $indexfile ]] || return
- [[ $prev == -l || $prev == -L || $prev == -o ]] && return
-
- COMPREPLY=($(command grep -E "^$cur" 2>/dev/null <$indexfile |
- cut -d'|' -f1))
- COMPREPLY2=($(command grep -E "^[^\|]+\|$portsdir$cur" 2>/dev/null \
- <$indexfile | cut -d'|' -f2))
- COMPREPLY2=(${COMPREPLY2[@]#$portsdir})
- COMPREPLY+=("${COMPREPLY2[@]}")
+ _comp_compgen_split -l -- "$(_comp_awk -F '|' '
+ BEGIN { portsdir = ENVIRON["portsdir"]; len = length(portsdir) }
+ { print $1 }
+ substr($2, 1, len) == portsdir { print substr($2, len + 1) }
+ ' "$indexfile")"
} &&
- complete -F _portinstall -o dirnames portinstall
+ complete -F _comp_cmd_portinstall -o dirnames portinstall
# ex: filetype=sh
diff --git a/completions/portsnap b/completions/portsnap
index a2f0a93..a5f880c 100644
--- a/completions/portsnap
+++ b/completions/portsnap
@@ -2,24 +2,24 @@
[[ $OSTYPE == *freebsd* ]] || return 1
-_portsnap()
+_comp_cmd_portsnap()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-d | -p)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-l | -f)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
- COMPREPLY=($(compgen -W "fetch cron extract update" -- $cur))
+ _comp_compgen -- -W "fetch cron extract update"
} &&
- complete -F _portsnap portsnap
+ complete -F _comp_cmd_portsnap portsnap
# ex: filetype=sh
diff --git a/completions/portupgrade b/completions/portupgrade
index ffe6305..1dc93c2 100644
--- a/completions/portupgrade
+++ b/completions/portupgrade
@@ -1,19 +1,19 @@
# bash completion for FreeBSD portupgrade -*- shell-script -*-
-_portupgrade()
+_comp_cmd_portupgrade()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
[[ $prev == -l || $prev == -L || $prev == -o ]] && return
local pkgdir=${PKG_DBDIR:-/var/db/pkg}/
- COMPREPLY=($(compgen -d -- "$pkgdir$cur"))
- COMPREPLY=(${COMPREPLY[@]#$pkgdir})
- COMPREPLY=(${COMPREPLY[@]%-*})
+ _comp_compgen -c "$pkgdir$cur" -- -d
+ COMPREPLY=("${COMPREPLY[@]#"$pkgdir"}")
+ COMPREPLY=("${COMPREPLY[@]%-*}")
} &&
- complete -F _portupgrade -o dirnames portupgrade
+ complete -F _comp_cmd_portupgrade -o dirnames portupgrade
# ex: filetype=sh
diff --git a/completions/postcat b/completions/postcat
index a58b0e5..ac74e80 100644
--- a/completions/postcat
+++ b/completions/postcat
@@ -1,39 +1,34 @@
# postcat(1) completion -*- shell-script -*-
-_postcat()
+_comp_cmd_postcat()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-c)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
return
fi
- local idx qfile=0
+ local idx qfile=""
for idx in "${words[@]}"; do
- [[ $idx == -q ]] && qfile=1 && break
+ [[ $idx == -q ]] && qfile=set && break
done
- if ((qfile == 1)); then
- local len=${#cur} pval
- for pval in $(mailq 2>/dev/null |
- command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//'); do
- if [[ $cur == "${pval:0:len}" ]]; then
- COMPREPLY+=($pval)
- fi
- done
+ if [[ $qfile ]]; then
+ _comp_compgen_split -- "$(mailq 2>/dev/null |
+ command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//')"
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _postcat postcat
+ complete -F _comp_cmd_postcat postcat
# ex: filetype=sh
diff --git a/completions/postconf b/completions/postconf
index 4cb324c..ac1b21b 100644
--- a/completions/postconf
+++ b/completions/postconf
@@ -1,19 +1,19 @@
# postconf(1) completion -*- shell-script -*-
-_postconf()
+_comp_cmd_postconf()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local eqext
case $prev in
-b | -t)
- _filedir
+ _comp_compgen_filedir
return
;;
-c)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-e)
@@ -23,7 +23,7 @@ _postconf()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
return
fi
@@ -34,6 +34,6 @@ _postconf()
fi
done
} &&
- complete -F _postconf postconf
+ complete -F _comp_cmd_postconf postconf
# ex: filetype=sh
diff --git a/completions/postfix b/completions/postfix
index f960550..a05f71f 100644
--- a/completions/postfix
+++ b/completions/postfix
@@ -1,33 +1,29 @@
# postfix(1) completion -*- shell-script -*-
-_postfix()
+_comp_cmd_postfix()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-c)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-D)
- COMPREPLY=($(compgen -W 'start' -- "$cur"))
+ _comp_compgen -- -W 'start'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(
- compgen -W \
- '$(_bashcomp_try_faketty "$1" --help 2>&1 | _parse_usage -)' \
- -- "$cur"
- ))
+ _comp_compgen_usage -c _comp_try_faketty "$1" --help
return
fi
- COMPREPLY=($(compgen -W 'check start stop abort flush reload status
- set-permissions upgrade-configuration' -- "$cur"))
+ _comp_compgen -- -W 'check start stop abort flush reload status
+ set-permissions upgrade-configuration'
} &&
- complete -F _postfix postfix
+ complete -F _comp_cmd_postfix postfix
# ex: filetype=sh
diff --git a/completions/postmap b/completions/postmap
index 35c4ada..48e5d9f 100644
--- a/completions/postmap
+++ b/completions/postmap
@@ -1,13 +1,13 @@
# postalias(1) and postmap(1) completion -*- shell-script -*-
-_postmap()
+_comp_cmd_postmap()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-c)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-[dq])
@@ -16,13 +16,13 @@ _postmap()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
return
fi
if [[ $cur == *:* ]]; then
compopt -o filenames
- COMPREPLY=($(compgen -f -- "${cur#*:}"))
+ _comp_compgen -c "${cur#*:}" -- -f
else
local len=${#cur} pval
for pval in $(/usr/sbin/postconf -m 2>/dev/null); do
@@ -32,10 +32,10 @@ _postmap()
done
if [[ ! ${COMPREPLY-} ]]; then
compopt -o filenames
- COMPREPLY=($(compgen -f -- "$cur"))
+ _comp_compgen -- -f
fi
fi
} &&
- complete -F _postmap postmap postalias
+ complete -F _comp_cmd_postmap postmap postalias
# ex: filetype=sh
diff --git a/completions/postsuper b/completions/postsuper
index 559449a..d195ac7 100644
--- a/completions/postsuper
+++ b/completions/postsuper
@@ -1,56 +1,40 @@
# postsuper(1) completion -*- shell-script -*-
-_postsuper()
+_comp_cmd_postsuper()
{
- local cur prev words cword
- _init_completion || return
-
- local pval len
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-c)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-[dr])
- len=${#cur}
- for pval in ALL $(mailq 2>/dev/null |
- command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//'); do
- if [[ $cur == "${pval:0:len}" ]]; then
- COMPREPLY+=($pval)
- fi
- done
+ _comp_compgen_split -- "ALL $(mailq 2>/dev/null |
+ command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//')"
return
;;
-h)
- len=${#cur}
- for pval in ALL $(mailq 2>/dev/null |
- command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* ].*$//; /!$/d'); do
- if [[ $cur == "${pval:0:len}" ]]; then
- COMPREPLY+=($pval)
- fi
- done
+ _comp_compgen_split -- "ALL $(mailq 2>/dev/null |
+ command sed \
+ -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* ].*$//; /!$/d')"
return
;;
-H)
- len=${#cur}
- for pval in ALL $(mailq 2>/dev/null |
- command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; /^[0-9A-Z]*[* ]/d; s/!.*$//'); do
- if [[ $cur == "${pval:0:len}" ]]; then
- COMPREPLY+=($pval)
- fi
- done
+ _comp_compgen_split -- "ALL $(mailq 2>/dev/null | command sed \
+ -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; /^[0-9A-Z]*[* ]/d; s/!.*$//')"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- COMPREPLY=($(compgen -W 'hold incoming active deferred' -- "$cur"))
+ _comp_compgen -- -W 'hold incoming active deferred'
} &&
- complete -F _postsuper postsuper
+ complete -F _comp_cmd_postsuper postsuper
# ex: filetype=sh
diff --git a/completions/povray b/completions/povray
index 56dfd94..868ff3e 100644
--- a/completions/povray
+++ b/completions/povray
@@ -1,22 +1,22 @@
# povray completion -*- shell-script -*-
# by "David Necas (Yeti)" <yeti@physics.muni.cz>
-_povray()
+_comp_cmd_povray()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local povcur=$cur pfx oext defoext
defoext=png # default output extension, if cannot be determined FIXME
- _expand || return
+ _comp_expand || return
case $povcur in
[-+]I*)
- cur="${povcur#[-+]I}" # to confuse _filedir
+ cur="${povcur#[-+]I}" # to confuse _comp_compgen_filedir
pfx="${povcur%"$cur"}"
- _filedir pov
- COMPREPLY=(${COMPREPLY[@]/#/$pfx})
+ _comp_compgen_filedir pov &&
+ _comp_compgen -Rv COMPREPLY -- -P "$pfx" -W '"${COMPREPLY[@]}"'
return
;;
[-+]O*)
@@ -31,34 +31,35 @@ _povray()
*) oext=$defoext ;;
esac
# complete filename corresponding to previously specified +I
- COMPREPLY=($(
- IFS=$'\n'
- command grep '^[-+]I' <<<"${words[*]}"
- ))
- COMPREPLY=(${COMPREPLY[@]#[-+]I})
- COMPREPLY=(${COMPREPLY[@]/%.pov/.$oext})
- cur="${povcur#[-+]O}" # to confuse _filedir
+ _comp_compgen -Rv COMPREPLY -- -X '![-+]I*' -W '"${words[@]}"'
+ _comp_compgen -Rv COMPREPLY -- -X '' -W '"${COMPREPLY[@]#[-+]I}"'
+ local i
+ for i in "${!COMPREPLY[@]}"; do
+ COMPREPLY[i]=${COMPREPLY[i]/%.pov/".$oext"}
+ done
+ cur="${povcur#[-+]O}" # to confuse _comp_compgen_filedir
pfx="${povcur%"$cur"}"
- _filedir $oext
- COMPREPLY=(${COMPREPLY[@]/#/$pfx})
+ _comp_compgen -a filedir "$oext"
+ ((${#COMPREPLY[@]})) &&
+ _comp_compgen -Rv COMPREPLY -- -P "$pfx" -W '"${COMPREPLY[@]}"'
return
;;
*.ini\[ | *.ini\[*[^]]) # sections in .ini files
cur="${povcur#*\[}"
pfx="${povcur%\["$cur"}" # prefix == filename
- [[ -r $pfx ]] || return
- COMPREPLY=($(command sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' \
- -e 't' -e 'd' -- "$pfx"))
- # to prevent [bar] expand to nothing. can be done more easily?
- COMPREPLY=("${COMPREPLY[@]/#/${pfx}[}")
+ [[ -f $pfx && -r $pfx ]] || return
+ _comp_compgen_split -l -- "$(command sed -ne \
+ 's/^[[:space:]]*\[\([^]]*\]\).*$/\1/p' -- "$pfx")" &&
+ # to prevent [bar] expand to nothing. can be done more easily?
+ _comp_compgen -Rv COMPREPLY -- -P "${pfx}[" -W '"${COMPREPLY[@]}"'
return
;;
*)
- _filedir '@(ini|pov)'
+ _comp_compgen_filedir '@(ini|pov)'
return
;;
esac
} &&
- complete -F _povray povray xpovray spovray
+ complete -F _comp_cmd_povray povray xpovray spovray
# ex: filetype=sh
diff --git a/completions/prelink b/completions/prelink
index 1c39611..51b1cd9 100644
--- a/completions/prelink
+++ b/completions/prelink
@@ -1,42 +1,42 @@
# prelink(8) completion -*- shell-script -*-
-_prelink()
+_comp_cmd_prelink()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-'?' | --help | --usage | -V | --version | -r | --reloc-only)
return
;;
-b | --black-list | --dynamic-linker | --undo-output)
- _filedir
+ _comp_compgen_filedir
return
;;
-c | --config-file)
- _filedir conf
+ _comp_compgen_filedir conf
return
;;
-C | --cache)
- _filedir cache
+ _comp_compgen_filedir cache
return
;;
--ld-library-path)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _prelink prelink
+ complete -F _comp_cmd_prelink prelink
# ex: filetype=sh
diff --git a/completions/printenv b/completions/printenv
index 3553e83..5bd565f 100644
--- a/completions/printenv
+++ b/completions/printenv
@@ -1,9 +1,9 @@
# printenv(1) completion -*- shell-script -*-
-_printenv()
+_comp_cmd_printenv()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--help | --version)
@@ -12,12 +12,12 @@ _printenv()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- COMPREPLY=($(compgen -v -- "$cur"))
+ _comp_compgen -- -v
} &&
- complete -F _printenv printenv
+ complete -F _comp_cmd_printenv printenv
# ex: filetype=sh
diff --git a/completions/protoc b/completions/protoc
index fdd77be..ac93e1c 100644
--- a/completions/protoc
+++ b/completions/protoc
@@ -1,63 +1,58 @@
# protoc completion -*- shell-script -*-
-_protoc()
+_comp_cmd_protoc()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
--version | -h | --help | --encode | --decode)
return
;;
--descriptor_set_out)
- _filedir
+ _comp_compgen_filedir
return
;;
--error_format)
- COMPREPLY=($(compgen -W 'gcc msvs' -- "$cur"))
+ _comp_compgen -- -W 'gcc msvs'
return
;;
--plugin)
- if [[ $cur != *=* ]]; then
- compopt -o filenames
- COMPREPLY=($(compgen -c -- "$cur"))
- fi
+ [[ $cur == *=* ]] || _comp_compgen_commands
return
;;
--proto_path | --*_out)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
case $cur in
-o*)
- cur=${cur:2}
- _filedir
- COMPREPLY=("${COMPREPLY[@]/#/-o}")
+ _comp_compgen -c "${cur:2}" filedir
+ ((${#COMPREPLY[@]})) && COMPREPLY=("${COMPREPLY[@]/#/-o}")
return
;;
-I*)
- cur=${cur:2}
- _filedir -d
- COMPREPLY=("${COMPREPLY[@]/#/-I}")
+ _comp_compgen -c "${cur:2}" filedir -d
+ ((${#COMPREPLY[@]})) && COMPREPLY=("${COMPREPLY[@]/#/-I}")
return
;;
-*)
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
local i
for i in "${!COMPREPLY[@]}"; do
- [[ ${COMPREPLY[i]} == -oFILE ]] && unset 'COMPREPLY[i]'
+ [[ ${COMPREPLY[i]} == -oFILE ]] && unset -v 'COMPREPLY[i]'
done
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
;;
esac
- _filedir proto
+ _comp_compgen_filedir proto
} &&
- complete -F _protoc protoc
+ complete -F _comp_cmd_protoc protoc
# ex: filetype=sh
diff --git a/completions/ps b/completions/ps
new file mode 100644
index 0000000..e816355
--- /dev/null
+++ b/completions/ps
@@ -0,0 +1,70 @@
+# bash completion for ps(1) -*- shell-script -*-
+
+_comp_cmd_ps()
+{
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+
+ case $prev in
+ --help)
+ _comp_compgen -- -W 'simple list output threads misc all'
+ return
+ ;;
+ --info | V | --version)
+ return
+ ;;
+ -C)
+ _comp_compgen_pnames
+ return
+ ;;
+ -[Gg] | --[Gg]roup)
+ _comp_compgen -- -g
+ return
+ ;;
+ ?(-)p | [^-]*p | --pid)
+ _comp_compgen_pids
+ return
+ ;;
+ --ppid)
+ _comp_compgen_pids # TODO: Only pids with children?
+ return
+ ;;
+ ?(-)q | [^-]*q | --quick-pid)
+ _comp_compgen_pids
+ return
+ ;;
+ -s | --sid)
+ # TODO
+ return
+ ;;
+ ?(-)t | [^-]*t | --tty)
+ _comp_expand_glob COMPREPLY '/dev/tty*' &&
+ _comp_compgen -- -W '"${COMPREPLY[@]}" "${COMPREPLY[@]#/dev/}"'
+ return
+ ;;
+ ?(-)U | [^-]*U | -u | --[Uu]ser)
+ _comp_compgen -- -u
+ return
+ ;;
+ --format | ?(-)[Oo] | [^-]*[Oo])
+ # TODO: This doesn't work well when there are multiple options for
+ # the non-first item (similarly to useradd --groups and others).
+ local labels=$("$1" L | _comp_awk '{ print $1 }')
+ _comp_delimited , -W '$labels'
+ return
+ ;;
+ esac
+
+ if [[ $cur == -* ]]; then
+ # sed: strip single char dashless ", x," that trip _comp_compgen_help
+ _comp_compgen_help - <<<"$({
+ "$1" --help
+ "$1" --help all
+ } 2>/dev/null |
+ command sed -e "s/, [A-Za-z],/,/")" ||
+ _comp_compgen_usage
+ fi
+} &&
+ complete -F _comp_cmd_ps ps
+
+# ex: filetype=sh
diff --git a/completions/psql b/completions/psql
index 4bc6049..b05b3a4 100644
--- a/completions/psql
+++ b/completions/psql
@@ -1,97 +1,104 @@
# bash completion for Postgresql -*- shell-script -*-
-_pg_databases()
+_comp_cmd_psql__databases()
{
# -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 -XAtqwlF $'\t' 2>/dev/null |
- awk 'NF > 1 { print $1 }')" -- "$cur"))
+ _comp_compgen_split -- "$(psql -XAtqwlF $'\t' 2>/dev/null |
+ _comp_awk 'NF > 1 { print $1 }')"
}
-_pg_users()
+_comp_cmd_psql__users()
{
# -w was introduced in 8.4, https://launchpad.net/bugs/164772
- COMPREPLY=($(compgen -W "$(psql -XAtqwc 'select usename from pg_user' \
- template1 2>/dev/null)" -- "$cur"))
- ((${#COMPREPLY[@]} == 0)) && COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen_split -- "$(psql -XAtqwc 'select usename from pg_user' \
+ template1 2>/dev/null)" ||
+ _comp_compgen -- -u
}
# createdb(1) completion
#
-_createdb()
+_comp_cmd_createdb()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[hUOpDET]*)'
+ # shellcheck disable=SC2254
case $prev in
- --host | -!(-*)h)
- _known_hosts_real -- "$cur"
+ --host | -${noargopts}h)
+ _comp_compgen_known_hosts -- "$cur"
return
;;
- --username | --owner | -!(-*)[UO])
- _pg_users
+ --username | --owner | -${noargopts}[UO])
+ _comp_cmd_psql__users
return
;;
- --help | --version | --port | --tablespace | --encoding | --template | -!(-*)[pDET])
+ --help | --version | --port | --tablespace | --encoding | --template | \
+ -${noargopts}[pDET])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- _pg_databases
+ _comp_cmd_psql__databases
fi
} &&
- complete -F _createdb createdb
+ complete -F _comp_cmd_createdb createdb
# createuser(1) completion
#
-_createuser()
+_comp_cmd_createuser()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[pchU]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | --port | --connection-limit | -!(-*)[pc])
+ --help | --version | --port | --connection-limit | -${noargopts}[pc])
return
;;
- --host | -!(-*)h)
- _known_hosts_real -- "$cur"
+ --host | -${noargopts}h)
+ _comp_compgen_known_hosts -- "$cur"
return
;;
- --username | -!(-*)U)
- _pg_users
+ --username | -${noargopts}U)
+ _comp_cmd_psql__users
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _createuser createuser
+ complete -F _comp_cmd_createuser createuser
# dropdb(1) completion
#
-_dropdb()
+_comp_cmd_dropdb()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[hU]*)'
+ # shellcheck disable=SC2254
case $prev in
- --host | -!(-*)h)
- _known_hosts_real -- "$cur"
+ --host | -${noargopts}h)
+ _comp_compgen_known_hosts -- "$cur"
return
;;
- --username | -!(-*)U)
- _pg_users
+ --username | -${noargopts}U)
+ _comp_cmd_psql__users
return
;;
--help | --version)
@@ -99,90 +106,95 @@ _dropdb()
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- _pg_databases
+ _comp_cmd_psql__databases
fi
} &&
- complete -F _dropdb dropdb
+ complete -F _comp_cmd_dropdb dropdb
# dropuser(1) completion
#
-_dropuser()
+_comp_cmd_dropuser()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[phU]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | --port | -!(-*)p)
+ --help | --version | --port | -${noargopts}p)
return
;;
- --host | -!(-*)h)
- _known_hosts_real -- "$cur"
+ --host | -${noargopts}h)
+ _comp_compgen_known_hosts -- "$cur"
return
;;
- --username | -!(-*)U)
- _pg_users
+ --username | -${noargopts}U)
+ _comp_cmd_psql__users
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- _pg_users
+ _comp_cmd_psql__users
fi
} &&
- complete -F _dropuser dropuser
+ complete -F _comp_cmd_dropuser dropuser
# psql(1) completion
#
-_psql()
+_comp_cmd_psql()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[hUdofLcFpPRTv]*)'
+ # shellcheck disable=SC2254
case $prev in
- --host | -!(-*)h)
- _known_hosts_real -- "$cur"
+ --host | -${noargopts}h)
+ _comp_compgen_known_hosts -- "$cur"
return
;;
- --username | -!(-*)U)
- _pg_users
+ --username | -${noargopts}U)
+ _comp_cmd_psql__users
return
;;
- --dbname | -!(-*)d)
- _pg_databases
+ --dbname | -${noargopts}d)
+ _comp_cmd_psql__databases
return
;;
- --output | --file | --log-file | -!(-*)[ofL])
- _filedir
+ --output | --file | --log-file | -${noargopts}[ofL])
+ _comp_compgen_filedir
return
;;
--help | --version | --command | --field-separator | --port | --pset | \
- --record-separator | --table-attr | --set | --variable | -!(-*)[?VcFpPRTv])
+ --record-separator | --table-attr | --set | --variable | \
+ -${noargopts}[?VcFpPRTv])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
# return list of available options
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
# return list of available databases
- _pg_databases
+ _comp_cmd_psql__databases
fi
} &&
- complete -F _psql psql
+ complete -F _comp_cmd_psql psql
# ex: filetype=sh
diff --git a/completions/puppet b/completions/puppet
index e8767de..3a8f585 100644
--- a/completions/puppet
+++ b/completions/puppet
@@ -1,64 +1,70 @@
# bash completion for puppet -*- shell-script -*-
-_puppet_logdest()
+_comp_cmd_puppet__logdest()
{
- if [[ -z $cur ]]; then
- COMPREPLY=($(compgen -W 'syslog console /' -- "$cur"))
+ if [[ ! $cur ]]; then
+ _comp_compgen -- -W 'syslog console /'
else
- COMPREPLY=($(compgen -W 'syslog console' -- "$cur"))
- _filedir
+ _comp_compgen -- -W 'syslog console'
+ _comp_compgen -a filedir
fi
}
-_puppet_digest()
+_comp_cmd_puppet__digest()
{
- COMPREPLY=($(compgen -W 'MD5 MD2 SHA1 SHA256' -- "$cur"))
+ _comp_compgen -- -W 'MD5 MD2 SHA1 SHA256'
}
-_puppet_certs()
+_comp_cmd_puppet__certs()
{
local puppetca="puppet cert"
PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type puppetca &>/dev/null &&
puppetca=puppetca
if [[ $1 == --all ]]; then
- cert_list=$($puppetca --list --all | command sed -e 's/^[+-]\{0,1\}\s*\(\S\+\)\s\+.*$/\1/')
+ cert_list=$(
+ $puppetca --list --all |
+ command sed -e 's/^[+-]\{0,1\}[[:space:]]*\([^[:space:]]\{1,\}\)[[:space:]]\{1,\}.*$/\1/'
+ )
else
- cert_list=$($puppetca --list)
+ cert_list=$("$puppetca" --list)
fi
- COMPREPLY+=($(compgen -W "$cert_list" -- "$cur"))
+ _comp_compgen -a -- -W "$cert_list"
}
-_puppet_types()
+_comp_cmd_puppet__types()
{
- puppet_types=$(puppet describe --list | command sed -e 's/^\(\S\{1,\}\).*$/\1/')
- COMPREPLY+=($(compgen -W "$puppet_types" -- "$cur"))
+ puppet_types=$(
+ puppet describe --list | command sed -e 's/^\([^[:space:]]\{1,\}\).*$/\1/'
+ )
+ _comp_compgen -a -- -W "$puppet_types"
}
-_puppet_references()
+_comp_cmd_puppet__references()
{
local puppetdoc="puppet doc"
PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type puppetdoc &>/dev/null &&
puppetdoc=puppetdoc
- puppet_doc_list=$($puppetdoc --list | command sed -e 's/^\(\S\{1,\}\).*$/\1/')
- COMPREPLY+=($(compgen -W "$puppet_doc_list" -- "$cur"))
+ puppet_doc_list=$(
+ $puppetdoc --list | command sed -e 's/^\([^[:space:]]\{1,\}\).*$/\1/'
+ )
+ _comp_compgen -a -- -W "$puppet_doc_list"
}
-_puppet_subcmd_opts()
+_comp_cmd_puppet__subcmd_opts()
{
# puppet cmd help is somewhat slow, avoid if possible
- [[ -z $cur || $cur == -* ]] &&
- COMPREPLY+=($(compgen -W \
- '$(_parse_usage "$1" "help $2")' -- "$cur"))
+ [[ ! $cur || $cur == -* ]] &&
+ _comp_compgen -a usage -- help ${2:+"$2"}
}
-_puppet()
+_comp_cmd_puppet()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- local subcommand action
+ local subcommand="" action
case $prev in
-h | --help | -V | --version)
@@ -96,16 +102,16 @@ _puppet()
;;
puppet)
case ${words[1]} in
- agent | apply | cert | describe | doc | filebucket | kick | master | parser | queue | resource)
+ agent | apply | cert | describe | doc | filebucket | kick | \
+ master | parser | queue | resource)
subcommand=${words[1]}
;;
*.pp | *.rb)
subcommand=apply
;;
*)
- COMPREPLY=($(compgen -W 'agent apply cert describe doc
- filebucket kick master parser queue resource' \
- -- "$cur"))
+ _comp_compgen -- -W 'agent apply cert describe doc
+ filebucket kick master parser queue resource'
return
;;
esac
@@ -116,33 +122,34 @@ _puppet()
agent)
case $prev in
--certname)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
--digest)
- _puppet_digest
+ _comp_cmd_puppet__digest
return
;;
--fqdn)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-l | --logdest)
- _puppet_logdest
+ _comp_cmd_puppet__logdest
return
;;
--masterport)
- COMPREPLY=($(compgen -W '8140' -- "$cur"))
+ _comp_compgen -- -W '8140'
return
;;
-w | --waitforcert)
- COMPREPLY=($(compgen -W '0 15 30 60 120' -- "$cur"))
+ _comp_compgen -- -W '0 15 30 60 120'
return
;;
*)
- _puppet_subcmd_opts "$1" $subcommand
- # _parse_usage doesn't grok [-D|--daemonize|--no-daemonize]
- COMPREPLY+=($(compgen -W '--no-daemonize' -- "$cur"))
+ _comp_cmd_puppet__subcmd_opts "$1" "$subcommand"
+ # _comp_compgen_usage doesn't grok
+ # [-D|--daemonize|--no-daemonize]
+ _comp_compgen -a -- -W '--no-daemonize'
return
;;
esac
@@ -150,22 +157,22 @@ _puppet()
apply)
case $prev in
--catalog)
- COMPREPLY=($(compgen -W '-' -- "$cur"))
- _filedir json
+ _comp_compgen -- -W '-'
+ _comp_compgen -a filedir json
return
;;
--execute)
return
;;
-l | --logdest)
- _puppet_logdest
+ _comp_cmd_puppet__logdest
return
;;
*)
if [[ $cur == -* ]]; then
- _puppet_subcmd_opts "$1" $subcommand
+ _comp_cmd_puppet__subcmd_opts "$1" "$subcommand"
else
- _filedir
+ _comp_compgen_filedir
fi
return
;;
@@ -174,35 +181,36 @@ _puppet()
cert)
case $prev in
--digest)
- _puppet_digest
+ _comp_cmd_puppet__digest
return
;;
*)
action=$prev
- COMPREPLY=($(compgen -W '--digest --debug --help --verbose --version' \
- -- "$cur"))
+ _comp_compgen -- -W '--digest --debug --help --verbose
+ --version'
case $action in
- fingerprint | list | verify | --fingerprint | --list | --verify)
- COMPREPLY+=($(compgen -W '--all' -- "$cur"))
- _puppet_certs --all
+ fingerprint | list | verify | --fingerprint | --list | \
+ --verify)
+ _comp_compgen -a -- -W '--all'
+ _comp_cmd_puppet__certs --all
return
;;
generate | --generate)
- _known_hosts_real -- "$cur"
+ _comp_compgen -a known_hosts -- "$cur"
return
;;
clean | print | revoke | --clean | --print | --revoke)
- _puppet_certs --all
+ _comp_cmd_puppet__certs --all
return
;;
sign | --sign)
- COMPREPLY+=($(compgen -W '--all' -- "$cur"))
- _puppet_certs
+ _comp_compgen -a -- -W '--all'
+ _comp_cmd_puppet__certs
return
;;
*)
- COMPREPLY+=($(compgen -W 'clean fingerprint generate
- list print revoke sign verify reinventory' -- "$cur"))
+ _comp_compgen -a -- -W 'clean fingerprint generate
+ list print revoke sign verify reinventory'
return
;;
esac
@@ -210,31 +218,31 @@ _puppet()
esac
;;
describe)
- _puppet_subcmd_opts "$1" $subcommand
+ _comp_cmd_puppet__subcmd_opts "$1" "$subcommand"
if [[ $cur != -* ]]; then
- _puppet_types
+ _comp_cmd_puppet__types
fi
return
;;
doc)
case $prev in
-o | --outputdir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-m | --mode)
- COMPREPLY=($(compgen -W 'text trac pdf rdoc' -- "$cur"))
+ _comp_compgen -- -W 'text trac pdf rdoc'
return
;;
-r | --reference)
- _puppet_references
+ _comp_cmd_puppet__references
return
;;
*)
if [[ $cur == -* ]]; then
- _puppet_subcmd_opts "$1" $subcommand
+ _comp_cmd_puppet__subcmd_opts "$1" "$subcommand"
else
- _filedir
+ _comp_compgen_filedir
fi
return
;;
@@ -243,20 +251,19 @@ _puppet()
filebucket)
case $prev in
-s | --server)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-b | --bucket)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
*)
if [[ $cur == -* ]]; then
- _puppet_subcmd_opts "$1" $subcommand
+ _comp_cmd_puppet__subcmd_opts "$1" "$subcommand"
else
- COMPREPLY=($(compgen -W 'backup get restore' \
- -- "$cur"))
- _filedir
+ _comp_compgen -- -W 'backup get restore'
+ _comp_compgen -a filedir
fi
return
;;
@@ -268,7 +275,7 @@ _puppet()
return
;;
--host)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-t | --tag)
@@ -276,9 +283,9 @@ _puppet()
;;
*)
if [[ $cur == -* ]]; then
- _puppet_subcmd_opts "$1" $subcommand
+ _comp_cmd_puppet__subcmd_opts "$1" "$subcommand"
else
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
fi
return
;;
@@ -287,13 +294,14 @@ _puppet()
master)
case $prev in
-l | --logdest)
- _puppet_logdest
+ _comp_cmd_puppet__logdest
return
;;
*)
- _puppet_subcmd_opts "$1" $subcommand
- # _parse_usage doesn't grok [-D|--daemonize|--no-daemonize]
- COMPREPLY+=($(compgen -W '--no-daemonize' -- "$cur"))
+ _comp_cmd_puppet__subcmd_opts "$1" "$subcommand"
+ # _comp_compgen_usage doesn't grok
+ # [-D|--daemonize|--no-daemonize]
+ _comp_compgen -a -- -W '--no-daemonize'
return
;;
esac
@@ -302,11 +310,11 @@ _puppet()
action=$prev
case $action in
validate)
- _filedir pp
+ _comp_compgen_filedir pp
return
;;
*)
- COMPREPLY=($(compgen -W 'validate' -- "$cur"))
+ _comp_compgen -- -W 'validate'
return
;;
esac
@@ -314,25 +322,26 @@ _puppet()
queue)
case $prev in
-l | --logdest)
- _puppet_logdest
+ _comp_cmd_puppet__logdest
return
;;
*)
if [[ $cur == -* ]]; then
- _puppet_subcmd_opts "$1" $subcommand
+ _comp_cmd_puppet__subcmd_opts "$1" "$subcommand"
else
- _filedir
+ _comp_compgen_filedir
fi
return
;;
esac
;;
resource | *)
- _puppet_subcmd_opts "$1" $subcommand
+ _comp_cmd_puppet__subcmd_opts "$1" ${subcommand:+"$subcommand"}
return
;;
esac
} &&
- complete -F _puppet puppetmasterd puppetd puppetca ralsh puppetrun puppetqd filebucket puppetdoc puppet
+ complete -F _comp_cmd_puppet puppetmasterd puppetd puppetca ralsh \
+ puppetrun puppetqd filebucket puppetdoc puppet
# ex: filetype=sh
diff --git a/completions/pv b/completions/pv
index 99933f2..ab3f070 100644
--- a/completions/pv
+++ b/completions/pv
@@ -1,31 +1,34 @@
# pv(1) completion -*- shell-script -*-
-_pv()
+_comp_cmd_pv()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[VAFDiwHNLBRPd]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | --last-written | --format | --delay-start | --interval | \
- --width | --height | --name | --rate-limit | --buffer-size | -!(-*)[hVAFDiwHNLB])
+ --help | --version | --last-written | --format | --delay-start | \
+ --interval | --width | --height | --name | --rate-limit | \
+ --buffer-size | -${noargopts}[hVAFDiwHNLB])
return
;;
- --remote | -!(-*)R)
- _pids
+ --remote | -${noargopts}R)
+ _comp_compgen_pids
return
;;
- --pidfile | --watchfd | -!(-*)[Pd])
- _filedir pid
+ --pidfile | --watchfd | -${noargopts}[Pd])
+ _comp_compgen_filedir pid
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _pv pv
+ complete -F _comp_cmd_pv pv
# ex: filetype=sh
diff --git a/completions/pwck b/completions/pwck
index fa07b0e..3e74ea5 100644
--- a/completions/pwck
+++ b/completions/pwck
@@ -1,18 +1,17 @@
# pwck(8) completion -*- shell-script -*-
-_pwck()
+_comp_cmd_pwck()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- local opts=$(_parse_help "$1")
- COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _pwck pwck
+ complete -F _comp_cmd_pwck pwck
# ex: filetype=sh
diff --git a/completions/pwd b/completions/pwd
index b9c4fbc..159dacc 100644
--- a/completions/pwd
+++ b/completions/pwd
@@ -1,9 +1,9 @@
# pwd(1) completion -*- shell-script -*-
-_pwd()
+_comp_cmd_pwd()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--help | --version)
@@ -11,10 +11,8 @@ _pwd()
;;
esac
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
- [[ ${COMPREPLY-} ]] ||
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage -c help -s "$1"
} &&
- complete -F _pwd pwd
+ complete -F _comp_cmd_pwd pwd
# ex: filetype=sh
diff --git a/completions/pwdx b/completions/pwdx
index 25a1a1e..ba460f2 100644
--- a/completions/pwdx
+++ b/completions/pwdx
@@ -1,9 +1,9 @@
# pwdx(1) completion -*- shell-script -*-
-_pwdx()
+_comp_cmd_pwdx()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-h | --help | -V | --version)
@@ -12,13 +12,12 @@ _pwdx()
esac
if [[ $cur == -* ]]; then
- local help='$(_parse_help "$1")'
- [[ $help ]] || help=-V
- COMPREPLY=($(compgen -W "$help" -- "$cur"))
+ _comp_compgen_help ||
+ _comp_compgen -- -W '-V'
else
- _pids
+ _comp_compgen_pids
fi
} &&
- complete -F _pwdx pwdx
+ complete -F _comp_cmd_pwdx pwdx
# ex: filetype=sh
diff --git a/completions/pwgen b/completions/pwgen
index 50d31d5..515ef1c 100644
--- a/completions/pwgen
+++ b/completions/pwgen
@@ -1,28 +1,30 @@
# pwgen(1) completion -*- shell-script -*-
-_pwgen()
+_comp_cmd_pwgen()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[NH]*)'
+ # shellcheck disable=SC2254
case $prev in
- --num-passwords | --help | -!(-*)[Nh])
+ --num-passwords | --help | -${noargopts}[Nh])
return
;;
- --sha1 | -!(-*)H)
- _filedir
+ --sha1 | -${noargopts}H)
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
} &&
- complete -F _pwgen pwgen
+ complete -F _comp_cmd_pwgen pwgen
# ex: filetype=sh
diff --git a/completions/pycodestyle b/completions/pycodestyle
index dec6f37..c8912bb 100644
--- a/completions/pycodestyle
+++ b/completions/pycodestyle
@@ -1,34 +1,34 @@
# pycodestyle completion -*- shell-script -*-
-_pycodestyle()
+_comp_cmd_pycodestyle()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-h | --help | --version)
return
;;
--format)
- COMPREPLY=($(compgen -W 'default pylint' -- "$cur"))
+ _comp_compgen -- -W 'default pylint'
return
;;
--config)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir py
+ _comp_compgen_filedir py
} &&
- complete -F _pycodestyle pycodestyle
+ complete -F _comp_cmd_pycodestyle pycodestyle
# ex: filetype=sh
diff --git a/completions/pydoc b/completions/pydoc
index e7b1178..2cf2987 100644
--- a/completions/pydoc
+++ b/completions/pydoc
@@ -1,42 +1,41 @@
# pydoc completion -*- shell-script -*-
-_pydoc()
+_comp_cmd_pydoc()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-k | -p)
return
;;
-w)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W \
- '$("$1" | command sed -e "s/^pydoc3\{0,1\} //" | _parse_help -)' \
- -- "$cur"))
+ _comp_compgen_help - <<<"$("$1" | command sed -e "s/^pydoc3\{0,1\} //")"
return
fi
- COMPREPLY=($(compgen -W 'keywords topics modules' -- "$cur"))
+ _comp_compgen -- -W 'keywords topics modules'
- if [[ $cur != @(.|*/)* ]]; then
- local python=python
- [[ ${1##*/} == *3* ]] && python=python3
- _xfunc python _python_modules $python
+ if ! _comp_looks_like_path "$cur"; then
+ # Prefer python in the same dir for resolving modules
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -ax python modules
fi
# Note that we don't do "pydoc modules" as it is known to hang on
- # some systems; _python_modules tends to work better and faster.
- COMPREPLY+=($(compgen -W \
- '$($1 keywords topics | command sed -e /^Here/d)' -- "$cur"))
+ # some systems; _comp_xfunc_python_modules tends to work better and faster.
+ _comp_compgen -a split -- "$("$1" keywords topics |
+ command sed -e '/^Here/d')"
- _filedir py
+ _comp_compgen -a filedir py
} &&
- complete -F _pydoc pydoc pydoc3
+ complete -F _comp_cmd_pydoc pydoc pydoc3
# ex: filetype=sh
diff --git a/completions/pydocstyle b/completions/pydocstyle
index acbf1ec..53f5690 100644
--- a/completions/pydocstyle
+++ b/completions/pydocstyle
@@ -1,35 +1,35 @@
# bash completion for pydocstyle -*- shell-script -*-
-_pydocstyle()
+_comp_cmd_pydocstyle()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
- --help | --version | --match | --ignore-decorators | --select | --ignore | \
- --add-select | --add-ignore | -!(-*)h)
+ --help | --version | --match | --ignore-decorators | --select | \
+ --ignore | --add-select | --add-ignore | -!(-*)h)
return
;;
--config)
- _filedir xml
+ _comp_compgen_filedir xml
return
;;
--convention)
- COMPREPLY=($(compgen -W "pep257 numpy" -- "$cur"))
+ _comp_compgen -- -W "pep257 numpy"
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir py
+ _comp_compgen_filedir py
} &&
- complete -F _pydocstyle pydocstyle
+ complete -F _comp_cmd_pydocstyle pydocstyle
# ex: filetype=sh
diff --git a/completions/pyflakes b/completions/pyflakes
index 0a4e977..a53904e 100644
--- a/completions/pyflakes
+++ b/completions/pyflakes
@@ -1,9 +1,9 @@
# pyflakes(1) completion -*- shell-script -*-
-_pyflakes()
+_comp_cmd_pyflakes()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-h | --help | --version)
@@ -12,12 +12,12 @@ _pyflakes()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- _filedir py
+ _comp_compgen_filedir py
} &&
- complete -F _pyflakes pyflakes
+ complete -F _comp_cmd_pyflakes pyflakes
# ex: filetype=sh
diff --git a/completions/pylint b/completions/pylint
index 8726f8b..84976d9 100644
--- a/completions/pylint
+++ b/completions/pylint
@@ -1,87 +1,119 @@
# pylint(1) completion -*- shell-script -*-
-_pylint()
+_comp_cmd_pylint__message_ids()
{
- local cur prev words cword split
- _init_completion -s || return
+ local filter=p
+ [[ ${2-} ]] && filter="/^$2 messages/,/^$/p"
+ # 6: arbitrary, assumed no ids shorter than that
+ # TODO(scop): The fallback here is slow, maybe memoize whether
+ # --list-msgs-enabled worked (>= 2.4.0) and avoid unnecessary tries
+ # again later?
+ local msgs="$(
+ set -o pipefail
+ "$1" --list-msgs-enabled 2>/dev/null |
+ command sed -ne "$filter" |
+ command sed -ne 's/^[[:space:]]\{1,\}\([a-z-]\{6,\}\).*/\1/p' ||
+ "$1" --list-msgs 2>/dev/null |
+ command sed -ne 's/^:\([a-z-]\{6,\}\).*/\1/p'
+ )"
+ _comp_delimited , -W "$msgs"
+}
+
+_comp_cmd_pylint()
+{
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
local python=python
[[ ${1##*/} == *3* ]] && python=python3
+ local noargopts='!(-*|*[edisrjf]*)'
+ # shellcheck disable=SC2254
case $prev in
- --version | --help | --long-help | --help-msg | --init-hook | --ignore | --enable | \
- --evaluation | --max-line-length | --max-module-lines | \
- --indent-string | --min-similarity-lines | --max-args | \
- --ignored-argument-names | --max-locals | --max-returns | --max-branchs | \
- --max-statements | --max-parents | --max-attributes | --min-public-methods | \
- --max-public-methods | --required-attributes | --bad-functions | \
- --module-rgx | --const-rgx | --class-rgx | --function-rgx | --method-rgx | \
- --attr-rgx | --argument-rgx | --variable-rgx | --inlinevar-rgx | --good-names | \
- --bad-names | --no-docstring-rgx | --dummy-variables-rgx | \
- --additional-builtins | --notes | --ignored-classes | --generated-members | \
+ --version | --help | --long-help | --init-hook | \
+ --ignore | --evaluation | --max-line-length | \
+ --max-module-lines | --indent-string | --min-similarity-lines | \
+ --max-args | --ignored-argument-names | --max-locals | \
+ --max-returns | --max-branches | --max-statements | --max-parents | \
+ --max-attributes | --min-public-methods | --max-public-methods | \
+ --required-attributes | --bad-functions | --module-rgx | \
+ --const-rgx | --class-rgx | --function-rgx | --method-rgx | \
+ --attr-rgx | --argument-rgx | --variable-rgx | --inlinevar-rgx | \
+ --good-names | --bad-names | --no-docstring-rgx | \
+ --dummy-variables-rgx | --additional-builtins | --notes | \
+ --ignored-classes | --generated-members | \
--overgeneral-exceptions | --ignore-iface-methods | \
--defining-attr-methods | --valid-classmethod-first-arg | \
- --valid-metaclass-classmethod-first-arg | -!(-*)[he])
+ --valid-metaclass-classmethod-first-arg | -${noargopts}[h])
+ return
+ ;;
+ --fail-on | --help-msg)
+ _comp_cmd_pylint__message_ids "$1"
return
;;
- --disable | -!(-*)d)
- COMPREPLY=($(compgen -W 'all' -- "$cur"))
+ --enable | -${noargopts}e)
+ _comp_cmd_pylint__message_ids "$1" Disabled
+ return
+ ;;
+ --disable | -${noargopts}d)
+ _comp_cmd_pylint__message_ids "$1" Enabled
+ _comp_compgen -a -- -W 'all'
return
;;
--rcfile)
- _filedir
+ _comp_compgen_filedir
return
;;
- --persistent | --include-ids | --symbols | --files-output | --reports | \
- --comment | --ignore-comments | --ignore-docstrings | --ignore-imports | \
- --init-import | --ignore-mixin-members | --zope | --suggestion-mode | \
- -!(-*)[isr])
- COMPREPLY=($(compgen -W 'yes no' -- "$cur"))
+ --persistent | --include-ids | --symbols | --files-output | \
+ --reports | --comment | --ignore-comments | --ignore-docstrings | \
+ --ignore-imports | --init-import | --ignore-mixin-members | \
+ --zope | --suggestion-mode | -${noargopts}[isr])
+ _comp_compgen -- -W 'yes no'
return
;;
--load-plugins | --deprecated-modules)
- local prefix=
- [[ $cur == *,* ]] && prefix="${cur%,*},"
- cur="${cur##*,}"
- _xfunc python _python_modules $python
- ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
+ _comp_compgen -c "${cur##*,}" -x python modules $python
+ ((${#COMPREPLY[@]})) &&
+ _comp_delimited , -W '"${COMPREPLY[@]}"'
return
;;
- --jobs | -!(-*)j)
- COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur"))
+ --jobs | -${noargopts}j)
+ local REPLY
+ _comp_get_ncpus
+ _comp_compgen -- -W "{1..$REPLY}"
return
;;
--confidence)
local prefix=
[[ $cur == *,* ]] && prefix="${cur%,*},"
- COMPREPLY=($(compgen -W "HIGH INFERENCE INFERENCE_FAILURE
- UNDEFINED" -- "${cur##*,}"))
- ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
+ _comp_compgen -c "${cur##*,}" -- -W "HIGH INFERENCE
+ INFERENCE_FAILURE UNDEFINED"
+ ((${#COMPREPLY[@]} == 1)) &&
+ _comp_compgen -Rv COMPREPLY -- -P "$prefix" -W '"$COMPREPLY"'
return
;;
- --format | -!(-*)f)
- COMPREPLY=($(compgen -W 'text parseable colorized json msvs' \
- -- "$cur"))
+ --format | -${noargopts}f)
+ _comp_compgen -- -W 'text parseable colorized json msvs'
return
;;
--import-graph | --ext-import-graph | --int-import-graph)
- _filedir dot
+ _comp_compgen_filedir dot
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W \
- '$(_parse_help "$1" --long-help)' -- "$cur"))
+ _comp_compgen_help -- --long-help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- [[ $cur == @(.|*/)* ]] || _xfunc python _python_modules $python
- _filedir py
+ _comp_compgen_set
+ _comp_looks_like_path "$cur" || _comp_compgen -x python modules $python
+ _comp_compgen -a filedir py
} &&
- complete -F _pylint pylint pylint-2 pylint-3
+ complete -F _comp_cmd_pylint pylint pylint-2 pylint-3
# ex: filetype=sh
diff --git a/completions/pytest b/completions/pytest
index 7457a84..9ed2575 100644
--- a/completions/pytest
+++ b/completions/pytest
@@ -1,134 +1,144 @@
# bash completion for pytest(1) -*- shell-script -*-
-_pytest()
+_comp_cmd_pytest__option_choice_args()
{
- local cur prev words cword split
- _init_completion -s -n : || return
+ local modes=$("$1" "$2=bash-completion-nonexistent" 2>&1 |
+ command sed -e 's/[^[:space:][:alnum:]_-]\{1,\}//g' \
+ -ne 's/.*choose from //p')
+ _comp_compgen -a -- -W '$modes'
+}
+_comp_cmd_pytest()
+{
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -n : -- "$@" || return
+
+ local noargopts='!(-*|*[kmorpcWn]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --maxfail | --report | --junit-prefix | --doctest-glob | -!(-*)[hkmorp])
+ --help | --maxfail | --report | --junit-prefix | --doctest-glob | \
+ -${noargopts}[hkmorp])
return
;;
--import-mode)
- COMPREPLY=($(compgen -W "prepend append" -- "$cur"))
+ _comp_compgen -- -W "prepend append importlib"
return
;;
--capture)
- COMPREPLY=($(compgen -W "fd sys no tee-sys" -- "$cur"))
+ _comp_compgen -- -W "fd sys no tee-sys"
return
;;
--lfnf | --last-failed-no-failures)
- COMPREPLY=($(compgen -W "all none" -- "$cur"))
+ _comp_compgen -- -W "all none"
return
;;
--tb)
- COMPREPLY=($(compgen -W "auto long short line native no" \
- -- "$cur"))
+ _comp_compgen -- -W 'auto long short line native no'
return
;;
--show-capture)
- COMPREPLY=($(compgen -W "no stdout stderr log all" -- "$cur"))
+ _comp_compgen -- -W "no stdout stderr log all"
return
;;
--color)
- COMPREPLY=($(compgen -W "yes no auto" -- "$cur"))
+ _comp_compgen -- -W "yes no auto"
return
;;
--pastebin)
- COMPREPLY=($(compgen -W "failed all" -- "$cur"))
+ _comp_compgen -- -W "failed all"
return
;;
--junit-xml)
- _filedir xml
+ _comp_compgen_filedir xml
return
;;
--result-log | --log-file)
- _filedir log
+ _comp_compgen_filedir log
return
;;
- --ignore)
- _filedir
+ --ignore | -${noargopts}c)
+ _comp_compgen_filedir
return
;;
--confcutdir | --basetemp | --rsyncdir | --rootdir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
--doctest-report)
- COMPREPLY=($(compgen -W "none cdiff ndiff udiff only_first_failure" -- "$cur"))
+ _comp_compgen -- -W 'none cdiff ndiff udiff only_first_failure'
return
;;
--assert)
- COMPREPLY=($(compgen -W "plain reinterp rewrite" -- "$cur"))
+ _comp_compgen -- -W "plain reinterp rewrite"
return
;;
--genscript)
- _filedir py
+ _comp_compgen_filedir py
return
;;
- --pythonwarnings | -!(-*)W)
- _xfunc python _python_warning_actions
+ --pythonwarnings | -${noargopts}W)
+ _comp_compgen -x python warning_actions
return
;;
- --numprocesses | -!(-*)n)
- COMPREPLY=($(compgen -W "{1..$(_ncpus)} auto" -- "$cur"))
+ --numprocesses | -${noargopts}n)
+ local REPLY
+ _comp_get_ncpus
+ _comp_compgen -- -W "{1..$REPLY} auto"
return
;;
- --dist)
- local modes=$("$1" --dist=nonexistent-distmode 2>&1 |
- command sed -e 's/[^[:space:][:alnum:]-]\{1,\}//g' \
- -ne 's/.*choose from //p')
- COMPREPLY=($(compgen -W '$modes' -- "$cur"))
+ --dist | --vcr-record?(-mode))
+ _comp_cmd_pytest__option_choice_args "$1" "$prev"
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
if [[ $cur == *.py::*:* ]]; then
local file=${cur/.py:*/.py}
- local class=${cur#*.py::} in_class=false
+ local class=${cur#*.py::} in_class=""
local line
class=${class%%:*}
while IFS= read -r line; do
if [[ $line =~ ^class[[:space:]]+${class}[[:space:]:\(] ]]; then
- in_class=true
+ in_class=set
elif [[ $line =~ ^class[[:space:]] ]]; then
- in_class=false
+ in_class=""
fi
- if $in_class && [[ $line =~ ^[[:space:]]+(async[[:space:]]+)?def[[:space:]]+(test_[A-Za-z0-9_]+) ]]; then
- COMPREPLY+=(${BASH_REMATCH[2]})
+ if [[ $in_class && $line =~ ^[[:space:]]+(async[[:space:]]+)?def[[:space:]]+(test_[A-Za-z0-9_]+) ]]; then
+ COMPREPLY+=("${BASH_REMATCH[2]}")
fi
done 2>/dev/null <"$file"
((!${#COMPREPLY[@]})) ||
- COMPREPLY=($(compgen -P "$file::$class::" -W '${COMPREPLY[@]}' \
- -- "${cur##*:?(:)}"))
- __ltrim_colon_completions "$cur"
+ _comp_compgen -c "${cur##*:?(:)}" -- -P "$file::$class::" \
+ -W '"${COMPREPLY[@]}"'
+ _comp_ltrim_colon_completions "$cur"
return
elif [[ $cur == *.py:* ]]; then
local file="${cur/.py:*/.py}" line
while IFS= read -r line; do
if [[ $line =~ ^class[[:space:]]+(Test[A-Za-z0-9_]+) ]]; then
- COMPREPLY+=(${BASH_REMATCH[1]})
+ COMPREPLY+=("${BASH_REMATCH[1]}")
elif [[ $line =~ ^(async[[:space:]]+)?def[[:space:]]+(test_[A-Za-z0-9_]+) ]]; then
- COMPREPLY+=(${BASH_REMATCH[2]})
+ COMPREPLY+=("${BASH_REMATCH[2]}")
fi
done 2>/dev/null <"$file"
((!${#COMPREPLY[@]})) ||
- COMPREPLY=($(compgen -P "$file::" -W '${COMPREPLY[@]}' \
- -- "${cur##*.py:?(:)}"))
- __ltrim_colon_completions "$cur"
+ _comp_compgen -c "${cur##*.py:?(:)}" -- -P "$file::" \
+ -W '"${COMPREPLY[@]}"'
+ _comp_ltrim_colon_completions "$cur"
return
fi
- _filedir py
+ _comp_compgen_filedir py
} &&
- complete -F _pytest pytest pytest-2 pytest-3 py.test py.test-2 py.test-3
+ complete -F _comp_cmd_pytest \
+ pytest pytest-2 pytest-3 py.test py.test-2 py.test-3
# ex: filetype=sh
diff --git a/completions/python b/completions/python
index d50c18f..5bf4b70 100644
--- a/completions/python
+++ b/completions/python
@@ -1,22 +1,42 @@
# bash completion for python -*- shell-script -*-
+# @since 2.12
+_comp_xfunc_python_compgen_modules()
+{
+ local _python=python
+ [[ ${comp_args[0]##*/} == *3* ]] && _python=python3
+ _comp_cmd_python__compgen_modules "$_python"
+}
+
+# @deprecated 2.12 use `_comp_xfunc_python_compgen_modules` instead
_python_modules()
{
- COMPREPLY+=($(compgen -W \
- "$(${1:-python} ${BASH_SOURCE[0]%/*}/../helpers/python $cur \
- 2>/dev/null)" -- "$cur"))
+ _comp_compgen -a -i python modules "${1:-python}"
+}
+
+_comp_cmd_python__compgen_modules()
+{
+ _comp_compgen_split -- "$("$1" \
+ "${BASH_SOURCE[0]%/*}/../helpers/python" "$cur" 2>/dev/null)"
}
+# @since 2.12
+_comp_xfunc_python_compgen_warning_actions()
+{
+ _comp_compgen -- -W "ignore default all module once error" \
+ ${prefix:+-P "$prefix"}
+}
+
+# @deprecated 2.12 use `_comp_xfunc_python_compgen_warning_actions` instead
_python_warning_actions()
{
- COMPREPLY+=($(compgen -W "ignore default all module once error" \
- ${prefix:+-P "$prefix"} -- "$cur"))
+ _comp_compgen -a -i python warning_actions "${1:-python}"
}
-_python()
+_comp_cmd_python()
{
- local cur prev words cword prefix
- _init_completion || return
+ local cur prev words cword comp_args prefix
+ _comp_initialize -- "$@" || return
case $cur in
-[QWX]?*)
@@ -26,42 +46,80 @@ _python()
;;
esac
+ local noargopts='!(-*|*[cmQWX]*)'
+
+ # if command, module, or script is already given by [-c command | -m module
+ # | script], complete all kind of files.
+ local i has_command=""
+ for ((i = 1; i < cword; i++)); do
+ # shellcheck disable=SC2254
+ case ${words[i]} in
+ -${noargopts}[QWX])
+ ((i++))
+ ;;
+ -${noargopts}[cm]?*)
+ has_command=set
+ break
+ ;;
+ -- | -${noargopts}[cm])
+ if ((i + 1 < cword)); then
+ has_command=set
+ break
+ fi
+ ;;
+ -*) ;;
+ *)
+ has_command=set
+ break
+ ;;
+ esac
+ done
+ if [[ $has_command ]]; then
+ _comp_compgen_filedir
+ return
+ fi
+
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | -!(-*)[?hVcX])
+ --help | --version | -${noargopts}[?hVc])
return
;;
- -!(-*)m)
- _python_modules "$1"
+ -${noargopts}m)
+ _comp_cmd_python__compgen_modules "$1"
return
;;
- -!(-*)Q)
- COMPREPLY=($(compgen -W "old new warn warnall" -P "$prefix" \
- -- "$cur"))
+ -${noargopts}Q)
+ _comp_compgen -- -W 'old new warn warnall' -P "$prefix"
return
;;
- -!(-*)W)
- _python_warning_actions
+ -${noargopts}W)
+ _comp_xfunc_python_compgen_warning_actions
+ return
+ ;;
+ -${noargopts}X)
+ _comp_compgen_split -- "$("$1" -h 2>&1 |
+ _comp_awk '$1 == "-X" && $2 ~ /:$/ {
+ sub(":$","",$2); sub("=.*","=",$2); print $2
+ }')"
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
;;
--jit)
# TODO: quite a few others, parse from "--jit help" output?
- COMPREPLY=($(compgen -W "help off" -- "$cur"))
+ _comp_compgen -- -W "help off"
return
;;
- !(?(*/)python*([0-9.])|?(*/)pypy*([0-9.])|-?))
- [[ $cword -lt 2 || ${words[cword - 2]} != -[QWX] ]] && _filedir
- ;;
esac
- # if -c or -m is already given, complete all kind of files.
- if [[ ${words[*]::cword} == *\ -[cm]\ * ]]; then
- _filedir
- elif [[ $cur != -* ]]; then
- _filedir 'py?([cowz])'
+ if [[ $prev == -- || $cur != -* ]]; then
+ _comp_compgen_filedir '@(py?([cowz])|zip)'
else
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ _comp_compgen_help - <<<"$("$1" -h |
+ _comp_awk '{ sub("\\(-bb:","\n-bb "); print }')"
fi
} &&
- complete -F _python python python2 python2.7 python3 python3.{3..8} pypy pypy3 micropython
+ complete -F _comp_cmd_python \
+ python python2 python2.7 python3 python3.{3..12} \
+ pypy pypy3 pyston pyston3 micropython
# ex: filetype=sh
diff --git a/completions/pyvenv b/completions/pyvenv
index 527a384..c7054df 100644
--- a/completions/pyvenv
+++ b/completions/pyvenv
@@ -1,9 +1,9 @@
# bash completion for pyvenv -*- shell-script -*-
-_pyvenv()
+_comp_cmd_pyvenv()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-h | --help)
@@ -11,15 +11,15 @@ _pyvenv()
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- _longopt "$1"
+ _comp_complete_longopt "$@"
return
fi
- _filedir -d
+ _comp_compgen_filedir -d
} &&
- complete -F _pyvenv pyvenv pyvenv-3.{4..8}
+ complete -F _comp_cmd_pyvenv pyvenv pyvenv-3.{4..12}
# ex: filetype=sh
diff --git a/completions/qdbus b/completions/qdbus
index 5b5a5e3..daf1065 100644
--- a/completions/qdbus
+++ b/completions/qdbus
@@ -1,14 +1,14 @@
# Qt qdbus, dcop completion -*- shell-script -*-
-_qdbus()
+_comp_cmd_qdbus()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- [[ -n $cur ]] && unset "words[$((${#words[@]} - 1))]"
- COMPREPLY=($(compgen -W '$(command ${words[@]} 2>/dev/null | \
- command sed "s/(.*)//")' -- "$cur"))
+ _comp_compgen_split -- "$(
+ command "${words[@]::cword}" 2>/dev/null | command sed 's/(.*)//'
+ )"
} &&
- complete -F _qdbus qdbus dcop
+ complete -F _comp_cmd_qdbus qdbus dcop
# ex: filetype=sh
diff --git a/completions/qemu b/completions/qemu
index 8382981..c8bd741 100644
--- a/completions/qemu
+++ b/completions/qemu
@@ -1,108 +1,106 @@
# bash completion for qemu -*- shell-script -*-
-_qemu()
+_comp_cmd_qemu()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
- -fd[ab] | -hd[abcd] | -cdrom | -option-rom | -kernel | -initrd | -bootp | -pidfile | \
- -loadvm | -mtdblock | -sd | -pflash | -bios)
- _filedir
+ -fd[ab] | -hd[abcd] | -cdrom | -option-rom | -kernel | -initrd | \
+ -bootp | -pidfile | -loadvm | -mtdblock | -sd | -pflash | -bios)
+ _comp_compgen_filedir
return
;;
-tftp | -smb | -L | -chroot)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-boot)
- COMPREPLY=($(compgen -W 'a c d n' -- "$cur"))
+ _comp_compgen -- -W 'a c d n'
return
;;
-k)
- COMPREPLY=($(compgen -W 'ar de-ch es fo fr-ca hu ja mk no pt-br
- sv da en-gb et fr fr-ch is lt nl pl ru th de en-us fi fr-be hr
- it lv nl-be pt sl tr' -- "$cur"))
+ local -a keymaps
+ _comp_expand_glob keymaps '/usr/{local/,}share/qemu/keymaps/!(common|modifiers)' &&
+ _comp_compgen -- -W '"${keymaps[@]##*/}"'
return
;;
-soundhw)
- COMPREPLY=($(compgen -W "$($1 -soundhw help | awk \
- '/^[[:lower:]]/ {print $1}') all" -- "$cur"))
+ _comp_compgen_split -- "$("$1" -soundhw help | _comp_awk '
+ function islower(s) { return length(s) > 0 && s == tolower(s); }
+ islower(substr($0, 1, 1)) {print $1}') all"
return
;;
-machine | -M)
- COMPREPLY=($(compgen -W "$($1 $prev help | awk \
- '/^[[:lower:]]/ {print $1}')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" "$prev" help | _comp_awk '
+ function islower(s) { return length(s) > 0 && s == tolower(s); }
+ islower(substr($0, 1, 1)) {print $1}')"
return
;;
-cpu)
- COMPREPLY=($(compgen -W "$($1 -cpu help | awk '{print $2}')" \
- -- "$cur"))
+ _comp_compgen_split -- "$("$1" -cpu help | _comp_awk '{print $2}')"
return
;;
-usbdevice)
- COMPREPLY=($(compgen -W 'mouse tablet disk: host: serial: braille
- net' -- "$cur"))
+ _comp_compgen -- -W 'mouse tablet disk: host: serial: braille net'
return
;;
-net)
- COMPREPLY=($(compgen -W 'nic user tap socket vde none dump' \
- -- "$cur"))
+ _comp_compgen -- -W 'nic user tap socket vde none dump'
return
;;
-serial | -parallel | -monitor)
- COMPREPLY=($(compgen -W 'vc pty none null /dev/ file: stdio pipe:
- COM udp: tcp: telnet: unix: mon: braille' -- "$cur"))
+ _comp_compgen -- -W 'vc pty none null /dev/ file: stdio pipe: COM
+ udp: tcp: telnet: unix: mon: braille'
return
;;
-redir)
- COMPREPLY=($(compgen -S":" -W 'tcp udp' -- "$cur"))
+ _comp_compgen -- -S":" -W 'tcp udp'
return
;;
-bt)
- COMPREPLY=($(compgen -W 'hci vhci device' -- "$cur"))
+ _comp_compgen -- -W 'hci vhci device'
return
;;
-vga)
- COMPREPLY=($(compgen -W 'cirrus std vmware xenfb none' -- "$cur"))
+ _comp_compgen -- -W 'cirrus std vmware xenfb none'
return
;;
-drive)
- COMPREPLY=($(compgen -S"=" -W 'file if bus unit index media cyls
- snapshot cache format serial addr' -- "$cur"))
+ _comp_compgen -- -S"=" -W 'file if bus unit index media cyls
+ snapshot cache format serial addr'
return
;;
-balloon)
- COMPREPLY=($(compgen -W 'none virtio' -- "$cur"))
+ _comp_compgen -- -W 'none virtio'
return
;;
-smbios)
- COMPREPLY=($(compgen -W 'file type' -- "$cur"))
+ _comp_compgen -- -W 'file type'
return
;;
-watchdog)
- COMPREPLY=($(compgen -W "$($1 -watchdog help 2>&1 |
- awk '{print $1}')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" -watchdog help 2>&1 |
+ _comp_awk '{print $1}')"
return
;;
-watchdog-action)
- COMPREPLY=($(compgen -W 'reset shutdown poweroff pause debug
- none' -- "$cur"))
+ _comp_compgen -- -W 'reset shutdown poweroff pause debug none'
return
;;
-runas)
- _allowed_users
+ _comp_compgen_allowed_users
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help) -fd{a,b}
- -hd{a..d}' -- "$cur"))
+ _comp_compgen_help -- -help
+ _comp_compgen -a -- -W '-fd{a,b} -hd{a..d}'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _qemu qemu qemu-kvm qemu-system-i386 qemu-system-x86_64
+ complete -F _comp_cmd_qemu qemu qemu-kvm qemu-system-i386 qemu-system-x86_64
# ex: filetype=sh
diff --git a/completions/qrunner b/completions/qrunner
index 3919ea2..cf54b68 100644
--- a/completions/qrunner
+++ b/completions/qrunner
@@ -1,18 +1,17 @@
# mailman qrunner completion -*- shell-script -*-
-_qrunner()
+_comp_cmd_qrunner()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--runner --once --list --verbose --subproc
- --help' -- "$cur"))
+ _comp_compgen -- -W '--runner --once --list --verbose --subproc --help'
fi
} &&
- complete -F _qrunner qrunner
+ complete -F _comp_cmd_qrunner qrunner
# ex: filetype=sh
diff --git a/completions/querybts b/completions/querybts
index edeba96..5b9f33a 100644
--- a/completions/querybts
+++ b/completions/querybts
@@ -1,40 +1,41 @@
# querybts completion -*- shell-script -*-
-_querybts()
+_comp_cmd_querybts()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[Bu]*)'
+ # shellcheck disable=SC2254
case $prev in
- --bts | -!(-*)B)
- COMPREPLY=($(compgen -W "debian guug kde mandrake help" \
- -- "$cur"))
+ --bts | -${noargopts}B)
+ _comp_compgen -- -W 'debian guug kde mandrake help'
return
;;
- --ui | --interface | -!(-*)u)
- COMPREPLY=($(compgen -W "newt text gnome" -- "$cur"))
+ --ui | --interface | -${noargopts}u)
+ _comp_compgen -- -W "newt text gnome"
return
;;
--mbox-reader-cmd)
- compopt -o filenames
- COMPREPLY=($(compgen -c -- "$cur"))
+ _comp_compgen_commands
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- COMPREPLY=($(compgen -W 'wnpp boot-floppies kernel bugs.debian.org
+ _comp_compgen -- -W 'wnpp boot-floppies kernel bugs.debian.org
cdimage.debian.org general installation-reports listarchives
lists.debian.org mirrors nm.debian.org press project qa.debian.org
release-notes security.debian.org tech-ctte upgrade-reports
- www.debian.org $(_xfunc apt-cache _apt_cache_packages)' -- "$cur"))
+ www.debian.org'
+ _comp_compgen -ax apt-cache packages
fi
} &&
- complete -F _querybts querybts
+ complete -F _comp_cmd_querybts querybts
# ex: filetype=sh
diff --git a/completions/quota b/completions/quota
index f5f9cc8..504284c 100644
--- a/completions/quota
+++ b/completions/quota
@@ -1,49 +1,47 @@
# bash completion for quota-tools -*- shell-script -*-
-_user_or_group()
+_comp_cmd_quota__user_or_group()
{
local i
# complete on groups if -g was given
for ((i = 1; i < cword; i++)); do
if [[ ${words[i]} == -@(g|-group) ]]; then
- COMPREPLY=($(compgen -g -- "$cur"))
+ _comp_compgen -- -g
return
fi
done
# otherwise complete on users
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
}
-_quota_parse_help()
+_comp_cmd_quota__parse_help()
{
- local opts=$(_parse_help "$1")
- COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
}
-_quota_formats()
+_comp_cmd_quota__formats()
{
- COMPREPLY=($(compgen -W 'vfsold vfsv0 rpc xfs' -- "$cur"))
+ _comp_compgen -- -W 'vfsold vfsv0 rpc xfs'
}
-_filesystems()
+_comp_cmd_quota__filesystems()
{
# Only list filesystems starting with "/", otherwise we also get
#+ "binfmt_misc", "proc", "tmpfs", ...
- COMPREPLY=($(compgen -W "$(awk '/^\// {print $1}' /etc/mtab)" \
- -- "$cur"))
+ _comp_compgen_split -- "$(_comp_awk '/^\// {print $1}' /etc/mtab)"
}
-_quota()
+_comp_cmd_quota()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-F | --format)
- _quota_formats
+ _comp_cmd_quota__formats
return
;;
-h | --help | -V | --version)
@@ -51,28 +49,28 @@ _quota()
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- _quota_parse_help "$1"
+ _comp_cmd_quota__parse_help "$1"
else
- _user_or_group
+ _comp_cmd_quota__user_or_group
fi
} &&
- complete -F _quota -o default quota
+ complete -F _comp_cmd_quota -o default quota
-_setquota()
+_comp_cmd_setquota()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-F | --format)
- _quota_formats
+ _comp_cmd_quota__formats
return
;;
-p | --prototype)
- _user_or_group
+ _comp_cmd_quota__user_or_group
return
;;
-h | --help | -V | --version)
@@ -80,43 +78,43 @@ _setquota()
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- _quota_parse_help "$1"
+ _comp_cmd_quota__parse_help "$1"
else
- local args
- _count_args
+ local REPLY
+ _comp_count_args
- case $args in
+ case $REPLY in
1)
- _user_or_group
+ _comp_cmd_quota__user_or_group
;;
2)
- _filesystems
+ _comp_cmd_quota__filesystems
;;
esac
fi
} &&
- complete -F _setquota -o default setquota
+ complete -F _comp_cmd_setquota -o default setquota
-_edquota()
+_comp_cmd_edquota()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-F | --format)
- _quota_formats
+ _comp_cmd_quota__formats
return
;;
-f | --filesystem)
- _filesystems
+ _comp_cmd_quota__filesystems
return
;;
-p | --prototype)
- _user_or_group
+ _comp_cmd_quota__user_or_group
return
;;
-h | --help | -V | --version)
@@ -124,24 +122,24 @@ _edquota()
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- _quota_parse_help "$1"
+ _comp_cmd_quota__parse_help "$1"
else
- _user_or_group
+ _comp_cmd_quota__user_or_group
fi
} &&
- complete -F _edquota -o default edquota
+ complete -F _comp_cmd_edquota -o default edquota
-_quotacheck()
+_comp_cmd_quotacheck()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-F | --format)
- _quota_formats
+ _comp_cmd_quota__formats
return
;;
-h | --help | -V | --version)
@@ -149,28 +147,28 @@ _quotacheck()
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- _quota_parse_help "$1"
+ _comp_cmd_quota__parse_help "$1"
else
- _filesystems
+ _comp_cmd_quota__filesystems
fi
} &&
- complete -F _quotacheck -o default quotacheck repquota
+ complete -F _comp_cmd_quotacheck -o default quotacheck repquota
-_quotaon()
+_comp_cmd_quotaon()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-F | --format)
- _quota_formats
+ _comp_cmd_quota__formats
return
;;
-x | --xfs-command)
- COMPREPLY=($(compgen -W 'delete enforce' -- "$cur"))
+ _comp_compgen -- -W 'delete enforce'
return
;;
-h | --help | -V | --version)
@@ -178,14 +176,14 @@ _quotaon()
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- _quota_parse_help "$1"
+ _comp_cmd_quota__parse_help "$1"
else
- _filesystems
+ _comp_cmd_quota__filesystems
fi
} &&
- complete -F _quotaon -o default quotaon quotaoff
+ complete -F _comp_cmd_quotaon -o default quotaon quotaoff
# ex: filetype=sh
diff --git a/completions/radvdump b/completions/radvdump
index 850628f..74ce574 100644
--- a/completions/radvdump
+++ b/completions/radvdump
@@ -1,22 +1,22 @@
# radvdump(8) completion -*- shell-script -*-
-_radvdump()
+_comp_cmd_radvdump()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-h | --help | -v | --version)
return
;;
-d | --debug)
- COMPREPLY=($(compgen -W '{1..4}' -- "$cur"))
+ _comp_compgen -- -W '{1..4}'
return
;;
esac
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
} &&
- complete -F _radvdump radvdump
+ complete -F _comp_cmd_radvdump radvdump
# ex: filetype=sh
diff --git a/completions/rcs b/completions/rcs
index c04d89d..aab018e 100644
--- a/completions/rcs
+++ b/completions/rcs
@@ -1,9 +1,9 @@
# bash completion for rcs -*- shell-script -*-
-_rcs()
+_comp_cmd_rcs()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local file dir i
@@ -13,7 +13,7 @@ _rcs()
# deal with relative directory
[[ $file == "$dir" ]] && dir=.
- COMPREPLY=($(compgen -f -- "$dir/RCS/$file"))
+ _comp_compgen -c "$dir/RCS/$file" -- -f
for i in ${!COMPREPLY[*]}; do
file=${COMPREPLY[i]##*/}
@@ -21,7 +21,7 @@ _rcs()
COMPREPLY[i]=$dir$file
done
- COMPREPLY+=($(compgen -G "$dir/$file*,v"))
+ _comp_compgen -aR -- -G "$dir/$file*,v"
for i in ${!COMPREPLY[*]}; do
COMPREPLY[i]=${COMPREPLY[i]%,v}
@@ -29,8 +29,8 @@ _rcs()
# default to files if nothing returned and we're checking in.
# otherwise, default to directories
- [[ ${#COMPREPLY[@]} -eq 0 && $1 == *ci ]] && _filedir || _filedir -d
+ [[ ${#COMPREPLY[@]} -eq 0 && $1 == *ci ]] && _comp_compgen -a filedir || _comp_compgen -a filedir -d
} &&
- complete -F _rcs ci co rlog rcs rcsdiff
+ complete -F _comp_cmd_rcs ci co rlog rcs rcsdiff
# ex: filetype=sh
diff --git a/completions/rdesktop b/completions/rdesktop
index 54c1ae6..42d2ccb 100644
--- a/completions/rdesktop
+++ b/completions/rdesktop
@@ -1,39 +1,34 @@
# bash completion for rdesktop -*- shell-script -*-
-_rdesktop()
+_comp_cmd_rdesktop()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
case $prev in
-*k)
- COMPREPLY=($(command ls \
- /usr/share/rdesktop/keymaps 2>/dev/null |
- command grep -E -v '(common|modifiers)'))
- COMPREPLY+=($(command ls $HOME/.rdesktop/keymaps 2>/dev/null))
- COMPREPLY+=($(command ls ./keymaps 2>/dev/null))
- COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur"))
+ _comp_expand_glob COMPREPLY '/usr/share/rdesktop/keymaps/!(*@(common|modifiers)*) {"$HOME/.rdesktop",.}/keymaps/*' &&
+ _comp_compgen -- -W '"${COMPREPLY[@]}"'
return
;;
-*a)
- COMPREPLY=($(compgen -W '8 15 16 24' -- "$cur"))
+ _comp_compgen -- -W '8 15 16 24'
return
;;
-*x)
- COMPREPLY=($(compgen -W 'broadband modem lan' -- "$cur"))
+ _comp_compgen -- -W 'broadband modem lan'
return
;;
-*r)
case $cur in
sound:*)
- COMPREPLY=($(compgen -W 'local off remote' \
- -- "${cur#sound:}"))
+ _comp_compgen -c "${cur#sound:}" -- -W 'local off remote'
;;
*:*) ;;
*)
- COMPREPLY=($(compgen -W 'comport: disk: lptport:
- printer: sound: lspci scard' -- "$cur"))
+ _comp_compgen -- -W 'comport: disk: lptport: printer:
+ sound: lspci scard'
[[ ${COMPREPLY-} == *: ]] && compopt -o nospace
;;
esac
@@ -45,13 +40,15 @@ _rdesktop()
esac
if [[ $cur == -* ]]; then
- local opts=($(_parse_help "$1"))
- COMPREPLY=($(compgen -W '${opts[@]%:}' -- "$cur"))
+ local -a opts
+ _comp_compgen -Rv opts help
+ ((${#opts[@]})) &&
+ _comp_compgen -- -W '"${opts[@]%:}"'
else
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
fi
} &&
- complete -F _rdesktop rdesktop
+ complete -F _comp_cmd_rdesktop rdesktop
# ex: filetype=sh
diff --git a/completions/remove_members b/completions/remove_members
index db7ad0b..4689b03 100644
--- a/completions/remove_members
+++ b/completions/remove_members
@@ -1,27 +1,30 @@
# mailman remove_members completion -*- shell-script -*-
-_remove_members()
+_comp_cmd_remove_members()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-f | --file)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--file --all --fromall --nouserack
- --noadminack --help' -- "$cur"))
+ _comp_compgen -- -W '--file --all --fromall --nouserack --noadminack
+ --help'
else
- _xfunc list_lists _mailman_lists
+ # Prefer `list_lists` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -x list_lists mailman_lists
fi
} &&
- complete -F _remove_members remove_members
+ complete -F _comp_cmd_remove_members remove_members
# ex: filetype=sh
diff --git a/completions/removepkg b/completions/removepkg
index a56beb0..73b632b 100644
--- a/completions/removepkg
+++ b/completions/removepkg
@@ -1,25 +1,22 @@
# Slackware Linux removepkg completion -*- shell-script -*-
-_removepkg()
+_comp_cmd_removepkg()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-copy -keep -preserve -warn' -- "$cur"))
+ _comp_compgen -- -W '-copy -keep -preserve -warn'
return
fi
- if [[ $cur == */* ]]; then
- _filedir
+ if _comp_looks_like_path "$cur"; then
+ _comp_compgen_filedir
return
fi
local root=${ROOT:-/}
- COMPREPLY=($(
- cd "$root/var/log/packages" 2>/dev/null || return 1
- compgen -f -- "$cur"
- ))
+ _comp_compgen -C "$root/var/log/packages" -- -f
} &&
- complete -F _removepkg removepkg
+ complete -F _comp_cmd_removepkg removepkg
# ex: filetype=sh
diff --git a/completions/reportbug b/completions/reportbug
index 69b12e9..30c4647 100644
--- a/completions/reportbug
+++ b/completions/reportbug
@@ -1,96 +1,76 @@
# bash completion for (Debian) reportbug -*- shell-script -*-
-_reportbug()
+_comp_cmd_reportbug()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[CefKHPsoiATjVuQtBS]*)'
+ # shellcheck disable=SC2254
case $prev in
- --class | --header | --pseudo-header | --mirror | --list-cc | --subject | \
- --http_proxy | --proxy | --email | --realname | --smtpuser | --smtppasswd | \
- --replyto | --reply-to | --justification | --package-version | --body | \
- --body-file | --timeout | --max-attachment-size | --envelope-from | \
- -!(-*)[CHPsjV])
+ --class | --header | --pseudo-header | --mirror | --list-cc | \
+ --subject | --http_proxy | --proxy | --email | --realname | \
+ --smtpuser | --smtppasswd | --replyto | --reply-to | \
+ --justification | --package-version | --body | --body-file | \
+ --timeout | --max-attachment-size | --envelope-from | \
+ -${noargopts}[CHPsjV])
return
;;
--filename | --include | --mta | --output | --attach | -[fioA])
- _filedir
+ _comp_compgen_filedir
return
;;
- --keyid | -!(-*)K)
- COMPREPLY=($(compgen -W '$(IFS=: ; \
- gpg --list-keys --with-colons 2>/dev/null \
- | while read -ra row ; do
- [[ "${row[0]}" == [ps]ub && ${row[11]} == *s* ]] && \
- printf "%s\n" "${row[4]}"
- done)' -- "$cur"))
+ --keyid | -${noargopts}K)
+ _comp_compgen_split -- "$(
+ IFS=:
+ gpg --list-keys --with-colons 2>/dev/null |
+ while read -ra row; do
+ [[ ${row[0]} == [ps]ub && ${row[11]} == *s* ]] &&
+ printf '%s\n' "${row[4]}"
+ done
+ )"
return
;;
- --bts | -!(-*)B)
- COMPREPLY=($(compgen -W "debian guug kde mandrake help" -- \
- "$cur"))
+ --tag | --ui | --interface | --type | --bts | --severity | --mode | -${noargopts}[TutBS])
+ _comp_compgen_split -- "$("$1" "$prev" help 2>&1 |
+ command sed -ne '/^[[:space:]]/p')"
return
;;
- --editor | --mua | --mbox-reader-cmd | -!(-*)e)
- compopt -o filenames
- COMPREPLY=($(compgen -c -- "$cur"))
- return
- ;;
- --mode)
- COMPREPLY=($(compgen -W "novice standard expert" -- "$cur"))
- return
- ;;
- --severity | -!(-*)S)
- COMPREPLY=($(compgen -W "grave serious important normal minor
- wishlist" -- "$cur"))
- return
- ;;
- --ui | --interface | -!(-*)u)
- COMPREPLY=($(compgen -W "newt text gnome" -- "$cur"))
- return
- ;;
- --type | -!(-*)t)
- COMPREPLY=($(compgen -W "gnats debbugs" -- "$cur"))
- return
- ;;
- --tag | -!(-*)T)
- COMPREPLY=($(compgen -W "none woody potato sarge sarge-ignore
- etch etch-ignore lenny lenny-ignore sid experimental confirmed
- d-i fixed fixed-in-experimental fixed-upstream help l10n
- moreinfo patch pending security unreproducible upstream wontfix
- ipv6 lfs" -- "$cur"))
+ --editor | --mua | --mbox-reader-cmd | -${noargopts}e)
+ _comp_compgen_commands
return
;;
--from-buildd)
- COMPREPLY=($(compgen -S "_" -W '$(apt-cache dumpavail | \
- command grep "^Source: $cur" | sort -u | cut -f2 -d" ")'))
+ _comp_compgen_split -S "_" -- "$(apt-cache dumpavail |
+ _comp_awk -F ' ' '$1 == "Source:" && !uniq[$2]++ { print $2 }')"
return
;;
--smtphost)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
--draftpath)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == -*= ]] && compopt -o nospace
return
fi
- COMPREPLY=($(compgen -W 'wnpp boot-floppies kernel bugs.debian.org
+ _comp_compgen -- -W 'wnpp boot-floppies kernel bugs.debian.org
cdimage.debian.org general installation-reports listarchives
lists.debian.org mirrors nm.debian.org press project qa.debian.org
release-notes security.debian.org tech-ctte upgrade-reports
- www.debian.org $(_xfunc apt-cache _apt_cache_packages)' -- "$cur"))
- _filedir
+ www.debian.org'
+ _comp_compgen -ax apt-cache packages
+ _comp_compgen -a filedir
} &&
- complete -F _reportbug reportbug
+ complete -F _comp_cmd_reportbug reportbug
# ex: filetype=sh
diff --git a/completions/resolvconf b/completions/resolvconf
index b407488..4389fa8 100644
--- a/completions/resolvconf
+++ b/completions/resolvconf
@@ -1,21 +1,21 @@
# bash completion for resolvconf -*- shell-script -*-
-_resolvconf()
+_comp_cmd_resolvconf()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-a | -d)
- _available_interfaces
+ _comp_compgen_available_interfaces
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-a -d -u' -- "$cur"))
+ _comp_compgen -- -W '-a -d -u'
fi
} &&
- complete -F _resolvconf resolvconf
+ complete -F _comp_cmd_resolvconf resolvconf
# ex: filetype=sh
diff --git a/completions/ri b/completions/ri
index 9c34b27..514bf6d 100644
--- a/completions/ri
+++ b/completions/ri
@@ -1,110 +1,116 @@
# ri completion for Ruby documentation -*- shell-script -*-
# by Ian Macdonald <ian@caliban.org>
-_ri_get_methods()
+# @var[in] ri_version
+# @var[in] prefix
+# @var[in] classes
+_comp_cmd_ri__compgen_methods()
{
- local regex
+ local _regex
+ local IFS=$' \t\n' # needed for ${classes[@]+"${classes[@]}"} in bash-5.2
+ local _methods
if [[ $ri_version == integrated ]]; then
- if [[ -z $separator ]]; then
- regex="(Instance|Class)"
+ if [[ ! $separator ]]; then
+ _regex="(Instance|Class)"
elif [[ $separator == "#" ]]; then
- regex=Instance
+ _regex=Instance
else
- regex=Class
+ _regex=Class
fi
- COMPREPLY+=(
- "$(ri "${classes[@]}" 2>/dev/null | ruby -ane \
- 'if /^'"$regex"' methods:/.../^------------------|^$/ and \
+ _comp_split -la _methods \
+ "$(ri ${classes[@]+"${classes[@]}"} 2>/dev/null | ruby -ane \
+ 'if /^'"$_regex"' methods:/.../^------------------|^$/ and \
/^ / then print $_.split(/, |,$/).grep(/^[^\[]*$/).join("\n"); \
- end' 2>/dev/null | sort -u)")
+ end' 2>/dev/null | sort -u)"
else
# older versions of ri didn't distinguish between class/module and
# instance methods
- COMPREPLY+=(
- "$(ruby -W0 $ri_path "${classes[@]}" 2>/dev/null | ruby -ane \
+ _comp_split -la _methods \
+ "$(ruby -W0 "$ri_path" ${classes[@]+"${classes[@]}"} 2>/dev/null | ruby -ane \
'if /^-/.../^-/ and ! /^-/ and ! /^ +(class|module): / then \
print $_.split(/, |,$| +/).grep(/^[^\[]*$/).join("\n"); \
- end' | sort -u)")
- fi
- COMPREPLY=($(compgen $prefix -W '${COMPREPLY[@]}' -- $method))
+ end' | sort -u)"
+ fi &&
+ _comp_compgen -- -P "$prefix" -W '"${_methods[@]}"'
}
# needs at least Ruby 1.8.0 in order to use -W0
-_ri()
+_comp_cmd_ri()
{
- local cur prev words cword split
- _init_completion -s -n : || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -n : -- "$@" || return
+ local noargopts='!(-*|*[wfd]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --width | -!(-*)[hw])
+ --help | --width | -${noargopts}[hw])
return
;;
- --format | -!(-*)f)
- COMPREPLY=($(compgen -W 'ansi bs html rdoc' -- "$cur"))
+ --format | -${noargopts}f)
+ _comp_compgen -- -W 'ansi bs html rdoc'
return
;;
- --doc-dir | -!(-*)d)
- _filedir -d
+ --doc-dir | -${noargopts}d)
+ _comp_compgen_filedir -d
return
;;
--dump)
- _filedir ri
+ _comp_compgen_filedir ri
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- local class method prefix ri_path ri_version ri_major separator IFS
+ local class method prefix="" ri_path ri_version ri_major="" separator
local -a classes
ri_path=$(type -p ri)
# which version of ri are we using?
# -W0 is required here to stop warnings from older versions of ri
# from being captured when used with Ruby 1.8.1 and later
- ri_version="$(ruby -W0 $ri_path -v 2>&1)" || ri_version=integrated
+ ri_version="$(ruby -W0 "$ri_path" -v 2>&1)" || ri_version=integrated
[[ $ri_version != "${ri_version%200*}" ]] && ri_version=integrated
[[ $ri_version =~ ri[[:space:]]v?([0-9]+) ]] && ri_major=${BASH_REMATCH[1]}
# need to also split on commas
- IFS=$', \n\t'
if [[ $cur == [A-Z]*[#.]* ]]; then
[[ $cur == *#* ]] && separator=# || separator=.
# we're completing on class and method
- class=${cur%$separator*}
- method=${cur#*$separator}
- classes=($class)
- prefix="-P $class$separator"
- _ri_get_methods
+ class=${cur%"$separator"*}
+ method=${cur#*"$separator"}
+ _comp_split -F $', \n\t' classes "$class"
+ prefix=$class$separator
+ _comp_compgen -c "$method" -i ri methods
return
fi
if [[ $ri_version == integrated ]]; then
# integrated ri from Ruby 1.9
- classes=($(ri -c 2>/dev/null | ruby -ne 'if /^\s*$/..$stdin.eof then \
- if /^ +[A-Z]/ then print; end; end' 2>/dev/null))
+ _comp_split -F $', \n\t' classes \
+ "$(ri -c 2>/dev/null | ruby -ne 'if /^\s*$/..$stdin.eof then \
+ if /^ +[A-Z]/ then print; end; end' 2>/dev/null)"
elif [[ $ri_major && $ri_major -ge 3 ]]; then
- classes=($(ri -l 2>/dev/null))
+ _comp_split -F $', \n\t' classes "$(ri -l 2>/dev/null)"
elif [[ $ri_version == "ri 1.8a" ]]; then
- classes=($(ruby -W0 $ri_path |
+ _comp_split -F $', \n\t' classes "$(ruby -W0 "$ri_path" |
ruby -ne 'if /^'"'"'ri'"'"' has/..$stdin.eof then \
- if /^ .*[A-Z]/ then print; end; end'))
+ if /^ .*[A-Z]/ then print; end; end')"
else
- classes=($(ruby -W0 $ri_path |
+ _comp_split -F $', \n\t' classes "$(ruby -W0 "$ri_path" |
ruby -ne 'if /^I have/..$stdin.eof then \
- if /^ .*[A-Z]/ then print; end; end'))
- fi
-
- COMPREPLY=($(compgen -W '${classes[@]}' -- "$cur"))
- __ltrim_colon_completions "$cur"
+ if /^ .*[A-Z]/ then print; end; end')"
+ fi &&
+ _comp_compgen -- -W '"${classes[@]}"'
+ _comp_ltrim_colon_completions "$cur"
if [[ $cur == [A-Z]* ]]; then
# we're completing on class or module alone
@@ -112,9 +118,8 @@ _ri()
fi
# we're completing on methods
- method=$cur
- _ri_get_methods
+ _comp_cmd_ri__compgen_methods
} &&
- complete -F _ri ri
+ complete -F _comp_cmd_ri ri
# ex: filetype=sh
diff --git a/completions/rmlist b/completions/rmlist
index 0cc473a..f3aca06 100644
--- a/completions/rmlist
+++ b/completions/rmlist
@@ -1,17 +1,20 @@
# mailman rmlist completion -*- shell-script -*-
-_rmlist()
+_comp_cmd_rmlist()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--archives --help' -- "$cur"))
+ _comp_compgen -- -W '--archives --help'
else
- _xfunc list_lists _mailman_lists
+ # Prefer `list_lists` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -x list_lists mailman_lists
fi
} &&
- complete -F _rmlist rmlist
+ complete -F _comp_cmd_rmlist rmlist
# ex: filetype=sh
diff --git a/completions/rmmod b/completions/rmmod
index 7ec29e6..a57a206 100644
--- a/completions/rmmod
+++ b/completions/rmmod
@@ -1,10 +1,10 @@
# Linux rmmod(8) completion. -*- shell-script -*-
# This completes on a list of all currently installed kernel modules.
-_rmmod()
+_comp_cmd_rmmod()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-h | --help | -V | --version)
@@ -13,12 +13,12 @@ _rmmod()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- _installed_modules "$cur"
+ _comp_compgen_inserted_kernel_modules
} &&
- complete -F _rmmod rmmod
+ complete -F _comp_cmd_rmmod rmmod
# ex: filetype=sh
diff --git a/completions/route b/completions/route
index f9b3196..3351415 100644
--- a/completions/route
+++ b/completions/route
@@ -2,13 +2,13 @@
[[ $OSTYPE == *linux* ]] || return 1
-_route()
+_comp_cmd_route()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $prev == dev ]]; then
- _available_interfaces
+ _comp_compgen_available_interfaces
return
fi
@@ -16,15 +16,16 @@ _route()
local opt found i
for opt in add del -host -net netmask metric mss window irtt reject mod \
dyn reinstate dev default gw; do
- found=false
- for ((i = 1; i < ${#words[@]} - 1; i++)); do
- [[ ${words[i]} == "$opt" ]] && found=true && break
+ found=""
+ for ((i = 1; i < cword; i++)); do
+ [[ ${words[i]} == "$opt" ]] && found=set && break
done
- $found || COMPREPLY+=("$opt")
+ [[ $found ]] || COMPREPLY+=("$opt")
done
- COMPREPLY=($(compgen -W '"${COMPREPLY[@]}"' -- "$cur"))
+ ((${#COMPREPLY[@]})) &&
+ _comp_compgen -- -W '"${COMPREPLY[@]}"'
} &&
- complete -F _route route
+ complete -F _comp_cmd_route route
# ex: filetype=sh
diff --git a/completions/rpcdebug b/completions/rpcdebug
index 6e2b88c..59778d9 100644
--- a/completions/rpcdebug
+++ b/completions/rpcdebug
@@ -1,46 +1,47 @@
# bash completion for rpcdebug -*- shell-script -*-
-_rpcdebug_flags()
+_comp_cmd_rpcdebug__flags()
{
local i module
for ((i = 1; i < ${#words[@]}; i++)); do
if [[ ${words[i]} == -m ]]; then
- module=${words[i + 1]}
+ module=${words[i + 1]-}
break
fi
done
- if [[ -n $module ]]; then
- COMPREPLY=($(compgen -W "$(rpcdebug -vh 2>&1 |
- command sed -ne 's/^'$module'[[:space:]]\{1,\}//p')" -- "$cur"))
+ if [[ $module ]]; then
+ _comp_compgen_split -- "$(rpcdebug -vh 2>&1 |
+ command sed -ne 's/^'"$module"'[[:space:]]\{1,\}//p')"
fi
}
-_rpcdebug()
+_comp_cmd_rpcdebug()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*s)
- _rpcdebug_flags
+ _comp_cmd_rpcdebug__flags
return
;;
-*c)
- _rpcdebug_flags
+ _comp_cmd_rpcdebug__flags
return
;;
-*m)
- COMPREPLY=($(compgen -W 'rpc nfs nfsd nlm' -- "$cur"))
+ _comp_compgen -- -W 'rpc nfs nfsd nlm'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" -h) -s -c' -- "$cur"))
+ _comp_compgen_usage -- -h
+ _comp_compgen -a -- -W '-s -c'
fi
} &&
- complete -F _rpcdebug rpcdebug
+ complete -F _comp_cmd_rpcdebug rpcdebug
# ex: filetype=sh
diff --git a/completions/rpm b/completions/rpm
index 8299a37..b6cafa5 100644
--- a/completions/rpm
+++ b/completions/rpm
@@ -2,99 +2,114 @@
# helper functions
-_rpm_installed_packages()
+# @since 2.12
+_comp_xfunc_rpm_compgen_installed_packages()
{
- if [[ -r /var/log/rpmpkgs && \
+ _comp_cmd_rpm__compgen_installed_packages rpm
+}
+
+_comp_cmd_rpm__compgen_installed_packages()
+{
+ if [[ -r /var/log/rpmpkgs &&
/var/log/rpmpkgs -nt /var/lib/rpm/Packages ]]; then
# using RHL 7.2 or later - this is quicker than querying the DB
- COMPREPLY=($(compgen -W "$(command sed -ne \
+ _comp_compgen_split -- "$(command sed -ne \
's|^\([^[:space:]]\{1,\}\)-[^[:space:]-]\{1,\}-[^[:space:]-]\{1,\}\.rpm$|\1|p' \
- /var/log/rpmpkgs)" -- "$cur"))
+ /var/log/rpmpkgs)"
elif type rpmqpack &>/dev/null; then
# SUSE's rpmqpack is faster than rpm -qa
- COMPREPLY=($(compgen -W '$(rpmqpack)' -- "$cur"))
+ _comp_compgen_split -- "$(rpmqpack)"
else
- COMPREPLY=($(${1:-rpm} -qa --nodigest --nosignature \
- --queryformat='%{NAME} ' "$cur*" 2>/dev/null))
+ _comp_compgen_split -- "$("${1:-rpm}" -qa --nodigest --nosignature \
+ --queryformat='%{NAME} ' "$cur*" 2>/dev/null)"
fi
}
-_rpm_groups()
+_comp_deprecate_func 2.12 _rpm_installed_packages \
+ _comp_xfunc_rpm_compgen_installed_packages
+
+_comp_cmd_rpm__groups()
{
- local IFS=$'\n'
- COMPREPLY=($(compgen -W "$(${1:-rpm} -qa --nodigest --nosignature \
- --queryformat='%{GROUP}\n' 2>/dev/null)" -- "$cur"))
+ _comp_compgen_split -l -- "$("${1:-rpm}" -qa --nodigest --nosignature \
+ --queryformat='%{GROUP}\n' 2>/dev/null)"
}
-_rpm_macros()
+_comp_cmd_rpm__macros()
{
# get a list of macros
- COMPREPLY=($(compgen -W "$(${1:-rpm} --showrc | command sed -ne \
- 's/^-\{0,1\}[0-9]\{1,\}[:=][[:space:]]\{1,\}\([^[:space:](]\{3,\}\).*/%\1/p')" \
- -- "$cur"))
+ _comp_compgen_split -- "$("${1:-rpm}" --showrc | command sed -ne \
+ 's/^-\{0,1\}[0-9]\{1,\}[:=][[:space:]]\{1,\}\([^[:space:](]\{3,\}\).*/%\1/p')"
}
-_rpm_buildarchs()
+# shellcheck disable=SC2120
+_comp_cmd_rpm__buildarchs()
{
- COMPREPLY=($(compgen -W "$(${1:-rpm} --showrc | command sed -ne \
- 's/^\s*compatible\s\s*build\s\s*archs\s*:\s*\(.*\)/\1/ p')" \
- -- "$cur"))
+ # Case-insensitive BRE to match "compatible build archs"
+ local regex_header='[cC][oO][mM][pP][aA][tT][iI][bB][lL][eE][[:space:]]\{1,\}[bB][uU][iI][lL][dD][[:space:]]\{1,\}[aA][rR][cC][hH][sS]'
+ _comp_compgen_split -- "$("${1:-rpm}" --showrc | command sed -ne \
+ "s/^[[:space:]]*${regex_header}[[:space:]]*:[[:space:]]*\(.*\)/\1/p")"
+}
+
+# shellcheck disable=SC2120
+_comp_cmd_rpm__configdir()
+{
+ cfgdir=$("${1:-rpm}" --eval '%{_rpmconfigdir}' 2>/dev/null)
}
# rpm(8) completion
#
-_rpm()
+_comp_cmd_rpm()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
if ((cword == 1)); then
# first parameter on line
case $cur in
--*)
- COMPREPLY=($(compgen -W '--help --version --initdb
- --checksig --addsign --delsign --rebuilddb --showrc
- --setperms --setugids --eval --install --upgrade --query
- --freshen --erase --verify --querytags --import' \
- -- "$cur"))
+ _comp_compgen -- -W '--help --version --initdb --checksig
+ --addsign --delsign --rebuilddb --showrc --setperms
+ --setugids --eval --install --upgrade --query --freshen
+ --erase --verify --querytags --import'
;;
*)
- COMPREPLY=($(compgen -W '-e -E -F -i -q -t -U -V' -- "$cur"))
+ _comp_compgen -- -W '-e -E -F -i -q -t -U -V'
;;
esac
return
fi
+ local noargopts='!(-*|*[rED]*)'
+ # shellcheck disable=SC2254
case $prev in
- --dbpath | --excludepath | --prefix | --relocate | --root | -!(-*)r)
- _filedir -d
+ --dbpath | --excludepath | --prefix | --relocate | --root | -${noargopts}r)
+ _comp_compgen_filedir -d
return
;;
- --eval | -!(-*)E)
- _rpm_macros $1
+ --eval | -${noargopts}E)
+ _comp_cmd_rpm__macros "$1"
return
;;
--pipe)
- compopt -o filenames
- COMPREPLY=($(compgen -c -- "$cur"))
+ _comp_compgen_commands
return
;;
--rcfile)
- _filedir
+ _comp_compgen_filedir
return
;;
--specfile)
# complete on .spec files
- _filedir spec
+ _comp_compgen_filedir spec
return
;;
--whatenhances | --whatprovides | --whatrecommends | --whatrequires | \
--whatsuggests | --whatsupplements)
- if [[ $cur == */* ]]; then
- _filedir
+ if _comp_looks_like_path "$cur"; then
+ _comp_compgen_filedir
else
# complete on capabilities
- local IFS=$'\n' fmt
+ local fmt
case $prev in
*enhances) fmt="%{ENHANCENAME}" ;;
*provides) fmt="%{PROVIDENAME}" ;;
@@ -103,176 +118,181 @@ _rpm()
*suggests) fmt="%{SUGGESTNAME}" ;;
*supplements) fmt="%{SUPPLEMENTNAME}" ;;
esac
- COMPREPLY=($(compgen -W "$($1 -qa --nodigest --nosignature \
- --queryformat=\"$fmt\\n\" 2>/dev/null |
- command grep -vF '(none)')" -- "$cur"))
+ _comp_compgen_split -l -- "$("$1" -qa --nodigest \
+ --nosignature --queryformat="\"$fmt\\n\"" 2>/dev/null |
+ command grep -vF '(none)')"
fi
return
;;
- --define | --fileid | --hdrid | --pkgid | -!(-*)D)
+ --define | --fileid | --hdrid | --pkgid | -${noargopts}D)
# argument required but no completions available
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
# options common to all modes
- local opts="--define= --eval= --macros= --nodigest --nosignature --rcfile=
- --quiet --pipe --verbose"
+ local -a opts=(
+ --define= --eval= --macros= --nodigest --nosignature --rcfile= --quiet
+ --pipe --verbose
+ )
case ${words[1]} in
-[iFU]* | --install | --freshen | --upgrade)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W "$opts --percent --force --test
- --replacepkgs --replacefiles --root --excludedocs --includedocs
- --noscripts --ignorearch --dbpath --prefix= --ignoreos --nodeps
- --allfiles --ftpproxy --ftpport --justdb --httpproxy --httpport
- --noorder --relocate= --badreloc --notriggers --excludepath=
- --ignoresize --oldpackage --queryformat --repackage
- --nosuggests" -- "$cur"))
+ _comp_compgen -- -W '"${opts[@]}" --percent --force --test
+ --replacepkgs --replacefiles --root --excludedocs
+ --includedocs --noscripts --ignorearch --dbpath --prefix=
+ --ignoreos --nodeps --allfiles --ftpproxy --ftpport
+ --justdb --httpproxy --httpport --noorder --relocate=
+ --badreloc --notriggers --excludepath= --ignoresize
+ --oldpackage --queryformat --repackage --nosuggests'
else
- _filedir '[rs]pm'
+ _comp_compgen_filedir '[rs]pm'
fi
;;
-e | --erase)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W "$opts --allmatches --noscripts
- --notriggers --nodeps --test --repackage" -- "$cur"))
+ _comp_compgen -- -W '"${opts[@]}" --allmatches --noscripts
+ --notriggers --nodeps --test --repackage'
else
- _rpm_installed_packages $1
+ _comp_cmd_rpm__compgen_installed_packages "$1"
fi
;;
-q* | --query)
# options common to all query types
- opts+=" --changelog --configfiles --conflicts --docfiles --dump
+ opts+=(
+ --changelog --configfiles --conflicts --docfiles --dump
--enhances --filesbypkg --filecaps --fileclass --filecolor
--fileprovide --filerequire --filesbypkg --info --list
--obsoletes --pipe --provides --queryformat= --requires
--scripts --suggests --triggers --xml --recommends
- --supplements --filetriggers --licensefiles"
+ --supplements --filetriggers --licensefiles
+ )
if [[ ${words[*]} == *\ -@(*([^ -])f|-file )* ]]; then
# -qf completion
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W "$opts --dbpath --fscontext
- --last --root --state" -- "$cur"))
+ _comp_compgen -- -W '"${opts[@]}" --dbpath --fscontext
+ --last --root --state'
else
- _filedir
+ _comp_compgen_filedir
fi
elif [[ ${words[*]} == *\ -@(*([^ -])g|-group )* ]]; then
# -qg completion
- _rpm_groups $1
+ _comp_cmd_rpm__groups "$1"
elif [[ ${words[*]} == *\ -@(*([^ -])p|-package )* ]]; then
# -qp; uninstalled package completion
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W "$opts --ftpport --ftpproxy
- --httpport --httpproxy --nomanifest" -- "$cur"))
+ _comp_compgen -- -W '"${opts[@]}" --ftpport --ftpproxy
+ --httpport --httpproxy --nomanifest'
else
- _filedir '[rs]pm'
+ _comp_compgen_filedir '[rs]pm'
fi
else
# -q; installed package completion
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W "$opts --all --file --fileid
+ _comp_compgen -- -W '"${opts[@]}" --all --file --fileid
--dbpath --fscontext --ftswalk --group --hdrid --last
--package --pkgid --root= --specfile --state
--triggeredby --whatenhances --whatprovides
--whatrecommends --whatrequires --whatsuggests
- --whatsupplements" \
- -- "$cur"))
+ --whatsupplements'
elif [[ ${words[*]} != *\ -@(*([^ -])a|-all )* ]]; then
- _rpm_installed_packages $1
+ _comp_cmd_rpm__compgen_installed_packages "$1"
fi
fi
;;
-K* | --checksig)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W "$opts --nopgp --nogpg --nomd5" \
- -- "$cur"))
+ _comp_compgen -- -W '"${opts[@]}" --nopgp --nogpg --nomd5'
else
- _filedir '[rs]pm'
+ _comp_compgen_filedir '[rs]pm'
fi
;;
-[Vy]* | --verify)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W "$opts --root= --dbpath --nodeps
+ _comp_compgen -- -W '"${opts[@]}" --root= --dbpath --nodeps
--nogroup --nolinkto --nomode --nomtime --nordev --nouser
--nofiles --noscripts --nomd5 --querytags --specfile
--whatenhances --whatprovides --whatrecommends
- --whatrequires --whatsuggests --whatsupplements" \
- -- "$cur"))
+ --whatrequires --whatsuggests --whatsupplements'
# check whether we're doing file completion
elif [[ ${words[*]} == *\ -@(*([^ -])f|-file )* ]]; then
- _filedir
+ _comp_compgen_filedir
elif [[ ${words[*]} == *\ -@(*([^ -])g|-group )* ]]; then
- _rpm_groups $1
+ _comp_cmd_rpm__groups "$1"
elif [[ ${words[*]} == *\ -@(*([^ -])p|-package )* ]]; then
- _filedir '[rs]pm'
+ _comp_compgen_filedir '[rs]pm'
else
- _rpm_installed_packages $1
+ _comp_cmd_rpm__compgen_installed_packages "$1"
fi
;;
--resign | --addsign | --delsign)
- _filedir '[rs]pm'
+ _comp_compgen_filedir '[rs]pm'
;;
--setperms | --setgids)
- _rpm_installed_packages $1
+ _comp_cmd_rpm__compgen_installed_packages "$1"
;;
--import | --dbpath | --root)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--import --dbpath --root=' \
- -- "$cur"))
+ _comp_compgen -- -W '--import --dbpath --root='
else
- _filedir
+ _comp_compgen_filedir
fi
;;
esac
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
} &&
- complete -F _rpm rpm
+ complete -F _comp_cmd_rpm rpm
-_rpmbuild()
+_comp_cmd_rpmbuild()
{
- local cur prev words cword split
- _init_completion -s || return
-
- local rpm="${1%build*}"
- [[ $rpm == "$1" ]] || ! type $rpm &>/dev/null && rpm=
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[rED]*)'
+ # shellcheck disable=SC2119,SC2254
case $prev in
- --buildroot | --root | --dbpath | -!(-*)r)
- _filedir -d
+ --buildroot | --root | --dbpath | -${noargopts}r)
+ _comp_compgen_filedir -d
return
;;
+ --target | --eval | -${noargopts}E | --buildpolicy)
+ # Prefer `rpm` in the same dir in utility functions
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ ;;&
--target)
- _rpm_buildarchs $rpm
+ _comp_cmd_rpm__buildarchs
return
;;
- --eval | -!(-*)E)
- _rpm_macros $rpm
+ --eval | -${noargopts}E)
+ _comp_cmd_rpm__macros
return
;;
--macros | --rcfile)
- _filedir
+ _comp_compgen_filedir
return
;;
--buildpolicy)
- local cfgdir=$($rpm --eval '%{_rpmconfigdir}' 2>/dev/null)
+ local cfgdir
+ _comp_cmd_rpm__configdir
if [[ $cfgdir ]]; then
- COMPREPLY=($(compgen -W "$(command ls $cfgdir 2>/dev/null |
- command sed -ne 's/^brp-//p')" -- "$cur"))
+ _comp_compgen_split -- "$(command ls "$cfgdir" 2>/dev/null |
+ command sed -ne 's/^brp-//p')"
fi
;;
- --define | --with | --without | -!(-*)D)
+ --define | --with | --without | -${noargopts}D)
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W "$(_parse_help "$1")" -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
@@ -295,8 +315,8 @@ _rpmbuild()
;;
esac
done
- [[ -n $ext ]] && _filedir $ext
+ [[ $ext ]] && _comp_compgen_filedir "$ext"
} &&
- complete -F _rpmbuild rpmbuild rpmbuild-md5
+ complete -F _comp_cmd_rpmbuild rpmbuild rpmbuild-md5
# ex: filetype=sh
diff --git a/completions/rpm2tgz b/completions/rpm2tgz
index 5ddcfd5..552a3a1 100644
--- a/completions/rpm2tgz
+++ b/completions/rpm2tgz
@@ -1,17 +1,17 @@
# Slackware rpm2tgz completion -*- shell-script -*-
-_rpm2tgz()
+_comp_cmd_rpm2tgz()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-s -S -n -r -d -c' -- "$cur"))
+ _comp_compgen -- -W '-s -S -n -r -d -c'
return
fi
- _filedir "rpm"
+ _comp_compgen_filedir "rpm"
} &&
- complete -F _rpm2tgz rpm2tgz rpm2txz rpm2targz
+ complete -F _comp_cmd_rpm2tgz rpm2tgz rpm2txz rpm2targz
# ex: filetype=sh
diff --git a/completions/rpmcheck b/completions/rpmcheck
index cf4ed95..d7d0348 100644
--- a/completions/rpmcheck
+++ b/completions/rpmcheck
@@ -1,24 +1,24 @@
# bash completion for rpmcheck -*- shell-script -*-
-_rpmcheck()
+_comp_cmd_rpmcheck()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-base)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-explain -failures -successes -dump
- -dump-all -base -help -compressed-input' -- "$cur"))
+ _comp_compgen -- -W '-explain -failures -successes -dump -dump-all
+ -base -help -compressed-input'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _rpmcheck rpmcheck
+ complete -F _comp_cmd_rpmcheck rpmcheck
# ex: filetype=sh
diff --git a/completions/rrdtool b/completions/rrdtool
index dcb9ce6..8f85687 100644
--- a/completions/rrdtool
+++ b/completions/rrdtool
@@ -1,17 +1,17 @@
# bash completion for rrdtool -*- shell-script -*-
-_rrdtool()
+_comp_cmd_rrdtool()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if ((${#words[@]} == 2)); then
- COMPREPLY=($(compgen -W 'create update updatev graph dump restore
- last lastupdate first info fetch tune resize xport' -- "$cur"))
+ _comp_compgen -- -W 'create update updatev graph dump restore last
+ lastupdate first info fetch tune resize xport'
else
- _filedir rrd
+ _comp_compgen_filedir rrd
fi
} &&
- complete -F _rrdtool rrdtool
+ complete -F _comp_cmd_rrdtool rrdtool
# ex: filetype=sh
diff --git a/completions/rsync b/completions/rsync
index 0bf5389..f471b46 100644
--- a/completions/rsync
+++ b/completions/rsync
@@ -1,67 +1,75 @@
# bash completion for rsync -*- shell-script -*-
-_rsync()
+_comp_cmd_rsync()
{
- local cur prev words cword split
- _init_completion -s -n : || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -n : -- "$@" || return
+ local noargopts='!(-*|*[Te]*)'
+ # shellcheck disable=SC2254
case $prev in
- --config | --password-file | --include-from | --exclude-from | --files-from | \
- --log-file | --write-batch | --only-write-batch | --read-batch)
+ --config | --password-file | --include-from | --exclude-from | \
+ --files-from | --log-file | --write-batch | --only-write-batch | \
+ --read-batch)
compopt +o nospace
- _filedir
+ _comp_compgen_filedir
return
;;
- --temp-dir | --compare-dest | --backup-dir | --partial-dir | --copy-dest | \
- --link-dest | -!(-*)T)
+ --temp-dir | --compare-dest | --backup-dir | --partial-dir | \
+ --copy-dest | --link-dest | -${noargopts}T)
compopt +o nospace
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
- --rsh | -!(-*)e)
+ --rsh | -${noargopts}e)
compopt +o nospace
- COMPREPLY=($(compgen -W 'rsh ssh' -- "$cur"))
+ _comp_compgen -- -W 'rsh ssh'
return
;;
--compress-level)
compopt +o nospace
- COMPREPLY=($(compgen -W '{1..9}' -- "$cur"))
+ _comp_compgen -- -W '{1..9}'
+ return
+ ;;
+ --info)
+ _comp_delimited , -W '
+ backup{,0}
+ copy{,0}
+ del{,0}
+ flist{,0,1,2}
+ misc{,0,1,2}
+ mount{,0}
+ name{,0,1,2}
+ nonreg{,0,1}
+ progress{,0,1,2}
+ remove{,0}
+ skip{,0,1,2}
+ stats{,0,1,2,3}
+ symsafe{,0}
+ all{,0,1,2,3,4}
+ none
+ help
+ '
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
- _expand || return
+ _comp_expand || return
case $cur in
-*)
- COMPREPLY=($(compgen -W '--verbose --quiet --no-motd --checksum
- --archive --recursive --relative --no-implied-dirs
- --backup --backup-dir= --suffix= --update --inplace --append
- --append-verify --dirs --old-dirs --links --copy-links
- --copy-unsafe-links --safe-links --copy-dirlinks
- --keep-dirlinks --hard-links --perms --executability --chmod=
- --acls --xattrs --owner --group --devices --copy-devices
- --specials --times --omit-dir-times --super --fake-super
- --sparse --dry-run --whole-file --no-whole-file
- --one-file-system --block-size= --rsh= --rsync-path=
- --existing --ignore-existing --remove-source-files --delete
- --delete-before --delete-during --delete-delay --delete-after
- --delete-excluded --ignore-errors --force --max-delete=
- --max-size= --min-size= --partial --partial-dir=
- --delay-updates --prune-empty-dirs --numeric-ids --timeout=
- --contimeout= --ignore-times --size-only --modify-window=
- --temp-dir= --fuzzy --compare-dest= --copy-dest= --link-dest=
- --compress --compress-level= --skip-compress= --cvs-exclude
- --filter= --exclude= --exclude-from= --include= --include-from=
- --files-from= --from0 --protect-args --address= --port=
- --sockopts= --blocking-io --no-blocking-io --stats
- --8-bit-output --human-readable --progress --itemize-changes
- --out-format= --log-file= --log-file-format= --password-file=
- --list-only --bwlimit= --write-batch= --only-write-batch=
- --read-batch= --protocol= --iconv= --ipv4 --ipv6 --version
- --help --daemon --config= --no-detach' -- "$cur"))
+ local tmp
+ # Account for the fact that older rsync versions (before cba00be6,
+ # meaning before v3.2.0) contain the following unusual line in
+ # --help:
+ # "(-h) --help show this help (-h is --help only if used alone)"
+ _comp_compgen -Rv tmp help - <<<"$("$1" --help 2>&1 | command sed -e 's/^([^)]*)//')"
+
+ _comp_compgen -- -W '"${tmp[@]}"
+ --daemon --old-d{,irs}
+ --no-{blocking-io,detach,whole-file,inc-recursive,i-r}' -X '--no-OPTION'
[[ ${COMPREPLY-} == *= ]] || compopt +o nospace
;;
*:*)
@@ -73,14 +81,14 @@ _rsync()
break
fi
done
- [[ $shell == ssh ]] && _xfunc ssh _scp_remote_files
+ [[ $shell == ssh ]] && _comp_compgen -x scp remote_files
;;
*)
- _known_hosts_real -c -a -- "$cur"
- _xfunc ssh _scp_local_files
+ _comp_compgen_known_hosts -c -a -- "$cur"
+ _comp_compgen -ax scp local_files
;;
esac
} &&
- complete -F _rsync -o nospace rsync
+ complete -F _comp_cmd_rsync -o nospace rsync
# ex: filetype=sh
diff --git a/completions/sbcl b/completions/sbcl
index 22a93e4..f74f841 100644
--- a/completions/sbcl
+++ b/completions/sbcl
@@ -2,20 +2,20 @@
# bash programmable completion for various Common Lisp implementations by
# Nikodemus Siivola <nikodemus@random-state.net>
-_sbcl()
+_comp_cmd_sbcl()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
# completing an option (may or may not be separated by a space)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--core --noinform --help --version
- --sysinit --userinit --eval --noprint --disable-debugger
- --end-runtime-options --end-toplevel-options ' -- "$cur"))
+ _comp_compgen -- -W '--core --noinform --help --version --sysinit
+ --userinit --eval --noprint --disable-debugger
+ --end-runtime-options --end-toplevel-options'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _sbcl sbcl sbcl-mt
+ complete -F _comp_cmd_sbcl sbcl sbcl-mt
# ex: filetype=sh
diff --git a/completions/sbopkg b/completions/sbopkg
index 16bd58f..a2fc5a6 100644
--- a/completions/sbopkg
+++ b/completions/sbopkg
@@ -1,31 +1,30 @@
# bash completion for sbopkg(8) -*- shell-script -*-
-_sbopkg()
+_comp_cmd_sbopkg()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ _comp_compgen_help -- -h
[[ ${COMPREPLY-} ]] && return
fi
case "$prev" in
-e)
- COMPREPLY=($(compgen -W 'ask continue stop' -- "$cur"))
+ _comp_compgen -- -W 'ask continue stop'
return
;;
-f)
- _filedir
+ _comp_compgen_filedir
return
;;
-d)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-V)
- COMPREPLY=($(compgen -W "?
- $(sbopkg -V '?' 2>&1 | cut -s -f1)" -- "$cur"))
+ _comp_compgen_split -- "? $(sbopkg -V '?' 2>&1 | cut -s -f1)"
return
;;
-i | -b) ;;
@@ -35,20 +34,20 @@ _sbopkg()
;;
esac
- local i config
+ local i REPLY config
config="/etc/sbopkg/sbopkg.conf"
- for ((i = ${#words[@]} - 1; i > 0; i--)); do
+ for ((i = ${#words[@]} - 2; i > 0; i--)); do
if [[ ${words[i]} == -f ]]; then
- config="${words[i + 1]}"
- __expand_tilde_by_ref config
+ _comp_expand_tilde "${words[i + 1]}"
+ config=$REPLY
break
fi
done
- [[ -r $config ]] || return
- . $config
+ [[ -f $config && -r $config ]] || return
+ . "$config"
- for ((i = 1; i < ${#words[@]}; i++)); do
+ for ((i = 1; i < ${#words[@]} - 1; i++)); do
case "${words[i]}" in
-V)
REPO_NAME="${words[i + 1]%%/*}"
@@ -59,15 +58,13 @@ _sbopkg()
;;
esac
done
- [[ -r $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT ]] || return
+ local file=${REPO_ROOT-}/${REPO_NAME-}/${REPO_BRANCH-}/SLACKBUILDS.TXT
+ [[ -f $file && -r $file ]] || return
- COMPREPLY=($(command sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}" \
- $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT)
- $(
- cd $QUEUEDIR
- compgen -f -X "!*.sqf" -- "$cur"
- ))
+ _comp_compgen_split -l -- "$(command sed -ne "s/^SLACKBUILD NAME: //p" \
+ "$file")"
+ _comp_compgen -aC "$QUEUEDIR" -- -f -X "!*.sqf"
} &&
- complete -F _sbopkg sbopkg
+ complete -F _comp_cmd_sbopkg sbopkg
# ex: filetype=sh
diff --git a/completions/screen b/completions/screen
index 651ca2c..ab4b7dd 100644
--- a/completions/screen
+++ b/completions/screen
@@ -1,12 +1,13 @@
# bash completion for screen -*- shell-script -*-
-_screen_sessions()
+_comp_cmd_screen__sessions()
{
- local sessions=($(command screen -ls | command sed -ne \
- 's|^\t\{1,\}\([0-9]\{1,\}\.[^\t]\{1,\}\).*'"$1"'.*$|\1|p'))
+ local -a sessions
+ _comp_split sessions "$(command screen -ls | command sed -ne \
+ 's|^\t\{1,\}\([0-9]\{1,\}\.[^\t]\{1,\}\).*'"$1"'.*$|\1|p')" || return
if [[ $cur == +([0-9])?(.*) ]]; then
# Complete sessions including pid prefixes
- COMPREPLY=($(compgen -W '${sessions[@]}' -- "$cur"))
+ _comp_compgen -- -W '"${sessions[@]}"'
else
# Create unique completions, dropping pids where possible
local -A res
@@ -17,26 +18,22 @@ _screen_sessions()
for i in "${!res[@]}"; do
[[ ${res[i]} == \ *\ * ]] && tmp+=" ${res[i]}" || tmp+=" $i"
done
- COMPREPLY=($(compgen -W '$tmp' -- "$cur"))
+ _comp_compgen -- -W '$tmp'
fi
} &&
- _screen()
+ _comp_cmd_screen()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if ((cword == 1)); then
if [[ $cur == /dev* ]]; then
- COMPREPLY=($(compgen -W "$(
- shopt -s nullglob
- printf '%s\n' \
- /dev/serial/by-id/* /dev/ttyUSB* /dev/ttyACM* 2>/dev/null
- )" \
- -- "$cur"))
+ _comp_expand_glob COMPREPLY '/dev/serial/*/* /dev/ttyUSB* /dev/ttyACM*' &&
+ _comp_compgen -- -W '"${COMPREPLY[@]}"'
return
fi
if [[ $cur == //* ]]; then
- COMPREPLY=($(compgen -W '//telnet' -- "$cur"))
+ _comp_compgen -- -W '//telnet'
return
fi
fi
@@ -44,14 +41,14 @@ _screen_sessions()
case ${words[1]} in
/dev*)
if ((cword == 2)); then
- COMPREPLY=($(compgen -W '110 300 600 1200 2400 4800 9600 \
- 14400 19200 38400 57600 115200 128000 256000' -- "$cur"))
+ _comp_compgen -- -W '110 300 600 1200 2400 4800 9600 14400
+ 19200 38400 57600 115200 128000 256000'
# TODO more, comma separated options
fi
return
;;
//telnet)
- ((cword == 2)) && _known_hosts_real -- "$cur"
+ ((cword == 2)) && _comp_compgen_known_hosts -- "$cur"
return
;;
esac
@@ -59,7 +56,7 @@ _screen_sessions()
if ((cword > 2)); then
case ${words[cword - 2]} in
-*[dD])
- _screen_sessions
+ _comp_cmd_screen__sessions
return
;;
esac
@@ -77,36 +74,36 @@ _screen_sessions()
;;
esac
- _command_offset $i
+ _comp_command_offset $i
return
done
case $prev in
-*[rR])
# list detached
- _screen_sessions 'Detached'
+ _comp_cmd_screen__sessions 'Detached'
return
;;
-*[dD])
# list attached
- _screen_sessions 'Attached'
+ _comp_cmd_screen__sessions 'Attached'
return
;;
-*x)
# list both
- _screen_sessions
+ _comp_cmd_screen__sessions
return
;;
-*s)
- _shells
+ _comp_compgen_shells
return
;;
-*c)
- _filedir
+ _comp_compgen_filedir
return
;;
-T)
- _terms
+ _comp_compgen_terms
return
;;
-*[ehpSt])
@@ -115,9 +112,9 @@ _screen_sessions()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
fi
} &&
- complete -F _screen screen
+ complete -F _comp_cmd_screen screen
# ex: filetype=sh
diff --git a/completions/scrub b/completions/scrub
index bbb37be..f989211 100644
--- a/completions/scrub
+++ b/completions/scrub
@@ -1,36 +1,38 @@
# scrub(1) completion -*- shell-script -*-
-_scrub()
+_comp_cmd_scrub()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[bsDpX]*)'
+ # shellcheck disable=SC2254
case $prev in
- --version | --help | --blocksize | --device-size | --dirent | -!(-*)[vhbsD])
+ --version | --help | --blocksize | --device-size | --dirent | \
+ -${noargopts}[vhbsD])
return
;;
- --pattern | -!(-*)p)
- COMPREPLY=($(compgen -W '$("$1" --help 2>&1 |
- awk "/^Available/{flag=1;next}/^ /&&flag{print \$1}")' \
- -- "$cur"))
+ --pattern | -${noargopts}p)
+ _comp_compgen_split -- "$("$1" --help 2>&1 |
+ _comp_awk '/^Available/{flag=1;next}/^ /&&flag{print $1}')"
return
;;
- --freespace | -!(-*)X)
- _filedir -d
+ --freespace | -${noargopts}X)
+ _comp_compgen_filedir -d
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _scrub scrub
+ complete -F _comp_cmd_scrub scrub
# ex: filetype=sh
diff --git a/completions/secret-tool b/completions/secret-tool
index 5462fc0..e8aafd8 100644
--- a/completions/secret-tool
+++ b/completions/secret-tool
@@ -1,50 +1,50 @@
# bash completion for secret-tool(1) -*- shell-script -*-
-_secret_tool()
+_comp_cmd_secret_tool()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
- $split && return
+ [[ $was_split ]] && return
local -i i
- local mode word
+ local mode="" has_mode="" word
for i in ${!words[*]}; do
if [[ $i -gt 0 && ${words[i]} != -* ]]; then
- ((i != cword)) && mode=${words[i]}
+ ((i != cword)) && mode=${words[i]} has_mode=set
break
fi
done
- if [[ ! -v mode ]]; then
- local -a modes
- modes=($("$1" nonexistent-mode 2>&1 |
+ if [[ ! $has_mode ]]; then
+ # generate modes
+ _comp_compgen_split -- "$("$1" nonexistent-mode 2>&1 |
while read -r first second third rest; do
if [[ $first == "${1##*/}" ]]; then
printf "%s\n" "$second"
elif [[ $first == usage: && $second == "${1##*/}" ]]; then
printf "%s\n" "$third"
fi
- done))
- COMPREPLY=($(compgen -W '${modes[@]}' -- "$cur"))
+ done)"
return
fi
case $mode in
store)
if [[ ${words[*]} != *\ --label[\ =]* ]]; then
- COMPREPLY=($(compgen -W "--label=" -- "$cur"))
+ _comp_compgen -- -W "--label="
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
;;
search)
local -A opts=([--all]="" [--unlock]="")
for word in "${words[@]:2}"; do
- [[ $word ]] && unset opts["$word"]
+ [[ $word ]] && unset -v 'opts[$word]'
done
- COMPREPLY=($(compgen -W '${opts[@]}' -- "$cur"))
+ ((${#opts[@]})) &&
+ _comp_compgen -- -W '"${!opts[@]}"'
;;
esac
} &&
- complete -F _secret_tool secret-tool
+ complete -F _comp_cmd_secret_tool secret-tool
# ex: filetype=sh
diff --git a/completions/sh b/completions/sh
index 5624ffa..5581bcc 100644
--- a/completions/sh
+++ b/completions/sh
@@ -1,36 +1,35 @@
# POSIX sh(1) completion -*- shell-script -*-
-_sh()
+_comp_cmd_sh()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-c)
return
;;
-o | +o)
- COMPREPLY=($(compgen -W 'allexport errexit ignoreeof monitor
- noclobber noglob noexec nolog notify nounset verbose vi
- xtrace' -- "$cur"))
+ _comp_compgen -- -W 'allexport errexit ignoreeof monitor noclobber
+ noglob noexec nolog notify nounset verbose vi xtrace'
return
;;
esac
local opts="-a -b -C -e -f -h -i -m -n -o -u -v -x"
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W "$opts -c -s" -- "$cur"))
+ _comp_compgen -- -W "$opts -c -s"
return
elif [[ $cur == +* ]]; then
- COMPREPLY=($(compgen -W "${opts//-/+}" -- "$cur"))
+ _comp_compgen -- -W "${opts//-/+}"
return
fi
- local args ext=
- _count_args "" "@(-c|[-+]o)"
- ((args == 1)) && ext="sh"
- _filedir $ext
+ local REPLY ext=
+ _comp_count_args -a "@(-c|[-+]o)"
+ ((REPLY == 1)) && ext="sh"
+ _comp_compgen_filedir $ext
} &&
- complete -F _sh sh
+ complete -F _comp_cmd_sh sh
# ex: filetype=sh
diff --git a/completions/sha256sum b/completions/sha256sum
new file mode 100644
index 0000000..adef1cd
--- /dev/null
+++ b/completions/sha256sum
@@ -0,0 +1,38 @@
+# bash completion for sha256(1) and friends -*- shell-script -*-
+
+_comp_cmd_sha256sum()
+{
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+
+ case $prev in
+ -h | --help | --version)
+ return
+ ;;
+ esac
+
+ [[ $was_split ]] && return
+
+ if [[ $cur == -* ]]; then
+ _comp_complete_longopt "$@"
+ return
+ fi
+
+ local sumtype=${1##*/}
+ sumtype=${sumtype%sum}
+
+ local opt
+ for opt in "${words[@]}"; do
+ if [[ $opt == -@(c|-check) ]]; then
+ _comp_compgen_filedir "$sumtype"
+ return
+ fi
+ done
+
+ local files
+ _comp_compgen -v files filedir &&
+ _comp_compgen -- -X "*.$sumtype" -W '"${files[@]}"'
+} &&
+ complete -F _comp_cmd_sha256sum b2sum md5sum sha{,1,224,256,384,512}sum
+
+# ex: filetype=sh
diff --git a/completions/shellcheck b/completions/shellcheck
index 6421d7b..dc14c07 100644
--- a/completions/shellcheck
+++ b/completions/shellcheck
@@ -1,63 +1,65 @@
# bash completion for shellcheck(1) -*- shell-script -*-
-_shellcheck_optarg()
+_comp_cmd_shellcheck__optarg()
{
local args=$("$1" --help 2>&1 |
- command sed -e 's/,/ /g' -ne 's/^.*'$2'\>.*(\([^)]*\)).*/\1/p')
- COMPREPLY+=($(compgen -W '$args' -- "$cur"))
+ command sed -e 's/,/ /g' -ne 's/^.*'"$2"'\>.*(\([^)]*\)).*/\1/p')
+ _comp_compgen -a -- -W '$args'
}
-_shellcheck()
+_comp_cmd_shellcheck()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[eifCsoPW]*)'
+ # shellcheck disable=SC2254
case $prev in
- --version | -!(-*)V*)
+ --version | -${noargopts}V*)
return
;;
- --exclude | --include | -!(-*)[ei])
+ --exclude | --include | -${noargopts}[ei])
return
;;
- --format | -!(-*)f)
+ --format | -${noargopts}f)
local args=$("$1" --format=nonexistent-format /dev/null 2>&1 |
command sed -ne '/^Supported formats/,//p' |
command sed -ne '/^[[:space:]]/p')
- COMPREPLY=($(compgen -W '$args' -- "$cur"))
+ _comp_compgen -- -W '$args'
return
;;
- --color | -!(-*)C)
- _shellcheck_optarg "$1" --color
+ --color | -${noargopts}C)
+ _comp_cmd_shellcheck__optarg "$1" --color
return
;;
- --shell | -!(-*)s)
- _shellcheck_optarg "$1" --shell
+ --shell | -${noargopts}s)
+ _comp_cmd_shellcheck__optarg "$1" --shell
return
;;
- --enable | -!(-*)o)
- COMPREPLY=($(compgen -W 'all' -- "$cur")) # TODO others?
+ --enable | -${noargopts}o)
+ _comp_compgen -- -W 'all' # TODO others?
return
;;
- --source-path | -!(-*)P)
- _filedir -d
- COMPREPLY+=($(compgen -W 'SCRIPTDIR' -- "$cur"))
+ --source-path | -${noargopts}P)
+ _comp_compgen_filedir -d
+ _comp_compgen -a -- -W 'SCRIPTDIR'
return
;;
- --wiki-link-count | -!(-*)W)
+ --wiki-link-count | -${noargopts}W)
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _shellcheck shellcheck
+ complete -F _comp_cmd_shellcheck shellcheck
# ex: filetype=sh
diff --git a/completions/sitecopy b/completions/sitecopy
index 8515687..87e8775 100644
--- a/completions/sitecopy
+++ b/completions/sitecopy
@@ -3,31 +3,33 @@
# 2011 Raphaël Droz <raphael.droz+floss@gmail.com>
# License: GNU GPL v2 or later
-_sitecopy()
+_comp_cmd_sitecopy()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[dgrp]*)'
+ # shellcheck disable=SC2254
case $prev in
- --debug | -!(-*)d)
- COMPREPLY=($(compgen -W "socket files rcfile ftp http httpbody
- rsh sftp xml xmlparse cleartext" -- "$cur"))
+ --debug | -${noargopts}d)
+ _comp_compgen -- -W 'socket files rcfile ftp http httpbody rsh sftp
+ xml xmlparse cleartext'
compopt -o nospace
return
;;
- --logfile | --rcfile | -!(-*)[gr])
- _filedir
+ --logfile | --rcfile | -${noargopts}[gr])
+ _comp_compgen_filedir
return
;;
- --storepath | -!(-*)p)
- _filedir -d
+ --storepath | -${noargopts}p)
+ _comp_compgen_filedir -d
return
;;
esac
case $cur in
--*)
- COMPREPLY=($(compgen -W "$(_parse_help $1)" -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
;;
@@ -41,10 +43,10 @@ _sitecopy()
esac
if [[ -r ~/.sitecopyrc ]]; then
- COMPREPLY=($(compgen -W "$($1 -v |
- command sed -n '/^Site:/s/Site: //p')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" -v |
+ command sed -n '/^Site:/s/Site: //p')"
fi
} &&
- complete -F _sitecopy -o default sitecopy
+ complete -F _comp_cmd_sitecopy -o default sitecopy
# ex: filetype=sh
diff --git a/completions/slackpkg b/completions/slackpkg
deleted file mode 100644
index 1d87928..0000000
--- a/completions/slackpkg
+++ /dev/null
@@ -1,112 +0,0 @@
-# bash completion for slackpkg(8) -*- shell-script -*-
-# options list is based on `grep '\-.*\=.*)' /usr/sbin/slackpkg | cut -f1 -d\)`
-
-_slackpkg()
-{
- local cur prev words cword
- _init_completion -n = || return
-
- local split=false
- if [[ $cur == -?*=* ]]; then
- prev="${cur%%?(\\)=*}"
- cur="${cur#*=}"
- split=true
- fi
-
- case "$prev" in
- -delall | -checkmd5 | -checkgpg | -checksize | -postinst | -onoff | -download_all | \
- -dialog | -batch | -only_new_dotnew | -use_includes | -spinning)
- COMPREPLY=($(compgen -W 'on off' -- "$cur"))
- return
- ;;
- -default_answer)
- COMPREPLY=($(compgen -W 'yes no' -- "$cur"))
- return
- ;;
- -dialog_maxargs | -mirror)
- # argument required but no completions available
- return
- ;;
- esac
-
- $split && return
-
- if [[ $cur == -* ]]; then
- compopt -o nospace
- COMPREPLY=($(compgen -W '-delall= -checkmd5= -checkgpg=
- -checksize= -postinst= -onoff= -download_all= -dialog=
- -dialog_maxargs= -batch= -only_new_dotnew= -use_includes=
- -spinning= -default_answer= -mirror=' -- "$cur"))
- return
- fi
-
- local confdir="/etc/slackpkg"
- local config="$confdir/slackpkg.conf"
-
- [[ -r $config ]] || return
- . "$config"
-
- local i action
- for ((i = 1; i < ${#words[@]}; i++)); do
- if [[ ${words[i]} != -* ]]; then
- action="${words[i]}"
- break
- fi
- done
-
- case "$action" in
- generate-template | search | file-search)
- # argument required but no completions available
- return
- ;;
- install-template | remove-template)
- if [[ -e $confdir/templates ]]; then
- COMPREPLY=($(
- cd "$confdir/templates"
- compgen -f -X "!*.template" -- "$cur"
- ))
- COMPREPLY=(${COMPREPLY[@]%.template})
- fi
- return
- ;;
- remove)
- _filedir
- COMPREPLY+=($(compgen -W 'a ap d e f k kde kdei l n t tcl x
- xap xfce y' -- "$cur"))
- COMPREPLY+=($(
- cd /var/log/packages
- compgen -f -- "$cur"
- ))
- return
- ;;
- install | reinstall | upgrade | blacklist | download)
- _filedir
- COMPREPLY+=($(compgen -W 'a ap d e f k kde kdei l n t tcl x
- xap xfce y' -- "$cur"))
- COMPREPLY+=($(cut -f 6 -d\ "${WORKDIR}/pkglist" 2>/dev/null |
- command grep "^$cur"))
- return
- ;;
- info)
- COMPREPLY=($(cut -f 6 -d\ "${WORKDIR}/pkglist" 2>/dev/null |
- command grep "^$cur"))
- return
- ;;
- update)
- # we should complete the same as the next `list` + "gpg"
- COMPREPLY=($(compgen -W 'gpg' -- "$cur"))
- ;&
- *)
- COMPREPLY+=($(compgen -W 'install reinstall upgrade remove
- blacklist download update install-new upgrade-all
- clean-system new-config check-updates help generate-template
- install-template remove-template search file-search info' -- \
- "$cur"))
- return
- ;;
- esac
-
-} &&
- complete -F _slackpkg slackpkg
-
-# ex: filetype=sh
diff --git a/completions/slapt-get b/completions/slapt-get
index 14c2dbe..1dc09e0 100644
--- a/completions/slapt-get
+++ b/completions/slapt-get
@@ -1,13 +1,13 @@
# slapt-get(8) completion -*- shell-script -*-
-_slapt_get()
+_comp_cmd_slapt_get()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case "$prev" in
--config | -c)
- _filedir
+ _comp_compgen_filedir
return
;;
--retry | --search)
@@ -17,7 +17,7 @@ _slapt_get()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur"))
+ _comp_compgen_help
if [[ ${COMPREPLY-} ]]; then
[[ $COMPREPLY == *= ]] && compopt -o nospace
return
@@ -25,7 +25,8 @@ _slapt_get()
fi
local i t
- # search for last action (--install|--install-set|--remove|--show|--filelist)
+ # search for last action
+ # (--install|--install-set|--remove|--show|--filelist)
for ((i = ${#words[@]} - 1; i > 0; i--)); do
if [[ ${words[i]} == --show ]]; then
t="all"
@@ -46,8 +47,9 @@ _slapt_get()
# search for config
for ((i = ${#words[@]} - 1; i > 0; i--)); do
if [[ ${words[i]} == -@(c|-config) ]]; then
- config="${words[i + 1]}"
- __expand_tilde_by_ref config
+ local REPLY
+ _comp_expand_tilde "${words[i + 1]-}"
+ config=$REPLY
break
fi
done
@@ -58,29 +60,29 @@ _slapt_get()
# slapt-get will fail to search for "^name-version"
# it can search for names only
local name=${cur%%-*}
- COMPREPLY=($(LC_ALL=C "$1" -c "$config" --search "^$name" \
- 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}"))
+ _comp_compgen_split -l -- "$(
+ LC_ALL=C "$1" -c "$config" --search "^$name" 2>/dev/null |
+ LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p;}"
+ )"
return
;;
avl) # --install|-i|
- COMPREPLY=($(LC_ALL=C "$1" -c "$config" --available \
- 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}"))
+ _comp_compgen_split -l -- "$(
+ LC_ALL=C "$1" -c "$config" --available 2>/dev/null |
+ LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p;}"
+ )"
return
;;
ins) # --remove|--filelist
- COMPREPLY=($(
- cd /var/log/packages
- compgen -f -- "$cur"
- ))
+ _comp_compgen -C /var/log/packages -- -f
return
;;
set) # --install-set
- COMPREPLY=($(compgen -W 'a ap d e f k kde kdei l n t tcl x
- xap xfce y' -- "$cur"))
+ _comp_compgen -- -W 'a ap d e f k kde kdei l n t tcl x xap xfce y'
return
;;
esac
} &&
- complete -F _slapt_get slapt-get
+ complete -F _comp_cmd_slapt_get slapt-get
# ex: filetype=sh
diff --git a/completions/slapt-src b/completions/slapt-src
index 1e3828c..cdf00c2 100644
--- a/completions/slapt-src
+++ b/completions/slapt-src
@@ -1,13 +1,13 @@
# slapt-src(8) completion -*- shell-script -*-
-_slapt_src()
+_comp_cmd_slapt_src()
{
- local cur prev words cword split
- _init_completion -s -n : || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -n : -- "$@" || return
case "$prev" in
--config | -c)
- _filedir
+ _comp_compgen_filedir
return
;;
--search | -s | --postprocess | -p)
@@ -16,17 +16,17 @@ _slapt_src()
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur"))
+ _comp_compgen_help
if [[ ${COMPREPLY-} ]]; then
[[ $COMPREPLY == *= ]] && compopt -o nospace
return
fi
fi
- local i t
+ local i t=""
# search for last action (-i|-w|-b|-f)
for ((i = ${#words[@]} - 1; i > 0; i--)); do
if [[ ${words[i]} == -@([iwfb]|-install|-show|-build|-fetch) ]]; then
@@ -42,8 +42,9 @@ _slapt_src()
# search for config
for ((i = ${#words[@]} - 1; i > 0; i--)); do
if [[ ${words[i]} == -@(c|-config) ]]; then
- config="${words[i + 1]}"
- __expand_tilde_by_ref config
+ local REPLY
+ _comp_expand_tilde "${words[i + 1]-}"
+ config=$REPLY
break
fi
if [[ ${words[i]} == --config=?* ]]; then
@@ -55,14 +56,19 @@ _slapt_src()
if [[ $cur == *:* ]]; then
local name=${cur%:*}
- COMPREPLY=($(LC_ALL=C "$1" --config "$config" --search "^$name" \
- 2>/dev/null | LC_ALL=C command sed -ne \
- "/^$cur/{s/^$name:\([^ ]*\) .*$/\1/;p}"))
+ _comp_compgen_split -l -- "$(
+ LC_ALL=C
+ "$1" --config "$config" --search "^$name" 2>/dev/null |
+ command sed -ne "/^$cur/{s/^$name:\([^ ]*\) .*$/\1/;p;}"
+ )"
else
- COMPREPLY=($(LC_ALL=C "$1" --config "$config" --search "^$cur" \
- 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}"))
+ _comp_compgen_split -l -- "$(
+ LC_ALL=C
+ "$1" --config "$config" --search "^$cur" 2>/dev/null |
+ command sed -ne "/^$cur/{s/ .*$//;p;}"
+ )"
fi
} &&
- complete -F _slapt_src slapt-src
+ complete -F _comp_cmd_slapt_src slapt-src
# ex: filetype=sh
diff --git a/completions/smartctl b/completions/smartctl
index ee45a7c..376ceb8 100644
--- a/completions/smartctl
+++ b/completions/smartctl
@@ -1,26 +1,17 @@
# bash completion for smartctl(8) -*- shell-script -*-
-_smartctl_quietmode()
-{
- COMPREPLY=($(compgen -W 'errorsonly silent noserial' -- "$cur"))
-}
-_smartctl_device()
+_comp_cmd_smartctl__device()
{
case $cur in
areca* | 3ware* | megaraid* | cciss*)
- # shellcheck disable=SC2054
- COMPREPLY+=(${cur%%,*},{0..31})
- COMPREPLY=($(compgen -W '"${COMPREPLY[@]}"' -- "$cur"))
+ _comp_compgen -- -W '${cur%%,*},{0..31}'
;;
hpt*)
- # shellcheck disable=SC2054
- COMPREPLY+=(hpt,{1..4}/{1..8} hpt,{1..4}/{1..8}/{1..5})
- COMPREPLY=($(compgen -W '"${COMPREPLY[@]}"' -- "$cur"))
+ _comp_compgen -- -W 'hpt,{1..4}/{1..8} hpt,{1..4}/{1..8}/{1..5}'
;;
*)
- COMPREPLY=($(compgen -W "ata scsi sat usbcypress usbjmicron
- usbsunplus marvell areca 3ware hpt megaraid cciss auto test" \
- -- "$cur"))
+ _comp_compgen -- -W 'ata scsi sat usbcypress usbjmicron usbsunplus
+ marvell areca 3ware hpt megaraid cciss auto test'
case "${COMPREPLY[@]}" in
areca | 3ware | hpt | megaraid | cciss)
compopt -o nospace
@@ -29,137 +20,101 @@ _smartctl_device()
;;
esac
}
-_smartctl_tolerance()
-{
- COMPREPLY=($(compgen -W 'normal conservative permissive verypermissive' \
- -- "$cur"))
-}
-_smartctl_badsum()
-{
- COMPREPLY=($(compgen -W 'warn exit ignore' -- "$cur"))
-}
-_smartctl_report()
-{
- COMPREPLY=($(compgen -W 'ioctl ataioctl scsiioctl' -- "$cur"))
-}
-_smartctl_powermode()
-{
- COMPREPLY=($(compgen -W 'never sleep standby idle' -- "$cur"))
-}
-_smartctl_feature()
-{
- COMPREPLY=($(compgen -W 'on off' -- "$cur"))
-}
-_smartctl_log()
-{
- COMPREPLY=($(compgen -W 'error selftest selective directory background
- sasphy sasphy,reset sataphy sataphy,reset scttemp scttempsts
- scttemphist scterc gplog smartlog xerror xselftest' -- "$cur"))
-}
-_smartctl_vendorattribute()
-{
- COMPREPLY=($(compgen -W 'help 9,minutes 9,seconds 9,halfminutes 9,temp
- 192,emergencyretractcyclect 193,loadunload 194,10xCelsius 194,unknown
- 198,offlinescanuncsectorct 200,writeerrorcount 201,detectedtacount
- 220,temp' -- "$cur"))
-}
-_smartctl_firmwarebug()
-{
- COMPREPLY=($(compgen -W 'none samsung samsung2 samsung3 swapid' \
- -- "$cur"))
-}
-_smartctl_presets()
-{
- COMPREPLY=($(compgen -W 'use ignore show showall' -- "$cur"))
-}
-_smartctl_test()
+_comp_cmd_smartctl__test()
{
[[ $cur == @(pending|scttempint|vendor), ]] && return
- COMPREPLY=($(compgen -W 'offline short long conveyance select,
- select,redo select,next afterselect,on afterselect,off pending,
- scttempint, vendor,' -- "$cur"))
+ _comp_compgen -- -W 'offline short long conveyance select, select,redo
+ select,next afterselect,on afterselect,off pending, scttempint,
+ vendor,'
[[ ${COMPREPLY-} == *, ]] && compopt -o nospace
}
-_smartctl_drivedb()
+_comp_cmd_smartctl__drivedb()
{
local prefix=
if [[ $cur == +* ]]; then
prefix=+
cur="${cur#+}"
fi
- _filedir h
- [[ -n $prefix ]] && COMPREPLY=("${COMPREPLY[@]/#/$prefix}")
+ _comp_compgen_filedir h && [[ $prefix ]] &&
+ _comp_compgen -Rv COMPREPLY -- -P "$prefix" -W '"${COMPREPLY[@]}"'
}
-_smartctl()
+_comp_cmd_smartctl()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[qdTbrnsoSlvFPBt]*)'
+ # shellcheck disable=SC2254
case $prev in
- --quietmode | -!(-*)q)
- _smartctl_quietmode
+ --quietmode | -${noargopts}q)
+ _comp_compgen -- -W 'errorsonly silent noserial'
+ return
;;
- --device | -!(-*)d)
- _smartctl_device
+ --device | -${noargopts}d)
+ _comp_cmd_smartctl__device
return
;;
- --tolerance | -!(-*)T)
- _smartctl_tolerance
+ --tolerance | -${noargopts}T)
+ _comp_compgen -- -W 'normal conservative permissive verypermissive'
return
;;
- --badsum | -!(-*)b)
- _smartctl_badsum
+ --badsum | -${noargopts}b)
+ _comp_compgen -- -W 'warn exit ignore'
return
;;
- --report | -!(-*)r)
- _smartctl_report
+ --report | -${noargopts}r)
+ _comp_compgen -- -W 'ioctl ataioctl scsiioctl'
return
;;
- --nocheck | -!(-*)n)
- _smartctl_powermode
+ --nocheck | -${noargopts}n)
+ _comp_compgen -- -W 'never sleep standby idle'
return
;;
- --smart | --offlineauto | --saveauto | -!(-*)[soS])
- _smartctl_feature
+ --smart | --offlineauto | --saveauto | -${noargopts}[soS])
+ _comp_compgen -- -W 'on off'
return
;;
- --log | -!(-*)l)
- _smartctl_log
+ --log | -${noargopts}l)
+ _comp_compgen -- -W 'error selftest selective directory background
+ sasphy sasphy,reset sataphy sataphy,reset scttemp scttempsts
+ scttemphist scterc gplog smartlog xerror xselftest'
return
;;
- --vendorattribute | -!(-*)v)
- _smartctl_vendorattribute
+ --vendorattribute | -${noargopts}v)
+ _comp_compgen -- -W 'help 9,minutes 9,seconds 9,halfminutes 9,temp
+ 192,emergencyretractcyclect 193,loadunload 194,10xCelsius
+ 194,unknown 198,offlinescanuncsectorct 200,writeerrorcount
+ 201,detectedtacount 220,temp'
return
;;
- --firmwarebug | -!(-*)F)
- _smartctl_firmwarebug
+ --firmwarebug | -${noargopts}F)
+ _comp_compgen -- -W 'none samsung samsung2 samsung3 swapid'
return
;;
- --presets | -!(-*)P)
- _smartctl_presets
+ --presets | -${noargopts}P)
+ _comp_compgen -- -W 'use ignore show showall'
return
;;
- --drivedb | -!(-*)B)
- _smartctl_drivedb
+ --drivedb | -${noargopts}B)
+ _comp_cmd_smartctl__drivedb
return
;;
- --test | -!(-*)t)
- _smartctl_test
+ --test | -${noargopts}t)
+ _comp_cmd_smartctl__test
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- cur=${cur:=/dev/}
- _filedir
+ _comp_compgen -c "${cur:-/dev/}" filedir
fi
} &&
- complete -F _smartctl smartctl
+ complete -F _comp_cmd_smartctl smartctl
# ex: filetype=sh
diff --git a/completions/smbclient b/completions/smbclient
index cea2107..bd2deeb 100644
--- a/completions/smbclient
+++ b/completions/smbclient
@@ -1,242 +1,248 @@
# bash completion for samba -*- shell-script -*-
-_samba_resolve_order()
+_comp_cmd_smbclient__resolve_order()
{
- COMPREPLY=($(compgen -W 'lmhosts host wins bcast' -- "$cur"))
+ _comp_compgen -- -W 'lmhosts host wins bcast'
}
-_samba_domains()
+_comp_cmd_smbclient__domains()
{
- if [[ -n ${COMP_SAMBA_SCAN:-} ]]; then
- COMPREPLY=($(compgen -W '$(smbtree -N -D)' -- "$cur"))
+ if [[ ${BASH_COMPLETION_CMD_SMBTREE_SCAN-${COMP_SAMBA_SCAN-}} ]]; then
+ _comp_compgen_split -- "$(smbtree -N -D)"
fi
}
-_samba_hosts()
+_comp_cmd_smbclient__hosts()
{
- if [[ -n ${COMP_SAMBA_SCAN:-} ]]; then
- COMPREPLY=($(compgen -W "$(
- smbtree -N -S |
- command sed -ne 's/^[[:space:]]*\\\\*\([^[:space:]]*\).*/\1/p'
- )" -- "$cur"))
+ if [[ ${BASH_COMPLETION_CMD_SMBTREE_SCAN-${COMP_SAMBA_SCAN-}} ]]; then
+ _comp_compgen_split -- "$(smbtree -N -S |
+ command sed -ne 's/^[[:space:]]*\\\\*\([^[:space:]]*\).*/\1/p')"
fi
}
-_samba_debuglevel()
+_comp_cmd_smbclient__debuglevel()
{
- COMPREPLY=($(compgen -W '{0..10}' -- "$cur"))
+ _comp_compgen -- -W '{0..10}'
}
-_samba_sockopts()
+_comp_cmd_smbclient__sockopts()
{
- COMPREPLY=($(compgen -W 'SO_KEEPALIVE SO_REUSEADDR SO_BROADCAST
- TCP_NODELAY IPTOS_LOWDELAY IPTOS_THROUGHPUT SO_SNDBUF SO_RCVBUF
- SO_SNDLOWAT SO_RCVLOWAT' -- "$cur"))
+ _comp_compgen -- -W 'SO_KEEPALIVE SO_REUSEADDR SO_BROADCAST TCP_NODELAY
+ IPTOS_LOWDELAY IPTOS_THROUGHPUT SO_SNDBUF SO_RCVBUF SO_SNDLOWAT
+ SO_RCVLOWAT'
}
-_samba_signing()
+_comp_cmd_smbclient__signing()
{
- COMPREPLY=($(compgen -W 'on off required' -- "$cur"))
+ _comp_compgen -- -W 'on off required'
}
-_smbclient()
+_comp_cmd_smbclient()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[RtsAlDOTWdLSpMIbUniTcm]*)'
+ # shellcheck disable=SC2254
case $prev in
- --name-resolve | -!(-*)R)
- _samba_resolve_order
+ --name-resolve | -${noargopts}R)
+ _comp_cmd_smbclient__resolve_order
return
;;
- -!(-*)t)
- COMPREPLY=($(compgen -W 'SJIS EUC JIS7 JIS8 JUNET HEX CAP' \
- -- "$cur"))
+ -${noargopts}t)
+ _comp_compgen -- -W 'SJIS EUC JIS7 JIS8 JUNET HEX CAP'
return
;;
- --configfile | --authentication-file | -!(-*)[sA])
- _filedir
+ --configfile | --authentication-file | -${noargopts}[sA])
+ _comp_compgen_filedir
return
;;
- --log-basename | --directory | -!(-*)[lD])
- _filedir -d
+ --log-basename | --directory | -${noargopts}[lD])
+ _comp_compgen_filedir -d
return
;;
- --socket-options | -!(-*)O)
- _samba_sockopts
+ --socket-options | -${noargopts}O)
+ _comp_cmd_smbclient__sockopts
return
;;
- -!(-*)T)
- COMPREPLY=($(compgen -W 'c x I X F b g q r N a' -- "$cur"))
+ -${noargopts}T)
+ _comp_compgen -- -W 'c x I X F b g q r N a'
return
;;
- --workgroup | -!(-*)W)
- _samba_domains
+ --workgroup | -${noargopts}W)
+ _comp_cmd_smbclient__domains
return
;;
- --debuglevel | -!(-*)d)
- _samba_debuglevel
+ --debuglevel | -${noargopts}d)
+ _comp_cmd_smbclient__debuglevel
return
;;
- --list | -!(-*)L)
- _samba_hosts
+ --list | -${noargopts}L)
+ _comp_cmd_smbclient__hosts
return
;;
- --signing | -!(-*)S)
- _samba_signing
+ --signing | -${noargopts}S)
+ _comp_cmd_smbclient__signing
return
;;
- --port | --message | --ip-address | --send-buffer | --user | --netbiosname | \
- --scope | --tar | --command | --max-protocol | -!(-*)[pMIbUniTcm])
+ --port | --message | --ip-address | --send-buffer | --user | \
+ --netbiosname | --scope | --tar | --command | --max-protocol | \
+ -${noargopts}[pMIbUniTcm])
return
;;
- --help | --version | -!(-*)[?V])
+ --help | --version | -${noargopts}[?V])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _smbclient smbclient
+ complete -F _comp_cmd_smbclient smbclient
-_smbget()
+_comp_cmd_smbget()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[ofdwupb]*)'
+ # shellcheck disable=SC2254
case $prev in
- --outputfile | --rcfile | -!(-*)[of])
- _filedir
+ --outputfile | --rcfile | -${noargopts}[of])
+ _comp_compgen_filedir
return
;;
- --debuglevel | -!(-*)d)
- _samba_debuglevel
+ --debuglevel | -${noargopts}d)
+ _comp_cmd_smbclient__debuglevel
return
;;
- --workgroup | -!(-*)w)
- _samba_domains
+ --workgroup | -${noargopts}w)
+ _comp_cmd_smbclient__domains
return
;;
- --username | --password | --blocksize | -!(-*)[upb])
+ --username | --password | --blocksize | -${noargopts}[upb])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _smbget smbget
+ complete -F _comp_cmd_smbget smbget
-_smbcacls()
+_comp_cmd_smbcacls()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[AsldOWDMaSCGniU]*)'
+ # shellcheck disable=SC2254
case $prev in
- --configfile | --authentication-file | -!(-*)[As])
- _filedir
+ --configfile | --authentication-file | -${noargopts}[As])
+ _comp_compgen_filedir
return
;;
- --log-basename | -!(-*)l)
- _filedir -d
+ --log-basename | -${noargopts}l)
+ _comp_compgen_filedir -d
return
;;
- --debuglevel | -!(-*)d)
- _samba_debuglevel
+ --debuglevel | -${noargopts}d)
+ _comp_cmd_smbclient__debuglevel
return
;;
--signing)
- _samba_signing
+ _comp_cmd_smbclient__signing
return
;;
- --socket-options | -!(-*)O)
- _samba_sockopts
+ --socket-options | -${noargopts}O)
+ _comp_cmd_smbclient__sockopts
return
;;
- --workgroup | -!(-*)W)
- _samba_domains
+ --workgroup | -${noargopts}W)
+ _comp_cmd_smbclient__domains
return
;;
- --help | --usage | --delete | --modify | --add | --set | --chown | --chgrp | \
- --netbiosname | --scope | --user | -!(-*)[?DMaSCGniU])
+ --help | --usage | --delete | --modify | --add | --set | --chown | \
+ --chgrp | --netbiosname | --scope | --user | -${noargopts}[?DMaSCGniU])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _smbcacls smbcacls
+ complete -F _comp_cmd_smbcacls smbcacls
-_smbcquotas()
+_comp_cmd_smbcquotas()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[sAldUuS]*)'
+ # shellcheck disable=SC2254
case $prev in
- --configfile | --authentication-file | -!(-*)[sA])
- _filedir
+ --configfile | --authentication-file | -${noargopts}[sA])
+ _comp_compgen_filedir
return
;;
- --log-basename | -!(-*)l)
- _filedir -d
+ --log-basename | -${noargopts}l)
+ _comp_compgen_filedir -d
return
;;
- --debuglevel | -!(-*)d)
- _samba_debuglevel
+ --debuglevel | -${noargopts}d)
+ _comp_cmd_smbclient__debuglevel
return
;;
--signing)
- _samba_signing
+ _comp_cmd_smbclient__signing
return
;;
- --help | --usage | --user | --set | -!(-*)[?UuS])
+ --help | --usage | --user | --set | -${noargopts}[?UuS])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _smbcquotas smbcquotas
+ complete -F _comp_cmd_smbcquotas smbcquotas
-_smbpasswd()
+_comp_cmd_smbpasswd()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*r)
- _samba_hosts
+ _comp_cmd_smbclient__hosts
return
;;
-*R)
- _samba_resolve_order
+ _comp_cmd_smbclient__resolve_order
return
;;
-*c)
- _filedir
+ _comp_compgen_filedir
return
;;
-*D)
- _samba_debuglevel
+ _comp_cmd_smbclient__debuglevel
return
;;
-*[Uhw])
@@ -245,31 +251,31 @@ _smbpasswd()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ _comp_compgen_help -- -h
fi
} &&
- complete -F _smbpasswd smbpasswd
+ complete -F _comp_cmd_smbpasswd smbpasswd
-_smbtar()
+_comp_cmd_smbtar()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*[rt])
- _filedir tar
+ _comp_compgen_filedir tar
return
;;
-*s)
- _samba_hosts
+ _comp_cmd_smbclient__hosts
return
;;
-*l)
- _samba_debuglevel
+ _comp_cmd_smbclient__debuglevel
return
;;
-*N)
- _filedir
+ _comp_compgen_filedir
return
;;
-*[pxbdu])
@@ -278,45 +284,47 @@ _smbtar()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
fi
} &&
- complete -F _smbtar smbtar
+ complete -F _comp_cmd_smbtar smbtar
-_smbtree()
+_comp_cmd_smbtree()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[sAldSU]*)'
+ # shellcheck disable=SC2254
case $prev in
- --configfile | --authentication-file | -!(-*)[sA])
- _filedir
+ --configfile | --authentication-file | -${noargopts}[sA])
+ _comp_compgen_filedir
return
;;
- --log-basename | -!(-*)l)
- _filedir -d
+ --log-basename | -${noargopts}l)
+ _comp_compgen_filedir -d
return
;;
- --debuglevel | -!(-*)d)
- _samba_debuglevel
+ --debuglevel | -${noargopts}d)
+ _comp_cmd_smbclient__debuglevel
return
;;
- --signing | -!(-*)S)
- _samba_signing
+ --signing | -${noargopts}S)
+ _comp_cmd_smbclient__signing
return
;;
- --help | --usage | --user | -!(-*)[?U])
+ --help | --usage | --user | -${noargopts}[?U])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _smbtree smbtree
+ complete -F _comp_cmd_smbtree smbtree
# ex: filetype=sh
diff --git a/completions/snownews b/completions/snownews
index 5b585d9..a767a6c 100644
--- a/completions/snownews
+++ b/completions/snownews
@@ -1,15 +1,15 @@
# snownews(1) completion -*- shell-script -*-
-_snownews()
+_comp_cmd_snownews()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
# return list of available options
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
fi
} &&
- complete -F _snownews snownews
+ complete -F _comp_cmd_snownews snownews
# ex: filetype=sh
diff --git a/completions/sqlite3 b/completions/sqlite3
index 26d38a1..d1393bf 100644
--- a/completions/sqlite3
+++ b/completions/sqlite3
@@ -1,24 +1,23 @@
# sqlite3(1) completion -*- shell-script -*-
-_sqlite3()
+_comp_cmd_sqlite3()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local dbexts='@(sqlite?(3)|?(s?(3))db)'
case $prev in
- -help | -version | -lookaside | -mmap | -newline | -nullvalue | -pagecache | \
- -scratch | -separator | *.$dbexts)
+ -help | -version | -lookaside | -maxsize | -mmap | -newline | \
+ -nullvalue | -pagecache | -scratch | -separator | -vfs | *.$dbexts)
return
;;
-init)
- _filedir
+ _comp_compgen_filedir
return
;;
-cmd)
- compopt -o filenames
- COMPREPLY=($(compgen -c -- "$cur"))
+ _comp_compgen_commands
return
;;
esac
@@ -27,12 +26,12 @@ _sqlite3()
return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
return
fi
- _filedir "$dbexts"
+ _comp_compgen_filedir "$dbexts"
} &&
- complete -F _sqlite3 sqlite3
+ complete -F _comp_cmd_sqlite3 sqlite3
# ex: filetype=sh
diff --git a/completions/ss b/completions/ss
index 4a27d51..e383fe5 100644
--- a/completions/ss
+++ b/completions/ss
@@ -1,41 +1,43 @@
# ss(8) completion -*- shell-script -*-
-_ss()
+_comp_cmd_ss()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[fADF]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | -!(-*)[hV])
+ --help | --version | -${noargopts}[hV])
return
;;
- --family | -!(-*)f)
- COMPREPLY=($(compgen -W 'unix inet inet6 link netlink' \
- -- "$cur"))
+ --family | -${noargopts}f)
+ _comp_compgen -- -W 'unix inet inet6 link netlink'
return
;;
- --query | -!(-*)A)
- local prefix=
- [[ $cur == *,* ]] && prefix="${cur%,*},"
- COMPREPLY=($(compgen -W '$("$1" --help | \
- command sed -e "s/|/ /g" -ne "s/.*QUERY := {\([^}]*\)}.*/\1/p")' \
- -- "${cur##*,}"))
- ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
+ --query | -${noargopts}A)
+ local queries=$("$1" --help |
+ command sed -e 's/|/ /g' -ne 's/.*QUERY := {\([^}]*\)}.*/\1/p')
+ _comp_delimited , -W '$queries'
return
;;
- --diag | --filter | -!(-*)[DF])
- _filedir
+ --diag | --filter | -${noargopts}[DF])
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
+ elif [[ $prev == state ]]; then
+ _comp_compgen -- -W 'all connected synchronized bucket big established
+ syn-sent syn-recv fin-wait-{1,2} time-wait closed close-wait
+ last-ack listening closing'
fi
} &&
- complete -F _ss ss
+ complete -F _comp_cmd_ss ss
# ex: filetype=sh
diff --git a/completions/ssh b/completions/ssh
index 907c039..386fd25 100644
--- a/completions/ssh
+++ b/completions/ssh
@@ -1,195 +1,229 @@
# ssh(1) completion -*- shell-script -*-
-_ssh_queries()
+_comp_cmd_ssh__compgen_queries()
{
- COMPREPLY+=($(compgen -W \
- "cipher cipher-auth help mac kex key key-cert key-plain key-sig
- protocol-version compression sig
- ciphers macs kexalgorithms pubkeyacceptedkeytypes
- hostkeyalgorithms hostbasedkeytypes hostbasedacceptedkeytypes" \
- -- "${cur,,}"))
+ local -a queries
+ _comp_compgen -v queries -i ssh query "$1" help ||
+ queries=(cipher cipher-auth mac kex key key-cert key-plain key-sig
+ protocol-version compression sig ciphers macs kexalgorithms
+ pubkeyacceptedkeytypes hostkeyalgorithms hostbasedkeytypes
+ hostbasedacceptedkeytypes)
+ _comp_compgen -c "${cur,,}" -U queries -- -W '"${queries[@]}" help'
}
+# @since 2.12
+_comp_xfunc_ssh_compgen_query()
+{
+ _comp_cmd_ssh__compgen_query ssh "$1"
+}
+
+# @deprecated 2.12 use _comp_xfunc_ssh_compgen_query
_ssh_query()
{
- ${1:-ssh} -Q $2 2>/dev/null
+ local -a queries=()
+ _comp_compgen -v queries -i ssh query "${1:-ssh}" "$2" &&
+ printf "%s\n" "${queries[@]}"
}
-_ssh_ciphers()
+_comp_cmd_ssh__compgen_query()
{
- local ciphers='$(_ssh_query "$1" cipher)'
- [[ $ciphers ]] || ciphers="3des-cbc aes128-cbc aes192-cbc aes256-cbc
- aes128-ctr aes192-ctr aes256-ctr arcfour128 arcfour256 arcfour
- blowfish-cbc cast128-cbc"
- COMPREPLY+=($(compgen -W "$ciphers" -- "$cur"))
+ _comp_compgen_split -- "$("$1" -Q "$2" 2>/dev/null)"
}
-_ssh_macs()
+_comp_cmd_ssh__compgen_ciphers()
{
- local macs='$(_ssh_query "$1" mac)'
- [[ $macs ]] || macs="hmac-md5 hmac-sha1 umac-64@openssh.com hmac-ripemd160
- hmac-sha1-96 hmac-md5-96"
- COMPREPLY+=($(compgen -W "$macs" -- "$cur"))
+ local -a queries
+ _comp_compgen -v queries -i ssh query "$1" cipher ||
+ queries=(3des-cbc aes128-cbc aes192-cbc aes256-cbc aes128-ctr
+ aes192-ctr aes256-ctr arcfour128 arcfour256 arcfour blowfish-cbc
+ cast128-cbc)
+ _comp_compgen -U queries -- -W '"${queries[@]}"'
}
-_ssh_options()
+_comp_cmd_ssh__compgen_macs()
{
- local opts=(
- AddKeysToAgent AddressFamily BatchMode BindAddress CanonicalDomains
- CanonicalizeFallbackLocal CanonicalizeHostname CanonicalizeMaxDots
- CanonicalizePermittedCNAMEs CASignatureAlgorithms CertificateFile
- ChallengeResponseAuthentication CheckHostIP Ciphers ClearAllForwardings
- Compression ConnectionAttempts ConnectTimeout ControlMaster ControlPath
- ControlPersist DynamicForward EnableSSHKeysign EscapeChar
- ExitOnForwardFailure FingerprintHash ForwardAgent ForwardX11
- ForwardX11Timeout ForwardX11Trusted GatewayPorts GlobalKnownHostsFile
- GSSAPIAuthentication GSSAPIClientIdentity GSSAPIDelegateCredentials
- GSSAPIKeyExchange GSSAPIRenewalForcesRekey GSSAPIServerIdentity
- GSSAPITrustDns HashKnownHosts Host HostbasedAuthentication
- HostbasedKeyTypes HostKeyAlgorithms HostKeyAlias HostName
+ local -a queries
+ _comp_compgen -v queries -i ssh query "$1" mac ||
+ queries=(hmac-md5 hmac-sha1 umac-64@openssh.com hmac-ripemd160
+ hmac-sha1-96 hmac-md5-96)
+ _comp_compgen -U queries -- -W '"${queries[@]}"'
+}
+
+# @since 2.12
+_comp_xfunc_ssh_compgen_options()
+{
+ # curl --silent https://raw.githubusercontent.com/openssh/openssh-portable/master/ssh_config.5 | _comp_awk '$1==".It" && $2=="Cm" && $3!="Host" && $3!="Match" {print " "$3}' | sort
+ local _opts=(
+ AddKeysToAgent AddressFamily BatchMode BindAddress BindInterface
+ CanonicalDomains CanonicalizeFallbackLocal CanonicalizeHostname
+ CanonicalizeMaxDots CanonicalizePermittedCNAMEs CASignatureAlgorithms
+ CertificateFile ChallengeResponseAuthentication CheckHostIP Ciphers
+ ClearAllForwardings Compression ConnectionAttempts ConnectTimeout
+ ControlMaster ControlPath ControlPersist DynamicForward
+ EnableSSHKeysign EscapeChar ExitOnForwardFailure FingerprintHash
+ ForwardAgent ForwardX11 ForwardX11Timeout ForwardX11Trusted
+ GatewayPorts GlobalKnownHostsFile GSSAPIAuthentication
+ GSSAPIDelegateCredentials HashKnownHosts HostbasedAuthentication
+ HostbasedKeyTypes HostKeyAlgorithms HostKeyAlias Hostname
IdentitiesOnly IdentityAgent IdentityFile IgnoreUnknown Include IPQoS
KbdInteractiveAuthentication KbdInteractiveDevices KexAlgorithms
LocalCommand LocalForward LogLevel MACs
NoHostAuthenticationForLocalhost NumberOfPasswordPrompts
PasswordAuthentication PermitLocalCommand PKCS11Provider Port
PreferredAuthentications ProxyCommand ProxyJump ProxyUseFdpass
- PubkeyAcceptedKeyTypes PubkeyAuthentication RekeyLimit RemoteCommand
- RemoteForward RequestTTY RevokedHostKeys SendEnv ServerAliveCountMax
- ServerAliveInterval SmartcardDevice StreamLocalBindMask
- StreamLocalBindUnlink StrictHostKeyChecking SyslogFacility TCPKeepAlive
- Tunnel TunnelDevice UpdateHostKeys UsePrivilegedPort User
- UserKnownHostsFile VerifyHostKeyDNS VisualHostKey XAuthLocation)
- local protocols=$(_ssh_query "$1" protocol-version)
- if [[ -z $protocols || $protocols == *1* ]]; then
- opts+=(Cipher CompressionLevel Protocol RhostsRSAAuthentication
+ PubkeyAcceptedAlgorithms PubkeyAuthentication RekeyLimit RemoteCommand
+ RemoteForward RequestTTY RequiredRSASize RevokedHostKeys
+ SecurityKeyProvider SendEnv ServerAliveCountMax ServerAliveInterval
+ SetEnv StreamLocalBindMask StreamLocalBindUnlink StrictHostKeyChecking
+ SyslogFacility TCPKeepAlive Tunnel TunnelDevice UpdateHostKeys User
+ UserKnownHostsFile VerifyHostKeyDNS VisualHostKey XAuthLocation
+ )
+ # Selected old ones
+ _opts+=(
+ GSSAPIKeyExchange GSSAPIRenewalForcesRekey GSSAPIServerIdentity
+ GSSAPITrustDns PubkeyAcceptedKeyTypes SmartcardDevice UsePrivilegedPort
+ )
+ local -a protocols
+ _comp_compgen -v protocols -i ssh query ssh protocol-version
+ if [[ ${protocols[*]-} == *1* ]]; then
+ _opts+=(Cipher CompressionLevel Protocol RhostsRSAAuthentication
RSAAuthentication)
fi
+ _comp_unlocal protocols
compopt -o nospace
- local IFS=$' \t\n' reset=$(shopt -p nocasematch)
- shopt -s nocasematch
- local option
- COMPREPLY=($(for option in "${opts[@]}"; do
- [[ $option == "$cur"* ]] && printf '%s=\n' "$option"
- done))
- $reset
+ _comp_compgen_split -l -- "$(
+ shopt -s nocasematch
+ local option
+ for option in "${_opts[@]}"; do
+ [[ $option == "$cur"* ]] && printf '%s=\n' "$option"
+ done
+ )"
}
+_comp_deprecate_func 2.12 _ssh_options _comp_xfunc_ssh_compgen_options
+
# Complete a ssh suboption (like ForwardAgent=y<tab>)
-# Two parameters: the string to complete including the equal sign, and
-# the ssh executable to invoke (optional).
+# @param $1 the ssh executable to invoke
+# @param $2 the string to complete including the equal sign
# Not all suboptions are completed.
# Doesn't handle comma-separated lists.
-_ssh_suboption()
+_comp_cmd_ssh__compgen_suboption()
{
# Split into subopt and subval
- local prev=${1%%=*} cur=${1#*=}
+ local _prev=${2%%=*} cur=${2#*=}
- case ${prev,,} in
+ case ${_prev,,} in
batchmode | canonicaldomains | canonicalizefallbacklocal | \
challengeresponseauthentication | checkhostip | \
- clearallforwardings | controlpersist | compression | enablesshkeysign | \
- exitonforwardfailure | forwardagent | forwardx11 | forwardx11trusted | \
- gatewayports | gssapiauthentication | gssapikeyexchange | \
- gssapidelegatecredentials | gssapirenewalforcesrekey | gssapitrustdns | \
- hashknownhosts | hostbasedauthentication | identitiesonly | \
- kbdinteractiveauthentication | kbdinteractivedevices | \
- nohostauthenticationforlocalhost | passwordauthentication | permitlocalcommand | \
- proxyusefdpass | pubkeyauthentication | rhostsrsaauthentication | \
+ clearallforwardings | controlpersist | compression | \
+ enablesshkeysign | exitonforwardfailure | forwardagent | \
+ forwardx11 | forwardx11trusted | gatewayports | \
+ gssapiauthentication | gssapikeyexchange | \
+ gssapidelegatecredentials | gssapirenewalforcesrekey | \
+ gssapitrustdns | hashknownhosts | hostbasedauthentication | \
+ identitiesonly | kbdinteractiveauthentication | \
+ kbdinteractivedevices | nohostauthenticationforlocalhost | \
+ passwordauthentication | permitlocalcommand | proxyusefdpass | \
+ pubkeyauthentication | rhostsrsaauthentication | \
rsaauthentication | streamlocalbindunlink | \
tcpkeepalive | useprivilegedport | visualhostkey)
- COMPREPLY=($(compgen -W 'yes no' -- "$cur"))
+ _comp_compgen -- -W 'yes no'
;;
addkeystoagent)
- COMPREPLY=($(compgen -W 'yes ask confirm no' -- "$cur"))
+ _comp_compgen -- -W 'yes ask confirm no'
;;
addressfamily)
- COMPREPLY=($(compgen -W 'any inet inet6' -- "$cur"))
+ _comp_compgen -- -W 'any inet inet6'
;;
bindaddress)
- _ip_addresses
+ _comp_compgen_ip_addresses
;;
canonicalizehostname)
- COMPREPLY=($(compgen -W 'yes no always' -- "$cur"))
+ _comp_compgen -- -W 'yes no always'
;;
identityfile)
- _ssh_identityfile
+ _comp_xfunc_ssh_compgen_identityfile
;;
- *file | identityagent | include | controlpath | revokedhostkeys | xauthlocation)
- _filedir
+ *file | identityagent | include | controlpath | revokedhostkeys | \
+ xauthlocation)
+ _comp_compgen_filedir
;;
casignaturealgorithms)
- COMPREPLY=($(compgen -W '$(_ssh_query "$2" sig)' -- "$cur"))
+ _comp_cmd_ssh__compgen_query "$1" sig
;;
cipher)
- COMPREPLY=($(compgen -W 'blowfish des 3des' -- "$cur"))
+ _comp_compgen -- -W 'blowfish des 3des'
;;
ciphers)
- _ssh_ciphers "$2"
+ _comp_cmd_ssh__compgen_ciphers "$1"
;;
controlmaster)
- COMPREPLY=($(compgen -W 'yes ask auto autoask no' -- "$cur"))
+ _comp_compgen -- -W 'yes ask auto autoask no'
;;
compressionlevel)
- COMPREPLY=($(compgen -W '{1..9}' -- "$cur"))
+ _comp_compgen -- -W '{1..9}'
;;
fingerprinthash)
- COMPREPLY=($(compgen -W 'md5 sha256' -- "$cur"))
+ _comp_compgen -- -W 'md5 sha256'
;;
ipqos)
- COMPREPLY=($(compgen -W 'af1{1..4} af2{2..3} af3{1..3} af4{1..3}
- cs{0..7} ef lowdelay throughput reliability' -- "$cur"))
+ _comp_compgen -- -W 'af1{1..4} af2{2..3} af3{1..3} af4{1..3}
+ cs{0..7} ef lowdelay throughput reliability'
;;
hostbasedkeytypes | hostkeyalgorithms)
- COMPREPLY=($(compgen -W '$(_ssh_query "$2" key)' -- "$cur"))
+ _comp_cmd_ssh__compgen_query "$1" key
;;
kexalgorithms)
- COMPREPLY=($(compgen -W '$(_ssh_query "$2" kex)' -- "$cur"))
+ _comp_cmd_ssh__compgen_query "$1" kex
;;
loglevel)
- COMPREPLY=($(compgen -W 'QUIET FATAL ERROR INFO VERBOSE DEBUG{,1,2,3}' -- "$cur"))
+ _comp_compgen -- -W 'QUIET FATAL ERROR INFO VERBOSE DEBUG{,1,2,3}'
;;
macs)
- _ssh_macs "$2"
+ _comp_cmd_ssh__compgen_macs "$1"
;;
pkcs11provider)
- _filedir so
+ _comp_compgen_filedir so
;;
preferredauthentications)
- COMPREPLY=($(compgen -W 'gssapi-with-mic host-based publickey
- keyboard-interactive password' -- "$cur"))
+ _comp_compgen -- -W 'gssapi-with-mic host-based publickey
+ keyboard-interactive password'
;;
protocol)
- local protocols=($(_ssh_query "$2" protocol-version))
- [[ $protocols ]] || protocols=(1 2)
+ local -a protocols
+ _comp_compgen -v protocols -i ssh query "$1" protocol-version
+ [[ ${protocols-} ]] || protocols=(1 2)
if ((${#protocols[@]} > 1)); then
- COMPREPLY=($(compgen -W '${protocols[@]}' -- "$cur"))
+ _comp_compgen -- -W '"${protocols[@]}"'
fi
;;
proxyjump)
- _known_hosts_real -a ${configfile:+-F "$configfile"} -- "$cur"
+ _comp_compgen_known_hosts -a ${configfile:+-F "$configfile"} -- "$cur"
;;
proxycommand | remotecommand | localcommand)
- COMPREPLY=($(compgen -c -- "$cur"))
+ _comp_compgen_commands
;;
- pubkeyacceptedkeytypes)
- COMPREPLY=($(compgen -W '$(_ssh_query "$2" key)' -- "$cur"))
+ pubkeyacceptedalgorithms | pubkeyacceptedkeytypes)
+ _comp_cmd_ssh__compgen_query "$1" key
;;
requesttty)
- COMPREPLY=($(compgen -W 'no yes force auto' -- "$cur"))
+ _comp_compgen -- -W 'no yes force auto'
+ ;;
+ requiredrsasize)
+ _comp_compgen -- -W '1024 2048 3072 4096 7680 15360'
;;
stricthostkeychecking)
- COMPREPLY=($(compgen -W 'accept-new ask no off' -- "$cur"))
+ _comp_compgen -- -W 'accept-new ask no off'
;;
syslogfacility)
- COMPREPLY=($(compgen -W 'DAEMON USER AUTH LOCAL{0..7}' -- "$cur"))
+ _comp_compgen -- -W 'DAEMON USER AUTH LOCAL{0..7}'
;;
tunnel)
- COMPREPLY=($(compgen -W 'yes no point-to-point ethernet' \
- -- "$cur"))
+ _comp_compgen -- -W 'yes no point-to-point ethernet'
;;
updatehostkeys | verifyhostkeydns)
- COMPREPLY=($(compgen -W 'yes no ask' -- "$cur"))
+ _comp_compgen -- -W 'yes no ask'
;;
esac
return 0
@@ -198,28 +232,46 @@ _ssh_suboption()
# Try to complete -o SubOptions=
#
# Returns 0 if the completion was handled or non-zero otherwise.
-_ssh_suboption_check()
+# @since 2.12
+_comp_xfunc_ssh_compgen_suboption_check()
+{
+ _comp_cmd_ssh__compgen_suboption_check ssh
+}
+
+# @param $1 the ssh executable to invoke
+_comp_cmd_ssh__compgen_suboption_check()
{
# Get prev and cur words without splitting on =
- local cureq=$(_get_cword :=) preveq=$(_get_pword :=)
- if [[ $cureq == *=* && $preveq == -*o ]]; then
- _ssh_suboption $cureq "$1"
+ local cur prev
+ _comp_get_words -n := cur prev
+ if [[ $cur == *=* && $prev == -*o ]]; then
+ _comp_unlocal prev
+ _comp_cmd_ssh__compgen_suboption "$1" "$cur"
return $?
fi
return 1
}
+# @deprecated 2.12 use `_comp_xfunc_ssh_compgen_suboption_check` instead
+_ssh_suboption_check()
+{
+ _comp_cmd_ssh__compgen_suboption_check "${1:-ssh}"
+}
+
# Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument
-_ssh_configfile()
+# @var[out] configfile Found configfile, if any
+_comp_cmd_ssh__configfile()
{
+ configfile=""
set -- "${words[@]}"
while (($# > 0)); do
if [[ $1 == -F* ]]; then
+ local REPLY
if ((${#1} > 2)); then
- configfile="$(dequote "${1:2}")"
+ _comp_dequote "${1:2}" && configfile=$REPLY
else
shift
- [[ ${1-} ]] && configfile="$(dequote "$1")"
+ [[ ${1-} ]] && _comp_dequote "$1" && configfile=$REPLY
fi
break
fi
@@ -228,79 +280,86 @@ _ssh_configfile()
}
# With $1 set, look for public key files, else private
+# @since 2.12
# shellcheck disable=SC2120
-_ssh_identityfile()
+_comp_xfunc_ssh_compgen_identityfile()
{
- [[ -z $cur && -d ~/.ssh ]] && cur=~/.ssh/id
- _filedir
- if ((${#COMPREPLY[@]} > 0)); then
- COMPREPLY=($(compgen -W '${COMPREPLY[@]}' \
- -X "${1:+!}*.pub" -- "$cur"))
- fi
+ local cur=$cur tmp
+ [[ ! $cur && -d ~/.ssh ]] && cur=~/.ssh/id
+ _comp_compgen -v tmp -c "$cur" filedir &&
+ _comp_compgen -U tmp -- -W '"${tmp[@]}"' -X "${1:+!}*.pub"
}
-_ssh()
+_comp_deprecate_func 2.12 _ssh_identityfile _comp_xfunc_ssh_compgen_identityfile
+
+_comp_cmd_ssh()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
local configfile
- _ssh_configfile
+ _comp_cmd_ssh__configfile
- _ssh_suboption_check "$1" && return
+ _comp_cmd_ssh__compgen_suboption_check "$1" && return
local ipvx
+ # Keep cases sorted the same they're in ssh's usage message
+ # (but do group ones with same arg completion)
case $prev in
+ -*B)
+ _comp_compgen_available_interfaces -a
+ return
+ ;;
-*b)
- _ip_addresses
+ _comp_compgen_ip_addresses
return
;;
-*c)
- _ssh_ciphers "$1"
+ _comp_cmd_ssh__compgen_ciphers "$1"
return
;;
-*[DeLpRW])
return
;;
-*[EFS])
- _filedir
+ _comp_compgen_filedir
return
;;
- -*i)
- _ssh_identityfile
+ -*I)
+ _comp_compgen_filedir so
return
;;
- -*I)
- _filedir so
+ -*i)
+ _comp_xfunc_ssh_compgen_identityfile
return
;;
-*J)
- _known_hosts_real -a ${configfile:+-F "$configfile"} -- "$cur"
+ _comp_compgen_known_hosts -a ${configfile:+-F "$configfile"} -- "$cur"
return
;;
-*l)
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
return
;;
-*m)
- _ssh_macs "$1"
+ _comp_cmd_ssh__compgen_macs "$1"
return
;;
-*O)
- COMPREPLY=($(compgen -W 'check forward cancel exit stop' -- "$cur"))
+ _comp_compgen -- -W 'check forward cancel exit stop'
return
;;
-*o)
- _ssh_options "$1"
+ _comp_xfunc_ssh_compgen_options "$1"
return
;;
-*Q)
- _ssh_queries "$1"
+ _comp_cmd_ssh__compgen_queries "$1"
return
;;
-*w)
- _available_interfaces
+ _comp_compgen_available_interfaces
return
;;
-*4*)
@@ -312,67 +371,71 @@ _ssh()
esac
if [[ $cur == -F* ]]; then
- cur=${cur#-F}
- _filedir
+ _comp_compgen -c "${cur#-F}" filedir
# Prefix completions with '-F'
COMPREPLY=("${COMPREPLY[@]/#/-F}")
- cur=-F$cur # Restore cur
elif [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
else
- _known_hosts_real ${ipvx-} -a ${configfile:+-F "$configfile"} -- "$cur"
-
- local args
- _count_args
- if ((args > 1)); then
+ local REPLY
+ # Keep glob sort in sync with cases above
+ _comp_count_args -n "=" -a "-*[BbcDeLpRWEFSIiJlmOoQw]"
+ if ((REPLY > 1)); then
compopt -o filenames
- COMPREPLY+=($(compgen -c -- "$cur"))
+ _comp_compgen_commands
+ else
+ _comp_compgen_known_hosts ${ipvx-} -a ${configfile:+-F "$configfile"} \
+ -- "$cur"
fi
fi
} &&
- shopt -u hostcomplete && complete -F _ssh ssh slogin autossh sidedoor
+ shopt -u hostcomplete &&
+ complete -F _comp_cmd_ssh ssh slogin autossh sidedoor
# sftp(1) completion
#
-_sftp()
+_comp_cmd_sftp()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local configfile
- _ssh_configfile
+ _comp_cmd_ssh__configfile
- _ssh_suboption_check && return
+ # Prefer `ssh` from same dir for resolving options, etc
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
- local ipvx
+ _comp_xfunc_ssh_compgen_suboption_check && return
+
+ local ipvx=
case $prev in
-*[BDlPRs])
return
;;
-*[bF])
- _filedir
+ _comp_compgen_filedir
return
;;
-*i)
- _ssh_identityfile
+ _comp_xfunc_ssh_compgen_identityfile
return
;;
-*c)
- _ssh_ciphers
+ _comp_cmd_ssh__compgen_ciphers
return
;;
-*J)
- _known_hosts_real -a ${configfile:+-F "$configfile"} -- "$cur"
+ _comp_compgen_known_hosts -a ${configfile:+-F "$configfile"} -- "$cur"
return
;;
-*o)
- _ssh_options
+ _comp_xfunc_ssh_compgen_options
return
;;
-*S)
- compopt -o filenames
- COMPREPLY=($(compgen -c -- "$cur"))
+ _comp_compgen_commands
return
;;
-*4*)
@@ -384,100 +447,119 @@ _sftp()
esac
if [[ $cur == -F* ]]; then
- cur=${cur#-F}
- _filedir
+ _comp_compgen -c "${cur#-F}" filedir
# Prefix completions with '-F'
COMPREPLY=("${COMPREPLY[@]/#/-F}")
- cur=-F$cur # Restore cur
elif [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
else
- _known_hosts_real ${ipvx-} -a ${configfile:+-F "$configfile"} -- "$cur"
+ _comp_compgen_known_hosts ${ipvx:+"$ipvx"} -a ${configfile:+-F "$configfile"} -- "$cur"
fi
} &&
- shopt -u hostcomplete && complete -F _sftp sftp
+ shopt -u hostcomplete && complete -F _comp_cmd_sftp sftp
# things we want to backslash escape in scp paths
# shellcheck disable=SC2089
-_scp_path_esc='[][(){}<>"'"'"',:;^&!$=?`\\|[:space:]]'
+_comp_cmd_scp__path_esc='[][(){}<>"'"'"',:;^&!$=?`\\|[:space:]]'
# Complete remote files with ssh. If the first arg is -d, complete on dirs
# only. Returns paths escaped with three backslashes.
+# @since 2.12
# shellcheck disable=SC2120
-_scp_remote_files()
+_comp_xfunc_scp_compgen_remote_files()
{
- local IFS=$'\n'
-
# remove backslash escape from the first colon
cur=${cur/\\:/:}
- local userhost=${cur%%?(\\):*}
- local path=${cur#*:}
+ local _userhost=${cur%%?(\\):*}
+ local _path=${cur#*:}
# unescape (3 backslashes to 1 for chars we escaped)
# shellcheck disable=SC2090
- path=$(command sed -e 's/\\\\\\\('$_scp_path_esc'\)/\\\1/g' <<<"$path")
+ _path=$(command sed -e 's/\\\\\\\('"$_comp_cmd_scp__path_esc"'\)/\\\1/g' <<<"$_path")
# default to home dir of specified user on remote host
- if [[ -z $path ]]; then
- path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null)
+ if [[ ! $_path ]]; then
+ _path=$(ssh -o 'Batchmode yes' "$_userhost" pwd 2>/dev/null)
fi
- local files
- if [[ $1 == -d ]]; then
+ local _files
+ if [[ ${1-} == -d ]]; then
# escape problematic characters; remove non-dirs
# shellcheck disable=SC2090
- files=$(ssh -o 'Batchmode yes' $userhost \
- command ls -aF1dL "$path*" 2>/dev/null |
- command sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e '/[^\/]$/d')
+ _files=$(ssh -o 'Batchmode yes' "$_userhost" \
+ command ls -aF1dL "$_path*" 2>/dev/null |
+ command sed -e 's/'"$_comp_cmd_scp__path_esc"'/\\\\\\&/g' -e '/[^\/]$/d')
else
# escape problematic characters; remove executables, aliases, pipes
# and sockets; add space at end of file names
# shellcheck disable=SC2090
- files=$(ssh -o 'Batchmode yes' $userhost \
- command ls -aF1dL "$path*" 2>/dev/null |
- command sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e 's/[*@|=]$//g' \
+ _files=$(ssh -o 'Batchmode yes' "$_userhost" \
+ command ls -aF1dL "$_path*" 2>/dev/null |
+ command sed -e 's/'"$_comp_cmd_scp__path_esc"'/\\\\\\&/g' -e 's/[*@|=]$//g' \
-e 's/[^\/]$/& /g')
fi
- COMPREPLY+=($files)
+ _comp_compgen_split -l -- "$_files"
}
-# This approach is used instead of _filedir to get a space appended
-# after local file/dir completions, and -o nospace retained for others.
-# If first arg is -d, complete on directory names only. The next arg is
-# an optional prefix to add to returned completions.
-_scp_local_files()
+# @deprecated 2.12 use `_comp_compgen -ax ssh remote_files` instead
+_scp_remote_files()
{
- local IFS=$'\n'
+ _comp_compgen -ax scp remote_files
+}
- local dirsonly=false
+# This approach is used instead of _comp_compgen_filedir to get a space
+# appended after local file/dir completions, and -o nospace retained for
+# others. If first arg is -d, complete on directory names only. The next arg
+# is an optional prefix to add to returned completions.
+# @since 2.12
+_comp_xfunc_scp_compgen_local_files()
+{
+ local _dirsonly=""
if [[ ${1-} == -d ]]; then
- dirsonly=true
+ _dirsonly=set
shift
fi
- if $dirsonly; then
- COMPREPLY+=($(command ls -aF1dL $cur* 2>/dev/null |
- command sed -e "s/$_scp_path_esc/\\\\&/g" -e '/[^\/]$/d' -e "s/^/${1-}/"))
+ local files
+ _comp_expand_glob files '"$cur"*' || return 0
+ if [[ $_dirsonly ]]; then
+ _comp_compgen -U files split -l -- "$(
+ command ls -aF1dL "${files[@]}" 2>/dev/null |
+ command sed -e "s/$_comp_cmd_scp__path_esc/\\\\&/g" \
+ -e '/[^\/]$/d' -e "s/^/${1-}/"
+ )"
else
- COMPREPLY+=($(command ls -aF1dL $cur* 2>/dev/null |
- command sed -e "s/$_scp_path_esc/\\\\&/g" -e 's/[*@|=]$//g' \
- -e 's/[^\/]$/& /g' -e "s/^/${1-}/"))
+ _comp_compgen -U files split -l -- "$(
+ command ls -aF1dL "${files[@]}" 2>/dev/null |
+ command sed -e "s/$_comp_cmd_scp__path_esc/\\\\&/g" \
+ -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' -e "s/^/${1-}/"
+ )"
fi
}
+# @deprecated 2.12
+_scp_local_files()
+{
+ _comp_compgen -ax scp local_files "$@"
+}
+
# scp(1) completion
#
-_scp()
+_comp_cmd_scp()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
local configfile
- _ssh_configfile
+ _comp_cmd_ssh__configfile
- _ssh_suboption_check && {
- COMPREPLY=("${COMPREPLY[@]/%/ }")
+ # Prefer `ssh` from same dir for resolving options, remote files, etc
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+
+ _comp_xfunc_ssh_compgen_suboption_check && {
+ ((${#COMPREPLY[@]})) && COMPREPLY=("${COMPREPLY[@]/%/ }")
return
}
@@ -485,34 +567,34 @@ _scp()
case $prev in
-*c)
- _ssh_ciphers
+ _comp_cmd_ssh__compgen_ciphers
COMPREPLY=("${COMPREPLY[@]/%/ }")
return
;;
-*F)
- _filedir
+ _comp_compgen_filedir
compopt +o nospace
return
;;
-*i)
- _ssh_identityfile
+ _comp_xfunc_ssh_compgen_identityfile
compopt +o nospace
return
;;
-*J)
- _known_hosts_real -a ${configfile:+-F "$configfile"} -- "$cur"
+ _comp_compgen_known_hosts -a ${configfile:+-F "$configfile"} -- "$cur"
return
;;
-*[lP])
return
;;
-*o)
- _ssh_options
+ _comp_xfunc_ssh_compgen_options
return
;;
-*S)
- compopt +o nospace -o filenames
- COMPREPLY=($(compgen -c -- "$cur"))
+ compopt +o nospace
+ _comp_compgen_commands
return
;;
-*4*)
@@ -523,12 +605,12 @@ _scp()
;;
esac
- _expand || return
+ _comp_expand || return
case $cur in
!(*:*)/* | [.~]*) ;; # looks like a path
*:*)
- _scp_remote_files
+ _comp_xfunc_scp_compgen_remote_files
return
;;
esac
@@ -541,23 +623,21 @@ _scp()
else
case $cur in
-*)
- COMPREPLY=($(compgen -W '$(_parse_usage "${words[0]}")' \
- -- "$cur"))
+ _comp_compgen_usage
COMPREPLY=("${COMPREPLY[@]/%/ }")
return
;;
- */* | [.~]*)
- # not a known host, pass through
- ;;
*)
- _known_hosts_real ${ipvx-} -c -a \
- ${configfile:+-F "$configfile"} -- "$cur"
+ if ! _comp_looks_like_path "$cur"; then
+ _comp_compgen_known_hosts ${ipvx-} -c -a \
+ ${configfile:+-F "$configfile"} -- "$cur"
+ fi
;;
esac
fi
- _scp_local_files "${prefix-}"
+ _comp_compgen -ax scp local_files "${prefix-}"
} &&
- complete -F _scp -o nospace scp
+ complete -F _comp_cmd_scp -o nospace scp
# ex: filetype=sh
diff --git a/completions/ssh-add b/completions/ssh-add
index d8f7492..23c73e0 100644
--- a/completions/ssh-add
+++ b/completions/ssh-add
@@ -1,35 +1,35 @@
# ssh-add(1) completion -*- shell-script -*-
-_ssh_add()
+_comp_cmd_ssh_add()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*E)
- COMPREPLY=($(compgen -W 'md5 sha256' -- "$cur"))
+ _comp_compgen -- -W 'md5 sha256'
return
;;
-*t)
return
;;
-*T)
- _filedir
+ _comp_compgen_filedir
return
;;
-*[se])
- _filedir so
+ _comp_compgen_filedir so
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" "-\?")' -- "$cur"))
+ _comp_compgen_help -- '-?'
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _ssh_add ssh-add
+ complete -F _comp_cmd_ssh_add ssh-add
# ex: filetype=sh
diff --git a/completions/ssh-copy-id b/completions/ssh-copy-id
index f628194..52aa9d7 100644
--- a/completions/ssh-copy-id
+++ b/completions/ssh-copy-id
@@ -1,32 +1,36 @@
# ssh-copy-id(1) completion -*- shell-script -*-
-_ssh_copy_id()
+_comp_cmd_ssh_copy_id()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
- _xfunc ssh _ssh_suboption_check "$1" && return
+ # Prefer `ssh` from same dir for resolving options, etc
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+
+ _comp_compgen -x ssh suboption_check && return
case $prev in
-i)
- _xfunc ssh _ssh_identityfile pub
+ _comp_compgen -x ssh identityfile pub
return
;;
-p)
return
;;
-o)
- _xfunc ssh _ssh_options
+ _comp_compgen -x ssh options
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ _comp_compgen_usage -- --help
else
- _known_hosts_real -a -- "$cur"
+ _comp_compgen_known_hosts -a -- "$cur"
fi
} &&
- complete -F _ssh_copy_id ssh-copy-id
+ complete -F _comp_cmd_ssh_copy_id ssh-copy-id
# ex: filetype=sh
diff --git a/completions/ssh-keygen b/completions/ssh-keygen
index 0e629a5..3f9d175 100644
--- a/completions/ssh-keygen
+++ b/completions/ssh-keygen
@@ -1,16 +1,16 @@
# ssh-keygen(1) completion -*- shell-script -*-
-_ssh_keygen()
+_comp_cmd_ssh_keygen()
{
- local cur prev words cword
- _init_completion -n := || return
+ local cur prev words cword comp_args
+ _comp_initialize -n := -- "$@" || return
case $prev in
-*[aCIJjMNPSVWz])
return
;;
-*b)
- local -a sizes
+ local -a sizes=()
case "${words[*]}" in
*" -t dsa"?( *))
sizes=(1024)
@@ -22,102 +22,110 @@ _ssh_keygen()
sizes=(1024 2048 3072 4096)
;;
esac
- COMPREPLY=($(compgen -W '${sizes[@]}' -- "$cur"))
+ ((${#sizes[@]})) &&
+ _comp_compgen -- -W '"${sizes[@]}"'
return
;;
-*E)
- COMPREPLY=($(compgen -W 'md5 sha256' -- "$cur"))
+ _comp_compgen -- -W 'md5 sha256'
return
;;
-*[FR])
# TODO: trim this down to actual entries in known hosts files
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
-*[Dw])
- _filedir so
+ _comp_compgen_filedir so
return
;;
-*[fGKsT])
- _filedir
+ _comp_compgen_filedir
return
;;
-*m)
- COMPREPLY=($(compgen -W 'PEM PKCS8 RFC4716' -- "$cur"))
+ _comp_compgen -- -W 'PEM PKCS8 RFC4716'
return
;;
-*n)
[[ ${words[*]} != *\ -*Y\ * ]] || return
- local prefix=
- [[ $cur == *,* ]] && prefix="${cur%,*},"
if [[ ${words[*]} == *\ -*h\ * ]]; then
- _known_hosts_real -- "${cur##*,}"
+ _comp_compgen_known_hosts -- "${cur##*,}"
+ ((${#COMPREPLY[@]})) &&
+ _comp_delimited , -W '"${COMPREPLY[@]}"'
else
- COMPREPLY=($(compgen -u -- "${cur##*,}"))
+ _comp_delimited , -u
fi
- ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
return
;;
-*O)
if [[ $cur != *=* ]]; then
- COMPREPLY=($(compgen -W '
- clear critical: extension: force-command=
+ _comp_compgen -- -W 'clear critical: extension: force-command=
no-agent-forwarding no-port-forwarding no-pty no-user-rc
no-x11-forwarding permit-agent-forwarding
permit-port-forwarding permit-pty permit-user-rc
permit-X11-forwarding no-touch-required source-address=
+ verify-required
lines= start-line= checkpoint= memory= start= generator=
- application challenge= device resident user
- write-attestation-path
- ' -- "$cur"))
+ application= challenge= device= no-touch-required resident
+ user= write-attestation='
+
[[ ${COMPREPLY-} == *[:=] ]] && compopt -o nospace
- __ltrim_colon_completions "$cur"
+ _comp_ltrim_colon_completions "$cur"
else
case $cur in
force-command=*)
compopt -o filenames
- COMPREPLY=($(compgen -c -- "${cur#*=}"))
+ _comp_compgen -c "${cur#*=}" commands
+ ;;
+ checkpoint=* | challenge=* | write-attestation=*)
+ _comp_compgen -c "${cur#*=}" filedir
+ ;;
+ application=*([^:=]))
+ _comp_compgen -c "${cur#*=}" -- -W "ssh:"
+ compopt -o nospace
;;
- checkpoint=* | challenge=*)
- cur=${cur#*=}
- _filedir
+ user=*)
+ _comp_compgen -c "${cur#*=}" -- -u
;;
esac
fi
return
;;
-*r)
- [[ ${words[*]} != *\ -*Y\ * ]] || _filedir
+ [[ ${words[*]} != *\ -*Y\ * ]] || _comp_compgen_filedir
return
;;
-*t)
- local protocols=$(_xfunc ssh _ssh_query "$1" protocol-version)
+ # Prefer `ssh` from same dir for resolving options, etc
+ local pathcmd protocols
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -v protocols -x ssh query protocol-version
local types='dsa ecdsa ecdsa-sk ed25519 ed25519-sk rsa'
- if [[ $protocols == *1* ]]; then
+ if [[ ${protocols[*]} == *1* ]]; then
types+=' rsa1'
fi
- COMPREPLY=($(compgen -W "$types" -- "$cur"))
+ _comp_compgen -- -W "$types"
return
;;
-*Y)
- COMPREPLY=($(compgen -W 'find-principals check-novalidate sign
- verify' -- "$cur"))
+ _comp_compgen -- -W 'find-principals check-novalidate sign verify'
return
;;
esac
+ _comp_compgen_set
if [[ $cur == -* ]]; then
- local opts=$(_parse_usage "$1" "-?")
- [[ -z $opts ]] && opts=$(_parse_help "$1" "-?") # OpenSSH < 7
- COMPREPLY=($(compgen -W "$opts" -- "$cur"))
+ _comp_compgen_usage -- "-?" ||
+ _comp_compgen_help -- "-?" # OpenSSH < 7
fi
if [[ ${words[*]} == *\ -*s\ * ]]; then
- _filedir pub
+ _comp_compgen -a filedir pub
fi
} &&
- complete -F _ssh_keygen ssh-keygen
+ complete -F _comp_cmd_ssh_keygen ssh-keygen
# ex: filetype=sh
diff --git a/completions/ssh-keyscan b/completions/ssh-keyscan
new file mode 100644
index 0000000..f5e4364
--- /dev/null
+++ b/completions/ssh-keyscan
@@ -0,0 +1,39 @@
+# ssh-keyscan(1) completion -*- shell-script -*-
+
+_comp_cmd_ssh_keyscan()
+{
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+
+ local ipvx
+
+ case $prev in
+ -*4*)
+ ipvx=-4
+ ;;
+ -*6*)
+ ipvx=-6
+ ;;
+ -*f)
+ _comp_compgen_filedir
+ return
+ ;;
+ -*p | -*T)
+ return
+ ;;
+ -*t)
+ _comp_delimited , -W "dsa ecdsa ed25519 rsa"
+ return
+ ;;
+ esac
+
+ if [[ $cur == -* ]]; then
+ _comp_compgen_usage
+ return
+ fi
+
+ _comp_compgen_known_hosts ${ipvx-} -- "$cur"
+} &&
+ complete -F _comp_cmd_ssh_keyscan ssh-keyscan
+
+# ex: filetype=sh
diff --git a/completions/sshfs b/completions/sshfs
index 223d029..4b3f388 100644
--- a/completions/sshfs
+++ b/completions/sshfs
@@ -1,23 +1,23 @@
# sshfs(1) completion -*- shell-script -*-
-_sshfs()
+_comp_cmd_sshfs()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
- _expand || return
+ _comp_expand || return
if [[ $cur == *:* ]]; then
- _xfunc ssh _scp_remote_files -d
+ _comp_compgen -x scp remote_files -d
# unlike scp and rsync, sshfs works with 1 backslash instead of 3
COMPREPLY=("${COMPREPLY[@]//\\\\\\/\\}")
return
fi
- [[ $cur == @(*/|[.~])* ]] || _known_hosts_real -c -a -- "$cur"
+ [[ $cur == @(*/|[.~])* ]] || _comp_compgen_known_hosts -c -a -- "$cur"
- _xfunc ssh _scp_local_files -d
+ _comp_compgen -ax scp local_files -d
} &&
- complete -F _sshfs -o nospace sshfs
+ complete -F _comp_cmd_sshfs -o nospace sshfs
# ex: filetype=sh
diff --git a/completions/sshmitm b/completions/sshmitm
index ee893e5..136d2f9 100644
--- a/completions/sshmitm
+++ b/completions/sshmitm
@@ -1,17 +1,17 @@
# sshmitm completion -*- shell-script -*-
-_sshmitm()
+_comp_cmd_sshmitm()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
else
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
fi
} &&
- complete -F _sshmitm sshmitm
+ complete -F _comp_cmd_sshmitm sshmitm
# ex: filetype=sh
diff --git a/completions/sshow b/completions/sshow
index 917444e..0d21bbb 100644
--- a/completions/sshow
+++ b/completions/sshow
@@ -1,26 +1,26 @@
# sshow completion -*- shell-script -*-
-_sshow()
+_comp_cmd_sshow()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*i)
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
return
;;
-*p)
- _filedir pcap
+ _comp_compgen_filedir pcap
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
fi
} &&
- complete -F _sshow sshow
+ complete -F _comp_cmd_sshow sshow
# ex: filetype=sh
diff --git a/completions/strace b/completions/strace
index 2b46ce8..917f64d 100644
--- a/completions/strace
+++ b/completions/strace
@@ -1,9 +1,9 @@
# bash completion for strace -*- shell-script -*-
-_strace()
+_comp_cmd_strace()
{
- local cur prev words cword
- _init_completion -n = || return
+ local cur prev words cword comp_args
+ _comp_initialize -n = -- "$@" || return
# check if we're still completing strace
local offset=0 i
@@ -22,7 +22,7 @@ _strace()
done
if ((offset > 0)); then
- _command_offset $offset
+ _comp_command_offset $offset
else
case $prev in
@@ -38,11 +38,11 @@ _strace()
local define syscall rest
local -A syscalls
while read -r define syscall rest; do
- [[ $define == "#define" && \
- $syscall =~ ^__NR_(.+) ]] &&
- syscalls[${BASH_REMATCH[1]}]=1
+ [[ $define == "#define" &&
+ $syscall =~ ^__NR_(.+) ]] &&
+ syscalls[${BASH_REMATCH[1]}]=set
done 2>/dev/null </usr/include/asm/unistd.h
- if [[ ! $syscalls ]]; then
+ if ((${#syscalls[@]} == 0)); then
local unistd arch=$(command uname -m)
if [[ $arch == *86 ]]; then
unistd=/usr/include/asm/unistd_32.h
@@ -50,50 +50,50 @@ _strace()
unistd=/usr/include/asm/unistd_64.h
fi
while read -r define syscall rest; do
- [[ $define == "#define" && \
- $syscall =~ ^__NR_(.+) ]] &&
- syscalls[${BASH_REMATCH[1]}]=1
+ [[ $define == "#define" &&
+ $syscall =~ ^__NR_(.+) ]] &&
+ syscalls[${BASH_REMATCH[1]}]=set
done 2>/dev/null <$unistd
fi
- COMPREPLY=($(compgen -W '${!syscalls[@]} file
- process network signal ipc desc all none' \
- -- "$cur"))
+ _comp_compgen -- -W \
+ '${syscalls[@]+"${!syscalls[@]}"} file process
+ network signal ipc desc all none'
return
;;
esac
else
compopt -o nospace
- COMPREPLY=($(compgen -S"=" -W 'trace abbrev verbose raw
- signal read write' -- "$cur"))
+ _comp_compgen -- -S"=" -W 'trace abbrev verbose raw signal
+ read write'
fi
return
;;
-*o)
- _filedir
+ _comp_compgen_filedir
return
;;
-*p)
- _pids
+ _comp_compgen_pids
return
;;
-*S)
- COMPREPLY=($(compgen -W 'time calls name nothing' -- "$cur"))
+ _comp_compgen -- -W 'time calls name nothing'
return
;;
-*u)
- _allowed_users
+ _comp_compgen_allowed_users
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ _comp_compgen_help -- -h
else
- COMPREPLY=($(compgen -c -- "$cur"))
+ _comp_compgen_commands
fi
fi
} &&
- complete -F _strace -o default strace
+ complete -F _comp_cmd_strace -o default strace
# ex: filetype=sh
diff --git a/completions/strings b/completions/strings
index 059f557..45f0e60 100644
--- a/completions/strings
+++ b/completions/strings
@@ -1,45 +1,50 @@
# strings(1) completion -*- shell-script -*-
-_strings()
+_comp_cmd_strings()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[nstTe]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | --bytes | -!(-*)[hvVn])
+ --help | --version | --bytes | --output-separator | -arch | \
+ -${noargopts}[hvVns])
return
;;
- --radix | -!(-*)t)
- COMPREPLY=($(compgen -W 'o d x' -- "$cur"))
+ --radix | -${noargopts}t)
+ _comp_compgen -- -W 'o d x'
return
;;
- --target | -!(-*)T)
- COMPREPLY=($(compgen -W '$(LC_ALL=C "$1" --help 2>/dev/null | \
- command sed -ne "s/: supported targets: \(.*\)/\1/p")' \
- -- "$cur"))
+ --target | -${noargopts}T)
+ _comp_compgen_split -- "$(LC_ALL=C "$1" --help 2>/dev/null |
+ command sed -ne 's/: supported targets: \(.*\)/\1/p')"
return
;;
- --encoding | -!(-*)e)
- COMPREPLY=($(compgen -W 's S b l B L' -- "$cur"))
+ --encoding | -${noargopts}e)
+ _comp_compgen_split -F , -- "$(LC_ALL=C "$1" --help 2>/dev/null |
+ command sed -ne 's/.*--encoding={\([^}]*\)}.*/\1/p')"
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ # macOS: ... [-t format] [-number] [-n number] ...
+ _comp_compgen_help ||
+ _comp_compgen_usage - <<<"$("$1" --help 2>&1 |
+ command sed -e "s/\[-number\]//")"
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
elif [[ $cur == @* ]]; then
- cur=${cur:1}
- _filedir
+ _comp_compgen -c "${cur:1}" filedir
COMPREPLY=("${COMPREPLY[@]/#/@}")
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _strings strings
+ complete -F _comp_cmd_strings strings
# ex: filetype=sh
diff --git a/completions/sudo b/completions/sudo
index c9a806b..2cfcf84 100644
--- a/completions/sudo
+++ b/completions/sudo
@@ -1,56 +1,58 @@
# bash completion for sudo(8) -*- shell-script -*-
-_sudo()
+_comp_cmd_sudo()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
local i mode=normal
[[ $1 == *sudoedit ]] && mode=edit
+ local noargopts='!(-*|*[uUgCp]*)'
[[ $mode == normal ]] &&
for ((i = 1; i <= cword; i++)); do
if [[ ${words[i]} != -* ]]; then
local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
- local root_command=${words[i]}
- _command_offset $i
+ local _comp_root_command=$1
+ _comp_command_offset $i
return
fi
- if [[ ${words[i]} == -@(!(-*)e*|-edit) ]]; then
+ # shellcheck disable=SC2254
+ if [[ ${words[i]} == -@(${noargopts}e*|-edit) ]]; then
mode=edit
break
fi
- [[ ${words[i]} == \
- -@(user|other-user|group|close-from|prompt|!(-*)[uUgCp]) ]] &&
+ # shellcheck disable=SC2254
+ [[ ${words[i]} == @(--@(user|other-user|group|close-from|prompt)|-${noargopts}[uUgCp]) ]] &&
((i++))
done
+ # shellcheck disable=SC2254
case "$prev" in
- --user | --other-user | -!(-*)[uU])
- COMPREPLY=($(compgen -u -- "$cur"))
+ --user | --other-user | -${noargopts}[uU])
+ _comp_compgen -- -u
return
;;
- --group | -!(-*)g)
- COMPREPLY=($(compgen -g -- "$cur"))
+ --group | -${noargopts}g)
+ _comp_compgen -- -g
return
;;
- --close-from | --prompt | -!(-*)[Cp])
+ --close-from | --prompt | -${noargopts}[Cp])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- local opts=$(_parse_help "$1")
- COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
if [[ $mode == edit ]]; then
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _sudo sudo sudoedit
+ complete -F _comp_cmd_sudo sudo sudoedit
# ex: filetype=sh
diff --git a/completions/svcadm b/completions/svcadm
index 5269c7b..8505457 100644
--- a/completions/svcadm
+++ b/completions/svcadm
@@ -11,25 +11,25 @@
# but to not clutter the interface with all completions, we will only
# cut every completion alternative at the next slash.
#
-# For example, if the user types <nothing><tab>, we will propose for svc://foo/bar/bar/baz
-# the following completion: foo/, bar/ and baz
+# For example, if the user types <nothing><tab>, we will propose
+# for svc://foo/bar/bar/baz the following completion: foo/, bar/ and baz
# If the user types <b><tab>, we will propose: bar/ and baz
# If the user types <bar/><tab>, we will propose: bar/bar/ and bar/baz
#
-# By default, the function proproses only abbreviated completions except if the user already
-# began to type svc:. In that case we will propose only the complete FMRI beginning with the
-# pattern
+# By default, the function proproses only abbreviated completions except if the
+# user already began to type svc:. In that case we will propose only the
+# complete FMRI beginning with the pattern
#
-_smf_complete_fmri()
+_comp_cmd_svcadm__fmri()
{
local cur="$1" prefix="$2"
local cur_prefix fmri fmri_list=""
- local exact_mode pattern
+ local exact_mode="" pattern
if [[ $cur == $prefix* ]]; then
[[ $cur == "$prefix" ]] && cur+="/"
pattern="$cur*"
- exact_mode=1
+ exact_mode=set
else
pattern="$prefix*/$cur*"
fi
@@ -38,22 +38,22 @@ _smf_complete_fmri()
for fmri in $(svcs -H -o FMRI "$pattern" 2>/dev/null); do
local fmri_part_list fmri_part
- if [[ -z $exact_mode ]]; then
- fmri=${fmri#$prefix/}
+ if [[ ! $exact_mode ]]; then
+ fmri=${fmri#"$prefix/"}
- # we generate all possibles abbrevations for the FMRI
+ # we generate all possibles abbreviations for the FMRI
# no need to have a generic loop as we will have a finite
# number of components
- local ifs="$IFS"
- IFS="/"
- set -- $fmri
- IFS=$ifs
- case $# in
- 1) fmri_part_list=" $1" ;;
- 2) fmri_part_list=" $2 $1/$2" ;;
- 3) fmri_part_list=" $3 $2/$3 $1/$2/$3" ;;
- 4) fmri_part_list=" $4 $3/$4 $2/$3/$4 $1/$2/$3/$4" ;;
- esac
+ local -a tmp
+ if _comp_split -F / tmp "$fmri"; then
+ set -- "${tmp[@]}"
+ case $# in
+ 1) fmri_part_list=" $1" ;;
+ 2) fmri_part_list=" $2 $1/$2" ;;
+ 3) fmri_part_list=" $3 $2/$3 $1/$2/$3" ;;
+ 4) fmri_part_list=" $4 $3/$4 $2/$3/$4 $1/$2/$3/$4" ;;
+ esac
+ fi
else
fmri_part_list="$fmri"
fi
@@ -62,14 +62,14 @@ _smf_complete_fmri()
# we cut them at the first slash
for fmri_part in $fmri_part_list; do
[[ $fmri_part == $cur* ]] || continue
- local first_part=${fmri_part#$cur_prefix}
+ local first_part=${fmri_part#"$cur_prefix"}
first_part=$cur_prefix${first_part%%/*}
[[ $first_part != "$fmri_part" ]] && first_part+="/"
fmri_list+=" $first_part"
done
done
- COMPREPLY=($fmri_list)
+ _comp_split COMPREPLY "$fmri_list"
# here we want to detect if there only one completion proposed and that
# it ends with a slash. That means the users will still have to complete
@@ -83,7 +83,7 @@ _smf_complete_fmri()
((i--))
done
if ((i == 0)); then
- _smf_complete_fmri "${COMPREPLY[0]}" "$prefix"
+ _comp_cmd_svcadm__fmri "${COMPREPLY[0]}" "$prefix"
return
fi
fi
@@ -98,53 +98,54 @@ _smf_complete_fmri()
done
}
-_svcadm()
+_comp_cmd_svcadm()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
local command_list="enable disable restart refresh clear mark milestone"
- local command i
+ local command="" i
for ((i = 1; i < cword; i++)); do
if [[ ${words[i]} == @(enable|disable|restart|refresh|clear|mark|milestone) ]]; then
command=${words[i]}
+ break
fi
done
- if [[ ! -v command ]]; then
+ if [[ ! $command ]]; then
if [[ ${cur} == -* ]]; then
- COMPREPLY=($(compgen -W "-v" -- ${cur}))
+ _comp_compgen -- -W "-v"
else
- COMPREPLY=($(compgen -W "$command_list" -- ${cur}))
+ _comp_compgen -- -W "$command_list"
fi
else
if [[ ${cur} == -* ]]; then
case "$command" in
enable)
- COMPREPLY=($(compgen -W "-r -s -t" -- ${cur}))
+ _comp_compgen -- -W "-r -s -t"
;;
disable)
- COMPREPLY=($(compgen -W "-s -t" -- ${cur}))
+ _comp_compgen -- -W "-s -t"
;;
mark)
- COMPREPLY=($(compgen -W "-I -t" -- ${cur}))
+ _comp_compgen -- -W "-I -t"
;;
milestone)
- COMPREPLY=($(compgen -W "-d" -- ${cur}))
+ _comp_compgen -- -W "-d"
;;
esac
else
- if [[ $command == "mark" ]] && [[ $prev != @(degraded|maintenance) ]]; then
- COMPREPLY=($(compgen -W "degraded maintenance" -- ${cur}))
+ if [[ $command == "mark" && $prev != @(degraded|maintenance) ]]; then
+ _comp_compgen -- -W "degraded maintenance"
elif [[ $command == "milestone" ]]; then
- _smf_complete_fmri "${cur}" "svc:/milestone"
+ _comp_cmd_svcadm__fmri "${cur}" "svc:/milestone"
else
- _smf_complete_fmri "${cur}" "svc:"
+ _comp_cmd_svcadm__fmri "${cur}" "svc:"
fi
fi
fi
} &&
- complete -F _svcadm svcadm
+ complete -F _comp_cmd_svcadm svcadm
# ex: filetype=sh
diff --git a/completions/svk b/completions/svk
index 9079df1..cfa6ede 100644
--- a/completions/svk
+++ b/completions/svk
@@ -1,9 +1,9 @@
# svk(1) completion -*- shell-script -*-
-_svk()
+_comp_cmd_svk()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local commands options command
@@ -16,18 +16,18 @@ _svk()
if ((cword == 1)); then
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--version' -- "$cur"))
+ _comp_compgen -- -W '--version'
else
- COMPREPLY=($(compgen -W "$commands" -- "$cur"))
+ _comp_compgen -- -W "$commands"
fi
else
case $prev in
-F | --file | --targets)
- _filedir
+ _comp_compgen_filedir
return
;;
--encoding)
- _xfunc iconv _iconv_charsets
+ _comp_compgen -x iconv charsets
return
;;
esac
@@ -172,26 +172,24 @@ _svk()
esac
options+=" --help -h"
- COMPREPLY=($(compgen -W "$options" -- "$cur"))
+ _comp_compgen -- -W "$options"
else
case $command in
help | h | \?)
- COMPREPLY=($(compgen -W "$commands environment commands
- intro" -- "$cur"))
+ _comp_compgen -- -W "$commands environment commands intro"
;;
admin)
- COMPREPLY=($(compgen -W 'help deltify dump hotcopy
- list-dblogs list-unused-dblogs load lstxns recover
- rmtxns setlog verify rmcache' -- "$cur"))
+ _comp_compgen -- -W 'help deltify dump hotcopy list-dblogs
+ list-unused-dblogs load lstxns recover rmtxns setlog
+ verify rmcache'
;;
patch)
- COMPREPLY=($(compgen -W '--ls --list --cat --view
- --regen --regenerate --up --update --apply --rm
- --delete' -- "$cur"))
+ _comp_compgen -- -W '--ls --list --cat --view --regen
+ --regenerate --up --update --apply --rm --delete'
;;
sync)
- COMPREPLY=($(compgen -W "$($1 mirror --list \
- 2>/dev/null | awk '/^\//{print $1}')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" mirror --list \
+ 2>/dev/null | _comp_awk '/^\//{print $1}')"
;;
co | checkout | push | pull)
if [[ $cur == //*/* ]]; then
@@ -199,16 +197,16 @@ _svk()
else
path=//
fi
- COMPREPLY=($(compgen -W "$($1 list $path 2>/dev/null |
- command sed -e 's|\(.*\)|'$path'\1|')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" list "$path" 2>/dev/null |
+ command sed -e 's|\(.*\)|'"$path"'\1|')"
;;
*)
- _filedir
+ _comp_compgen_filedir
;;
esac
fi
fi
} &&
- complete -F _svk svk
+ complete -F _comp_cmd_svk svk
# ex: filetype=sh
diff --git a/completions/sync_members b/completions/sync_members
index 397f8b0..e8c07a7 100644
--- a/completions/sync_members
+++ b/completions/sync_members
@@ -1,31 +1,34 @@
# mailman sync_members completion -*- shell-script -*-
-_sync_members()
+_comp_cmd_sync_members()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-w | -g | -d | --welcome-msg | --goodbye-msg | --digest)
- COMPREPLY=($(compgen -W 'y n' -- "$cur"))
+ _comp_compgen -- -W 'y n'
return
;;
--file)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--no-change --welcome-msg --goodbye-msg
- --digest --notifyadmin --file --help' -- "$cur"))
+ _comp_compgen -- -W '--no-change --welcome-msg --goodbye-msg --digest
+ --notifyadmin --file --help'
else
- _xfunc list_lists _mailman_lists
+ # Prefer `list_lists` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -x list_lists mailman_lists
fi
} &&
- complete -F _sync_members sync_members
+ complete -F _comp_cmd_sync_members sync_members
# ex: filetype=sh
diff --git a/completions/synclient b/completions/synclient
index c4a0d42..12a7d54 100644
--- a/completions/synclient
+++ b/completions/synclient
@@ -1,9 +1,9 @@
# bash completion for synclient(1) -*- shell-script -*-
-_synclient()
+_comp_cmd_synclient()
{
- local cur prev words cword
- _init_completion -n = || return
+ local cur prev words cword comp_args
+ _comp_initialize -n = -- "$@" || return
case $prev in
-\? | -h | -V)
@@ -12,13 +12,13 @@ _synclient()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
elif [[ $cur != *=?* ]]; then
- COMPREPLY=($(compgen -S = -W '$($1 -l 2>/dev/null | \
- awk "/^[ \t]/ { print \$1 }")' -- "$cur"))
+ _comp_compgen_split -S = -- "$("$1" -l 2>/dev/null |
+ _comp_awk '/^[ \t]/ { print $1 }')"
compopt -o nospace
fi
} &&
- complete -F _synclient synclient
+ complete -F _comp_cmd_synclient synclient
# ex: filetype=sh
diff --git a/completions/sysbench b/completions/sysbench
index 0af7cc3..7f9e87e 100644
--- a/completions/sysbench
+++ b/completions/sysbench
@@ -1,9 +1,9 @@
# bash completion for sysbench -*- shell-script -*-
-_sysbench()
+_comp_cmd_sysbench()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
--num-threads | --max-requests | --max-time | --thread-stack-size | \
@@ -11,122 +11,121 @@ _sysbench()
return
;;
--init-rng | --debug | --validate)
- COMPREPLY=($(compgen -W 'on off' -- "$cur"))
+ _comp_compgen -- -W 'on off'
return
;;
--test)
- COMPREPLY=($(compgen -W 'fileio cpu memory threads mutex oltp' \
- -- "$cur"))
+ _comp_compgen -- -W 'fileio cpu memory threads mutex oltp'
return
;;
--cpu-max-prime)
return
;;
--file-test-mode)
- COMPREPLY=($(compgen -W 'seqwr seqrewr seqrd rndrd rndwr rndrw' \
- -- "$cur"))
+ _comp_compgen -- -W 'seqwr seqrewr seqrd rndrd rndwr rndrw'
return
;;
--file-io-mode)
- COMPREPLY=($(compgen -W 'sync async fastmmap slowmmap' -- "$cur"))
+ _comp_compgen -- -W 'sync async fastmmap slowmmap'
return
;;
--file-extra-flags)
- COMPREPLY=($(compgen -W 'sync dsync direct' -- "$cur"))
+ _comp_compgen -- -W 'sync dsync direct'
return
;;
--file-fsync-all | --file-fsync-end)
- COMPREPLY=($(compgen -W 'on off' -- "$cur"))
+ _comp_compgen -- -W 'on off'
return
;;
--file-fsync-mode)
- COMPREPLY=($(compgen -W 'fsync fdatasync' -- "$cur"))
+ _comp_compgen -- -W 'fsync fdatasync'
return
;;
--memory-scope)
- COMPREPLY=($(compgen -W 'global local' -- "$cur"))
+ _comp_compgen -- -W 'global local'
return
;;
--memory-hugetlb)
- COMPREPLY=($(compgen -W 'on off' -- "$cur"))
+ _comp_compgen -- -W 'on off'
return
;;
--memory-oper)
- COMPREPLY=($(compgen -W 'read write none' -- "$cur"))
+ _comp_compgen -- -W 'read write none'
return
;;
--memory-access-mode)
- COMPREPLY=($(compgen -W 'seq rnd' -- "$cur"))
+ _comp_compgen -- -W 'seq rnd'
return
;;
--oltp-test-mode)
- COMPREPLY=($(compgen -W 'simple complex nontrx sp' -- "$cur"))
+ _comp_compgen -- -W 'simple complex nontrx sp'
return
;;
--oltp-read-only | --oltp-skip-trx | --oltp-quto-inc | --mysql-ssl)
- COMPREPLY=($(compgen -W 'on off' -- "$cur"))
+ _comp_compgen -- -W 'on off'
return
;;
--oltp-nontrx-mode)
- COMPREPLY=($(compgen -W 'select update_key update_nokey insert
- delete' -- "$cur"))
+ _comp_compgen -- -W 'select update_key update_nokey insert delete'
return
;;
--oltp-dist-type)
- COMPREPLY=($(compgen -W 'uniform gaussian special' -- "$cur"))
+ _comp_compgen -- -W 'uniform gaussian special'
return
;;
--db-driver)
- COMPREPLY=($(compgen -W "$($1 --test=oltp help 2>/dev/null |
+ _comp_compgen_split -- "$("$1" --test=oltp help 2>/dev/null |
command sed -e '/^.*database drivers:/,/^$/!d' \
- -ne 's/^ *\([^ ]*\) .*/\1/p')" -- "$cur"))
+ -ne 's/^ *\([^ ]*\) .*/\1/p')"
return
;;
--db-ps-mode)
- COMPREPLY=($(compgen -W 'auto disable' -- "$cur"))
+ _comp_compgen -- -W 'auto disable'
return
;;
--mysql-socket)
- _filedir sock
+ _comp_compgen_filedir sock
return
;;
--mysql-table-engine)
- COMPREPLY=($(compgen -W 'myisam innodb bdb heap ndbcluster
- federated' -- "$cur"))
+ _comp_compgen -- -W 'myisam innodb bdb heap ndbcluster federated'
return
;;
--mysql-engine-trx)
- COMPREPLY=($(compgen -W 'yes no auto' -- "$cur"))
+ _comp_compgen -- -W 'yes no auto'
return
;;
--*)
- $split && return
+ [[ $was_split ]] && return
;;
esac
# find out which test we're running
- local i test
+ local i test="" has_test=""
for ((i = 1; i < ${#words[@]} - 1; i++)); do
# TODO --test= is deprecated, bare test name preferred
- if [[ ${words[i]} == --test* ]]; then
+ if [[ ${words[i]} == --test=* ]]; then
test=${words[i]#*=}
+ has_test=set
break
fi
done
- local opts=$(_parse_help "$1")
- if [[ -v test ]]; then
- local help=($(_parse_help "$1" "--test=$test help"))
- opts="${opts/--test=/} ${help[*]} prepare run cleanup help version"
+ local opts
+ _comp_compgen -v opts help
+ if [[ $has_test ]]; then
+ opts=("${opts[@]/#--test=/}")
+ _comp_compgen -aRv opts help -- --test="$test" help
+ opts+=(prepare run cleanup help version)
fi
- if [[ $cur == -* || ! -v test ]]; then
- COMPREPLY=($(compgen -W "$opts" -- "$cur"))
+ if [[ $cur == -* || ! $has_test ]]; then
+ _comp_compgen -- -W '"${opts[@]}"'
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- COMPREPLY=($(compgen -W "prepare run cleanup help version" -- "$cur"))
+ _comp_compgen -- -W "prepare run cleanup help version"
fi
} &&
- complete -F _sysbench sysbench
+ complete -F _comp_cmd_sysbench sysbench
# ex: filetype=sh
diff --git a/completions/sysctl b/completions/sysctl
index 005452d..4062a7f 100644
--- a/completions/sysctl
+++ b/completions/sysctl
@@ -1,31 +1,33 @@
# bash completion for sysctl -*- shell-script -*-
-_sysctl()
+_comp_cmd_sysctl()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[rpf]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | --pattern | -!(-*)[hVr])
+ --help | --version | --pattern | -${noargopts}[hVr])
return
;;
- --load | -!(-*)[pf])
- _filedir conf
+ --load | -${noargopts}[pf])
+ _comp_compgen_filedir conf
return
;;
esac
if [[ $cur == -* ]]; then
- local opts="$(_parse_help "$1")"
- COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
else
local suffix=
[[ $prev == -w ]] && suffix="="
- COMPREPLY=($(compgen -S "$suffix" -W \
- "$(PATH="$PATH:/sbin" $1 -N -a 2>/dev/null)" -- "$cur"))
+ _comp_compgen_split -S "$suffix" -- "$(
+ PATH="$PATH:/sbin" $1 -N -a 2>/dev/null
+ )"
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _sysctl sysctl
+ complete -F _comp_cmd_sysctl sysctl
# ex: filetype=sh
diff --git a/completions/tar b/completions/tar
index 04b7fc0..83a4073 100644
--- a/completions/tar
+++ b/completions/tar
@@ -12,15 +12,15 @@
#
# We rather advice the 'tar -czf /tmp/archive.tar -T patterns.txt' format of
# arguments. Though, if user starts the 'first' tar argument without leading
-# dash, we treat the command line apropriately.
+# dash, we treat the command line appropriately.
#
#
# long/short options origin
# -------------------------
#
# For GNU tar, everything is parsed from `tar --help` output so not so much
-# per-distribution work should be needed. The _parse_help does not seem to be
-# good enough so parsed here directly.
+# per-distribution work should be needed. The _comp_compgen_help does not seem
+# to be good enough so parsed here directly.
#
#
# FIXME: --starting-file (-K) (should be matched for extraction only)
@@ -37,8 +37,29 @@
# - mode option should be advised only once
# - format option should be advised only once
# ...
+#
+# Tar files vs internal paths
+# ===========================
+#
+# bash's programmable completion is limited in how it handles the list of
+# possible completions it returns.
+#
+# Because the paths returned from within the tar file are likely not existing
+# paths on the file system, `-o dirnames` must be passed to the `complete`
+# built-in to make it treat them as such. However, then bash will append a
+# space when completing on directories during pathname completion to the tar
+# files themselves.
+#
+# It's more important to have proper completion of paths to tar files than it
+# is to have completion for their contents, so this sacrifice was made and
+# `-o filenames` is used with complete instead by default. Setting the
+# `$BASH_COMPLETION_CMD_TAR_INTERNAL_PATHS` environment variable to a non-null
+# value *before sourcing* this completion toggles that the other way around.
-__gtar_parse_help_opt()
+_comp_deprecate_var 2.12 \
+ COMP_TAR_INTERNAL_PATHS BASH_COMPLETION_CMD_TAR_INTERNAL_PATHS
+
+_comp_cmd_gtar__parse_help_opt()
{
local opttype arg opt separator optvar
opttype=long
@@ -77,35 +98,36 @@ __gtar_parse_help_opt()
eval "$optvar=\"\$$optvar$separator\"\"$opt\""
}
-__gtar_parse_help_line()
+_comp_cmd_gtar__parse_help_line()
{
local i
-
- for i in $1; do
- case "$i" in
- # regular options
- --* | -*)
- __gtar_parse_help_opt "$i" "$2"
- ;;
-
- # end once there is single non-option word
- *)
- break
- ;;
- esac
- done
+ local -a tmp
+ while read -ra tmp; do
+ for i in "${tmp[@]}"; do
+ case "$i" in
+ # regular options
+ --* | -*)
+ _comp_cmd_gtar__parse_help_opt "$i" "$2"
+ ;;
+
+ # end once there is single non-option word
+ *)
+ break
+ ;;
+ esac
+ done
+ done <<<"$1"
}
-__gnu_tar_parse_help()
+_comp_cmd_gtar__parse_help()
{
local str line arg
- while IFS= read line; do
+ while IFS= read -r line; do
# Ok, this requires some comment probably. The GNU help output prints
# options on lines beginning with spaces. After that, there is one
# or more options separated by ', ' separator string. We are matching
# like this then: ^<spaces>(<separator>?<option>)+<whatever>$
- if [[ $line =~ \
- ^[[:blank:]]{1,10}(((,[[:blank:]])?(--?([\]\[a-zA-Z0-9?=-]+))(,[[:space:]])?)+).*$ ]]; then
+ if [[ $line =~ ^[[:blank:]]{1,10}(((,[[:blank:]])?(--?([\]\[a-zA-Z0-9?=-]+))(,[[:space:]])?)+).*$ ]]; then
line=${BASH_REMATCH[1]}
str="${line//,/ }"
@@ -116,10 +138,10 @@ __gnu_tar_parse_help()
# variable may contain e.g. '-X, --XXX[=NAME], -XXX2[=NAME]'.
arg=none
if [[ $line =~ --[A-Za-z0-9-]+(\[?)= ]]; then
- [[ -n ${BASH_REMATCH[1]} ]] && arg=opt || arg=req
+ [[ ${BASH_REMATCH[1]} ]] && arg=opt || arg=req
fi
- __gtar_parse_help_line "$str" "$arg"
+ _comp_cmd_gtar__parse_help_line "$str" "$arg"
fi
done <<<"$(tar --help)"
@@ -130,59 +152,55 @@ __gnu_tar_parse_help()
}
# Hack: parse --warning keywords from tar's error output
-__gtar_parse_warnings()
+_comp_cmd_gtar__parse_warnings()
{
- local line
- LC_ALL=C tar --warning= 2>&1 | while IFS= read line; do
+ local -a warnings=()
+ local lines line
+ _comp_split -l lines "$(LC_ALL=C exec tar --warning= 2>&1)"
+ for line in "${line[@]}"; do
if [[ $line =~ ^[[:blank:]]*-[[:blank:]]*[\`\']([a-zA-Z0-9-]+)\'$ ]]; then
- echo "${BASH_REMATCH[1]} no-${BASH_REMATCH[1]}"
+ warnings+=("${BASH_REMATCH[1]}" "no-${BASH_REMATCH[1]}")
fi
done
+ _comp_compgen -- -W '"${warnings[@]}"'
}
-# Helper to obtain last character of string.
-__tar_last_char()
-{
- echo "${1:$((${#1} - 1))}"
-}
-
-__tar_parse_old_opt()
+_comp_cmd_tar__parse_old_opt()
{
local first_word char
# current word is the first word
- [[ $cword -eq 1 && -n $cur && ${cur:0:1} != '-' ]] &&
- old_opt_progress=1
+ [[ $cword -eq 1 && $cur && ${cur:0:1} != '-' ]] &&
+ old_opt_progress=set
# check that first argument does not begin with "-"
first_word=${words[1]}
- [[ -n $first_word && ${first_word:0:1} != "-" ]] &&
- old_opt_used=1
+ [[ $first_word && ${first_word:0:1} != "-" ]] &&
+ old_opt_used=set
# parse the old option (if present) contents to allow later code expect
# corresponding arguments
- if ((old_opt_used == 1)); then
+ if [[ $old_opt_used ]]; then
char=${first_word:0:1}
- while [[ -n $char ]]; do
- if __tar_is_argreq "$char"; then
+ while [[ $char ]]; do
+ if _comp_cmd_tar__is_argreq "$char"; then
old_opt_parsed+=("$char")
fi
- first_word=${first_word##$char}
+ first_word=${first_word##"$char"}
char=${first_word:0:1}
done
fi
}
# Make the analysis of whole command line.
-__tar_preparse_cmdline()
+_comp_cmd_tar__preparse_cmdline()
{
- local first_arg i modes="ctxurdA"
+ local first_arg=set i modes="ctxurdA"
shift # progname
- __tar_parse_old_opt
+ _comp_cmd_tar__parse_old_opt
- first_arg=1
for i in "$@"; do
case "$i" in
--delete | --test-label)
@@ -201,36 +219,36 @@ __tar_preparse_cmdline()
;;
*[$modes]*)
# Only the first arg may be "MODE" without leading dash
- if ((first_arg == 1)); then
+ if [[ $first_arg ]]; then
tar_mode=${i//[^$modes]/}
tar_mode=${tar_mode:0:1}
tar_mode_arg=$i
fi
;;
esac
- first_arg=0
+ first_arg=""
done
}
# Generate completions for -f/--file.
-__tar_file_option()
+_comp_cmd_tar__file_option()
{
local ext="$1"
case "$tar_mode" in
c)
# no need to advise user to re-write existing tarball
- _filedir -d
+ _comp_compgen_filedir -d
;;
*)
- _filedir "$ext"
+ _comp_compgen_filedir "$ext"
;;
esac
}
# Returns truth if option requires argument. No equal sign must be pasted.
# Accepts option in format: 'c', '-c', '--create'
-__tar_is_argreq()
+_comp_cmd_tar__is_argreq()
{
local opt
opt=$1
@@ -250,14 +268,14 @@ __tar_is_argreq()
}
# Called only for short parameter
-__tar_complete_mode()
+_comp_cmd_tar__mode()
{
local short_modes rawopt generated \
allshort_raw_unused allshort_raw \
filler i
short_modes="ctx"
- [[ ! -v basic_tar ]] && short_modes="ctxurdA"
+ [[ ! $basic_tar ]] && short_modes="ctxurdA"
# Remove prefix when needed
rawopt=${cur#-}
@@ -270,25 +288,25 @@ __tar_complete_mode()
# when user passed something like 'tar cf' do not put the '-' before
filler=
- if [[ -z $cur && ! -v basic_tar ]]; then
+ if [[ ! $cur && ! $basic_tar ]]; then
filler=-
fi
generated=""
for ((i = 0; 1; i++)); do
local c="${short_modes:i:1}"
- [[ -z $c ]] && break
+ [[ ! $c ]] && break
generated+=" $filler$cur$c"
done
- COMPREPLY=($(compgen -W "$generated"))
+ _comp_compgen -R -- -W "$generated"
return 0
fi
# The last short option requires argument, like '-cf<TAB>'. Cut the
# completion here to enforce argument processing.
- if ((old_opt_progress == 0)) &&
- __tar_is_argreq "$(__tar_last_char "$cur")"; then
+ if [[ ! $old_opt_progress ]] &&
+ _comp_cmd_tar__is_argreq "${cur: -1}"; then
COMPREPLY=("$cur") && return 0
fi
@@ -300,25 +318,25 @@ __tar_complete_mode()
generated=
for ((i = 0; 1; i++)); do
local c="${allshort_raw_unused:i:1}"
- [[ -z $c ]] && break
+ [[ ! $c ]] && break
generated+=" $cur$c"
done
- COMPREPLY=($(compgen -W "$generated"))
+ _comp_compgen -R -- -W "$generated"
return 0
}
-__gtar_complete_lopts()
+_comp_cmd_tar__gnu_long_options()
{
local rv
- COMPREPLY=($(compgen -W "$long_opts" -- "$cur"))
+ _comp_compgen -- -W "$long_opts"
rv=$?
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return $rv
}
-__gtar_complete_sopts()
+_comp_cmd_tar__gnu_short_options()
{
local generated short_mode_opts i c
short_mode_opts="ctxurdA"
@@ -326,52 +344,51 @@ __gtar_complete_sopts()
for ((i = 0; 1; i++)); do
c="${allshort_raw_unused:i:1}"
- [[ -z $c ]] && break
+ [[ ! $c ]] && break
generated+=" $cur$c"
done
- COMPREPLY=($(compgen -W "$generated" -- "$cur"))
+ _comp_compgen -- -W "$generated"
}
-__tar_try_mode()
+_comp_cmd_tar__try_mode()
{
case "$cur" in
--*)
# posix tar does not support long opts
- [[ -v basic_tar ]] && return 0
- __gtar_complete_lopts
+ [[ $basic_tar ]] && return 0
+ _comp_cmd_tar__gnu_long_options
return $?
;;
-*)
- # posix tar does not support short optios
- [[ -v basic_tar ]] && return 0
+ # posix tar does not support short options
+ [[ $basic_tar ]] && return 0
- __tar_complete_mode && return 0
+ _comp_cmd_tar__mode && return 0
;;
*)
if [[ $cword -eq 1 || $tar_mode == none ]]; then
- __tar_complete_mode && return 0
+ _comp_cmd_tar__mode && return 0
fi
;;
esac
return 1
}
-__tar_adjust_PREV_from_old_option()
+_comp_cmd_tar__adjust_PREV_from_old_option()
{
# deal with old style arguments here
# $ tar cfTC # expects this sequence of arguments:
# $ tar cfTC ARCHIVE_FILE PATTERNS_FILE CHANGE_DIR
- if ((old_opt_used == 1 && cword > 1 && \
- cword < ${#old_opt_parsed[@]} + 2)); then
+ if [[ $old_opt_used ]] && ((cword > 1 && cword < ${#old_opt_parsed[@]} + 2)); then
# make e.g. 'C' option from 'cffCT'
prev="-${old_opt_parsed[cword - 2]}"
fi
}
-__tar_extract_like_mode()
+_comp_cmd_tar__extract_like_mode()
{
local i
for i in x d t delete; do
@@ -380,14 +397,15 @@ __tar_extract_like_mode()
return 1
}
-__tar_try_list_archive()
+_comp_cmd_tar__try_list_archive()
{
- local tarball tarbin untar i
+ local tarball="" tarbin untar i
- __tar_extract_like_mode || return 1
+ _comp_cmd_tar__extract_like_mode || return 1
# This all is just to approach directory completion from "virtual"
- # directory structure in tarball (for which the _filedir is unusable)
+ # directory structure in tarball (for which the _comp_compgen_filedir is
+ # unusable)
set -- "${words[@]}"
tarbin=$1
@@ -400,29 +418,39 @@ __tar_try_list_archive()
break
fi
done
- if [[ -n $tarball ]]; then
- local IFS=$'\n'
- COMPREPLY=($(compgen -o filenames -W "$(
+ if [[ $tarball ]]; then
+ _comp_compgen -c "$(printf %q "$cur")" split -lo filenames -- "$(
$tarbin $untar "$tarball" 2>/dev/null |
- while read line; do
- printf "%q\n" "$(printf %q"\n" "$line")"
+ while read -r line; do
+ printf "%q\n" "$line"
done
- )" -- "$(printf "%q\n" "$cur")"))
+ )"
return 0
fi
}
-__tar_cleanup_prev()
+_comp_cmd_tar__cleanup_prev()
{
if [[ $prev =~ ^-[a-zA-Z0-9?]*$ ]]; then
# transform '-caf' ~> '-f'
- prev="-$(__tar_last_char "$prev")"
+ prev="-${prev: -1}"
fi
}
-__tar_detect_ext()
+_comp_cmd_tar__detect_ext()
{
- local tars='@(@(tar|gem|spkg)?(.@(Z|[bgx]z|bz2|lz?(ma|o)|zst))|t@([abglx]z|b?(z)2|zst))'
+ local tars='@(@(tar|spkg)?(.@(Z|[bgx]z|bz2|lz?(ma|o)|zst))|t@([abglx]z|b?(z)2|zst)|cbt|gem|xbps)'
+ if [[ ${COMP_WORDS[0]} == ?(*/)bsdtar ]]; then
+ # https://github.com/libarchive/libarchive/wiki/LibarchiveFormats
+ tars=${tars/%\)/|pax|cpio|iso|zip|@(j|x)ar|mtree|a|7z|warc}
+ if _comp_cmd_tar__extract_like_mode; then
+ # read only
+ tars+="|l@(ha|zh)|rar|cab)"
+ else
+ # write only
+ tars+="|shar)"
+ fi
+ fi
ext="$tars"
case "$tar_mode_arg" in
@@ -430,7 +458,7 @@ __tar_detect_ext()
# Should never happen?
;;
?(-)*[cr]*f)
- ext='@(tar|gem|spkg)'
+ ext='@(tar|gem|spkg|cbt|xpbs)'
case ${words[1]} in
*a*) ext="$tars" ;;
*z*) ext='t?(ar.)gz' ;;
@@ -443,24 +471,24 @@ __tar_detect_ext()
# Pass through using defaults above
;;
*[Zz]*f)
- ext='@(@(t?(ar.)|gem.|spkg.)@(gz|Z)|taz)'
+ ext='@(@(t?(ar.)|spkg.)@(gz|Z)|taz)'
;;
*[jy]*f)
- ext='@(@(t?(ar.)|gem.)bz?(2)|spkg|tb2)'
+ ext='@(t?(ar.)bz?(2)|spkg|tb2)'
;;
*[J]*f)
- ext='@(@(tar|gem|spkg).@(lzma|xz)|t[lx]z)'
+ ext='@(@(tar|spkg).@(lzma|xz)|t[lx]z)'
;;
esac
}
-_gtar()
+_comp_cmd_tar__gnu()
{
- local long_opts short_opts \
+ local long_opts short_opts basic_tar="" \
long_arg_none="" long_arg_opt="" long_arg_req="" \
short_arg_none="" short_arg_opt="" short_arg_req="" \
- tar_mode tar_mode_arg old_opt_progress=0 \
- old_opt_used=0 old_opt_parsed=()
+ tar_mode tar_mode_arg old_opt_progress="" \
+ old_opt_used="" old_opt_parsed=()
# Main mode, e.g. -x or -c (extract/creation)
local tar_mode=none
@@ -469,81 +497,93 @@ _gtar()
# FIXME: handle long options
local tar_mode_arg=
- if [[ -v BASHCOMP_TAR_OPT_DEBUG ]]; then
+ if [[ -v _comp_cmd_tar__debug ]]; then
set -x
- PS4='$BASH_SOURCE:$LINENO: '
+ local PS4='$BASH_SOURCE:$LINENO: '
fi
- local cur prev words cword split
+ local cur prev words cword was_split comp_args
- _init_completion -s || return
+ _comp_initialize -s -- "$@" || return
# Fill the {long,short}_{opts,arg*}
- __gnu_tar_parse_help
+ _comp_cmd_gtar__parse_help
- __tar_preparse_cmdline "${words[@]}"
+ _comp_cmd_tar__preparse_cmdline "${words[@]}"
local ext
- __tar_detect_ext
+ _comp_cmd_tar__detect_ext
while true; do # just-for-easy-break while, not looping
- __tar_adjust_PREV_from_old_option
- __tar_posix_prev_handle && break
- __tar_cleanup_prev
+ _comp_cmd_tar__adjust_PREV_from_old_option
+ _comp_cmd_tar__posix_prev_handle && break
+ _comp_cmd_tar__cleanup_prev
# Handle all options *REQUIRING* argument. Optional arguments are up to
# user (TODO: is there any sane way to deal with this?). This case
# statement successes only if there already is PREV.
+ local noargopts='!(-*|*[TXgCFIfH]*)'
+ # shellcheck disable=SC2254
case $prev in
- --directory | -!(-*)C)
- _filedir -d
+ --add-file | --exclude | --exclude-ignore | \
+ --exclude-ignore-recursive | --exclude-tag | \
+ --exclude-tag-all | --exclude-tag-under | --files-from | \
+ --exclude-from | --listed-incremental | --group-map | \
+ --mtime | --owner-map | --volno-file | --newer | \
+ --after-date | --index-file | -${noargopts}[TXg])
+ _comp_compgen_filedir
+ break
+ ;;
+ --directory | -${noargopts}C)
+ _comp_compgen_filedir -d
+ break
+ ;;
+ --hole-detection)
+ _comp_compgen -- -W 'raw seek'
+ break
+ ;;
+ --to-command | --info-script | --new-volume-script | \
+ --rmt-command | --rsh-command | --use-compress-program | \
+ -${noargopts}[FI])
+ _comp_compgen_commands
break
;;
--atime-preserve)
- COMPREPLY=($(compgen -W 'replace system' -- "$cur"))
+ _comp_compgen -- -W 'replace system'
break
;;
--group)
- COMPREPLY=($(compgen -g -- "$cur"))
+ _comp_compgen -- -g
break
;;
--owner)
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
break
;;
- --info-script | --new-volume-script | --rmt-command | --rsh-command | \
- --use-compress-program | -!(-*)[FI])
- compopt -o filenames
- COMPREPLY=($(compgen -c -- "$cur"))
+ --sort)
+ _comp_compgen -- -W 'none name inode'
break
;;
- --volno-file | --add-file | --files-from | --exclude-from | \
- --index-file | --listed-incremental | -!(-*)[TXg])
- _filedir
+ --file | -${noargopts}f)
+ _comp_cmd_tar__file_option "$ext"
break
;;
- --format | -!(-*)H)
- COMPREPLY=($(compgen -W 'gnu oldgnu pax posix ustar v7' \
- -- "$cur"))
+ --format | -${noargopts}H)
+ _comp_compgen -- -W 'gnu oldgnu pax posix ustar v7'
break
;;
--quoting-style)
- COMPREPLY=($(compgen -W 'literal shell shell-always c c-maybe
- escape locale clocale' -- "$cur"))
+ _comp_compgen -- -W 'literal shell shell-always shell-escape
+ shell-escape-always c c-maybe escape locale clocale'
break
;;
--totals)
- COMPREPLY=($(compgen -W 'SIGHUP SIGQUIT SIGINT SIGUSR1 SIGUSR2' \
- -- "$cur"))
+ _comp_compgen -- -W 'SIGHUP SIGQUIT SIGINT SIGUSR1 SIGUSR2'
break
;;
--warning)
- COMPREPLY=($(compgen -W "$(__gtar_parse_warnings)" -- "$cur"))
- break
- ;;
- --file | -!(-*)f)
- __tar_file_option "$ext"
+ _comp_cmd_gtar__parse_warnings
break
;;
--*)
@@ -557,12 +597,12 @@ _gtar()
# if there is some unknown option with '=', for example
# (literally) user does --nonexistent=<TAB>, we do not want
# continue also
- $split && break
+ [[ $was_split ]] && break
# Most probably, when code goes here, the PREV variable contains
# some string from "$long_arg_none" and we want continue.
;;
- -!(-*)[a-zA-Z0-9?])
+ -${noargopts}[a-zA-Z0-9?])
# argument required but no completion yet
[[ $short_arg_req =~ ${prev##-} ]] && break
;;
@@ -578,17 +618,17 @@ _gtar()
# Handle the main operational mode of tar. We should do it as soon as
# possible.
- __tar_try_mode && break
+ _comp_cmd_tar__try_mode && break
# handle others
case "$cur" in
--*)
- __gtar_complete_lopts
+ _comp_cmd_tar__gnu_long_options
break
;;
-*)
# called only if it is *not* first parameter
- __gtar_complete_sopts
+ _comp_cmd_tar__gnu_short_options
break
;;
esac
@@ -597,27 +637,26 @@ _gtar()
# was truth - the 'break' statement would have been already called
((cword == 1)) && break
- __tar_try_list_archive && break
+ _comp_cmd_tar__try_list_archive && break
# file completion on relevant files
if [[ $tar_mode != none ]]; then
- _filedir
+ _comp_compgen_filedir
fi
break
done # just-for-easy-break while
- if [[ -v BASHCOMP_TAR_OPT_DEBUG ]]; then
+ if [[ -v _comp_cmd_tar__debug ]]; then
set +x
- unset PS4
fi
}
-__tar_posix_prev_handle()
+_comp_cmd_tar__posix_prev_handle()
{
case "$prev" in
-f)
- __tar_file_option "$ext"
+ _comp_cmd_tar__file_option "$ext"
return 0
;;
-b)
@@ -628,13 +667,13 @@ __tar_posix_prev_handle()
return 1
}
-_posix_tar()
+_comp_cmd_tar__posix()
{
- local long_opts short_opts basic_tar \
+ local long_opts short_opts basic_tar=set \
long_arg_none="" long_arg_opt long_arg_req="" \
short_arg_none short_arg_opt short_arg_req \
- tar_mode tar_mode_arg old_opt_progress=0 \
- old_opt_used=1 old_opt_parsed=()
+ tar_mode tar_mode_arg old_opt_progress="" \
+ old_opt_used=set old_opt_parsed=()
# Main mode, e.g. -x or -c (extract/creation)
local tar_mode=none
@@ -642,11 +681,10 @@ _posix_tar()
# The mode argument, e.g. -cpf or -c
local tar_mode_arg=
- local cur prev words cword split
+ local cur prev words cword was_split comp_args
- _init_completion -s || return
+ _comp_initialize -s -- "$@" || return
- basic_tar=yes
tar_mode=none
# relatively compatible modes are {c,t,x}
@@ -655,57 +693,57 @@ _posix_tar()
short_arg_none="wmv"
short_opts="$short_arg_req$short_arg_none"
- __tar_preparse_cmdline "${words[@]}"
+ _comp_cmd_tar__preparse_cmdline "${words[@]}"
local ext
- __tar_detect_ext
+ _comp_cmd_tar__detect_ext
- __tar_adjust_PREV_from_old_option
+ _comp_cmd_tar__adjust_PREV_from_old_option
- __tar_posix_prev_handle && return
+ _comp_cmd_tar__posix_prev_handle && return
- __tar_try_mode && return
+ _comp_cmd_tar__try_mode && return
- __tar_try_list_archive && return
+ _comp_cmd_tar__try_list_archive && return
# file completion on relevant files
- _filedir
+ _comp_compgen_filedir
}
-_tar()
+_comp_cmd_tar()
{
local cmd=${COMP_WORDS[0]} func line
- line="$($cmd --version 2>/dev/null)"
+ line="$("$cmd" --version 2>/dev/null)"
case "$line" in
*GNU*)
- func=_gtar
+ func=_comp_cmd_tar__gnu
;;
*)
- func=_posix_tar
+ func=_comp_cmd_tar__posix
;;
esac
$func "$@"
# Install real completion for subsequent completions
- if [[ ${COMP_TAR_INTERNAL_PATHS-} ]]; then
+ if [[ ${BASH_COMPLETION_CMD_TAR_INTERNAL_PATHS-} ]]; then
complete -F $func -o dirnames tar
else
complete -F $func tar
fi
- unset -f _tar
+ unset -f "$FUNCNAME"
}
-if [[ ${COMP_TAR_INTERNAL_PATHS-} ]]; then
- complete -F _tar -o dirnames tar
- complete -F _gtar -o dirnames gtar
- complete -F _posix_tar -o dirnames bsdtar
- complete -F _posix_tar -o dirnames star
+if [[ ${BASH_COMPLETION_CMD_TAR_INTERNAL_PATHS-} ]]; then
+ complete -F _comp_cmd_tar -o dirnames tar
+ complete -F _comp_cmd_tar__gnu -o dirnames gtar
+ complete -F _comp_cmd_tar__posix -o dirnames bsdtar
+ complete -F _comp_cmd_tar__posix -o dirnames star
else
- complete -F _tar tar
- complete -F _gtar gtar
- complete -F _posix_tar bsdtar
- complete -F _posix_tar star
+ complete -F _comp_cmd_tar tar
+ complete -F _comp_cmd_tar__gnu gtar
+ complete -F _comp_cmd_tar__posix bsdtar
+ complete -F _comp_cmd_tar__posix star
fi
# ex: filetype=sh
diff --git a/completions/tcpdump b/completions/tcpdump
index 9a7c2e9..f09dc6f 100644
--- a/completions/tcpdump
+++ b/completions/tcpdump
@@ -1,64 +1,64 @@
# bash completion for tcpdump -*- shell-script -*-
-_tcpdump()
+_comp_cmd_tcpdump()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[rwFVimTzZBcCDEGMsWyjQ]*)'
+ # shellcheck disable=SC2254
case $prev in
- -!(-*)[rwFV])
- _filedir
+ -${noargopts}[rwFV])
+ _comp_compgen_filedir
return
;;
- --interface | -!(-*)i)
- _available_interfaces -a
+ --interface | -${noargopts}i)
+ _comp_compgen_available_interfaces -a
return
;;
- -!(-*)m)
- _filedir mib
+ -${noargopts}m)
+ _comp_compgen_filedir mib
return
;;
- -!(-*)T)
- COMPREPLY=($(compgen -W 'aodv carp cnfp lmp pgm pgm_zmtp1 radius
- resp rpc rtcp rtp rtcp snmp tftp vat vxlan wb zmtp1' \
- -- "$cur"))
+ -${noargopts}T)
+ _comp_compgen -- -W 'aodv carp cnfp lmp pgm pgm_zmtp1 radius resp
+ rpc rtcp rtp rtcp snmp tftp vat vxlan wb zmtp1'
return
;;
- -!(-*)z)
- compopt -o filenames
- COMPREPLY=($(compgen -c -- "$cur"))
+ -${noargopts}z)
+ _comp_compgen_commands
return
;;
- --relinquish-privileges | -!(-*)Z)
- _allowed_users
+ --relinquish-privileges | -${noargopts}Z)
+ _comp_compgen_allowed_users
return
;;
- -!(-*)[BcCDEGMsWy])
+ -${noargopts}[BcCDEGMsWy])
return
;;
- --time-stamp-type | -!(-*)j)
- COMPREPLY=($(compgen -W 'host host_lowprec host_hiprec adapter
- adapter_unsynced' -- "$cur"))
+ --time-stamp-type | -${noargopts}j)
+ _comp_compgen -- -W 'host host_lowprec host_hiprec adapter
+ adapter_unsynced'
return
;;
- --direction | -!(-*)Q)
- COMPREPLY=($(compgen -W 'in out inout' -- "$cur"))
+ --direction | -${noargopts}Q)
+ _comp_compgen -- -W 'in out inout'
return
;;
--time-stamp-precision)
- COMPREPLY=($(compgen -W 'micro nano' -- "$cur"))
+ _comp_compgen -- -W 'micro nano'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _tcpdump tcpdump
+ complete -F _comp_cmd_tcpdump tcpdump
# ex: filetype=sh
diff --git a/completions/tcpkill b/completions/tcpkill
index 189d928..87bf51a 100644
--- a/completions/tcpkill
+++ b/completions/tcpkill
@@ -1,22 +1,22 @@
# tcpkill completion -*- shell-script -*-
-_tcpkill()
+_comp_cmd_tcpkill()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*i)
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-i -1 -2 -3 -4 -5 -6 -7 -8 -9' -- "$cur"))
+ _comp_compgen -- -W '-i -1 -2 -3 -4 -5 -6 -7 -8 -9'
fi
} &&
- complete -F _tcpkill tcpkill
+ complete -F _comp_cmd_tcpkill tcpkill
# ex: filetype=sh
diff --git a/completions/tcpnice b/completions/tcpnice
index c6a94d6..b33d7db 100644
--- a/completions/tcpnice
+++ b/completions/tcpnice
@@ -1,22 +1,22 @@
# tcpnice completion -*- shell-script -*-
-_tcpnice()
+_comp_cmd_tcpnice()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*i)
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
fi
} &&
- complete -F _tcpnice tcpnice
+ complete -F _comp_cmd_tcpnice tcpnice
# ex: filetype=sh
diff --git a/completions/timeout b/completions/timeout
index 32ff2e3..f5115d2 100644
--- a/completions/timeout
+++ b/completions/timeout
@@ -1,39 +1,38 @@
# timeout(1) completion -*- shell-script -*-
-_timeout()
+_comp_cmd_timeout()
{
- local cur prev words cword split i found=false
- _init_completion -s || return
+ local cur prev words cword was_split comp_args i
+ _comp_initialize -s -- "$@" || return
- for ((i = 1; i <= COMP_CWORD; i++)); do
- if [[ ${COMP_WORDS[i]} != -* && ${COMP_WORDS[i - 1]} != = ]]; then
- if $found; then
- _command_offset $i
- return
- fi
- found=true
+ local noargopts='!(-*|*[ks]*)'
+ for ((i = 1; i < cword; i++)); do
+ if [[ ${words[i]} != -* ]]; then
+ _comp_command_offset "$((i + 1))"
+ return
fi
- [[ ${COMP_WORDS[i]} == -@(-kill-after|-signal|!(-*)[ks]) ]] && ((i++))
+ # shellcheck disable=SC2254
+ [[ ${words[i]} == -@(-kill-after|-signal|${noargopts}[ks]) ]] && ((i++))
done
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | --kill-after | -!(-*)k)
+ --help | --version | --kill-after | -${noargopts}k)
return
;;
- --signal | -!(-*)s)
- _signals
+ --signal | -${noargopts}s)
+ _comp_compgen_signals
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- local opts=$(_parse_help "$1")
- COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _timeout timeout
+ complete -F _comp_cmd_timeout timeout
# ex: filetype=sh
diff --git a/completions/tipc b/completions/tipc
index 44ade36..11d35a6 100644
--- a/completions/tipc
+++ b/completions/tipc
@@ -1,26 +1,26 @@
# tipc(8) completion -*- shell-script -*-
-_tipc_media()
+_comp_cmd_tipc__media()
{
local optind=$1
if ((cword == optind)); then
- COMPREPLY=($(compgen -W 'media' -- $cur))
+ _comp_compgen -- -W 'media'
return 0
elif ((cword == optind + 1)); then
- COMPREPLY=($(compgen -W 'udp eth ib' -- $cur))
+ _comp_compgen -- -W 'udp eth ib'
return 0
fi
return 1
}
-_tipc_bearer()
+_comp_cmd_tipc__bearer()
{
local optind=$1
- local media i
+ local media="" i
- if _tipc_media $optind; then
+ if _comp_cmd_tipc__media "$optind"; then
return
fi
@@ -33,52 +33,54 @@ _tipc_bearer()
if ((cword == optind + 2)); then
case "$media" in
"udp")
- COMPREPLY=($(compgen -W 'name' -- $cur))
+ _comp_compgen -- -W 'name'
;;
"eth" | "ib")
- COMPREPLY=($(compgen -W 'device' -- $cur))
+ _comp_compgen -- -W 'device'
;;
esac
elif ((cword == optind + 3)); then
case "$media" in
"udp")
- local names=$(tipc bearer list 2>/dev/null | awk -F: '/^udp:/ {print $2}')
- COMPREPLY=($(compgen -W '$names' -- $cur))
+ local names=$(
+ tipc bearer list 2>/dev/null | _comp_awk -F : '/^udp:/ {print $2}'
+ )
+ _comp_compgen -- -W '$names'
;;
"eth")
local interfaces=$(command ls /sys/class/net/)
- COMPREPLY=($(compgen -W '$interfaces' -- $cur))
+ _comp_compgen -- -W '$interfaces'
;;
esac
fi
}
-_tipc_link_opts()
+_comp_cmd_tipc__link_opts()
{
- COMPREPLY=($(compgen -W 'priority tolerance window' -- $cur))
+ _comp_compgen -- -W 'priority tolerance window'
}
-_tipc_link()
+_comp_cmd_tipc__link()
{
local optind=$1
local filter=$2
if ((cword == optind)); then
- COMPREPLY=($(compgen -W 'link' -- $cur))
+ _comp_compgen -- -W 'link'
elif ((cword == optind + 1)); then
# awk drops link state and last trailing :
local links=$(tipc link list 2>/dev/null |
- awk '{print substr($1, 0, length($1))}')
+ _comp_awk '{print substr($1, 0, length($1))}')
local -a exclude
[[ $filter == peers ]] && exclude=(-X broadcast-link)
- COMPREPLY=($(compgen "${exclude[@]}" -W '$links' -- $cur))
+ _comp_compgen -- "${exclude[@]}" -W '$links'
fi
}
-_tipc()
+_comp_cmd_tipc()
{
- local cur prev words cword optind i p
- _init_completion || return
+ local cur prev words cword comp_args optind i p
+ _comp_initialize -- "$@" || return
optind=1
COMPREPLY=()
@@ -86,13 +88,13 @@ _tipc()
# Flags can be placed anywhere in the commandline
case "$cur" in
-*)
- COMPREPLY=($(compgen -W '-h --help' -- $cur))
+ _comp_compgen -- -W '-h --help'
return
;;
esac
if ((cword == 1)); then
- COMPREPLY=($(compgen -W 'bearer link media nametable node socket' -- $cur))
+ _comp_compgen -- -W 'bearer link media nametable node socket'
return
fi
@@ -101,17 +103,17 @@ _tipc()
((optind++))
if ((cword == optind)); then
- COMPREPLY=($(compgen -W 'enable disable set get list' -- $cur))
+ _comp_compgen -- -W 'enable disable set get list'
return
fi
case "${words[optind]}" in
enable)
- local media params
+ local media="" params
((optind++))
if ((cword < optind + 4)); then
- _tipc_bearer $optind
+ _comp_cmd_tipc__bearer $optind
return
fi
@@ -122,20 +124,20 @@ _tipc()
done
case "$media" in
"udp")
- declare -a params=("localip" "localport" "remoteip"
+ local -a params=("localip" "localport" "remoteip"
"remoteport" "domain" "priority")
;;
"eth" | "ib")
- declare -a params=("domain" "priority")
+ local -a params=("domain" "priority")
;;
*)
return
;;
esac
- # If the previous word was a known parameter, we assume a value for
- # that key. Note that this would break if the user attempts to use
- # a known key as value.
+ # If the previous word was a known parameter, we assume a
+ # value for that key. Note that this would break if the
+ # user attempts to use a known key as value.
for i in "${params[@]}"; do
if [[ $prev == "$i" ]]; then
return
@@ -151,29 +153,29 @@ _tipc()
done
done
- COMPREPLY=($(compgen -W '${params[@]}' -- $cur))
+ _comp_compgen -- -W '"${params[@]}"' -X ''
;;
disable)
((optind++))
- _tipc_bearer $optind
+ _comp_cmd_tipc__bearer $optind
;;
get)
((optind++))
if ((cword == optind)); then
- _tipc_link_opts
+ _comp_cmd_tipc__link_opts
elif ((cword >= optind + 1)); then
- _tipc_bearer $((optind + 1))
+ _comp_cmd_tipc__bearer $((optind + 1))
fi
;;
set)
((optind++))
if ((cword == optind)); then
- _tipc_link_opts
+ _comp_cmd_tipc__link_opts
elif ((cword >= optind + 2)); then
- _tipc_bearer $((optind + 2))
+ _comp_cmd_tipc__bearer $((optind + 2))
fi
;;
esac
@@ -182,7 +184,7 @@ _tipc()
((optind++))
if ((cword == optind)); then
- COMPREPLY=($(compgen -W 'get set list statistics' -- $cur))
+ _comp_compgen -- -W 'get set list statistics'
return
fi
@@ -191,31 +193,31 @@ _tipc()
((optind++))
if ((cword == optind)); then
- _tipc_link_opts
+ _comp_cmd_tipc__link_opts
elif ((cword >= optind + 1)); then
- _tipc_link $((optind + 1)) "peers"
+ _comp_cmd_tipc__link $((optind + 1)) "peers"
fi
;;
set)
((optind++))
if ((cword == optind)); then
- _tipc_link_opts
+ _comp_cmd_tipc__link_opts
elif ((cword >= optind + 2)); then
- _tipc_link $((optind + 2)) "peers"
+ _comp_cmd_tipc__link $((optind + 2)) "peers"
fi
;;
statistics)
((optind++))
if ((cword == optind)); then
- COMPREPLY=($(compgen -W 'show reset' -- $cur))
+ _comp_compgen -- -W 'show reset'
return
fi
case "${words[optind]}" in
show | reset)
- _tipc_link $((optind + 1))
+ _comp_cmd_tipc__link $((optind + 1))
;;
esac
;;
@@ -225,7 +227,7 @@ _tipc()
((optind++))
if ((cword == optind)); then
- COMPREPLY=($(compgen -W 'get set list' -- $cur))
+ _comp_compgen -- -W 'get set list'
return
fi
@@ -234,18 +236,18 @@ _tipc()
((optind++))
if ((cword == optind)); then
- _tipc_link_opts
+ _comp_cmd_tipc__link_opts
elif ((cword >= optind + 1)); then
- _tipc_media $((optind + 1))
+ _comp_cmd_tipc__media $((optind + 1))
fi
;;
set)
((optind++))
if ((cword == optind)); then
- _tipc_link_opts
+ _comp_cmd_tipc__link_opts
elif ((cword >= optind + 2)); then
- _tipc_media $((optind + 2))
+ _comp_cmd_tipc__media $((optind + 2))
fi
;;
esac
@@ -254,14 +256,14 @@ _tipc()
((optind++))
if ((cword == optind)); then
- COMPREPLY=($(compgen -W 'show' -- $cur))
+ _comp_compgen -- -W 'show'
fi
;;
node)
((optind++))
if ((cword == optind)); then
- COMPREPLY=($(compgen -W 'list get set' -- $cur))
+ _comp_compgen -- -W 'list get set'
return
fi
@@ -270,7 +272,7 @@ _tipc()
((optind++))
if ((cword == optind)); then
- COMPREPLY=($(compgen -W 'address netid' -- $cur))
+ _comp_compgen -- -W 'address netid'
fi
;;
esac
@@ -279,11 +281,11 @@ _tipc()
((optind++))
if ((cword == optind)); then
- COMPREPLY=($(compgen -W 'list' -- $cur))
+ _comp_compgen -- -W 'list'
fi
;;
esac
} &&
- complete -F _tipc tipc
+ complete -F _comp_cmd_tipc tipc
# ex: filetype=sh
diff --git a/completions/tox b/completions/tox
index 0ea656e..b4b88bd 100644
--- a/completions/tox
+++ b/completions/tox
@@ -1,9 +1,9 @@
# tox completion -*- shell-script -*-
-_tox()
+_comp_cmd_tox()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
# Complete defaults following a "--"
if [[ "${words[*]:0:cword} " == *\ --\ * && $cur != -- ]]; then
@@ -11,19 +11,22 @@ _tox()
return
fi
+ local noargopts='!(-*|*[nice]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | --num | --index-url | --hashseed | --force-dep | -!(-*)[hni])
+ --help | --version | --num | --index-url | --hashseed | --force-dep | \
+ -${noargopts}[hni])
return
;;
- -!(-*)c)
- _filedir ini
+ -${noargopts}c)
+ _comp_compgen_filedir ini
return
;;
--installpkg | --result-json | --workdir)
- _filedir
+ _comp_compgen_filedir
return
;;
- -!(-*)e)
+ -${noargopts}e)
local envs=$(
{
"$1" --listenvs-all || "$1" --listenvs
@@ -33,19 +36,17 @@ _tox()
command sed -e 's/,/ /g' -ne 's/^envlist[[:space:]]*=//p' \
tox.ini 2>/dev/null
)
- local prefix=""
- [[ $cur == *,* ]] && prefix="${cur%,*},"
- COMPREPLY=($(compgen -X '*[{}]*' -W "$envs ALL" -- "${cur##*,}"))
- ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
+ _comp_delimited , -X '*[{}]*' -W "$envs ALL"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1") --' -- "$cur"))
+ _comp_compgen_help
+ _comp_compgen -a -- -W '--'
return
fi
} &&
- complete -F _tox tox
+ complete -F _comp_cmd_tox tox
# ex: filetype=sh
diff --git a/completions/tracepath b/completions/tracepath
index 176534f..d8269bd 100644
--- a/completions/tracepath
+++ b/completions/tracepath
@@ -1,9 +1,9 @@
# tracepath(8) completion -*- shell-script -*-
-_tracepath()
+_comp_cmd_tracepath()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*[lmp])
@@ -12,15 +12,14 @@ _tracepath()
esac
if [[ $cur == -* ]]; then
- local opts=$(_parse_help "$1")
- COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
return
fi
local ipvx
[[ $1 == *6 ]] && ipvx=-6
- _known_hosts_real ${ipvx-} -- "$cur"
+ _comp_compgen_known_hosts ${ipvx-} -- "$cur"
} &&
- complete -F _tracepath tracepath tracepath6
+ complete -F _comp_cmd_tracepath tracepath tracepath6
# ex: filetype=sh
diff --git a/completions/tree b/completions/tree
new file mode 100644
index 0000000..d274137
--- /dev/null
+++ b/completions/tree
@@ -0,0 +1,46 @@
+# tree(1) completion -*- shell-script -*-
+
+_comp_cmd_tree()
+{
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+
+ local noargopts='!(-*|*[LPIHTo]*)'
+ # shellcheck disable=SC2254
+ case $prev in
+ -${noargopts}[LPIHT] | --filelimit | --timefmt | --help | --version)
+ return
+ ;;
+ --charset)
+ _comp_compgen -x iconv charsets
+ return
+ ;;
+ -${noargopts}o)
+ _comp_compgen_filedir
+ return
+ ;;
+ --sort)
+ _comp_compgen -- -W "name version size mtime ctime"
+ return
+ ;;
+ esac
+
+ [[ $was_split ]] && return
+
+ if [[ $cur == -* ]]; then
+ _comp_compgen_help
+ return
+ fi
+
+ # Note: bash-4.2 has a bug with [[ ${arr[*]} == *text* ]], so we
+ # assign ${words[*]} in a temporary variable "line".
+ local line="${words[*]}"
+ if [[ $line == *\ --fromfile\ * ]]; then
+ _comp_compgen_filedir
+ else
+ _comp_compgen_filedir -d
+ fi
+} &&
+ complete -F _comp_cmd_tree tree
+
+# ex: filetype=sh
diff --git a/completions/truncate b/completions/truncate
new file mode 100644
index 0000000..94534a2
--- /dev/null
+++ b/completions/truncate
@@ -0,0 +1,32 @@
+# truncate(1) completion -*- shell-script -*-
+
+_comp_cmd_truncate()
+{
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+
+ local noargopts='!(-*|*[sr]*)'
+ # shellcheck disable=SC2254
+ case $prev in
+ -${noargopts}s | --size | --help | --version)
+ return
+ ;;
+ -${noargopts}r | --reference)
+ _comp_compgen_filedir
+ return
+ ;;
+ esac
+
+ [[ $was_split ]] && return
+
+ if [[ $cur == -* ]]; then
+ _comp_compgen_help
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
+ return
+ fi
+
+ _comp_compgen_filedir
+} &&
+ complete -F _comp_cmd_truncate truncate
+
+# ex: filetype=sh
diff --git a/completions/tshark b/completions/tshark
index 396fbcb..249670f 100644
--- a/completions/tshark
+++ b/completions/tshark
@@ -1,9 +1,9 @@
# tshark(1) completion -*- shell-script -*-
-_tshark()
+_comp_cmd_tshark()
{
- local cur prev words cword prefix
- _init_completion -n : || return
+ local cur prev words cword comp_args prefix
+ _comp_initialize -n : -- "$@" || return
case $cur in
-o*)
@@ -20,15 +20,14 @@ _tshark()
;;
-o*)
if [[ $cur == *:* ]]; then
- cur=${cur#*:}
- _filedir
+ _comp_compgen -c "${cur#*:}" filedir
else
- [[ -v _tshark_prefs ]] ||
- _tshark_prefs="$("$1" -G defaultprefs 2>/dev/null | command sed -ne 's/^#\{0,1\}\([a-z0-9_.-]\{1,\}:\).*/\1/p' |
+ [[ -v _comp_cmd_tshark__prefs ]] ||
+ _comp_cmd_tshark__prefs="$("$1" -G defaultprefs 2>/dev/null | command sed -ne 's/^#\{0,1\}\([a-z0-9_.-]\{1,\}:\).*/\1/p' |
tr '\n' ' ')"
: ${prefix:=}
- COMPREPLY=($(compgen -P "$prefix" -W "$_tshark_prefs" \
- -- "${cur:${#prefix}}"))
+ _comp_compgen -c "${cur:${#prefix}}" -- -P "$prefix" \
+ -W "$_comp_cmd_tshark__prefs"
[[ ${COMPREPLY-} == *: ]] && compopt -o nospace
fi
return
@@ -37,8 +36,7 @@ _tshark()
return
;;
-*i)
- COMPREPLY=($(compgen -W \
- "$("$1" -D 2>/dev/null | awk '{print $2}')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" -D 2>/dev/null | _comp_awk '{print $2}')"
return
;;
-*y)
@@ -49,88 +47,81 @@ _tshark()
break
fi
done
- COMPREPLY=($(compgen -W "$("$1" $opts -L 2>/dev/null |
- awk '/^ / { print $1 }')" -- "$cur"))
+ # shellcheck disable=SC2086
+ _comp_compgen_split -- "$("$1" $opts -L 2>/dev/null |
+ _comp_awk '/^ / { print $1 }')"
return
;;
-*[ab])
- COMPREPLY=($(compgen -W 'duration: filesize: files:' -- "$cur"))
+ _comp_compgen -- -W 'duration: filesize: files:'
[[ ${COMPREPLY-} == *: ]] && compopt -o nospace
return
;;
-*[rH])
# -r accepts a lot of different file types
- _filedir
+ _comp_compgen_filedir
return
;;
-*w)
- _filedir
+ _comp_compgen_filedir
[[ $cur == @(|-) ]] && COMPREPLY+=(-)
return
;;
-*F)
- COMPREPLY=($(compgen -W "$("$1" -F 2>&1 |
- awk '/^ / { print $1 }')" -- "$cur"))
+ _comp_compgen_split -- "$("$1" -F 2>&1 | _comp_awk '/^ / { print $1 }')"
return
;;
-*O)
- local prefix=
- [[ $cur == *,* ]] && prefix="${cur%,*},"
- [[ -v _tshark_protocols ]] ||
- _tshark_protocols="$("$1" -G protocols 2>/dev/null |
+ [[ -v _comp_cmd_tshark__protocols ]] ||
+ _comp_cmd_tshark__protocols="$("$1" -G protocols 2>/dev/null |
cut -f 3 | tr '\n' ' ')"
- COMPREPLY=($(compgen -W "$_tshark_protocols" -- "${cur##*,}"))
- ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
+ _comp_delimited , -W "$_comp_cmd_tshark__protocols"
return
;;
-*T)
- # Parse from: tshark -T . 2>&1 | awk -F \" '/^\t*"/ { print $2 }'
- COMPREPLY=($(compgen -W \
- 'pdml ps psml json jsonraw ek tabs text fields' -- "$cur"))
+ # Parse from: tshark -T . 2>&1 | _comp_awk -F \" '/^\t*"/ { print $2 }'
+ _comp_compgen -- -W 'pdml ps psml json jsonraw ek tabs text fields'
return
;;
-*t)
- # Parse from: tshark -t . 2>&1 | awk -F \" '/^\t*"/ { print $2 }'
- COMPREPLY=($(compgen -W \
- 'a ad adoy d dd e r u ud udoy' -- "$cur"))
+ # Parse from: tshark -t . 2>&1 | _comp_awk -F \" '/^\t*"/ { print $2 }'
+ _comp_compgen -- -W 'a ad adoy d dd e r u ud udoy'
return
;;
-*u)
# TODO: could be parsed from "-u ." output
- COMPREPLY=($(compgen -W 's hms' -- "$cur"))
+ _comp_compgen -- -W 's hms'
return
;;
-*W)
- COMPREPLY=($(compgen -W 'n' -- "$cur"))
+ _comp_compgen -- -W 'n'
return
;;
-*X)
if [[ ${cur:${#prefix}} == lua_script:* ]]; then
- cur=${cur#*:}
- _filedir lua
+ _comp_compgen -c "${cur#*:}" filedir lua
else
- COMPREPLY=($(compgen -P "$prefix" -W 'lua_script:' -- \
- "${cur:${#prefix}}"))
+ _comp_compgen -c "${cur:${#prefix}}" -- -P "$prefix" \
+ -W 'lua_script:'
[[ ${COMPREPLY-} == *: ]] && compopt -o nospace
fi
return
;;
-*G)
- COMPREPLY=($(compgen -W "$("$1" -G \? 2>/dev/null |
- awk '/^[ \t]*-G / \
- { sub("^[[]","",$2); sub("[]]$","",$2); print $2 }')" \
- -- "$cur"))
+ _comp_compgen_split -- "$("$1" -G \? 2>/dev/null |
+ _comp_awk '/^[ \t]*-G / {
+ sub("^[[]","",$2); sub("[]]$","",$2); print $2
+ }')"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h 2>/dev/null)' \
- -- "$cur"))
+ _comp_compgen_help -- -h
return
fi
} &&
- complete -F _tshark tshark
+ complete -F _comp_cmd_tshark tshark
# ex: filetype=sh
diff --git a/completions/tsig-keygen b/completions/tsig-keygen
index 017e9d8..01fabe8 100644
--- a/completions/tsig-keygen
+++ b/completions/tsig-keygen
@@ -1,28 +1,28 @@
# tsig-keygen(8) completion -*- shell-script -*-
-_tsig_keygen()
+_comp_cmd_tsig_keygen()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-h)
return
;;
-a)
- COMPREPLY=($(compgen -W 'hmac-{md5,sha{1,224,256,384,512}}' -- "$cur"))
+ _comp_compgen -- -W 'hmac-{md5,sha{1,224,256,384,512}}'
return
;;
-r)
- COMPREPLY=($(compgen -W keyboard -- "$cur"))
- _filedir
+ _comp_compgen -- -W keyboard
+ _comp_compgen -a filedir
return
;;
esac
[[ $cur != -* ]] ||
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
} &&
- complete -F _tsig_keygen tsig-keygen
+ complete -F _comp_cmd_tsig_keygen tsig-keygen
# ex: filetype=sh
diff --git a/completions/tune2fs b/completions/tune2fs
index 66d629c..6d62aa2 100644
--- a/completions/tune2fs
+++ b/completions/tune2fs
@@ -1,32 +1,32 @@
# tune2fs(8) completion -*- shell-script -*-
-_tune2fs()
+_comp_cmd_tune2fs()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*[cCEiJLmrT])
return
;;
-*e)
- COMPREPLY=($(compgen -W 'continue remount-ro panic' -- "$cur"))
+ _comp_compgen -- -W 'continue remount-ro panic'
return
;;
-*g)
- _gids
- COMPREPLY=($(compgen -g -W '${COMPREPLY[@]}' -- "$cur"))
+ _comp_compgen_gids
+ _comp_compgen -a -- -g
return
;;
-*M)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-*o)
local -a opts=(^debug ^bsdgroups ^user_xattr ^acl ^uid16
^journal_data ^journal_data_ordered ^journal_data_writeback
^nobarrier ^block_validity ^discard ^nodelalloc)
- COMPREPLY=($(compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur"))
+ _comp_compgen -- -W '"${opts[@]}" "${opts[@]#^}"'
return
;;
-*O)
@@ -34,28 +34,27 @@ _tune2fs()
^filetype ^flex_bg ^has_journal ^huge_file ^large_file
^metadata_csum ^mmp ^project ^quota ^read-only ^resize_inode
^sparse_super ^uninit_bg)
- COMPREPLY=($(compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur"))
+ _comp_compgen -- -W '"${opts[@]}" "${opts[@]#^}"'
return
;;
-*u)
- _uids
- COMPREPLY=($(compgen -u -W '${COMPREPLY[@]}' -- "$cur"))
+ _comp_compgen_uids
+ _comp_compgen -a -- -u
return
;;
-*U)
- COMPREPLY=($(compgen -W 'clear random time' -- "$cur"))
+ _comp_compgen -- -W 'clear random time'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
return
fi
- cur=${cur:=/dev/}
- _filedir
+ _comp_compgen -c "${cur:-/dev/}" filedir
} &&
- complete -F _tune2fs tune2fs
+ complete -F _comp_cmd_tune2fs tune2fs
# ex: filetype=sh
diff --git a/completions/ulimit b/completions/ulimit
index e596bf7..9f6f13b 100644
--- a/completions/ulimit
+++ b/completions/ulimit
@@ -1,16 +1,16 @@
# bash completion for ulimit -*- shell-script -*-
-_ulimit()
+_comp_cmd_ulimit()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
# TODO combined option support (-aH, -Sc etc)
- local mode
+ local mode=
case $prev in
-a)
- COMPREPLY=($(compgen -W "-S -H" -- "$cur"))
+ _comp_compgen -- -W "-S -H"
return
;;
-[SH]) ;;
@@ -20,23 +20,20 @@ _ulimit()
;;
esac
- if [[ ! -v mode ]]; then
+ if [[ ! $mode ]]; then
local word
for word in "${words[@]}"; do
[[ $word == -*a* ]] && return
done
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage -c help -s "$1"
return
fi
fi
- local args
- _count_args
- ((args == 1)) &&
- COMPREPLY=($(compgen -W "soft hard unlimited" -- "$cur"))
+ [[ ${mode-} ]] && _comp_compgen -- -W "soft hard unlimited"
} &&
- complete -F _ulimit ulimit
+ complete -F _comp_cmd_ulimit ulimit
# ex: filetype=sh
diff --git a/completions/unace b/completions/unace
index 7d6bd42..da647b8 100644
--- a/completions/unace
+++ b/completions/unace
@@ -1,20 +1,20 @@
# unace(1) completion -*- shell-script -*-
-_unace()
+_comp_cmd_unace()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-c -c- -f -f- -o -o- -p -y -y-' -- "$cur"))
+ _comp_compgen -- -W '-c -c- -f -f- -o -o- -p -y -y-'
else
if ((cword == 1)); then
- COMPREPLY=($(compgen -W 'e l t v x' -- "$cur"))
+ _comp_compgen -- -W 'e l t v x'
else
- _filedir ace
+ _comp_compgen_filedir '@(ace|cba)'
fi
fi
} &&
- complete -F _unace unace
+ complete -F _comp_cmd_unace unace
# ex: filetype=sh
diff --git a/completions/unpack200 b/completions/unpack200
index 8814259..3724f37 100644
--- a/completions/unpack200
+++ b/completions/unpack200
@@ -1,48 +1,50 @@
# unpack200(1) completion -*- shell-script -*-
-_unpack200()
+_comp_cmd_unpack200()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[Hl]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | -!(-*)[?hVJ])
+ --help | --version | -${noargopts}[?hVJ])
return
;;
- --deflate-hint | -!(-*)H)
- COMPREPLY=($(compgen -W 'true false keep' -- "$cur"))
+ --deflate-hint | -${noargopts}H)
+ _comp_compgen -- -W 'true false keep'
return
;;
- --log-file | -!(-*)l)
- COMPREPLY=($(compgen -W '-' -- "$cur"))
- _filedir log
+ --log-file | -${noargopts}l)
+ _comp_compgen -- -W '-'
+ _comp_compgen -a filedir log
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
# Check if a pack or a jar was already given.
- local word pack=false jar=false
+ local word pack="" jar=""
for word in "${words[@]:1}"; do
case $word in
- *.pack | *.pack.gz) pack=true ;;
- *.jar) jar=true ;;
+ *.pack | *.pack.gz) pack=set ;;
+ *.jar) jar=set ;;
esac
done
- if ! $pack; then
+ if [[ ! $pack ]]; then
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--deflate-hint= --remove-pack-file
- --verbose --quiet --log-file= --help --version' -- "$cur"))
+ _comp_compgen -- -W '--deflate-hint= --remove-pack-file --verbose
+ --quiet --log-file= --help --version'
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- _filedir 'pack?(.gz)'
+ _comp_compgen_filedir 'pack?(.gz)'
fi
- elif ! $jar; then
- _filedir jar
+ elif [[ ! $jar ]]; then
+ _comp_compgen_filedir jar
fi
} &&
- complete -F _unpack200 unpack200
+ complete -F _comp_cmd_unpack200 unpack200
# ex: filetype=sh
diff --git a/completions/unrar b/completions/unrar
index 4cbac8f..f3d4549 100644
--- a/completions/unrar
+++ b/completions/unrar
@@ -1,23 +1,23 @@
# unrar(1) completion -*- shell-script -*-
-_unrar()
+_comp_cmd_unrar()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-ad -ap -av- -c- -cfg- -cl -cu -dh -ep -f
- -idp -ierr -inul -kb -o+ -o- -ow -p -p- -r -ta -tb -tn -to -u -v
- -ver -vp -x -x@ -y' -- "$cur"))
+ _comp_compgen -- -W '-ad -ap -av- -c- -cfg- -cl -cu -dh -ep -f -idp
+ -ierr -inul -kb -o+ -o- -ow -p -p- -r -ta -tb -tn -to -u -v -ver
+ -vp -x -x@ -y'
else
if ((cword == 1)); then
- COMPREPLY=($(compgen -W 'e l lb lt p t v vb vt x' -- "$cur"))
+ _comp_compgen -- -W 'e l lb lt p t v vb vt x'
else
- _filedir '@(rar|exe)'
+ _comp_compgen_filedir '@(rar|exe|cbr)'
fi
fi
} &&
- complete -F _unrar unrar
+ complete -F _comp_cmd_unrar unrar
# ex: filetype=sh
diff --git a/completions/unshunt b/completions/unshunt
index 95a1601..0486d1f 100644
--- a/completions/unshunt
+++ b/completions/unshunt
@@ -1,17 +1,17 @@
# mailman unshunt completion -*- shell-script -*-
-_unshunt()
+_comp_cmd_unshunt()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
else
- _filedir -d
+ _comp_compgen_filedir -d
fi
} &&
- complete -F _unshunt unshunt
+ complete -F _comp_cmd_unshunt unshunt
# ex: filetype=sh
diff --git a/completions/update-alternatives b/completions/update-alternatives
index 25d2ce6..0d678fc 100644
--- a/completions/update-alternatives
+++ b/completions/update-alternatives
@@ -1,8 +1,8 @@
# bash completion for update-alternatives -*- shell-script -*-
-_installed_alternatives()
+_comp_cmd_update_alternatives__installed()
{
- local admindir
+ local i admindir
# find the admin dir
for i in alternatives dpkg/alternatives rpm/alternatives; do
[[ -d /var/lib/$i ]] && admindir=/var/lib/$i && break
@@ -13,17 +13,17 @@ _installed_alternatives()
break
fi
done
- COMPREPLY=($(compgen -W '$(command ls $admindir)' -- "$cur"))
+ [[ -d $admindir ]] && _comp_compgen_split -- "$(command ls "$admindir")"
}
-_update_alternatives()
+_comp_cmd_update_alternatives()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--altdir | --admindir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
--help | --usage | --version)
@@ -31,7 +31,7 @@ _update_alternatives()
;;
esac
- local mode args i
+ local mode="" args i
# find which mode to use and how many real args used so far
for ((i = 1; i < cword; i++)); do
@@ -46,10 +46,10 @@ _update_alternatives()
--install)
case $args in
1 | 3)
- _filedir
+ _comp_compgen_filedir
;;
2)
- _installed_alternatives
+ _comp_cmd_update_alternatives__installed
;;
4)
# priority - no completions
@@ -57,13 +57,13 @@ _update_alternatives()
*)
case $((args % 4)) in
0 | 2)
- _filedir
+ _comp_compgen_filedir
;;
1)
- COMPREPLY=($(compgen -W '--slave' -- "$cur"))
+ _comp_compgen -- -W '--slave'
;;
3)
- _installed_alternatives
+ _comp_cmd_update_alternatives__installed
;;
esac
;;
@@ -72,21 +72,21 @@ _update_alternatives()
--remove | --set)
case $args in
1)
- _installed_alternatives
+ _comp_cmd_update_alternatives__installed
;;
2)
- _filedir
+ _comp_compgen_filedir
;;
esac
;;
--auto | --remove-all | --display | --config)
- _installed_alternatives
+ _comp_cmd_update_alternatives__installed
;;
*)
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
;;
esac
} &&
- complete -F _update_alternatives update-alternatives alternatives
+ complete -F _comp_cmd_update_alternatives update-alternatives alternatives
# ex: filetype=sh
diff --git a/completions/update-rc.d b/completions/update-rc.d
index 9b281d5..a5040d4 100644
--- a/completions/update-rc.d
+++ b/completions/update-rc.d
@@ -2,57 +2,57 @@
#
# Copyright (C) 2004 Servilio Afre Puentes <servilio@gmail.com>
-_update_rc_d()
+_comp_cmd_update_rc_d()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local sysvdir services options
[[ -d /etc/rc.d/init.d ]] && sysvdir=/etc/rc.d/init.d ||
sysvdir=/etc/init.d
- services=($(printf '%s ' $sysvdir/!(README*|*.sh|$_backup_glob)))
- services=(${services[@]#$sysvdir/})
+ _comp_expand_glob services '"$sysvdir"/!(README*|*.sh|$_comp_backup_glob)' &&
+ services=("${services[@]#$sysvdir/}")
options=(-f -n)
if [[ $cword -eq 1 || $prev == -* ]]; then
- COMPREPLY=($(compgen -W '${options[@]} ${services[@]}' \
- -X '$(tr " " "|" <<<${words[@]})' -- "$cur"))
- elif [[ $prev == ?($(tr " " "|" <<<"${services[*]}")) ]]; then
- COMPREPLY=($(compgen -W 'remove defaults start stop' -- "$cur"))
+ _comp_compgen -- -W '"${options[@]}" ${services[@]+"${services[@]}"}' \
+ -X '$(tr " " "|" <<<${words[@]})'
+ elif ((${#services[@]})) && [[ $prev == ?($(tr " " "|" <<<"${services[*]}")) ]]; then
+ _comp_compgen -- -W 'remove defaults start stop'
elif [[ $prev == defaults && $cur == [0-9] ]]; then
COMPREPLY=(0 1 2 3 4 5 6 7 8 9)
elif [[ $prev == defaults && $cur == [sk]?([0-9]) ]]; then
COMPREPLY=(0 1 2 3 4 5 6 7 8 9)
- elif [[ $prev == defaults && -z $cur ]]; then
+ elif [[ $prev == defaults && ! $cur ]]; then
COMPREPLY=(0 1 2 3 4 5 6 7 8 9 s k)
elif [[ $prev == ?(start|stop) ]]; then
- if [[ $cur == [0-9] || -z $cur ]]; then
+ if [[ $cur == [0-9] || ! $cur ]]; then
COMPREPLY=(0 1 2 3 4 5 6 7 8 9)
elif [[ $cur == [0-9][0-9] ]]; then
- COMPREPLY=($cur)
+ COMPREPLY=("$cur")
else
COMPREPLY=()
fi
elif [[ $prev == ?([0-9][0-9]|[0-6S]) ]]; then
- if [[ -z $cur ]]; then
+ if [[ ! $cur ]]; then
if [[ $prev == [0-9][0-9] ]]; then
COMPREPLY=(0 1 2 3 4 5 6 S)
else
COMPREPLY=(0 1 2 3 4 5 6 S .)
fi
elif [[ $cur == [0-6S.] ]]; then
- COMPREPLY=($cur)
+ COMPREPLY=("$cur")
else
COMPREPLY=()
fi
elif [[ $prev == "." ]]; then
- COMPREPLY=($(compgen -W "start stop" -- "$cur"))
+ _comp_compgen -- -W "start stop"
else
COMPREPLY=()
fi
} &&
- complete -F _update_rc_d update-rc.d
+ complete -F _comp_cmd_update_rc_d update-rc.d
# ex: filetype=sh
diff --git a/completions/upgradepkg b/completions/upgradepkg
index d3ce608..f359e9a 100644
--- a/completions/upgradepkg
+++ b/completions/upgradepkg
@@ -1,30 +1,28 @@
# Slackware Linux upgradepkg completion -*- shell-script -*-
-_upgradepkg()
+_comp_cmd_upgradepkg()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--dry-run --install-new --reinstall
- --verbose' -- "$cur"))
+ _comp_compgen -- -W '--dry-run --install-new --reinstall --verbose'
return
fi
if [[ $cur == ?*%* ]]; then
prev="${cur%%?(\\)%*}"
cur="${cur#*%}"
- local nofiles IFS=$'\n'
+ local nofiles=""
compopt -o filenames
- COMPREPLY=($(compgen -P "$prev%" -f -X "!*.@(t[bgxl]z)" -- "$cur"))
- [[ ${COMPREPLY-} ]] || nofiles=1
- COMPREPLY+=($(compgen -P "$prev%" -S '/' -d -- "$cur"))
- [[ -v nofiles ]] && compopt -o nospace
+ _comp_compgen -- -P "$prev%" -f -X "!*.@(t[bgxl]z)" || nofiles=set
+ _comp_compgen -a -- -P "$prev%" -S '/' -d
+ [[ $nofiles ]] && compopt -o nospace
return
fi
- _filedir 't[bglx]z'
+ _comp_compgen_filedir 't[bglx]z'
} &&
- complete -F _upgradepkg upgradepkg
+ complete -F _comp_cmd_upgradepkg upgradepkg
# ex: filetype=sh
diff --git a/completions/urlsnarf b/completions/urlsnarf
index e327076..6ac58a4 100644
--- a/completions/urlsnarf
+++ b/completions/urlsnarf
@@ -1,26 +1,26 @@
# urlsnarf completion -*- shell-script -*-
-_urlsnarf()
+_comp_cmd_urlsnarf()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*i)
- _available_interfaces -a
+ _comp_compgen_available_interfaces -a
return
;;
-*p)
- _filedir pcap
+ _comp_compgen_filedir pcap
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
fi
} &&
- complete -F _urlsnarf urlsnarf
+ complete -F _comp_cmd_urlsnarf urlsnarf
# ex: filetype=sh
diff --git a/completions/uscan b/completions/uscan
index 441bae3..e82f625 100644
--- a/completions/uscan
+++ b/completions/uscan
@@ -1,33 +1,34 @@
-# uscan completion -*- shell-script -*-
+# uscan completion -*- shell-script -*-
-_uscan()
+_comp_cmd_uscan()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
--package)
- COMPREPLY=($(_xfunc apt-cache _apt_cache_src_packages))
+ _comp_compgen -x apt-cache sources
return
;;
--watchfile)
- _filedir
+ _comp_compgen_filedir
return
;;
--destdir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
- --timeout | --upstream-version | --download-version | --check-dirname-level | --check-dirname-regex)
+ --timeout | --upstream-version | --download-version | \
+ --check-dirname-level | --check-dirname-regex)
COMPREPLY=()
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
} &&
- complete -F _uscan uscan
+ complete -F _comp_cmd_uscan uscan
# ex: filetype=sh
diff --git a/completions/useradd b/completions/useradd
index ceeca91..6c0bef1 100644
--- a/completions/useradd
+++ b/completions/useradd
@@ -1,46 +1,57 @@
# useradd(8) completion -*- shell-script -*-
-_useradd()
+_comp_cmd_useradd()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
# TODO: if -o/--non-unique is given, could complete on existing uids
# with -u/--uid
+ local word chroot="" has_chroot=""
+ for word in "${words[@]}"; do
+ if [[ $has_chroot ]]; then
+ chroot=$word
+ break
+ fi
+ [[ $word != -@(R|-root) ]] || has_chroot=set
+ done
+
+ local noargopts='!(-*|*[cefKpubdkRgGZs]*)'
+ # shellcheck disable=SC2254
case $prev in
- --comment | --help | --expiredate | --inactive | --key | --password | --uid | \
- --selinux-user | -!(-*)[chefKpuZ])
+ --comment | --help | --expiredate | --inactive | --key | --password | \
+ --uid | -${noargopts}[chefKpu])
+ return
+ ;;
+ --base-dir | --home-dir | --skel | --root | -${noargopts}[bdkR])
+ _comp_compgen_filedir -d
return
;;
- --base-dir | --home-dir | --skel | --root | -!(-*)[bdkR])
- _filedir -d
+ --gid | -${noargopts}g)
+ _comp_compgen_gids
+ _comp_compgen -a -- -g
return
;;
- --gid | -!(-*)g)
- _gids
- COMPREPLY=($(compgen -W '${COMPREPLY[@]} $(compgen -g)' \
- -- "$cur"))
+ --groups | -${noargopts}G)
+ _comp_delimited , -g
return
;;
- --groups | -!(-*)G)
- local prefix=
- [[ $cur == *,* ]] && prefix="${cur%,*},"
- COMPREPLY=($(compgen -g -- "${cur##*,}"))
- ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
+ --selinux-user | -${noargopts}Z)
+ _comp_compgen_selinux_users
return
;;
- --shell | -!(-*)s)
- _shells
+ --shell | -${noargopts}s)
+ _comp_compgen_shells "${chroot-}"
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
[[ $cur == -* ]] &&
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
} &&
- complete -F _useradd useradd
+ complete -F _comp_cmd_useradd useradd
# ex: filetype=sh
diff --git a/completions/userdel b/completions/userdel
index ed98447..e95da5c 100644
--- a/completions/userdel
+++ b/completions/userdel
@@ -1,27 +1,29 @@
# userdel(8) completion -*- shell-script -*-
-_userdel()
+_comp_cmd_userdel()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[R]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | -!(-*)h)
+ --help | -${noargopts}h)
return
;;
- --root | -!(-*)R)
- _filedir -d
+ --root | -${noargopts}R)
+ _comp_compgen_filedir -d
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
} &&
- complete -F _userdel userdel
+ complete -F _comp_cmd_userdel userdel
# ex: filetype=sh
diff --git a/completions/usermod b/completions/usermod
index 77ab33c..797e536 100644
--- a/completions/usermod
+++ b/completions/usermod
@@ -1,51 +1,62 @@
# usermod(8) completion -*- shell-script -*-
-_usermod()
+_comp_cmd_usermod()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
# TODO: if -o/--non-unique is given, could complete on existing uids
# with -u/--uid
+ local word chroot="" has_chroot=""
+ for word in "${words[@]}"; do
+ if [[ $has_chroot ]]; then
+ chroot=$word
+ break
+ fi
+ [[ $word != -@(R|-root) ]] || has_chroot=set
+ done
+
+ local noargopts='!(-*|*[cdeflpugGRZs]*)'
+ # shellcheck disable=SC2254
case $prev in
- --comment | --home | --expiredate | --inactive | --help | --login | --password | \
- --uid | --selinux-user | -!(-*)[cdefhlpuZ])
+ --comment | --home | --expiredate | --inactive | --help | --login | \
+ --password | --uid | -${noargopts}[cdefhlpu])
+ return
+ ;;
+ --gid | -${noargopts}g)
+ _comp_compgen_gids
+ _comp_compgen -a -- -g
return
;;
- --gid | -!(-*)g)
- _gids
- COMPREPLY=($(compgen -W '${COMPREPLY[@]} $(compgen -g)' \
- -- "$cur"))
+ --groups | -${noargopts}G)
+ _comp_delimited , -g
return
;;
- --groups | -!(-*)G)
- local prefix=
- [[ $cur == *,* ]] && prefix="${cur%,*},"
- COMPREPLY=($(compgen -g -- "${cur##*,}"))
- ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
+ --root | -${noargopts}R)
+ _comp_compgen_filedir -d
return
;;
- --root | -!(-*)R)
- _filedir -d
+ --selinux-user | -${noargopts}Z)
+ _comp_compgen_selinux_users
return
;;
- --shell | -!(-*)s)
- _shells
+ --shell | -${noargopts}s)
+ _comp_compgen_shells "${chroot-}"
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
# TODO: -U/--unlock, -p/--password, -L/--lock mutually exclusive
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- COMPREPLY=($(compgen -u -- "$cur"))
+ _comp_compgen -- -u
} &&
- complete -F _usermod usermod
+ complete -F _comp_cmd_usermod usermod
# ex: filetype=sh
diff --git a/completions/valgrind b/completions/valgrind
index f541161..7043aa3 100644
--- a/completions/valgrind
+++ b/completions/valgrind
@@ -1,22 +1,19 @@
# valgrind(1) completion -*- shell-script -*-
-_valgrind()
+_comp_cmd_valgrind()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
local i
- # Note: intentionally using COMP_WORDS and COMP_CWORD instead of
- # words and cword here due to splitting on = causing index differences
- # (_command_offset assumes the former).
- for ((i = 1; i <= COMP_CWORD; i++)); do
- if [[ ${COMP_WORDS[i]} != @([-=])* && ${COMP_WORDS[i - 1]} != = ]]; then
- _command_offset $i
+ for ((i = 1; i <= cword; i++)); do
+ if [[ ${words[i]} != @([-=])* ]]; then
+ _comp_command_offset $i
return
fi
done
- local word tool
+ local word tool=""
for word in "${words[@]:1}"; do
if [[ $word == --tool=?* ]]; then
tool=$word
@@ -31,81 +28,83 @@ _valgrind()
--tool)
# Tools seem to be named e.g. like memcheck-amd64-linux from which
# we want to grab memcheck.
- COMPREPLY=($(compgen -W '$(
- for f in /usr{,/local}/lib{,64,exec}{/*-linux-gnu,}/valgrind/*
- do
- [[ $f != *.so && -x $f && $f =~ ^.*/(.*)-[^-]+-[^-]+ ]] &&
- printf "%s\n" "${BASH_REMATCH[1]}"
- done)' -- "$cur"))
+ local -a files
+ if _comp_expand_glob files '/usr{,/local}/lib{,64,exec}{/*-linux-gnu,}/valgrind/*'; then
+ _comp_compgen_split -- "$(
+ for f in "${files[@]}"; do
+ [[ $f != *.so && -x $f && $f =~ ^.*/(.*)-[^-]+-[^-]+ ]] &&
+ printf '%s\n' "${BASH_REMATCH[1]}"
+ done
+ )"
+ fi
return
;;
--sim-hints)
- COMPREPLY=($(compgen -W 'lax-ioctls enable-outer' -- "$cur"))
+ _comp_compgen -- -W 'lax-ioctls enable-outer'
return
;;
--soname-synonyms)
- COMPREPLY=($(compgen -W 'somalloc' -S = -- "$cur"))
+ _comp_compgen -- -W 'somalloc' -S =
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
;;
--kernel-variant)
- COMPREPLY=($(compgen -W 'bproc' -- "$cur"))
+ _comp_compgen -- -W 'bproc'
return
;;
# callgrind:
--callgrind-out-file)
- _filedir
+ _comp_compgen_filedir
return
;;
# exp-dhat:
--sort-by)
- COMPREPLY=($(compgen -W 'max-bytes-live tot-bytes-allocd
- max-blocks-live' -- "$cur"))
+ _comp_compgen -- -W 'max-bytes-live tot-bytes-allocd
+ max-blocks-live'
return
;;
# massif:
--time-unit)
- COMPREPLY=($(compgen -W 'i ms B' -- "$cur"))
+ _comp_compgen -- -W 'i ms B'
return
;;
# generic cases parsed from --help output
--+([-A-Za-z0-9_]))
- local value=$($1 --help-debug ${tool-} 2>/dev/null |
- command sed -ne "s|^[[:blank:]]*$prev=\([^[:blank:]]\{1,\}\).*|\1|p")
+ # shellcheck disable=SC2086
+ local value=$("$1" --help-debug $tool 2>/dev/null |
+ command sed \
+ -ne "s|^[[:blank:]]*$prev=\([^[:blank:]]\{1,\}\).*|\1|p")
case $value in
\<file*\>)
- _filedir
+ _comp_compgen_filedir
return
;;
\<command\>)
- compopt -o filenames
- COMPREPLY=($(compgen -c -- "$cur"))
+ _comp_compgen_commands
return
;;
\<+([0-9])..+([0-9])\>)
- COMPREPLY=($(compgen -W "{${value:1:${#value}-2}}" \
- -- "$cur"))
+ _comp_compgen -- -W "{${value:1:${#value}-2}}"
return
;;
# "yes", "yes|no", etc (but not "string", "STR",
# "hint1,hint2,...")
yes | +([-a-z0-9])\|+([-a-z0-9\|]))
- COMPREPLY=($(IFS='|' compgen -W '$value' -- "$cur"))
+ _comp_compgen -F '|' -- -W '$value'
return
;;
esac
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" "--help ${tool-}")' \
- -- "$cur"))
+ _comp_compgen_help -- --help ${tool:+"$tool"}
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
} &&
- complete -F _valgrind valgrind
+ complete -F _comp_cmd_valgrind valgrind
# ex: filetype=sh
diff --git a/completions/vipw b/completions/vipw
index b3a7415..bfaa48a 100644
--- a/completions/vipw
+++ b/completions/vipw
@@ -1,22 +1,24 @@
# vipw(8) and vigr completion -*- shell-script -*-
-_vipw()
+_comp_cmd_vipw()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[R]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | -!(-*)h)
+ --help | -${noargopts}h)
return
;;
- --root | -!(-*)R)
- _filedir -d
+ --root | -${noargopts}R | -d)
+ _comp_compgen_filedir -d
return
;;
esac
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
} &&
- complete -F _vipw vipw vigr
+ complete -F _comp_cmd_vipw vipw vigr
# ex: filetype=sh
diff --git a/completions/vmstat b/completions/vmstat
index e36934a..36f9bb8 100644
--- a/completions/vmstat
+++ b/completions/vmstat
@@ -1,27 +1,29 @@
# vmstat(8) completion -*- shell-script -*-
-_vmstat()
+_comp_cmd_vmstat()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local noargopts='!(-*|*[cMNnwpS]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | --partition | -!(-*)[hVcMNnwp])
+ --help | --version | --partition | -${noargopts}[hVcMNnwp])
return
;;
- --unit | -!(-*)S)
+ --unit | -${noargopts}S)
[[ $OSTYPE == *linux* ]] &&
- COMPREPLY=($(compgen -W 'k K m M' -- "$cur"))
+ _comp_compgen -- -W 'k K m M'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} ]] ||
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
fi
} &&
- complete -F _vmstat vmstat
+ complete -F _comp_cmd_vmstat vmstat
# ex: filetype=sh
diff --git a/completions/vncviewer b/completions/vncviewer
index ba55226..17dd7da 100644
--- a/completions/vncviewer
+++ b/completions/vncviewer
@@ -1,74 +1,74 @@
# bash completion for vncviewer -*- shell-script -*-
-_vncviewer_bootstrap()
+_comp_cmd_vncviewer__bootstrap()
{
- local fname
- case $(_realcommand vncviewer) in
- *xvnc4viewer) fname=_xvnc4viewer ;;
- *tightvncviewer) fname=_tightvncviewer ;;
- *) fname=_known_hosts ;;
+ local fname REPLY
+ _comp_realcommand vncviewer
+ case $REPLY in
+ *xvnc4viewer) fname=_comp_cmd_xvnc4viewer ;;
+ *tightvncviewer) fname=_comp_cmd_tightvncviewer ;;
+ *) fname=_comp_complete_known_hosts ;;
esac
# Install real completion for subsequent completions
complete -F $fname vncviewer
- $fname # Generate completions once for now
- unset -f _vncviewer_bootstrap
+ $fname "$@" # Generate completions once for now
+ unset -f "$FUNCNAME"
} &&
- complete -F _vncviewer_bootstrap vncviewer
+ complete -F _comp_cmd_vncviewer__bootstrap vncviewer
-_tightvncviewer()
+_comp_cmd_tightvncviewer()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-passwd)
- _filedir
+ _comp_compgen_filedir
return
;;
-encodings)
- COMPREPLY=($(compgen -W 'copyrect tight hextile zlib corre rre
- raw' -- "$cur"))
+ _comp_compgen -- -W 'copyrect tight hextile zlib corre rre raw'
return
;;
-via)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-help -listen -via -shared -noshared
- -viewonly -fullscreen -noraiseonbeep -passwd -encodings -bgr233
- -owncmap -truecolour -truecolor -depth -compresslevel -quality
- -nojpeg -nocursorshape -x11cursor' -- "$cur"))
+ _comp_compgen -- -W '-help -listen -via -shared -noshared -viewonly
+ -fullscreen -noraiseonbeep -passwd -encodings -bgr233 -owncmap
+ -truecolour -truecolor -depth -compresslevel -quality -nojpeg
+ -nocursorshape -x11cursor'
else
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
fi
} &&
- complete -F _tightvncviewer tightvncviewer
+ complete -F _comp_cmd_tightvncviewer tightvncviewer
# NOTE: - VNC Viewer options are case insensitive.
# Preferred case is taken from -help.
-_xvnc4viewer()
+_comp_cmd_xvnc4viewer()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
# Both single dash (-) and double dash (--) are allowed as option prefix
local opt=${prev/#--/-}
case ${opt,,} in
# -passwd, -PasswordFile
-passwd | -passwordfile)
- _filedir
+ _comp_compgen_filedir
return
;;
-preferredencoding)
- COMPREPLY=($(compgen -W 'zrle hextile raw' -- "$cur"))
+ _comp_compgen -- -W 'zrle hextile raw'
return
;;
-via)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
esac
@@ -83,17 +83,17 @@ _xvnc4viewer()
WMDecorationWidth ZlibLevel)
[[ $cur == --* ]] && dash=-- || dash=-
- local IFS=$' \t\n' reset=$(shopt -p nocasematch)
- shopt -s nocasematch
- local option
- COMPREPLY=($(for option in "${options[@]}"; do
- [[ $dash$option == "$cur"* ]] && printf '%s\n' $dash$option
- done))
- $reset
+ _comp_split COMPREPLY "$(
+ shopt -s nocasematch
+ local option
+ for option in "${options[@]}"; do
+ [[ $dash$option == "$cur"* ]] && printf '%s\n' "$dash$option"
+ done
+ )"
else
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
fi
} &&
- complete -F _xvnc4viewer xvnc4viewer
+ complete -F _comp_cmd_xvnc4viewer xvnc4viewer
# ex: filetype=sh
diff --git a/completions/vpnc b/completions/vpnc
index bbdb8ee..79ffff3 100644
--- a/completions/vpnc
+++ b/completions/vpnc
@@ -1,82 +1,78 @@
# bash completion for vpnc -*- shell-script -*-
-_vpnc()
+_comp_cmd_vpnc()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
- --help | --long-help | --version | --id | --username | --domain | --ifname | \
- --application-version | --local-addr | --local-port | --udp-port | --dpd-idle | \
- --target-network | --ifmtu)
+ --help | --long-help | --version | --id | --username | --domain | \
+ --ifname | --application-version | --local-addr | --local-port | \
+ --udp-port | --dpd-idle | --target-network | --ifmtu)
return
;;
--gateway)
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
return
;;
--vendor)
- COMPREPLY=($(compgen -W 'cisco netscreen' -- "$cur"))
+ _comp_compgen -- -W 'cisco netscreen'
return
;;
--natt-mode)
- COMPREPLY=($(compgen -W 'natt none force-natt cisco-udp' \
- -- "$cur"))
+ _comp_compgen -- -W 'natt none force-natt cisco-udp'
return
;;
--script | --pid-file | --ca-file)
- _filedir
+ _comp_compgen_filedir
return
;;
--dh)
- COMPREPLY=($(compgen -W 'dh1 dh2 dh5' -- "$cur"))
+ _comp_compgen -- -W 'dh1 dh2 dh5'
return
;;
--pfs)
- COMPREPLY=($(compgen -W 'nopfs dh1 dh2 dh5 server' -- "$cur"))
+ _comp_compgen -- -W 'nopfs dh1 dh2 dh5 server'
return
;;
--ifmode)
- COMPREPLY=($(compgen -W 'tun tap' -- "$cur"))
+ _comp_compgen -- -W 'tun tap'
return
;;
--debug)
- COMPREPLY=($(compgen -W '0 1 2 3 99' -- "$cur"))
+ _comp_compgen -- -W '0 1 2 3 99'
return
;;
--auth-mode)
- COMPREPLY=($(compgen -W 'psk cert hybrid' -- "$cur"))
+ _comp_compgen -- -W 'psk cert hybrid'
return
;;
--ca-dir)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
--password-helper)
- compopt -o filenames
- COMPREPLY=($(compgen -c -- "$cur"))
+ _comp_compgen_commands
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" --long-help)' -- "$cur"))
- elif [[ $cur == */* ]]; then
+ _comp_compgen_help -- --long-help
+ elif _comp_looks_like_path "$cur"; then
# explicit filename
- _filedir conf
+ _comp_compgen_filedir conf
else
# config name, /etc/vpnc/<name>.conf
- local IFS=$' \t\n' reset=$(shopt -p nullglob)
- shopt -s nullglob
- local -a configs=(/etc/vpnc/*.conf)
- configs=("${configs[@]##*/}")
- configs=("${configs[@]%.conf}")
- $reset
- IFS=$'\n'
- compopt -o filenames
- COMPREPLY=($(compgen -W '${configs[@]}' -- "$cur"))
+ local -a configs
+ if _comp_expand_glob configs '/etc/vpnc/*.conf'; then
+ configs=("${configs[@]##*/}")
+ configs=("${configs[@]%.conf}")
+ compopt -o filenames
+ _comp_compgen -- -W '"${configs[@]}"'
+ fi
fi
} &&
- complete -F _vpnc vpnc
+ complete -F _comp_cmd_vpnc vpnc
# ex: filetype=sh
diff --git a/completions/watch b/completions/watch
index efc0a98..443bed3 100644
--- a/completions/watch
+++ b/completions/watch
@@ -1,19 +1,21 @@
# watch(1) completion -*- shell-script -*-
-[[ $OSTYPE == *linux* ]] || return 1
+[[ $OSTYPE == *@(linux|darwin)* ]] || return 1
-_watch()
+_comp_cmd_watch()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
local offset=0 i
+ local noargopts='!(-*|*[dn]*)'
+ # shellcheck disable=SC2254
for ((i = 1; i <= cword; i++)); do
case ${words[i]} in
- --help | --version | -!(-*)h)
+ --help | --version | -${noargopts}h)
return
;;
- --interval | -!(-*)n)
+ --interval | -${noargopts}n)
((i++))
continue
;;
@@ -26,29 +28,30 @@ _watch()
done
if ((offset > 0)); then
- _command_offset $offset
+ _comp_command_offset $offset
return
fi
+ # shellcheck disable=SC2254
case $prev in
- --differences | -!(-*)d)
+ --differences | -${noargopts}d)
[[ $cur != -* ]] &&
- COMPREPLY=($(compgen -W 'cumulative' -- "$cur"))
+ _comp_compgen -- -W 'cumulative'
return
;;
- --interval | -!(-*)n)
+ --interval | -${noargopts}n)
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
} &&
- complete -F _watch watch
+ complete -F _comp_cmd_watch watch
# ex: filetype=sh
diff --git a/completions/webmitm b/completions/webmitm
index 549c5ef..df6faa2 100644
--- a/completions/webmitm
+++ b/completions/webmitm
@@ -1,17 +1,17 @@
# webmitm completion -*- shell-script -*-
-_webmitm()
+_comp_cmd_webmitm()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_usage
else
- _known_hosts_real -- "$cur"
+ _comp_compgen_known_hosts -- "$cur"
fi
} &&
- complete -F _webmitm webmitm
+ complete -F _comp_cmd_webmitm webmitm
# ex: filetype=sh
diff --git a/completions/wget b/completions/wget
index d6a2fe9..fcc59aa 100644
--- a/completions/wget
+++ b/completions/wget
@@ -1,24 +1,26 @@
# wget(1) completion -*- shell-script -*-
-_wget()
+_comp_cmd_wget()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[DPoaOitTwlQeBUARIX]*)'
+ # shellcheck disable=SC2254
case $prev in
- --version | --help | -!(-*)[hV])
+ --version | --help | -${noargopts}[hV])
return
;;
--progress)
- COMPREPLY=($(compgen -W 'bar dot' -- "$cur"))
+ _comp_compgen -- -W 'bar dot'
return
;;
--bind-address)
- _ip_addresses
+ _comp_compgen_ip_addresses
return
;;
- --domains | --exclude-domains | -!(-*)D)
- _known_hosts_real -- "$cur"
+ --domains | --exclude-domains | -${noargopts}D)
+ _comp_compgen_known_hosts -- "$cur"
return
;;
--restrict-file-names)
@@ -47,84 +49,87 @@ _wget()
local lastopt=${cur/*,/} prevopt=
[[ $cur == *,* ]] && prevopt=${cur%,*},
- COMPREPLY=($(compgen -P "$prevopt" -X "@($excludes_str)" \
- -W 'unix windows nocontrol ascii lowercase uppercase' \
- -- "$lastopt"))
+ _comp_compgen -c "$lastopt" -- -P "$prevopt" \
+ -X "@($excludes_str)" \
+ -W 'unix windows nocontrol ascii lowercase uppercase'
# +o nospace when no more valid option is possible (= append a space)
- local opt_as_arr=(${COMPREPLY[0]//,/ })
+ local -a opt_as_arr
+ _comp_split -F $', \t\n' opt_as_arr "${COMPREPLY[0]}"
((${#opt_as_arr[@]} < 4)) && compopt -o nospace
return
;;
--prefer-family)
- COMPREPLY=($(compgen -W 'IPv4 IPv6 none' -- "$cur"))
+ _comp_compgen -- -W 'IPv4 IPv6 none'
return
;;
- --directory-prefix | --ca-directory | --warc-tempdir | -!(-*)P)
- _filedir -d
+ --directory-prefix | --ca-directory | --warc-tempdir | -${noargopts}P)
+ _comp_compgen_filedir -d
return
;;
- --output-file | --append-output | --config | --load-cookies | --save-cookies | \
- --post-file | --certificate | --ca-certificate | --private-key | \
- --random-file | --egd-file | --warc-file | --warc-dedup | -!(-*)[oa])
- _filedir
+ --output-file | --append-output | --config | --load-cookies | \
+ --save-cookies | --post-file | --certificate | --ca-certificate | \
+ --private-key | --random-file | --egd-file | --warc-file | \
+ --warc-dedup | -${noargopts}[oa])
+ _comp_compgen_filedir
return
;;
- --output-document | --input-file | -!(-*)[Oi])
- _filedir && [[ $cur == - || -z $cur ]] && COMPREPLY+=(-)
+ --output-document | --input-file | -${noargopts}[Oi])
+ _comp_compgen_filedir && [[ $cur == - || ! $cur ]] && COMPREPLY+=(-)
return
;;
--secure-protocol)
- COMPREPLY=($(compgen -W 'auto SSLv2 SSLv3 TLSv1' -- "$cur"))
+ _comp_compgen -- -W 'auto SSLv2 SSLv3 TLSv1'
return
;;
--certificate-type | --private-key-type)
- COMPREPLY=($(compgen -W 'PEM DER' -- "$cur"))
+ _comp_compgen -- -W 'PEM DER'
return
;;
--follow-tags | --ignore-tags)
local lastopt=${cur/*,/} prevopt=
[[ $cur == *,* ]] && prevopt=${cur%,*},
- COMPREPLY=($(compgen -P "$prevopt" -W 'a abbr acronym address
- applet area b base basefont bdo big blockquote body br button
- caption center cite code col colgroup dd del dir div dfn dl dt
- em fieldset font form frame frameset h6 head hr html i iframe
- img input ins isindex kbd label legend li link map menu meta
- noframes noscript object ol optgroup option p param pre q s
- samp script select small span strike strong style sub sup table
- tbody td textarea tfoot th thead title tr tt u ul var xmp' \
- -- "$lastopt"))
- return
- ;;
- --tries | --timeout | --dns-timeout | --connect-timeout | --read-timeout | \
- --wait | --waitretry | --cut-dirs | --max-redirect | --level | -!(-*)[tTwl])
+ _comp_compgen -c "$lastopt" -- -P "$prevopt" -W 'a abbr acronym
+ address applet area b base basefont bdo big blockquote body br
+ button caption center cite code col colgroup dd del dir div dfn
+ dl dt em fieldset font form frame frameset h6 head hr html i
+ iframe img input ins isindex kbd label legend li link map menu
+ meta noframes noscript object ol optgroup option p param pre q
+ s samp script select small span strike strong style sub sup
+ table tbody td textarea tfoot th thead title tr tt u ul var
+ xmp'
+ return
+ ;;
+ --tries | --timeout | --dns-timeout | --connect-timeout | \
+ --read-timeout | --wait | --waitretry | --cut-dirs | \
+ --max-redirect | --level | -${noargopts}[tTwl])
# expect integer number
- COMPREPLY+=($(compgen -P "$cur" -W "{0..9}"))
+ _comp_compgen -aR -- -P "$cur" -W "{0..9}"
compopt -o nospace
return
;;
- --quota | --limit-rate | --warc-max-size | -!(-*)Q)
+ --quota | --limit-rate | --warc-max-size | -${noargopts}Q)
# expect size
if [[ $cur == *[km] ]]; then
- COMPREPLY=($(compgen -W "$cur"))
+ _comp_compgen -R -- -W "$cur"
elif [[ $cur ]]; then
- COMPREPLY=($(compgen -P "$cur" -W "{0..9} k m"))
+ _comp_compgen -R -- -P "$cur" -W "{0..9} k m"
compopt -o nospace
else
- COMPREPLY=($(compgen -W "{0..9}"))
+ _comp_compgen -R -- -W "{0..9}"
compopt -o nospace
fi
return
;;
--user | --http-user | --proxy-user | --ftp-user)
- COMPREPLY=($(compgen -W "$(command sed -n \
+ _comp_compgen_split -- "$(command sed -n \
'/^login/s/^[[:blank:]]*login[[:blank:]]//p' ~/.netrc \
- 2>/dev/null)" -- "$cur"))
+ 2>/dev/null)"
return
;;
--header)
- COMPREPLY=($(compgen -W 'Accept Accept-Charset Accept-Encoding
+ _comp_compgen -- -W 'Accept Accept-Charset Accept-Encoding
Accept-Language Accept-Ranges Age Allow Authorization
Cache-Control Connection Content-Encoding Content-Language
Content-Length Content-Location Content-MD5 Content-Range
@@ -133,42 +138,43 @@ _wget()
Last-Modified Location Max-Forwards Pragma Proxy-Authenticate
Proxy-Authorization Range Referer Retry-After Server TE Trailer
Transfer-Encoding Upgrade User-Agent Vary Via Warning
- WWW-Authenticate' -- "$cur"))
+ WWW-Authenticate'
compopt -o nospace
return
;;
--local-encoding | --remote-encoding)
- type -P xauth &>/dev/null && _xfunc iconv _iconv_charsets
+ type -P xauth &>/dev/null && _comp_compgen -x iconv charsets
return
;;
- --execute | -!(-*)e)
+ --execute | -${noargopts}e)
return # TODO base=STR
;;
--report-speed)
- COMPREPLY=($(compgen -W 'bits' -- "$cur"))
+ _comp_compgen -- -W 'bits'
return
;;
--regex-type)
- COMPREPLY=($(compgen -W 'posix' -- "$cur"))
+ _comp_compgen -- -W 'posix'
return
;;
- --base | --password | --ftp-password | --http-password | --proxy-password | \
- --default-page | --referer | --user-agent | --post-data | --warc-header | \
- --accept | --reject | --accept-regex | --reject-regex | --include-directories | \
- --exclude-directories | -!(-*)[BUARIX])
+ --base | --password | --ftp-password | --http-password | \
+ --proxy-password | --default-page | --referer | --user-agent | \
+ --post-data | --warc-header | --accept | --reject | \
+ --accept-regex | --reject-regex | --include-directories | \
+ --exclude-directories | -${noargopts}[BUARIX])
# argument required but no completions available
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _wget wget
+ complete -F _comp_cmd_wget wget
# ex: filetype=sh
diff --git a/completions/wine b/completions/wine
index 429fede..239f44b 100644
--- a/completions/wine
+++ b/completions/wine
@@ -1,20 +1,26 @@
# bash completion for wine(1) -*- shell-script -*-
-_wine()
+_comp_cmd_wine()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+
+ case $prev in
+ --help | --version)
+ return
+ ;;
+ esac
if ((cword == 1)); then
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--help --version' -- "$cur"))
+ _comp_compgen -- -W '--help --version'
[[ ${COMPREPLY-} ]] && return
fi
- _filedir '@([eE][xX][eE]?(.[sS][oO])|[cC][oO][mM]|[sS][cC][rR]|[mM][sS][iI])'
+ _comp_compgen_filedir '@([eE][xX][eE]?(.[sS][oO])|[cC][oO][mM]|[sS][cC][rR]|[mM][sS][iI])'
else
- _filedir
+ _comp_compgen_filedir
fi
} &&
- complete -F _wine wine wine-development wine-stable
+ complete -F _comp_cmd_wine wine{,64}{,-development,-stable}
# ex: filetype=sh
diff --git a/completions/withlist b/completions/withlist
index 4142471..f687511 100644
--- a/completions/withlist
+++ b/completions/withlist
@@ -1,18 +1,20 @@
# mailman withlist completion -*- shell-script -*-
-_withlist()
+_comp_cmd_withlist()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--lock --interactive --run --all --quiet
- --help' -- "$cur"))
+ _comp_compgen -- -W '--lock --interactive --run --all --quiet --help'
else
- _xfunc list_lists _mailman_lists
+ # Prefer `list_lists` in the same dir as command
+ local pathcmd
+ pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH
+ _comp_compgen -x list_lists mailman_lists
fi
} &&
- complete -F _withlist withlist
+ complete -F _comp_cmd_withlist withlist
# ex: filetype=sh
diff --git a/completions/wodim b/completions/wodim
index b308291..095fa0d 100644
--- a/completions/wodim
+++ b/completions/wodim
@@ -1,9 +1,9 @@
# bash completion for cdrecord/wodim -*- shell-script -*-
-_cdrecord()
+_comp_cmd_wodim()
{
- local cur prev words cword
- _init_completion -n = || return
+ local cur prev words cword comp_args
+ _comp_initialize -n = -- "$@" || return
local generic_options track_options track_mode
@@ -13,11 +13,11 @@ _cdrecord()
cur=${cur#*=}
case $prev in
textfile | cuefile | msifile)
- _filedir
+ _comp_compgen_filedir
;;
blank)
- COMPREPLY=($(compgen -W 'help all fast track unreserve trtail
- unclose session' -- "$cur"))
+ _comp_compgen -- -W 'help all fast track unreserve trtail
+ unclose session'
;;
driveropts)
if [[ $cur == *=* ]]; then
@@ -25,30 +25,29 @@ _cdrecord()
cur=${cur#*=}
case $prev in
varirec)
- COMPREPLY=($(compgen -W "-2 -1 0 1 2" -- "$cur"))
+ _comp_compgen -- -W "-2 -1 0 1 2"
;;
gigarec)
- COMPREPLY=($(compgen -W "0.6 0.7 0.8 1.0 1.2 1.3
- 1.4" -- "$cur"))
+ _comp_compgen -- -W "0.6 0.7 0.8 1.0 1.2 1.3 1.4"
;;
tattoofile)
- _filedir
+ _comp_compgen_filedir
;;
esac
else
- COMPREPLY=($(compgen -W 'burnfree noburnfree varirec=
- gigarec= audiomaster forcespeed noforcespeed speedread
+ _comp_compgen -- -W 'burnfree noburnfree varirec= gigarec=
+ audiomaster forcespeed noforcespeed speedread
nospeedread singlesession nosinglesession hidecdr
- nohidecdr tattooinfo tattoofile=' -- "$cur"))
+ nohidecdr tattooinfo tattoofile='
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
;;
driver)
- COMPREPLY=($(compgen -W "$($1 driver=help 2>&1 |
- awk 'NR > 1 { print $1 }') help" -- "$cur"))
+ _comp_compgen_split -- "$("$1" driver=help 2>&1 |
+ _comp_awk 'NR > 1 { print $1 }') help"
;;
minbuf)
- COMPREPLY=($(compgen -W '{25..95}' -- "$cur"))
+ _comp_compgen -- -W '{25..95}'
;;
esac
return
@@ -66,15 +65,15 @@ _cdrecord()
-isosize -pad -nopad -shorttrack -noshorttrack -preemp -nopreemp
-copy -nocopy -scms "isrc=" "index=" "padsize=" "pregap=" "tsize=")
# look if previous was either a file or a track option
- track_mode=0
+ track_mode=""
if ((cword > 1)); then
if [[ -f $prev ]]; then
- track_mode=1
+ track_mode=set
else
local opt
for opt in "${track_options[@]}"; do
if [[ $opt == "$prev" ]]; then
- track_mode=1
+ track_mode=set
break
fi
done
@@ -82,15 +81,15 @@ _cdrecord()
fi
# files are always eligible completion
- _filedir
+ _comp_compgen_filedir
# track options are always available
- COMPREPLY+=($(compgen -W '${track_options[@]}' -- "$cur"))
+ _comp_compgen -a -- -W '"${track_options[@]}"'
# general options are no more available after file or track option
- if ((track_mode == 0)); then
- COMPREPLY+=($(compgen -W '${generic_options[@]}' -- "$cur"))
+ if [[ ! $track_mode ]]; then
+ _comp_compgen -a -- -W '"${generic_options[@]}"'
fi
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
} &&
- complete -F _cdrecord cdrecord wodim
+ complete -F _comp_cmd_wodim wodim cdrecord
# ex: filetype=sh
diff --git a/completions/wol b/completions/wol
index eada070..7e409a1 100644
--- a/completions/wol
+++ b/completions/wol
@@ -1,42 +1,45 @@
# wol(1) completion -*- shell-script -*-
-_wol()
+_comp_cmd_wol()
{
- local cur prev words cword split
- _init_completion -s -n : || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -n : -- "$@" || return
+ local noargopts='!(-*|*[pwhif]*)'
+ # shellcheck disable=SC2254
case $prev in
- --version | --help | --port | --passwd | --wait | -!(-*)[Vpw])
+ --version | --help | --port | --passwd | --wait | -${noargopts}[Vpw])
return
;;
- --host | --ipaddr | -!(-*)[hi])
+ --host | --ipaddr | -${noargopts}[hi])
# Broadcast addresses
local PATH=$PATH:/sbin
- COMPREPLY=($({
- ip addr show || ifconfig -a
+ _comp_compgen_split -- "$({
+ ip -c=never addr show || ip addr show || ifconfig -a
} 2>/dev/null |
- command sed -ne 's/.*[[:space:]]Bcast:\([^[:space:]]*\).*/\1/p' -ne \
- 's/.*inet.*[[:space:]]brd[[:space:]]\([^[:space:]]*\).*/\1/p' -ne \
- 's/.*[[:space:]]broadcast[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p'))
- _known_hosts_real -- "$cur"
+ command sed \
+ -ne 's/.*[[:space:]]Bcast:\([^[:space:]]*\).*/\1/p' \
+ -ne 's/.*inet.*[[:space:]]brd[[:space:]]\([^[:space:]]*\).*/\1/p' \
+ -ne 's/.*[[:space:]]broadcast[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p')"
+ _comp_compgen -a known_hosts -- "$cur"
return
;;
- --file | -!(-*)f)
- _filedir
+ --file | -${noargopts}f)
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _mac_addresses
+ _comp_compgen_mac_addresses
} &&
- complete -F _wol wol
+ complete -F _comp_cmd_wol wol
# ex: filetype=sh
diff --git a/completions/wsimport b/completions/wsimport
index d5bec9f..cee8c09 100644
--- a/completions/wsimport
+++ b/completions/wsimport
@@ -1,48 +1,48 @@
# wsimport(1) completion -*- shell-script -*-
-_wsimport()
+_comp_cmd_wsimport()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
case $prev in
-help | -version | -B | -p | -wsdllocation)
return
;;
-b)
- _filedir '@(xml|xjb)'
+ _comp_compgen_filedir '@(xml|xjb)'
return
;;
-catalog)
- _filedir '@(xml|soc|catalog)'
+ _comp_compgen_filedir '@(xml|soc|catalog)'
return
;;
-d | –s)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-target)
- COMPREPLY=($(compgen -W '2.0 2.1 2.2' -- "$cur"))
+ _comp_compgen -- -W '2.0 2.1 2.2'
return
;;
-clientjar)
- _filedir jar
+ _comp_compgen_filedir jar
return
;;
esac
if [[ $cur == -httpproxy:* ]]; then
- _known_hosts_real -- "${cur#-httpproxy:}"
+ _comp_compgen_known_hosts -- "${cur#-httpproxy:}"
return
elif [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
[[ ${COMPREPLY-} == *: ]] && compopt -o nospace
- __ltrim_colon_completions "$cur"
+ _comp_ltrim_colon_completions "$cur"
return
fi
- _filedir wsdl
+ _comp_compgen_filedir wsdl
} &&
- complete -F _wsimport wsimport
+ complete -F _comp_cmd_wsimport wsimport
# ex: filetype=sh
diff --git a/completions/wtf b/completions/wtf
index 27fc10a..c565c56 100644
--- a/completions/wtf
+++ b/completions/wtf
@@ -1,42 +1,45 @@
# wtf completion -*- shell-script -*-
# Raphael Droz, 25/09/2009
-_wtf()
+_comp_cmd_wtf()
{
- local cur prev words cword addf
- _init_completion || return
+ local cur prev words cword comp_args addf
+ _comp_initialize -- "$@" || return
- [[ $prev == -f ]] && _filedir && return
+ [[ $prev == -f ]] && _comp_compgen_filedir && return
[[ ${words[*]} == *\ -f* ]] && addf= || addf=-f
if [[ $cur == -* ]]; then
- COMPREPLY=($addf)
+ COMPREPLY=(${addf:+"$addf"})
return
fi
- local db
+ local db="" has_db=""
set -- "${words[@]}"
while (($# > 0)); do
if [[ $1 == -f ]]; then
shift
- db=$1
+ if (($# > 0)); then
+ db=$1
+ has_db=set
+ fi
break
fi
shift
done
- if [[ ! -v db ]]; then
+ if [[ ! $has_db ]]; then
local f
for f in "${ACRONYMDB-}" /usr/share/misc/acronyms \
/usr/share/games/bsdgames/acronyms; do
- [[ -f $f ]] && db="$f" && break
+ [[ -f $f ]] && db="$f" has_db=set && break
done
- [[ -v db ]] || return
+ [[ $has_db ]] || return
fi
- COMPREPLY=($(compgen -W "$(cut -f 1 -s $db* 2>/dev/null) $addf" \
- -- "${cur^^}"))
+ _comp_compgen -c "${cur^^}" split \
+ -- "$(cut -f 1 -s "$db"* 2>/dev/null) $addf"
} &&
- complete -F _wtf wtf
+ complete -F _comp_cmd_wtf wtf
# ex: filetype=sh
diff --git a/completions/wvdial b/completions/wvdial
index 8667400..bdadeac 100644
--- a/completions/wvdial
+++ b/completions/wvdial
@@ -1,24 +1,24 @@
# bash completion for wvdial -*- shell-script -*-
-_wvdial()
+_comp_cmd_wvdial()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
--config)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
local config i IFS=$'\n'
case $cur in
-*)
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
;;
*)
@@ -33,14 +33,14 @@ _wvdial()
done
# parse config files for sections and
# remove default section
- COMPREPLY=($(command sed -ne "s|^\[Dialer \($cur.*\)\]$|\1|p" $config \
- 2>/dev/null | command grep -v '^Defaults$'))
+ _comp_compgen_split -l -X 'Defaults' -- "$(command sed -ne \
+ 's/^\[Dialer \(.*\)\]$/\1/p' "$config" 2>/dev/null)"
# escape spaces
- COMPREPLY=(${COMPREPLY[@]// /\\ })
+ COMPREPLY=("${COMPREPLY[@]// /\\ }")
;;
esac
} &&
- complete -F _wvdial wvdial
+ complete -F _comp_cmd_wvdial wvdial
# ex: filetype=sh
diff --git a/completions/xdg-mime b/completions/xdg-mime
index 74c26c4..db97034 100644
--- a/completions/xdg-mime
+++ b/completions/xdg-mime
@@ -1,74 +1,85 @@
# xdg-mime(1) completion -*- shell-script -*-
-_xdg_mime_mimetype()
+_comp_cmd_xdg_mime__mimetype()
{
- COMPREPLY+=($(compgen -S / -W 'application audio font image message model
- multipart text video' -- "$cur"))
- [[ ${COMPREPLY-} == */ ]] && compopt -o nospace
+ local d i
+ local -a arr
+ for d in /usr/share/mime /usr/local/share/mime; do
+ _comp_compgen -v arr -C "$d" -- -f -o plusdirs -X "!*.xml" || continue
+ for i in "${!arr[@]}"; do
+ case ${arr[i]} in
+ packages*) unset -v "arr[i]" ;; # not a MIME type dir
+ *.xml) arr[i]=${arr[i]%.xml} ;;
+ */*) ;;
+ *) arr[i]+=/ ;;
+ esac
+ done
+ ((${#arr[@]})) &&
+ COMPREPLY+=("${arr[@]}")
+ done
+ [[ ${COMPREPLY-} != */ ]] || compopt -o nospace
}
-_xdg_mime()
+_comp_cmd_xdg_mime()
{
- local cur prev words cword
- _init_completion || return
-
- local args
- _count_args
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+ local REPLY
+ _comp_count_args
+ local args=$REPLY
if ((args == 1)); then
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--help --manual --version' -- "$cur"))
+ _comp_compgen -- -W '--help --manual --version'
return
fi
- COMPREPLY=($(compgen -W \
- 'query default install uninstall' -- "$cur"))
+ _comp_compgen -- -W 'query default install uninstall'
return
fi
case ${words[1]} in
query)
if ((args == 2)); then
- COMPREPLY=($(compgen -W 'filetype default' -- "$cur"))
+ _comp_compgen -- -W 'filetype default'
return
fi
- case ${words[2]} in # TODO and args == 3 (takes only one arg!)
- filetype) _filedir ;;
- default) _xdg_mime_mimetype ;;
+ ((args == 3)) || return
+ case ${words[2]} in
+ filetype) _comp_compgen_filedir ;;
+ default) _comp_cmd_xdg_mime__mimetype ;;
esac
;;
default)
if ((args == 2)); then
- local IFS=$' \t\n' reset=$(shopt -p nullglob)
- shopt -s nullglob
- local -a desktops=(/usr/share/applications/*.desktop)
- desktops=("${desktops[@]##*/}")
- $reset
- IFS=$'\n'
- COMPREPLY=($(compgen -W '${desktops[@]}' -- "$cur"))
+ local -a desktops
+ if _comp_expand_glob desktops '/usr/share/applications/*.desktop'; then
+ desktops=("${desktops[@]##*/}")
+ _comp_compgen -- -W '"${desktops[@]}"'
+ fi
else
- _xdg_mime_mimetype
+ _comp_cmd_xdg_mime__mimetype
fi
;;
install)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--mode --novendor' -- "$cur"))
+ _comp_compgen -- -W '--mode --novendor'
elif [[ $prev == --mode ]]; then
- COMPREPLY=($(compgen -W 'user system' -- "$cur"))
+ _comp_compgen -- -W 'user system'
else
- _filedir xml
+ _comp_compgen_filedir xml
fi
;;
uninstall)
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '--mode' -- "$cur"))
+ _comp_compgen -- -W '--mode'
elif [[ $prev == --mode ]]; then
- COMPREPLY=($(compgen -W 'user system' -- "$cur"))
+ _comp_compgen -- -W 'user system'
else
- _filedir xml
+ _comp_compgen_filedir xml
fi
;;
esac
} &&
- complete -F _xdg_mime xdg-mime
+ complete -F _comp_cmd_xdg_mime xdg-mime
# ex: filetype=sh
diff --git a/completions/xdg-settings b/completions/xdg-settings
index abd9246..df03222 100644
--- a/completions/xdg-settings
+++ b/completions/xdg-settings
@@ -1,9 +1,9 @@
# xdg-settings completion -*- shell-script -*-
-_xdg_settings()
+_comp_cmd_xdg_settings()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--help | --list | --manual | --version)
@@ -12,20 +12,18 @@ _xdg_settings()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$("$1" --help |
- tr "{|" "\n" | _parse_help -)' -- "$cur"))
+ _comp_compgen_help - <<<"$("$1" --help | tr '{|' '\n')"
return
fi
- local args
- _count_args
- if ((args == 1)); then
- COMPREPLY=($(compgen -W "get check set" -- "$cur"))
- elif ((args == 2)); then
- COMPREPLY=($(compgen -W \
- '$("$1" --list | awk "!/^Known/ { print \$1 }")' -- "$cur"))
+ local REPLY
+ _comp_count_args
+ if ((REPLY == 1)); then
+ _comp_compgen -- -W "get check set"
+ elif ((REPLY == 2)); then
+ _comp_compgen_split -- "$("$1" --list | _comp_awk '!/^Known/ { print $1 }')"
fi
} &&
- complete -F _xdg_settings xdg-settings
+ complete -F _comp_cmd_xdg_settings xdg-settings
# ex: filetype=sh
diff --git a/completions/xev b/completions/xev
new file mode 100644
index 0000000..78df177
--- /dev/null
+++ b/completions/xev
@@ -0,0 +1,31 @@
+# xev(1) completion -*- shell-script -*-
+
+_comp_cmd_xev()
+{
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+
+ case $prev in
+ -display | -geometry | -bw | -id | -name)
+ return
+ ;;
+ -bs)
+ _comp_compgen -- -W 'NotUseful WhenMapped Always'
+ return
+ ;;
+ -event)
+ _comp_compgen -- -W 'keyboard mouse expose visibility structure
+ substructure focus property colormap owner_grab_button randr
+ button'
+ return
+ ;;
+ esac
+
+ if [[ $cur == -* ]]; then
+ _comp_compgen_help
+ return
+ fi
+} &&
+ complete -F _comp_cmd_xev xev
+
+# ex: filetype=sh
diff --git a/completions/xfreerdp b/completions/xfreerdp
index f17414f..66b42ad 100644
--- a/completions/xfreerdp
+++ b/completions/xfreerdp
@@ -1,67 +1,78 @@
# xfreerdp completion -*- shell-script -*-
-_xfreerdp()
+_comp_cmd_xfreerdp()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
- case $prev in # old/dash syntax
+ case $prev in
-k)
- COMPREPLY=($(compgen -W '$("$1" --kbd-list |
- awk "/^0x/ { print \$1 }")' -- "$cur"))
+ _comp_compgen_split -- "$("$1" --kbd-list |
+ _comp_awk '/^0x/ { print $1 }')"
return
;;
-a)
- COMPREPLY=($(compgen -W '8 15 16 24 32' -- "$cur"))
+ _comp_compgen -- -W '8 15 16 24 32'
return
;;
-x)
- COMPREPLY=($(compgen -W 'broadband modem lan' -- "$cur"))
+ _comp_compgen -- -W 'broadband modem lan'
return
;;
--plugin)
- COMPREPLY=($(compgen -W 'cliprdr rdpsnd rdpdr' -- "$cur"))
+ _comp_compgen -- -W 'cliprdr rdpsnd rdpdr'
+ return
+ ;;
+ /help | /version | -h | --help | --version)
return
;;
esac
- case $cur in # new/slash syntax
+ case $cur in
/kbd:*)
- COMPREPLY=($(compgen -W '$("$1" /kbd-list |
- awk "/^0x/ { print \$1 }")' -- "${cur#/kbd:}"))
+ local kbd_list
+ kbd_list=$("$1" /kbd-list 2>/dev/null) ||
+ kbd_list=$("$1" /list:kbd 2>/dev/null)
+ _comp_compgen -c "${cur#/kbd:}" split -- "$(
+ _comp_awk '/^0x/ { print $1 }' <<<"$kbd_list"
+ )"
return
;;
/bpp:*)
- COMPREPLY=($(compgen -W '8 15 16 24 32' -- "${cur#/bpp:}"))
+ _comp_compgen -c "${cur#/bpp:}" -- -W '8 15 16 24 32'
return
;;
- /*:* | /help | /version | -h | --help | --version)
+ /*:*)
return
;;
esac
if [[ $cur == /* ]]; then
- COMPREPLY=($(compgen -W '$("$1" --help |
- awk "\$1 ~ /^\\// && \$1 !~ /^.(flag\$|option:)/ { sub(\":.*\",\":\",\$1); print \$1 }")' \
- -- "$cur"))
+ _comp_compgen_filedir rdp
+ _comp_compgen -a split -- "$(
+ "$1" --help | _comp_awk '$1 ~ /^\// && $1 !~ /^.(flag$|option:)/ {
+ sub(":.*",":",$1); print $1 }'
+ )"
[[ ${COMPREPLY-} == *: ]] && compopt -o nospace
elif [[ $cur == [+-]* ]]; then
local char=${cur:0:1}
- local help="$($1 --help)"
+ local help="$("$1" --help)"
if [[ $help == */help* ]]; then # new/slash syntax
- COMPREPLY=($(compgen -W '$(awk "
- \$1 ~ /^[+-]/ && \$1 !~ /^.toggle\$/ { sub(\"^.\",\"$char\",\$1); print \$1 }
- " <<<"$help")' -- "$cur"))
+ _comp_compgen_split -- "$(_comp_awk '$1 ~ /^[+-]/ && $1 !~ /^.toggle$/ {
+ sub("^.","'"$char"'",$1); print $1 }' <<<"$help")"
else # old/dash syntax
- COMPREPLY=($(_parse_help - <<<"$help"))
- COMPREPLY=($(compgen -W '${COMPREPLY[@]%:}' -- "$cur"))
+ _comp_compgen -R help - <<<"$help"
+ ((${#COMPREPLY[@]})) &&
+ _comp_compgen -- -W '"${COMPREPLY[@]%:}"'
fi
else
- COMPREPLY=($(compgen -W "$(awk '{print $1}' ~/.freerdp/known_hosts \
- 2>/dev/null)" -- "$cur"))
+ _comp_compgen_filedir rdp
+ _comp_compgen -a split -- "$(
+ _comp_awk '{print $1}' ~/.freerdp/known_hosts 2>/dev/null
+ )"
fi
} &&
- complete -F _xfreerdp xfreerdp
+ complete -F _comp_cmd_xfreerdp xfreerdp
# ex: filetype=sh
diff --git a/completions/xgamma b/completions/xgamma
index 8d77ba3..2a0c409 100644
--- a/completions/xgamma
+++ b/completions/xgamma
@@ -1,15 +1,15 @@
# bash completion for xgamma(1) -*- shell-script -*-
-_xgamma()
+_comp_cmd_xgamma()
{
- local cur prev words cword
- _init_completion -n : || return
+ local cur prev words cword comp_args
+ _comp_initialize -n : -- "$@" || return
case "$prev" in
-screen)
local screens=$(xrandr --query 2>/dev/null | command sed -n \
'/^Screen /s|^Screen \{1,\}\(.*\):.*$|\1|p' 2>/dev/null)
- COMPREPLY=($(compgen -W "$screens" -- "$cur"))
+ _comp_compgen -- -W "$screens"
return
;;
-gamma | -rgamma | -ggamma | -bgamma)
@@ -17,7 +17,7 @@ _xgamma()
if [[ $cur && $cur != *.* ]]; then
COMPREPLY=(.)
fi
- COMPREPLY+=($(compgen -W "{0..9}"))
+ _comp_compgen -aR -- -W "{0..9}"
compopt -o nospace
return
;;
@@ -26,18 +26,17 @@ _xgamma()
if [[ $cur == :* && $cur != :*.* ]]; then
# FIXME: where to get local display numbers?
local display=${cur#:}
- COMPREPLY=($(compgen -W "${display:-0}."))
+ _comp_compgen -R -- -W "${display:-0}."
compopt -o nospace
elif [[ $cur == :*.* ]]; then
# local screen numbers
local t screens=$(xrandr --query 2>/dev/null | command sed -ne \
'/^Screen /s|^Screen \{1,\}\(.*\):.*$|\1|p' 2>/dev/null)
t="${cur#:}"
- COMPREPLY=($(compgen -P "${t%.*}." -W "$screens" -- \
- "${cur##*.}"))
+ _comp_compgen -c "${cur##*.}" -- -P "${t%.*}." -W '$screens'
elif [[ $cur != *:* ]]; then
# complete hostnames
- _known_hosts_real -c -- "$cur"
+ _comp_compgen_known_hosts -c -- "$cur"
if [[ ! $cur ]]; then
COMPREPLY+=(:)
fi
@@ -49,13 +48,13 @@ _xgamma()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
if [[ ${COMPREPLY-} ]]; then
[[ $COMPREPLY == *= ]] && compopt -o nospace
return
fi
fi
} &&
- complete -F _xgamma xgamma
+ complete -F _comp_cmd_xgamma xgamma
# ex: filetype=sh
diff --git a/completions/xhost b/completions/xhost
index 648ae4f..9491030 100644
--- a/completions/xhost
+++ b/completions/xhost
@@ -1,16 +1,16 @@
# xhost(1) completion -*- shell-script -*-
-_xhost()
+_comp_cmd_xhost()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $cur in
- +*) _known_hosts_real -p+ -- "${cur:1}" ;;
- -*) _known_hosts_real -p- -- "${cur:1}" ;;
- *) _known_hosts_real -- "$cur" ;;
+ +*) _comp_compgen_known_hosts -p+ -- "${cur:1}" ;;
+ -*) _comp_compgen_known_hosts -p- -- "${cur:1}" ;;
+ *) _comp_compgen_known_hosts -- "$cur" ;;
esac
} &&
- complete -F _xhost xhost
+ complete -F _comp_cmd_xhost xhost
# ex: filetype=sh
diff --git a/completions/xmllint b/completions/xmllint
index a6ef38f..57445bb 100644
--- a/completions/xmllint
+++ b/completions/xmllint
@@ -1,13 +1,13 @@
# bash completion for xmllint(1) -*- shell-script -*-
-_xmllint()
+_comp_cmd_xmllint()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-o | --output)
- _filedir
+ _comp_compgen_filedir
return
;;
--path | --dtdvalidfpi | --maxmem | --pattern | --xpath)
@@ -15,39 +15,39 @@ _xmllint()
return
;;
--dtdvalid)
- _filedir 'dtd?(.gz)'
+ _comp_compgen_filedir 'dtd?(.gz)'
return
;;
--relaxng)
- _filedir 'rng?(.gz)'
+ _comp_compgen_filedir 'rng?(.gz)'
return
;;
--schema)
- _filedir 'xsd?(.gz)'
+ _comp_compgen_filedir 'xsd?(.gz)'
return
;;
--schematron)
- _filedir 'sch?(.gz)'
+ _comp_compgen_filedir 'sch?(.gz)'
return
;;
--encode)
- _xfunc iconv _iconv_charsets
+ _comp_compgen -x iconv charsets
return
;;
--pretty)
- COMPREPLY=($(compgen -W '{0..2}' -- "$cur"))
+ _comp_compgen -- -W '{0..2}'
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
COMPREPLY=("${COMPREPLY[@]%:}")
return
fi
- _filedir '@(*ml|htm|svg?(z)|xs[dl]|rng|wsdl|jnlp|tld|dbk|docbook|page)?(.gz)'
+ _comp_compgen_filedir '@(*ml|htm|svg?(z)|xs[dl]|rng|wsdl|jnlp|tld|dbk|docbook|page)?(.gz)'
} &&
- complete -F _xmllint xmllint
+ complete -F _comp_cmd_xmllint xmllint
# ex: filetype=sh
diff --git a/completions/xmlwf b/completions/xmlwf
index b397af9..d047ee1 100644
--- a/completions/xmlwf
+++ b/completions/xmlwf
@@ -1,32 +1,31 @@
# bash completion for xmlwf(1) -*- shell-script -*-
-_xmlwf()
+_comp_cmd_xmlwf()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-*d)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
-*e)
- COMPREPLY=($(compgen -W 'US-ASCII UTF-8 UTF-16 ISO-8859-1' \
- -- "$cur"))
+ _comp_compgen -- -W 'US-ASCII UTF-8 UTF-16 ISO-8859-1'
return
;;
- -*v)
+ -*[abv])
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ _comp_compgen_help || _comp_compgen_usage
return
fi
- _filedir '@(*ml|htm|svg|xs[dl]|rng|wsdl|jnlp|tld|dbk|docbook|page)'
+ _comp_compgen_filedir '@(*ml|htm|svg|xs[dl]|rng|wsdl|jnlp|tld|dbk|docbook|page)'
} &&
- complete -F _xmlwf xmlwf
+ complete -F _comp_cmd_xmlwf xmlwf
# ex: filetype=sh
diff --git a/completions/xmms b/completions/xmms
index af4aefe..49bc381 100644
--- a/completions/xmms
+++ b/completions/xmms
@@ -1,29 +1,31 @@
# bash completion for xmms -*- shell-script -*-
-_xmms()
+_comp_cmd_xmms()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[SRA]*)'
+ # shellcheck disable=SC2254
case $prev in
- --help | --version | -!(-*)[hv])
+ --help | --version | -${noargopts}[hv])
return
;;
- --toggle-shuffle | --toggle-repeat | --toggle-advance | -!(-*)[SRA])
- COMPREPLY=($(compgen -W 'on off' -- "$cur"))
+ --toggle-shuffle | --toggle-repeat | --toggle-advance | -${noargopts}[SRA])
+ _comp_compgen -- -W 'on off'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
else
- _filedir '@(mp[23]|ogg|wav|pls|m3u|xm|mod|s[3t]m|it|mtm|ult|flac)'
+ _comp_compgen_filedir '@(mp[23]|ogg|wav|pls|m3u|xm|mod|s[3t]m|it|mtm|ult|flac)'
fi
} &&
- complete -F _xmms xmms
+ complete -F _comp_cmd_xmms xmms
# ex: filetype=sh
diff --git a/completions/xmodmap b/completions/xmodmap
index 7cfa230..f8d2957 100644
--- a/completions/xmodmap
+++ b/completions/xmodmap
@@ -1,9 +1,9 @@
# xmodmap(1) completion -*- shell-script -*-
-_xmodmap()
+_comp_cmd_xmodmap()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-display | -e)
@@ -12,12 +12,12 @@ _xmodmap()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ _comp_compgen_help -- -help
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _xmodmap xmodmap
+ complete -F _comp_cmd_xmodmap xmodmap
# ex: filetype=sh
diff --git a/completions/xrandr b/completions/xrandr
index 16704e3..c071ab4 100644
--- a/completions/xrandr
+++ b/completions/xrandr
@@ -1,63 +1,178 @@
# bash completion for xrandr -*- shell-script -*-
-_xrandr()
+_comp_cmd_xrandr__compgen_outputs()
{
- local cur prev words cword
- _init_completion || return
+ _comp_compgen_split -- "$("$1" -q 2>/dev/null | _comp_awk '/connected/ {print $1}')"
+}
+
+_comp_cmd_xrandr__compgen_monitors()
+{
+ _comp_compgen_split -- "$(
+ "$1" --listmonitors 2>/dev/null |
+ command sed -ne 's/.* [0-9]*: [+\*]*\([^ ]*\).*/\1/p'
+ )"
+}
+
+_comp_cmd_xrandr__compgen_providers()
+{
+ _comp_compgen_split -- "$("$1" --listproviders 2>/dev/null |
+ command sed -ne "s/.*cap:.*$2.* name:\([^ ]*\).*/\1/p")"
+}
+
+_comp_cmd_xrandr__compgen_modes()
+{
+ _comp_compgen_split -- "$(
+ "$1" -q 2>/dev/null | command sed \
+ -e "1,/^$2 / d" \
+ -e '/connected/,$ d' \
+ -e '/^[[:space:]]*h: / d' \
+ -e '/^[[:space:]]*v: / d' \
+ -e 's/\([^[:space:]]\)[[:space:]].*/\1/'
+ )"
+}
+
+_comp_cmd_xrandr__compgen_all_modes()
+{
+ _comp_compgen_split -- "$(
+ "$1" -q 2>/dev/null | command sed \
+ -e '/^[^[:space:]].*/ d' \
+ -e '/^[[:space:]]*h: / d' \
+ -e '/^[[:space:]]*v: / d' \
+ -e 's/[[:space:]]*\([^[:space:]]*\)[[:space:]].*/\1/'
+ )"
+}
+
+_comp_cmd_xrandr()
+{
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
+
+ local i output has_output=""
+ for ((i = cword - 1; i > 0; i--)); do
+ if [[ ${words[i]} == --output ]]; then
+ output=${words[i + 1]}
+ has_output=set
+ break
+ fi
+ done
case "$prev" in
- -display | -d | -help | -s | --size | -r | --rate | --refresh | --screen | --fb | --fbmm | \
- --dpi | --pos | --set | --scale | --transform | --crtc | --panning | --gamma | \
- --newmode | --rmmode | --addmode | --delmode)
+ -display | -d | -s | --size | -r | --rate | --refresh | --screen | \
+ --fb | --fbmm | --pos | --set | --scale | --transform | --crtc | \
+ --panning | --gamma | --newmode | --rmmode | --setmonitor)
+ return
+ ;;
+ --output | --addmode | --delmode | --dpi)
+ _comp_cmd_xrandr__compgen_outputs "$1"
return
;;
- --output | --left-of | --right-of | --above | --below | --same-as)
- local outputs=$("$1" | awk '/connected/ {print $1}')
- COMPREPLY=($(compgen -W "$outputs" -- "$cur"))
+ --left-of | --right-of | --above | --below | --same-as)
+ if [[ $has_output ]]; then
+ _comp_cmd_xrandr__compgen_outputs "$1"
+ fi
return
;;
--mode)
- local i output
- for ((i = 1; i < cword; i++)); do
- if [[ ${words[i]} == --output ]]; then
- output=${words[i + 1]}
- break
- fi
- done
- if [[ -v output ]]; then
- local modes=$("$1" | command sed -e "1,/^$output / d" \
- -e "/connected/,$ d" \
- -e "s/\([^[:space:]]\)[[:space:]].*/\1/")
- COMPREPLY=($(compgen -W "$modes" -- "$cur"))
+ if [[ $has_output ]]; then
+ _comp_cmd_xrandr__compgen_modes "$1" "$output"
fi
return
;;
-o | --orientation)
- COMPREPLY=($(compgen -W 'normal inverted left right 0 1 2 3' -- \
- "$cur"))
+ _comp_compgen -- -W 'normal inverted left right 0 1 2 3'
return
;;
--reflect)
- COMPREPLY=($(compgen -W 'normal x y xy' -- "$cur"))
+ if [[ $has_output ]]; then
+ _comp_compgen -- -W 'normal x y xy'
+ fi
return
;;
--rotate)
- COMPREPLY=($(compgen -W 'normal inverted left right' -- "$cur"))
+ if [[ $has_output ]]; then
+ _comp_compgen -- -W 'normal inverted left right'
+ fi
return
;;
- --setprovideroutputsource | --setprovideroffloadsink)
- local providers=$("$1" --listproviders 2>/dev/null |
- command sed -ne 's/.* name:\([^ ]*\).*/\1/p')
- COMPREPLY=($(compgen -W "$providers" -- "$cur"))
- # TODO 2nd arg needed, is that a provider as well?
+ --filter)
+ if [[ $has_output ]]; then
+ _comp_compgen -- -W 'bilinear nearest'
+ fi
+ return
+ ;;
+ --setprovideroutputsource)
+ _comp_cmd_xrandr__compgen_providers "$1" "Sink Output"
+ return
+ ;;
+ --setprovideroffloadsink)
+ _comp_cmd_xrandr__compgen_providers "$1" "Source Offload"
+ return
+ ;;
+ --delmonitor)
+ _comp_cmd_xrandr__compgen_monitors "$1"
return
;;
esac
- COMPREPLY=($(compgen -W '$("$1" -help 2>&1 |
- command sed -e "s/ or / /g" -e "s/<[^>]*>]//g" | _parse_help -)' \
- -- "$cur"))
+ # second arguments
+ if ((cword >= 2)); then
+ case "${words[cword - 2]}" in
+ --set)
+ return
+ ;;
+ --addmode)
+ _comp_cmd_xrandr__compgen_all_modes "$1"
+ return
+ ;;
+ --delmode)
+ _comp_cmd_xrandr__compgen_modes "$1" "${words[cword - 1]}"
+ return
+ ;;
+ --setmonitor)
+ _comp_compgen -- -W 'auto'
+ return
+ ;;
+ --setprovideroutputsource)
+ _comp_cmd_xrandr__compgen_providers "$1" "Source Output"
+ _comp_compgen -a -- -W "0x0"
+ return
+ ;;
+ --setprovideroffloadsink)
+ _comp_cmd_xrandr__compgen_providers "$1" "Sink Offload"
+ _comp_compgen -a -- -W "0x0"
+ return
+ ;;
+ esac
+ fi
+
+ # third arguments
+ if ((cword >= 3)); then
+ case "${words[cword - 3]}" in
+ --setmonitor)
+ _comp_compgen -c "${cur##*,}" -i xrandr outputs "$1"
+ _comp_compgen -ac "${cur##*,}" -- -W "none"
+ _comp_delimited , -W '"${COMPREPLY[@]}"'
+ return
+ ;;
+ esac
+ fi
+
+ local options
+ if [[ $has_output ]]; then
+ _comp_compgen -v options help - <<<"$(
+ "$1" --help 2>/dev/null |
+ command sed -e 's/ or /\n /g' -e 's/<[^>]*>]//g'
+ )"
+ else
+ # if no output is specified, remove per-output options
+ _comp_compgen -v options help - <<<"$(
+ "$1" --help 2>/dev/null |
+ command sed -e '/^ -/!d' -e 's/ or /\n /g' -e 's/<[^>]*>]//g'
+ )"
+ fi
+
+ _comp_compgen -- -W '"${options[@]}"'
} &&
- complete -F _xrandr xrandr
+ complete -F _comp_cmd_xrandr xrandr
# ex: filetype=sh
diff --git a/completions/xrdb b/completions/xrdb
index f46f90b..0bd2598 100644
--- a/completions/xrdb
+++ b/completions/xrdb
@@ -1,27 +1,27 @@
# xrdb(1) completion -*- shell-script -*-
-_xrdb()
+_comp_cmd_xrdb()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-backup | -display | -help)
return
;;
-cpp | -edit)
- _filedir
+ _comp_compgen_filedir
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _xrdb xrdb
+ complete -F _comp_cmd_xrdb xrdb
# ex: filetype=sh
diff --git a/completions/xsltproc b/completions/xsltproc
index 4cb7071..5d75596 100644
--- a/completions/xsltproc
+++ b/completions/xsltproc
@@ -1,13 +1,13 @@
# xsltproc(1) completion -*- shell-script -*-
-_xsltproc()
+_comp_cmd_xsltproc()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
--output | -o)
- _filedir
+ _comp_compgen_filedir
return
;;
# TODO : number only
@@ -16,8 +16,8 @@ _xsltproc()
;;
--encoding)
# some aliases removed
- COMPREPLY=($(compgen -X '@(UTF[1378]|8859|ISO[0-9_])*' \
- -W "$(iconv -l | command sed -e 's/\/.*//')" -- "$cur"))
+ local encodings=$(iconv -l | command sed -e 's/\/.*//')
+ _comp_compgen -- -X '@(UTF[1378]|8859|ISO[0-9_])*' -W '$encodings'
return
;;
--param | --stringparam)
@@ -25,25 +25,25 @@ _xsltproc()
;;
# not really like --writesubtree
--path)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
--writesubtree)
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
esac
- [[ $cword -gt 2 && $(_get_cword '' 2) == --?(string)param ]] && return
+ [[ $cword -gt 2 && ${words[cword - 2]} == --?(string)param ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
COMPREPLY=("${COMPREPLY[@]%:}")
else
# TODO: 1st file xsl|xslt, 2nd XML
- _filedir '@(xsl|xslt|xml|dbk|docbook|page)'
+ _comp_compgen_filedir '@(xsl|xslt|xml|dbk|docbook|page)'
fi
} &&
- complete -F _xsltproc xsltproc
+ complete -F _comp_cmd_xsltproc xsltproc
# ex: filetype=sh
diff --git a/completions/xvfb-run b/completions/xvfb-run
index ed2788a..9ae1fc8 100644
--- a/completions/xvfb-run
+++ b/completions/xvfb-run
@@ -1,36 +1,39 @@
# bash completion for xvfb-run -*- shell-script -*-
-_xvfb_run()
+_comp_cmd_xvfb_run()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*[npsef]*)'
local i
- for ((i = 1; i <= COMP_CWORD; i++)); do
- if [[ ${COMP_WORDS[i]} != -* ]]; then
- _command_offset $i
+ for ((i = 1; i <= cword; i++)); do
+ if [[ ${words[i]} != -* ]]; then
+ _comp_command_offset $i
return
fi
- [[ ${COMP_WORDS[i]} == -!(-*)[npsef] ]] && ((i++))
+ # shellcheck disable=SC2254
+ [[ ${words[i]} == -${noargopts}[npsef] ]] && ((i++))
done
+ # shellcheck disable=SC2254
case $prev in
- --help | --server-num | --xauth-protocol | --server-args | -!(-*)[hnps])
+ --help | --server-num | --xauth-protocol | --server-args | -${noargopts}[hnps])
return
;;
- --error-file | --auth-file | -!(-*)[ef])
- _filedir
+ --error-file | --auth-file | -${noargopts}[ef])
+ _comp_compgen_filedir
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
- complete -F _xvfb_run xvfb-run
+ complete -F _comp_cmd_xvfb_run xvfb-run
# ex: filetype=sh
diff --git a/completions/xxd b/completions/xxd
index a470bb0..b9facde 100644
--- a/completions/xxd
+++ b/completions/xxd
@@ -1,23 +1,24 @@
# xxd(1) completion -*- shell-script -*-
-_xxd()
+_comp_cmd_xxd()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
- -h | -help | -c | -cols | -g | -groupsize | -l | -len | -s | -seek | -v | -version)
+ -h | -help | -c | -cols | -g | -groupsize | -l | -len | -s | -seek | \
+ -v | -version)
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ _comp_compgen_help -- -h
return
fi
- _filedir
+ _comp_compgen_filedir
} &&
- complete -F _xxd xxd
+ complete -F _comp_cmd_xxd xxd
# ex: filetype=sh
diff --git a/completions/xz b/completions/xz
index 73958c5..8d6c53b 100644
--- a/completions/xz
+++ b/completions/xz
@@ -1,56 +1,59 @@
# xz(1) completion -*- shell-script -*-
-_xz()
+_comp_cmd_xz()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
local xspec="*.@(xz|lzma|txz|tlz)"
+ local noargopts='!(-*|*[CFTMS]*)'
+ # shellcheck disable=SC2254
case $prev in
- --decompress | --list | --test | -!(-*)[dlt]*)
+ --decompress | --list | --test | -${noargopts}[dlt]*)
xspec="!"$xspec
;;
--files | --files0)
- _filedir
+ _comp_compgen_filedir
return
;;
- --check | -!(-*)C)
- COMPREPLY=($(compgen -W 'crc32 crc64 sha256 none' -- "$cur"))
+ --check | -${noargopts}C)
+ _comp_compgen -- -W 'crc32 crc64 sha256 none'
return
;;
- --format | -!(-*)F)
- COMPREPLY=($(compgen -W 'auto xz lzma raw' -- "$cur"))
+ --format | -${noargopts}F)
+ _comp_compgen -- -W 'auto xz lzma raw'
return
;;
- --threads | -!(-*)T)
- COMPREPLY=($(compgen -W "{0..$(_ncpus)}" -- "$cur"))
+ --threads | -${noargopts}T)
+ local REPLY
+ _comp_get_ncpus
+ _comp_compgen -- -W "{0..$REPLY}"
return
;;
--memlimit | --memlimit-compress | --memlimit-decompress | --memory | \
- --suffix | --delta | --lzma1 | --lzma2 | -!(-*)[MS])
+ --suffix | --delta | --lzma1 | --lzma2 | -${noargopts}[MS])
return
;;
- --help | --long-help | --version | --info-memory | -!(-*)[hHV])
+ --help | --long-help | --version | --info-memory | -${noargopts}[hHV])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1" --long-help) {-1..-9}' \
- -- "$cur"))
+ _comp_compgen_help -- --long-help
+ _comp_compgen -a -- -W '{-1..-9}'
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _tilde "$cur" || return
+ _comp_compgen_tilde && return
- local IFS=$'\n'
compopt -o filenames
- COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur"))
+ _comp_compgen -- -f -X "$xspec" -o plusdirs
} &&
- complete -F _xz xz pxz
+ complete -F _comp_cmd_xz xz pxz
# ex: filetype=sh
diff --git a/completions/xzdec b/completions/xzdec
index 993bd2b..21ee6ec 100644
--- a/completions/xzdec
+++ b/completions/xzdec
@@ -1,29 +1,31 @@
# xzdec(1) completion -*- shell-script -*-
-_xzdec()
+_comp_cmd_xzdec()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
+ local noargopts='!(-*|*M*)'
+ # shellcheck disable=SC2254
case $prev in
- --memory | -!(-*)M)
+ --memory | -${noargopts}M)
return
;;
- --help | --version | -!(-*)[hV])
+ --help | --version | -${noargopts}[hV])
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ _comp_compgen_help
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _filedir xz # no lzma support here as of xz 4.999.9beta
+ _comp_compgen_filedir xz # no lzma support here as of xz 4.999.9beta
} &&
- complete -F _xzdec xzdec
+ complete -F _comp_cmd_xzdec xzdec
# ex: filetype=sh
diff --git a/completions/ypmatch b/completions/ypmatch
index 13249f0..db5a233 100644
--- a/completions/ypmatch
+++ b/completions/ypmatch
@@ -1,9 +1,9 @@
# bash completion for yp-tools -*- shell-script -*-
-_ypmatch()
+_comp_cmd_ypmatch()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
local map cmd=${1##*/}
@@ -12,15 +12,12 @@ _ypmatch()
if [[ $cmd == ypmatch && $cword -eq 1 && ${#words[@]} -eq 3 ]]; then
map=${words[2]}
- COMPREPLY=($(compgen -W '$(ypcat $map 2>/dev/null | \
- cut -d':' -f 1)' -- "$cur"))
+ _comp_compgen_split -- "$(ypcat "$map" 2>/dev/null | cut -d':' -f 1)"
else
[[ $cmd == ypmatch && $cword -ne 2 ]] && return
- COMPREPLY=($(compgen -W \
- '$(printf "%s\n" $(ypcat -x 2>/dev/null | \
- cut -d"\"" -f 2))' -- "$cur"))
+ _comp_compgen_split -- "$(ypcat -x 2>/dev/null | cut -d'"' -f 2)"
fi
} &&
- complete -F _ypmatch ypmatch ypcat
+ complete -F _comp_cmd_ypmatch ypmatch ypcat
# ex: filetype=sh
diff --git a/completions/yum-arch b/completions/yum-arch
index 883c77e..070d020 100644
--- a/completions/yum-arch
+++ b/completions/yum-arch
@@ -1,16 +1,16 @@
# yum-arch(8) completion -*- shell-script -*-
-_yum_arch()
+_comp_cmd_yum_arch()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W '-d -v -vv -n -c -z -s -l -q' -- "$cur"))
+ _comp_compgen -- -W '-d -v -vv -n -c -z -s -l -q'
else
- _filedir -d
+ _comp_compgen_filedir -d
fi
} &&
- complete -F _yum_arch yum-arch
+ complete -F _comp_cmd_yum_arch yum-arch
# ex: filetype=sh
diff --git a/completions/zopfli b/completions/zopfli
index 8c02885..49d5305 100644
--- a/completions/zopfli
+++ b/completions/zopfli
@@ -1,9 +1,9 @@
# bash completion for zopfli -*- shell-script -*-
-_zopfli()
+_comp_cmd_zopfli()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword comp_args
+ _comp_initialize -- "$@" || return
case $prev in
-h)
@@ -12,18 +12,19 @@ _zopfli()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=($(compgen -W \
- '$(_parse_help "$1" -h | command sed -e "s/#$//")' -- "$cur"))
+ _comp_compgen -R help -- -h
+ ((${#COMPREPLY[@]})) &&
+ _comp_compgen -- -W '"${COMPREPLY[@]%#}"'
[[ ${COMPREPLY-} == --i ]] && compopt -o nospace
return
fi
- _tilde "$cur" || return
+ _comp_compgen_tilde && return
- local IFS=$'\n' xspec="*.@(gz|t[ag]z)"
+ local xspec="*.@(gz|t[ag]z)"
compopt -o filenames
- COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur"))
+ _comp_compgen -- -f -X "$xspec" -o plusdirs
} &&
- complete -F _zopfli zopfli
+ complete -F _comp_cmd_zopfli zopfli
# ex: filetype=sh
diff --git a/completions/zopflipng b/completions/zopflipng
index 4526cd9..76a0c30 100644
--- a/completions/zopflipng
+++ b/completions/zopflipng
@@ -1,39 +1,40 @@
# bash completion for zopflipng -*- shell-script -*-
-_zopflipng()
+_comp_cmd_zopflipng()
{
- local cur prev words cword split
- _init_completion -s || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -- "$@" || return
case $prev in
-h | --help)
return
;;
--splitting)
- COMPREPLY=($(compgen -W '{0..3}' -- "$cur"))
+ _comp_compgen -- -W '{0..3}'
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
if [[ $cur == -* ]]; then
- COMPREPLY=($(_parse_help "$1" -h))
- COMPREPLY=($(compgen -W '${COMPREPLY[@]%:}' -- "$cur"))
+ _comp_compgen -R help -- -h
+ ((${#COMPREPLY[@]})) &&
+ _comp_compgen -- -W '"${COMPREPLY[@]%:}"'
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
if [[ ${words[*]} != *\ --prefix=* ]]; then
# 2 png args only if --prefix not given
- local args
- _count_args
- ((args < 3)) && _filedir png
+ local REPLY
+ _comp_count_args
+ ((REPLY < 3)) && _comp_compgen_filedir png
else
# otherwise arbitrary number of png args
- _filedir png
+ _comp_compgen_filedir png
fi
} &&
- complete -F _zopflipng zopflipng
+ complete -F _comp_cmd_zopflipng zopflipng
# ex: filetype=sh