From 95623d39d6029ba78ec96ad5ea08e9ac12629b91 Mon Sep 17 00:00:00 2001 From: "Gabriel F. T. Gomes" Date: Mon, 3 Aug 2020 18:43:13 -0300 Subject: New upstream version 2.11 --- .dir-locals.el | 2 + .editorconfig | 5 +- .gitignore | 4 - .markdownlint.yaml | 4 + .perltidyrc | 1 + .pre-commit-config.yaml | 97 ++ .shellcheckrc | 14 +- .travis.yml | 36 +- CHANGES | 371 +++++++ CONTRIBUTING.md | 23 +- README.md | 63 +- bash_completion | 1164 +++++++++++--------- bash_completion.sh.in | 6 +- completions/.gitignore | 3 + completions/2to3 | 20 +- completions/7z | 65 +- completions/Makefile.am | 16 +- completions/_adb | 30 +- completions/_cal | 10 +- completions/_chsh | 10 +- completions/_dmesg | 16 +- completions/_eject | 10 +- completions/_hexdump | 6 +- completions/_hwclock | 8 +- completions/_ionice | 16 +- completions/_look | 6 +- completions/_mock | 40 +- completions/_modules | 49 +- completions/_mount | 28 +- completions/_mount.linux | 264 ++--- completions/_newgrp | 6 +- completions/_nmcli | 96 +- completions/_renice | 10 +- completions/_repomanage | 10 +- completions/_reptyr | 4 +- completions/_rfkill | 14 +- completions/_rtcwake | 16 +- completions/_su | 20 +- completions/_svn | 59 +- completions/_svnadmin | 20 +- completions/_svnlook | 22 +- completions/_udevadm | 38 +- completions/_umount | 4 +- completions/_umount.linux | 52 +- completions/_xm | 58 +- completions/_yum | 77 +- completions/a2x | 14 +- completions/abook | 28 +- completions/aclocal | 18 +- completions/acpi | 8 +- completions/add_members | 14 +- completions/alias | 8 +- completions/ant | 30 +- completions/apache2ctl | 6 +- completions/appdata-validate | 12 +- completions/apt-build | 29 +- completions/apt-cache | 62 +- completions/apt-get | 60 +- completions/aptitude | 108 +- completions/arch | 66 +- completions/arp | 18 +- completions/arping | 6 +- completions/arpspoof | 6 +- completions/asciidoc | 26 +- completions/aspell | 50 +- completions/autoconf | 22 +- completions/automake | 18 +- completions/autoreconf | 22 +- completions/autorpm | 6 +- completions/autoscan | 12 +- completions/avctrl | 10 +- completions/badblocks | 6 +- completions/bind | 14 +- completions/bk | 6 +- completions/brctl | 19 +- completions/btdownloadheadless.py | 12 +- completions/bts | 69 +- completions/bzip2 | 26 +- completions/cancel | 8 +- completions/cardctl | 8 +- completions/carton | 31 +- completions/ccache | 18 +- completions/ccze | 27 +- completions/cfagent | 8 +- completions/cfrun | 26 +- completions/chage | 14 +- completions/change_pw | 10 +- completions/check_db | 6 +- completions/check_perms | 6 +- completions/checksec | 10 +- completions/chgrp | 16 +- completions/chkconfig | 18 +- completions/chmod | 11 +- completions/chown | 14 +- completions/chpasswd | 16 +- completions/chromium-browser | 18 +- completions/chronyc | 28 +- completions/chrpath | 8 +- completions/cksfv | 8 +- completions/cleanarch | 8 +- completions/clisp | 8 +- completions/clone_member | 10 +- completions/complete | 26 +- completions/config_list | 10 +- completions/configure | 22 +- completions/convert | 202 ++-- completions/cowsay | 10 +- completions/cpan2dist | 20 +- completions/cpio | 44 +- completions/cppcheck | 44 +- completions/crontab | 14 +- completions/cryptsetup | 43 +- completions/curl | 58 +- completions/cvs | 184 ++-- completions/cvsps | 26 +- completions/dd | 24 +- completions/deja-dup | 10 +- completions/desktop-file-validate | 4 +- completions/dhclient | 10 +- completions/dict | 28 +- completions/dmypy | 25 +- completions/dnssec-keygen | 16 +- completions/dnsspoof | 6 +- completions/dot | 24 +- completions/dpkg | 102 +- completions/dpkg-source | 34 +- completions/dselect | 12 +- completions/dsniff | 8 +- completions/dumpdb | 8 +- completions/dumpe2fs | 6 +- completions/e2freefrag | 8 +- completions/e2label | 4 +- completions/ebtables | 58 +- completions/ecryptfs-migrate-home | 8 +- completions/eog | 8 +- completions/ether-wake | 4 +- completions/evince | 12 +- completions/export | 16 +- completions/faillog | 14 +- completions/fbgs | 32 +- completions/fbi | 32 +- completions/feh | 81 +- completions/file | 14 +- completions/file-roller | 12 +- completions/filefrag | 6 +- completions/filesnarf | 6 +- completions/find | 63 +- completions/find_member | 10 +- completions/fio | 31 +- completions/firefox | 20 +- completions/flake8 | 18 +- completions/freebsd-update | 10 +- completions/freeciv | 24 +- completions/freeciv-server | 8 +- completions/function | 20 +- completions/fusermount | 10 +- completions/gcc | 60 +- completions/gcl | 8 +- completions/gdb | 33 +- completions/genaliases | 6 +- completions/gendiff | 4 +- completions/genisoimage | 14 +- completions/geoiplookup | 6 +- completions/getconf | 14 +- completions/getent | 48 +- completions/gkrellm | 16 +- completions/gm | 8 +- completions/gnatmake | 8 +- completions/gnokii | 134 +-- completions/gnome-mplayer | 14 +- completions/gnome-screenshot | 14 +- completions/gpasswd | 12 +- completions/gpg | 26 +- completions/gpg2 | 28 +- completions/gpgv | 12 +- completions/gphoto2 | 25 +- completions/gprof | 22 +- completions/groupadd | 10 +- completions/groupdel | 12 +- completions/groupmems | 14 +- completions/groupmod | 12 +- completions/growisofs | 14 +- completions/grpck | 8 +- completions/gssdp-discover | 21 +- completions/gzip | 30 +- completions/hcitool | 178 +-- completions/hddtemp | 16 +- completions/hid2hci | 8 +- completions/hostname | 10 +- completions/hping2 | 16 +- completions/htop | 18 +- completions/htpasswd | 25 +- completions/hunspell | 19 +- completions/iconv | 20 +- completions/id | 8 +- completions/idn | 14 +- completions/ifstat | 38 +- completions/iftop | 6 +- completions/ifup | 12 +- completions/influx | 17 +- completions/info | 26 +- completions/inject | 8 +- completions/inotifywait | 22 +- completions/insmod | 10 +- completions/installpkg | 10 +- completions/interdiff | 8 +- completions/invoke-rc.d | 32 +- completions/ip | 237 ++-- completions/ipcalc | 25 + completions/iperf | 38 +- completions/ipmitool | 123 ++- completions/ipsec | 54 +- completions/iptables | 58 +- completions/ipv6calc | 20 +- completions/iscsiadm | 24 +- completions/isort | 30 +- completions/isql | 6 +- completions/iwconfig | 64 +- completions/iwlist | 12 +- completions/iwpriv | 14 +- completions/iwspy | 10 +- completions/jar | 6 +- completions/jarsigner | 32 +- completions/java | 154 +-- completions/javaws | 12 +- completions/jpegoptim | 18 +- completions/jps | 8 +- completions/jq | 32 +- completions/jshint | 14 +- completions/json_xs | 12 +- completions/jsonschema | 15 +- completions/k3b | 20 +- completions/kcov | 36 +- completions/kill | 6 +- completions/killall | 12 +- completions/kldload | 8 +- completions/kldunload | 6 +- completions/koji | 68 +- completions/ktutil | 50 +- completions/larch | 8 +- completions/lastlog | 12 +- completions/ldapsearch | 50 +- completions/ldapvi | 28 +- completions/lftp | 11 +- completions/lftpget | 6 +- completions/lilo | 40 +- completions/links | 50 +- completions/lintian | 73 +- completions/lisp | 8 +- completions/list_admins | 6 +- completions/list_lists | 10 +- completions/list_members | 20 +- completions/list_owners | 8 +- completions/locale-gen | 12 +- completions/lpq | 10 +- completions/lpr | 14 +- completions/lrzip | 14 +- completions/lsof | 20 +- completions/lspci | 10 +- completions/lsscsi | 10 +- completions/lsusb | 6 +- completions/lua | 6 +- completions/luac | 6 +- completions/luseradd | 22 +- completions/luserdel | 10 +- completions/lvm | 412 +++---- completions/lz4 | 14 +- completions/lzip | 16 +- completions/lzma | 22 +- completions/lzop | 20 +- completions/macof | 7 +- completions/mailmanctl | 10 +- completions/make | 48 +- completions/makepkg | 12 +- completions/man | 51 +- completions/mc | 12 +- completions/mcrypt | 44 +- completions/mdadm | 89 +- completions/mdtool | 27 +- completions/medusa | 10 +- completions/mii-diag | 12 +- completions/mii-tool | 20 +- completions/minicom | 28 +- completions/mkinitrd | 14 +- completions/mktemp | 12 +- completions/mmsitepass | 6 +- completions/modinfo | 24 +- completions/modprobe | 66 +- completions/monodevelop | 8 +- completions/mplayer | 177 ++- completions/mr | 41 +- completions/msynctool | 26 +- completions/mtx | 22 +- completions/munin-node-configure | 10 +- completions/munin-run | 14 +- completions/munin-update | 8 +- completions/munindoc | 6 +- completions/mussh | 24 +- completions/mutt | 95 +- completions/mypy | 20 +- completions/mysql | 53 +- completions/mysqladmin | 30 +- completions/nc | 19 +- completions/ncftp | 12 +- completions/nethogs | 8 +- completions/newlist | 10 +- completions/newusers | 14 +- completions/ngrep | 14 +- completions/nmap | 52 +- completions/nproc | 8 +- completions/nslookup | 32 +- completions/nsupdate | 12 +- completions/ntpdate | 10 +- completions/oggdec | 20 +- completions/op | 35 +- completions/openssl | 202 +--- completions/opera | 26 +- completions/optipng | 22 +- completions/p4 | 34 +- completions/pack200 | 48 +- completions/passwd | 8 +- completions/patch | 34 +- completions/pdftotext | 19 +- completions/perl | 44 +- completions/perlcritic | 24 +- completions/perltidy | 20 +- completions/pgrep | 26 +- completions/pidof | 8 +- completions/pine | 18 +- completions/ping | 20 +- completions/pkg-config | 30 +- completions/pkg-get | 72 +- completions/pkg_delete | 8 +- completions/pkgadd | 34 +- completions/pkgrm | 20 +- completions/pkgtool | 12 +- completions/pkgutil | 48 +- completions/plague-client | 8 +- completions/pm-hibernate | 4 +- completions/pm-is-supported | 6 +- completions/pm-powersave | 4 +- completions/pngfix | 12 +- completions/portinstall | 18 +- completions/portsnap | 8 +- completions/portupgrade | 10 +- completions/postcat | 14 +- completions/postconf | 10 +- completions/postfix | 16 +- completions/postmap | 16 +- completions/postsuper | 24 +- completions/povray | 28 +- completions/prelink | 14 +- completions/printenv | 23 + completions/protoc | 24 +- completions/psql | 86 +- completions/puppet | 129 ++- completions/pv | 12 +- completions/pwck | 6 +- completions/pwd | 10 +- completions/pwdx | 6 +- completions/pwgen | 10 +- completions/pycodestyle | 10 +- completions/pydoc | 19 +- completions/pydocstyle | 14 +- completions/pyflakes | 6 +- completions/pylint | 79 +- completions/pytest | 90 +- completions/python | 29 +- completions/pyvenv | 6 +- completions/qdbus | 8 +- completions/qemu | 71 +- completions/qrunner | 8 +- completions/querybts | 22 +- completions/quota | 68 +- completions/radvdump | 10 +- completions/rcs | 20 +- completions/rdesktop | 38 +- completions/remove_members | 10 +- completions/removepkg | 14 +- completions/reportbug | 67 +- completions/resolvconf | 8 +- completions/ri | 56 +- completions/rmlist | 6 +- completions/rmmod | 6 +- completions/route | 10 +- completions/rpcdebug | 18 +- completions/rpm | 174 +-- completions/rpm2tgz | 6 +- completions/rpmcheck | 8 +- completions/rrdtool | 10 +- completions/rsync | 28 +- completions/sbcl | 8 +- completions/sbopkg | 41 +- completions/screen | 177 +-- completions/scrub | 16 +- completions/secret-tool | 50 + completions/sh | 18 +- completions/shellcheck | 38 +- completions/sitecopy | 22 +- completions/slackpkg | 67 +- completions/slapt-get | 41 +- completions/slapt-src | 35 +- completions/smartctl | 88 +- completions/smbclient | 139 +-- completions/snownews | 6 +- completions/sqlite3 | 16 +- completions/ss | 27 +- completions/ssh | 273 ++--- completions/ssh-add | 6 +- completions/ssh-copy-id | 6 +- completions/ssh-keygen | 86 +- completions/sshfs | 10 +- completions/sshmitm | 6 +- completions/sshow | 6 +- completions/strace | 36 +- completions/strings | 24 +- completions/sudo | 48 +- completions/svcadm | 71 +- completions/svk | 82 +- completions/sync_members | 14 +- completions/synclient | 10 +- completions/sysbench | 77 +- completions/sysctl | 14 +- completions/tar | 252 ++--- completions/tcpdump | 30 +- completions/tcpkill | 6 +- completions/tcpnice | 6 +- completions/timeout | 14 +- completions/tipc | 385 +++---- completions/tox | 25 +- completions/tracepath | 6 +- completions/tshark | 80 +- completions/tsig-keygen | 28 + completions/tune2fs | 18 +- completions/ulimit | 18 +- completions/unace | 8 +- completions/unpack200 | 32 +- completions/unrar | 10 +- completions/unshunt | 6 +- completions/update-alternatives | 36 +- completions/update-rc.d | 60 +- completions/upgradepkg | 18 +- completions/urlsnarf | 6 +- completions/uscan | 10 +- completions/useradd | 29 +- completions/userdel | 12 +- completions/usermod | 31 +- completions/valgrind | 54 +- completions/vipw | 8 +- completions/vmstat | 16 +- completions/vncviewer | 47 +- completions/vpnc | 45 +- completions/watch | 24 +- completions/webmitm | 6 +- completions/wget | 107 +- completions/wine | 10 +- completions/withlist | 8 +- completions/wodim | 66 +- completions/wol | 22 +- completions/wsimport | 12 +- completions/wtf | 24 +- completions/wvdial | 16 +- completions/xdg-mime | 41 +- completions/xdg-settings | 18 +- completions/xfreerdp | 50 +- completions/xgamma | 36 +- completions/xhost | 6 +- completions/xmllint | 14 +- completions/xmlwf | 10 +- completions/xmms | 12 +- completions/xmodmap | 8 +- completions/xrandr | 40 +- completions/xrdb | 10 +- completions/xsltproc | 18 +- completions/xvfb-run | 14 +- completions/xxd | 6 +- completions/xz | 34 +- completions/xzdec | 12 +- completions/ypmatch | 10 +- completions/yum-arch | 6 +- completions/zopfli | 12 +- completions/zopflipng | 18 +- configure.ac | 2 +- doc/styleguide.txt | 25 +- doc/testing.txt | 61 +- extra/git-post-commit.sh | 4 +- extra/git-pre-push.sh | 9 +- extra/make-changelog.py | 34 +- helpers/python | 2 +- setup-symlinks.sh | 6 +- test/.gitignore | 5 - test/Makefile.am | 15 +- test/completion/alias.exp | 1 - test/completion/cd.exp | 1 - test/completion/chown.exp | 1 - test/completion/finger.exp | 1 - test/completion/scp.exp | 1 - test/completion/sftp.exp | 1 - test/completion/slapt-get.exp | 1 - test/completion/slapt-src.exp | 1 - test/completion/ssh.exp | 1 - test/completion/sudo.exp | 1 - test/completion/umount.exp | 1 - test/completion/upgradepkg.exp | 1 - test/completion/xhost.exp | 1 - test/config/bashrc | 17 +- test/config/default.exp | 21 - test/config/inputrc | 18 +- test/docker/docker-script.sh | 18 +- .../_known_hosts_real/.ssh/config_asterisk_1 | 1 + .../_known_hosts_real/.ssh/config_asterisk_2 | 1 + .../_known_hosts_real/.ssh/config_question_mark | 1 + test/fixtures/_known_hosts_real/config | 6 +- test/fixtures/_known_hosts_real/config_include | 2 + test/fixtures/_known_hosts_real/config_tilde | 4 +- .../fixtures/_known_hosts_real/gee-filename-canary | 0 test/fixtures/_known_hosts_real/localhost_config | 2 +- test/fixtures/_known_hosts_real/spaced conf | 7 +- test/fixtures/_longopt/various.txt | 5 + test/fixtures/ant/.gitignore | 3 +- .../dpkg/bash-completion-test-nonsubject.txt | 0 test/fixtures/lftp/.lftp/bookmarks | 2 + test/fixtures/lilo/lilo.conf | 34 + test/fixtures/nmap/nmap-h.txt | 114 ++ test/fixtures/perl/Devel/BashCompletion.pm | 2 + test/fixtures/perldoc/BashCompletionModule.pm | 4 + test/fixtures/pytest/test_async.py | 17 + test/fixtures/slackware/etc/slapt-get/slapt-getrc | 0 test/fixtures/slackware/etc/slapt-get/slapt-srcrc | 0 test/fixtures/ssh-copy-id/.ssh/id_rsa | 0 test/lib/completion.exp | 24 - test/lib/completions/alias.exp | 32 - test/lib/completions/cd.exp | 31 - test/lib/completions/chown.exp | 43 - test/lib/completions/finger.exp | 41 - test/lib/completions/scp.exp | 117 -- test/lib/completions/sftp.exp | 60 - test/lib/completions/slapt-get.exp | 32 - test/lib/completions/slapt-src.exp | 29 - test/lib/completions/ssh.exp | 61 - test/lib/completions/sudo.exp | 42 - test/lib/completions/umount.exp | 95 -- test/lib/completions/upgradepkg.exp | 26 - test/lib/completions/xhost.exp | 95 -- test/lib/library.exp | 970 ---------------- test/lib/library.sh | 38 - test/lib/unit.exp | 25 - test/requirements-dev.txt | 4 + test/requirements.txt | 2 +- test/run | 67 -- test/run-shellcheck | 4 - test/runCompletion | 8 - test/runInstall | 7 - test/runLint | 14 +- test/runUnit | 8 - test/setup.cfg | 9 + test/t/Makefile.am | 9 + test/t/conftest.py | 367 ++++-- test/t/test_2to3.py | 2 +- test/t/test_7z.py | 5 +- test/t/test_alias.py | 4 + test/t/test_ant.py | 13 +- test/t/test_apt_cache.py | 6 +- test/t/test_apt_get.py | 6 +- test/t/test_aptitude.py | 16 + test/t/test_arpspoof.py | 7 +- test/t/test_bmake.py | 7 + test/t/test_ccache.py | 6 +- test/t/test_cd.py | 6 +- test/t/test_chown.py | 34 +- test/t/test_complete.py | 4 + test/t/test_cpan2dist.py | 4 +- test/t/test_cpio.py | 12 +- test/t/test_cppcheck.py | 6 +- test/t/test_crontab.py | 9 + test/t/test_curl.py | 8 +- test/t/test_cvs.py | 2 +- test/t/test_dd.py | 2 +- test/t/test_dmypy.py | 6 +- test/t/test_dnssec_keygen.py | 2 +- test/t/test_dpkg_deb.py | 4 + test/t/test_dpkg_query.py | 18 + test/t/test_feh.py | 4 +- test/t/test_find.py | 13 +- test/t/test_finger.py | 24 +- test/t/test_gcc.py | 11 +- test/t/test_ip.py | 4 + test/t/test_ipcalc.py | 23 + test/t/test_irb.py | 2 +- test/t/test_iscsiadm.py | 4 +- test/t/test_isort.py | 2 +- test/t/test_jsonschema.py | 4 +- test/t/test_kcov.py | 2 +- test/t/test_ldd.py | 4 +- test/t/test_less.py | 4 + test/t/test_lftp.py | 14 +- test/t/test_lilo.py | 9 + test/t/test_ls.py | 2 +- test/t/test_lspci.py | 4 +- test/t/test_make.py | 19 +- test/t/test_man.py | 26 +- test/t/test_mkdir.py | 3 +- test/t/test_modprobe.py | 2 +- test/t/test_mount.py | 2 +- test/t/test_mr.py | 13 +- test/t/test_mypy.py | 2 +- test/t/test_nmap.py | 44 +- test/t/test_openssl.py | 5 +- test/t/test_perl.py | 2 +- test/t/test_pgrep.py | 22 + test/t/test_postfix.py | 16 +- test/t/test_printenv.py | 19 + test/t/test_protoc.py | 9 + test/t/test_pydocstyle.py | 4 +- test/t/test_pylint.py | 2 +- test/t/test_pytest.py | 39 + test/t/test_python.py | 4 + test/t/test_python3.py | 4 + test/t/test_ri.py | 2 +- test/t/test_sbcl.py | 3 +- test/t/test_sbcl_mt.py | 3 +- test/t/test_scp.py | 79 ++ test/t/test_screen.py | 8 +- test/t/test_secret_tool.py | 12 + test/t/test_sftp.py | 37 +- test/t/test_slapt_get.py | 28 + test/t/test_slapt_src.py | 31 +- test/t/test_ssh.py | 28 +- test/t/test_ssh_keygen.py | 51 + test/t/test_sudo.py | 36 +- test/t/test_tar.py | 20 +- test/t/test_totem.py | 7 + test/t/test_tshark.py | 9 +- test/t/test_tsig_keygen.py | 12 + test/t/test_umount.py | 78 ++ test/t/test_upgradepkg.py | 17 + test/t/test_userdel.py | 4 +- test/t/test_valgrind.py | 4 +- test/t/test_wol.py | 7 +- test/t/test_write.py | 4 +- test/t/test_xfreerdp.py | 32 +- test/t/test_xgamma.py | 2 +- test/t/test_xhost.py | 22 + test/t/unit/Makefile.am | 5 +- test/t/unit/test_unit_count_args.py | 4 +- test/t/unit/test_unit_expand.py | 20 +- test/t/unit/test_unit_expand_tilde_by_ref.py | 32 +- test/t/unit/test_unit_filedir.py | 138 ++- test/t/unit/test_unit_get_comp_words_by_ref.py | 101 +- test/t/unit/test_unit_get_cword.py | 25 +- test/t/unit/test_unit_init_completion.py | 16 +- test/t/unit/test_unit_known_hosts_real.py | 158 +++ test/t/unit/test_unit_longopt.py | 18 + test/t/unit/test_unit_quote.py | 2 +- test/t/unit/test_unit_quote_readline.py | 15 + test/t/unit/test_unit_variables.py | 10 +- test/t/unit/test_unit_xinetd_services.py | 22 + test/test-cmd-list.txt | 687 ++++++++++++ test/unit/__expand_tilde_by_ref.exp | 65 -- test/unit/_expand.exp | 33 - test/unit/_filedir.exp | 124 --- test/unit/_get_comp_words_by_ref.exp | 91 -- test/unit/_get_cword.exp | 37 - test/unit/_known_hosts_real.exp | 171 --- test/update-test-cmd-list | 13 + 665 files changed, 11133 insertions(+), 10371 deletions(-) create mode 100644 .markdownlint.yaml create mode 100644 .pre-commit-config.yaml create mode 100644 completions/ipcalc create mode 100644 completions/printenv create mode 100644 completions/secret-tool create mode 100644 completions/tsig-keygen delete mode 100644 test/completion/alias.exp delete mode 100644 test/completion/cd.exp delete mode 100644 test/completion/chown.exp delete mode 100644 test/completion/finger.exp delete mode 100644 test/completion/scp.exp delete mode 100644 test/completion/sftp.exp delete mode 100644 test/completion/slapt-get.exp delete mode 100644 test/completion/slapt-src.exp delete mode 100644 test/completion/ssh.exp delete mode 100644 test/completion/sudo.exp delete mode 100644 test/completion/umount.exp delete mode 100644 test/completion/upgradepkg.exp delete mode 100644 test/completion/xhost.exp delete mode 100644 test/config/default.exp create mode 100644 test/fixtures/_known_hosts_real/.ssh/config_asterisk_1 create mode 100644 test/fixtures/_known_hosts_real/.ssh/config_asterisk_2 create mode 100644 test/fixtures/_known_hosts_real/.ssh/config_question_mark create mode 100644 test/fixtures/_known_hosts_real/gee-filename-canary create mode 100644 test/fixtures/_longopt/various.txt create mode 100644 test/fixtures/dpkg/bash-completion-test-nonsubject.txt create mode 100644 test/fixtures/lilo/lilo.conf create mode 100644 test/fixtures/nmap/nmap-h.txt create mode 100644 test/fixtures/pytest/test_async.py delete mode 100644 test/fixtures/slackware/etc/slapt-get/slapt-getrc delete mode 100644 test/fixtures/slackware/etc/slapt-get/slapt-srcrc create mode 100644 test/fixtures/ssh-copy-id/.ssh/id_rsa delete mode 100644 test/lib/completion.exp delete mode 100644 test/lib/completions/alias.exp delete mode 100644 test/lib/completions/cd.exp delete mode 100644 test/lib/completions/chown.exp delete mode 100644 test/lib/completions/finger.exp delete mode 100644 test/lib/completions/scp.exp delete mode 100644 test/lib/completions/sftp.exp delete mode 100644 test/lib/completions/slapt-get.exp delete mode 100644 test/lib/completions/slapt-src.exp delete mode 100644 test/lib/completions/ssh.exp delete mode 100644 test/lib/completions/sudo.exp delete mode 100644 test/lib/completions/umount.exp delete mode 100644 test/lib/completions/upgradepkg.exp delete mode 100644 test/lib/completions/xhost.exp delete mode 100644 test/lib/library.exp delete mode 100644 test/lib/library.sh delete mode 100644 test/lib/unit.exp create mode 100644 test/requirements-dev.txt delete mode 100755 test/run delete mode 100755 test/run-shellcheck delete mode 100755 test/runCompletion delete mode 100755 test/runInstall delete mode 100755 test/runUnit create mode 100644 test/t/test_bmake.py create mode 100644 test/t/test_dpkg_query.py create mode 100644 test/t/test_ipcalc.py create mode 100644 test/t/test_printenv.py create mode 100644 test/t/test_scp.py create mode 100644 test/t/test_secret_tool.py create mode 100644 test/t/test_totem.py create mode 100644 test/t/test_tsig_keygen.py create mode 100644 test/t/test_xhost.py create mode 100644 test/t/unit/test_unit_known_hosts_real.py create mode 100644 test/t/unit/test_unit_quote_readline.py create mode 100644 test/t/unit/test_unit_xinetd_services.py create mode 100644 test/test-cmd-list.txt delete mode 100644 test/unit/__expand_tilde_by_ref.exp delete mode 100644 test/unit/_expand.exp delete mode 100644 test/unit/_filedir.exp delete mode 100644 test/unit/_get_comp_words_by_ref.exp delete mode 100644 test/unit/_get_cword.exp delete mode 100644 test/unit/_known_hosts_real.exp create mode 100755 test/update-test-cmd-list diff --git a/.dir-locals.el b/.dir-locals.el index db8dc273..56279dee 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -4,5 +4,7 @@ ((python-mode (eval add-hook 'before-save-hook 'blacken-buffer nil t)) (sh-mode + (mode . shfmt-on-save) + (shfmt-arguments "-s") (flycheck-sh-bash-args "-O" "extglob") (sh-indent-comment . t))) diff --git a/.editorconfig b/.editorconfig index 1ef5717d..85032d1b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,9 +7,12 @@ charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true max_line_length = 79 +# for shfmt +function_next_line = true +switch_case_indent = true [Makefile.am] indent_style = tab -[*.yml] +[*.{yml,yaml}] indent_size = 2 diff --git a/.gitignore b/.gitignore index d58464b7..ae29894c 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,3 @@ __pycache__/ .pytest_cache/ .python-version pytestdebug.log -.mypy_cache/ -helpers/perl.bak -helpers/perl.tdy -helpers/perl.ERR diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 00000000..0204e77e --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,4 @@ +MD007: + false # for lists in FAQ/A +MD033: + allowed_elements: [kbd] diff --git a/.perltidyrc b/.perltidyrc index cf0a0e4c..9f681d2f 100644 --- a/.perltidyrc +++ b/.perltidyrc @@ -3,3 +3,4 @@ --paren-tightness=2 --cuddled-else --warning-output +--converge diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..57d12648 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,97 @@ +repos: + + - repo: local + hooks: + - id: shfmt + name: shfmt + language: golang + additional_dependencies: [mvdan.cc/sh/v3/cmd/shfmt@v3.1.2] + entry: shfmt + args: [-w, -s] + types: [text] + files: ^(bash_completion|completions/.+|test/(config/bashrc|update-test-cmd-list)|.+\.sh(\.in)?)$ + exclude: ^completions/(\.gitignore|Makefile.*)$ + + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.7.1.1 + hooks: + - id: shellcheck + args: [-f, gcc] + types: [text] + files: ^(bash_completion|completions/.+|test/(config/bashrc|update-test-cmd-list)|.+\.sh(\.in)?)$ + exclude: ^completions/(\.gitignore|Makefile.*)$ + require_serial: false # We disable SC1090 anyway, so parallel is ok + + - repo: local + hooks: + - id: update-test-cmd-list + name: update-test-cmd-list + language: script + entry: test/update-test-cmd-list + files: ^test/t/.+\.py$ + pass_filenames: false + + - repo: https://github.com/psf/black + rev: 19.10b0 + hooks: + - id: black + types: [text] + files: ^(helpers/python|.+\.py)$ + exclude: ^completions/ + + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.8.3 + hooks: + - id: flake8 + args: [--config=test/setup.cfg] + additional_dependencies: [flake8-bugbear==20.1.4] + types: [text] + files: ^(helpers/python|.+\.py)$ + exclude: ^completions/ + + - repo: https://github.com/timothycrosley/isort + rev: 5.1.4 + hooks: + - id: isort + args: [--settings-path=test/setup.cfg] + types: [text] + files: ^(helpers/python|.+\.py)$ + exclude: ^completions/ + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.782 + hooks: + - id: mypy + args: [--config-file=test/setup.cfg] + # Intentionally not run on helpers/python (support very old versions) + exclude: ^completions/|^test/fixtures/pytest/ + + - repo: https://github.com/asottile/pyupgrade + rev: v2.7.2 + hooks: + - id: pyupgrade + args: [--py3-plus, --keep-percent-format] + exclude: ^completions/ + + - repo: https://github.com/perltidy/perltidy + rev: "20200619" + hooks: + - id: perltidy + types: [text] + files: ^(helpers/perl|.+\.p[ml])$ + + - repo: local + hooks: + - id: perlcritic + name: perlcritic + language: perl + additional_dependencies: [PETDANCE/Perl-Critic-1.138.tar.gz] + entry: perlcritic + args: [--quiet, --verbose, "5"] + types: [text] + files: ^(helpers/perl|.+\.p[ml])$ + + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.23.2 + hooks: + - id: markdownlint diff --git a/.shellcheckrc b/.shellcheckrc index 9bec7145..cf5ed4bc 100644 --- a/.shellcheckrc +++ b/.shellcheckrc @@ -1,4 +1,16 @@ shell=bash disable=SC1090 # not really fixable usually (ever?) +disable=SC2034 # for localizing variables set in called functions disable=SC2128 # intentional style choice -disable=SC2155 # TODO +disable=SC2206 # suggested alternatives fail in posix mode or use temp files +disable=SC2207 # suggested alternatives fail in posix mode or use temp files + +# These disables are to be investigated and decided + +disable=SC1004 +disable=SC2015 +disable=SC2016 +disable=SC2086 +disable=SC2155 +disable=SC2162 +disable=SC2231 diff --git a/.travis.yml b/.travis.yml index 9e793d9b..1ab73f5d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,32 @@ language: generic -sudo: required +dist: bionic services: - docker -env: - - DIST=alpine - - DIST=centos6 - - DIST=debian10 - - DIST=fedoradev - - DIST=ubuntu14 - - DIST=ubuntu14 BSD=true NETWORK=none - - DIST=tools +jobs: + include: + - stage: lint + language: go + go: "1.14" + services: [] + cache: + directories: + - $HOME/.cache/pip + - $HOME/.cache/pre-commit + before_install: [] + script: + - pyenv shell 3.8 + - pip3 install "$(grep ^pre-commit test/requirements-dev.txt)" + - pre-commit run --all-files --color=always + - stage: test + env: DIST=alpine + - env: DIST=centos7 + - env: DIST=debian10 + - env: DIST=fedoradev + - env: DIST=ubuntu14 + - env: DIST=ubuntu14 BSD=true NETWORK=none before_install: - docker build @@ -23,10 +37,6 @@ script: -e CI=true -e DIST=$DIST -e BSD=$BSD -e NETWORK=$NETWORK ${NETWORK:+--network $NETWORK} -t bash-completion:$DIST - - if test $DIST = tools; then - test/run-shellcheck -f gcc - bash_completion bash_completion.sh.in completions/!(Makefile*); - fi before_deploy: - docker start bash-completion diff --git a/CHANGES b/CHANGES index cfd18c4a..7a26a1bb 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,374 @@ +bash-completion (2.11) + + [ Alexander Meshcheryakov ] + * _known_hosts_real: check that ruptime is present before calling + (#390) + + [ Andrew Gaul ] + * totem: reuse kaffeine completions (#372) + + [ Damien Nadé ] + * __reassemble_comp_words_by_ref: avoid triggering nounset on + indirect references + + [ Felix Lechner ] + * lintian: complete paths for Ubuntu's .ddeb and Debian's buildinfo + files (#397) + + [ Felix Yan ] + * ip: complete route add table arg + * ip: style fixes similar to ip-netns + * ip: add more completions for ip-rule + * ip: add support for netns (#391) + * ip: improve completion of route subcommands (#326) + + [ Hans-Christoph Steiner ] + * unzip, zipinfo: complete *.aar (#428) + + [ Jakub Jelen ] + * ssh: add new -Q completions in OpenSSH 8.2p1 (#400) + + [ Kevin Locke ] + * python: support executables with minor version (#389) + + [ Michal Suchánek ] + * insmod, modinfo, modprobe: support xz compressed modules (#401) + + [ Phan Duc Nhat Minh ] + * tshark: complete -r arg with all filenames (#422) + + [ Sebastian Jakubiak ] + * openssl: update -starttls completions (#403) + * _filedir*: update link to bug-bash discussion on -X (#404) + * test/python: add testcase for submodule completion + + [ Ville Skyttä ] + * Release 2.11 + * extra/make-changelog: check and output usage message + * pre-commit: anchor exclude patterns + * pytest: rewrite in bash, support toplevel funcs, avoid nondef ones + and classes + * test/xfreerdp: skip --help failure cases + * test/tshark: fix multiple -O completion with no http2 support + * test/ant: avoid complete-ant-cmd.pl interference with ANT_ARGS + * _xinetd_services: avoid nounset error on bash 4.2 + * pre-commit: upgrade isort to 5.1.4 + * pre-commit: upgrade pyupgrade to 2.7.2 + * pre-commit: add pyupgrade, run it + * test/ant: gitignore all target cache files + * _known_hosts_real: exclude Host negations + * pre-commit: upgrade isort to 5.0.7 + * pre-commit: update shellcheck-py URL + * test/inputrc: do not set print-completions-horizontally + * test/inputrc: comment typo fix + * pytest: complete async test class methods + * __get_cword_at_cursor_by_ref: fix regression on bash 4.2 + * test: upgrade markdownlint-cli to 0.23.2 + * _known_hosts_real: avoid errors in nounset mode on Ubuntu 14 and + 16 + * _longopt: exclude too many dashes, allow underscores, require ends + with alnum + * _included_ssh_config_files: support globs + * _known_hosts_real: prevent unwanted pathname expansion on host + entries + * test/shfmt: upgrade to 3.1.2, reformat with it + * test/_known_hosts_real: add explicit no globbing test case + * test: upgrade mypy to 0.782 + * CONTRIBUTING.md: add posix and nounset mode item + * test: upgrade mypy to 0.781 + * test: upgrade perltidy to 20200619 + * _known_hosts_real: fix completion of Host entries after a wildcard + etc + * _known_hosts_real: fix # handling in ssh configs + * test: upgrade flake8 to 3.8.3 + * test/xhost: multiple expected result handling fixes + * test/slapt-src: single expected result handling fixes + * test: partial hostname completion fixes + * test: simplify completion parsing + * test/dpkg-query: mark as xfail on non-Debian based systems + * .gitignore: clean up some no longer needed ignores + * test/lspci: skip -A arg test if lspci fails -A help, e.g. busybox + lspci + * test: regex escape our magic mark for completeness + * test: upgrade mypy to 0.780 + * test/_known_hosts_real: don't modify class scoped base expected + list + * test/_known_hosts_real: reset COMP_KNOWN_HOSTS_WITH_HOSTFILE + between tests + * test/_known_hosts_real: tolerate duplicates + * bash_completion: trivial cleanups + * gcc: avoid errors in nounset mode + * pytest: fix test class method completion with BSD awk + * man, mutt: avoid errors in nounset mode on Ubuntu 14 and 16 + * java, make: avoid errors in nounset mode on Ubuntu 14 and 16 + * README: document GNU make build requirement + * pytest: add test class method completion + * _known_hosts: avoid errors in nounset mode and no arguments + * bash_completion: fix array set checks with empty elements in them + * *: avoid more errors in nounset mode + * cfrun: fix $hostfile leak + * _command_offset, route: cleanups + * *: avoid more errors in nounset mode + * qemu: add -machine arg completion + * qemu, sbopkg: avoid unintentional globbing on option arg + completions + * test: enable shellcheck SC2035 + * *: drop support for bash 4.1 + * _init_completion: fix unassigned redirect completion in nounset + mode + * ip: route shfmt, arithmetic evaluation + * _filedir: avoid unbound variable error on Ubuntu 14 and 16 + * _pids, _pgids, _pnames: improve shfmt formatting + * scp, sftp, ssh: fix completion on options bundled with -4/-6 + * modprobe, tshark, _included_ssh_config_files: use [[ ]] instead of + [ ] + * test/runLint: warn about [ ] instead of [[ ]] use + * test: skip various tests if we don't get a useful usage message + * *: mark nounset mode as supported, issues with it are bugs now + * *: avoid more errors in nounset mode + * *: avoid more errors in nounset mode + * *: avoid more errors in nounset mode + * test/inputrc: comment and whitespace tweaks + * *: avoid more errors in nounset mode + * test/unit: sort files included in dist + * test/unit: include test_unit_known_hosts_real.py in dist + * bash_completion: line wrapping tweaks, NFC + * 7z: fix -o/-w attached arg completion + * postfix: try to arrange a fake tty so we can tickle the usage + message out + * _bashcomp_try_faketty: new function to try running command with a + fake tty + * mr: avoid herestrings, simplify command parsing + * test/mr: handle missing "clean" with skipif + * test: mark known non-ASCII issues with test suite as xfail + * dpkg-deb: add --raw-extract and -X arg completions + * test: add some dpkg-query test cases + * dpkg-deb: fix --show/-W completion + * test: upgrade markdownlint-cli to 0.23.1 + * *: use more arithmetic evaluation + * test: try harder to restore environment and cwd on failures + * *: use $ifs for storing/restoring $IFS + * test/irb: xfail options test if --help is not available + * test: upgrade flake8 to 3.8.1 + * test: pre-commit config cleanups, ordering + * test: upgrade pre-commit to 2.4.0+, drop shfmt kludge + * test: sync shfmt and shellcheck configs + * test: shfmt bashrc + * test: remove unused run-shellcheck, shellcheck is in pre-commit + now + * test: remove old test suite code no longer used \o/ + * test/_known_hosts_real: port remaining test cases to + pytest+pexpect + * test: remove more no longer needed old test suite code + * test/_known_hosts_real: port more test cases to pytest+pexpect + * test/_get_cword: port remaining test case to pytest+pexpect + * test: replace some echos with printfs + * test/_filedir: fix shutil.rmtree on Python < 3.6 + * test/_expand: port remaining test cases to pytest+pexpect + * test: drop some no longer needed old test suite code + * test/_filedir: port remaining test cases to pytest+pexpect + * test: run all Travis jobs on dist: bionic + * test: drop not needed sudo on Travis + * test/_filedir: port more test cases to pytest+pexpect + * test/__expand_tilde_by_ref: port remaining test cases to + pytest+pexpect + * test/_get_comp_words_by_ref: convert remaining test cases to + pytest+pexpect + * test: run pytest --verbose in docker + * lftp: use "bookmark list" command to list bookmarks + * test: drop some no longer needed old test suite code + * test/slapt-src: convert remaining test case to pytest+pexpect + * _xfunc: simplify + * apt-cache: avoid nonzero exit code from _apt_cache_packages + * test/slapt-get: convert remaining test case to pytest+pexpect + * test/secret-tool: add to test command list + * test/scp: port remaining test case to pytest+pexpect + * test/umount: convert remaining test case to pytest+pexpect + * secret-tool: new completion + * apt-get: complete build-dep with dirs + * travis: use golang 1.14 for shfmt + * *: run all shell code through shfmt -s + * pre-commit etc: add shfmt + * test: fix incorrect fixtures/shared/default xfails/expectations + * test: upgrade markdownlint to 0.23.0 + * nmap: simplify help scraping a bit, don't try to emit unnecessary + newlines + * test: prefix fake test commands with underscore + * test: port most umount test cases to pytest+pexpect + * test: add note about unescaped assert_complete single return + values + * editorconfig: apply yaml settings to .yaml too + * pre-commit: use local perlcritic hook + * *: doc and comment link updates + * pre-commit, *.md: add markdownlint, address findings + * README: clarify loading automatically on demand + * ssh-keygen: -O arg updates and improvements + * ssh-keygen: add -b arg completions according to specified -t + * ssh-keygen: option and arg completion updates for new versions + * _command: improve commentary + * reportbug, scp, sftp, svn: use compgen -c instead of _command + * find: fix -exec etc argument and its completion + * extra: trigger docker builds only on test-cmd-list.txt changes + * test: add script to maintain list of executables for full test + coverage + * test: run lint tests on Travis in a quickish separate first stage + * test/make: mark more cases as requiring command + * make: add bmake alias + * test: run pre-commit on host instead of docker + * test: add perlcritic to pre-commit, run on all perl + * *: remove some unused variables, thanks to shellcheck SC2034 + * *: various loop iteration improvements + * crontab: fix loop over already given args + * apt-cache: fix command mode handling + * doc: add loop variable naming guideline + * test: make at-point completion tests easier + * ssh, xsltproc: address shellcheck SC2006 + * scp: work around shellcheck SC1003 + * mutt: address shellchec SC2236 + * wget: address shellcheck SC2116 + * pytest: address shellcheck SC2002 + * bash_completion, java, tipc: for loop whitespace consistency + tweaks + * *: more arithmetic evaluation cleanups, thanks to shellcheck + SC2004 + * __reassemble_comp_words_by_ref, java: address and work around + shellcheck SC2102 + * test: enable parallel pre-commit shellcheck + * test: remove shellcheck severity filter, add explicit disables + instead + * doc: recommend arithmetic evaluation + * *: array subscript cleanups + * ssh-keygen: -s and -n completion improvements + * *: enable and address shellcheck SC2053 + * bash_completion, invoke-rc.d, svcadm: trivial cleanups + * *: replace various conditional expressions with arithmetic + evaluation + * carton: fix command parsing with BSD sed + * nmap: fix option parsing with BSD sed + * test/alias: port remaining test case to pytest+pexpect + * test: generalize complete at point test + * test/cd: fix test_dir_at_point for setups that repeat "trailer" + * pytest: add some option arg (non-)completions + * pytest: complete test classes + * pgrep, pkill: add --ns and --nslist arg completions + * test: run skipif and xfail commands without caring if they output + or not + * test: make it possible to not care whether command did output or + not + * test/xfreerdp: skip xfreerdp kbd test if kbd-list returns empty + * test: tolerate duplicates from compgen actions + * test: bump shellcheck severity to warning + some disables + * *: address shellcheck SC2046 + * test/lib/library.sh: address shellcheck SC2125 + * java, pkgadd, sysbench: address shellchec SC2124 + * scp: address shellcheck SC2089 and SC2090 + * _filedir_xspec: address shellcheck SC2140 + * rpm, ssh, umount.linux: address shellcheck SC2120 + * cvs, modprobe, sh: address shellcheck SC2209 + * mutt: address shellcheck SC2088 + * _upvar, _upvars, _variables, rpm: address shellcheck SC1083 + * test/run: address shellcheck SC2164 + * renice: address shellcheck SC2254 + * tipc: comment grammar and spelling fixes + * man, perl, route, tipc: address shellcheck SC2053 + * info, java: address shellcheck SC2153 + * quote_readline: fix $ret leak + * test: upgrade shellcheck to 0.7.1 + * test/printenv: xfail if --help doesn't contain options (e.g. + busybox) + * test/aptitude: require command where necessary + * _known_hosts_real, op: address shellcheck SC2184 + * test: don't run shellcheck on completions/.gitignore + * protoc: complete all --*_out without more specific handling with + dirs + * sysbench: add --test= deprecation TODO + * pkgadd: indentation fix + * chronyc, wvdial: address shellcheck SC2178 + * java, pkgadd, sysbench: address shellcheck SC2124 + * mplayer: address shellcheck SC1078 false positive + * smartctl: hush shellcheck SC2054 false positives + * *: address shellcheck SC2221 and SC2222 + * bash_completion: address shellcheck SC2220 + * crontab, wodim: silence shellcheck SC2191 and SC2192 + * aptitude: add some option arg (non)completions + * aptitude: parse options list from --help, hardcode less + * test/aptitude: add some test cases + * *: argument interation improvements + * *: whitespace tweaks + * apt-get etc: use _apt_cache_packages from apt-cache + * pre-commit: run most python checks on helpers/python too + * test/ldd: xfail if --help is not implemented + * test/printenv: require command for arg completion test + * printenv: indentation fixes + * test: upgrade mypy to 0.770 + * test: split dependencies requiring Python 3.6.1+ to requirements- + dev.txt + * git: trigger docker rebuild on pre-commit config change + * test: require openssl command for option argument tests + * test: move perltidy to pre-commit, run with --converge + * test: move shellcheck to pre-commit + * test: ignore flake8 messages that are in black's domain + * _xinetd_services: look up from $BASHCOMP_XINETDDIR, add some unit + tests + * printenv: new completion + * copyright: add 2020 + * test: fix CompletionResult.__eq__ UnboundLocalError + * test: run pre-commit in tools container + * test: shellcheck tweaks + * test: add isort to pre-commit, run it + * test: add flake8-bugbear + * test: install black for Python 3.6 too + * pre-commit: add config with black, flake8, and mypy + * test: drop redundant black args from docker runs + * *: python type hint fixes and improvements + * extra/make-changelog: run through black + * test/totem: add basic test case + * test/cd: remove unused import + * openssl: complete -writerand with filenames + * openssl: parse available options from $command -help + * openssl: support getting digest list from more recent openssl + versions + * nmap: handle options split on equals sign + * nmap: parse options from -h output + * test/cd: make dir_at_point produce better debuggable failures + * test/cd: convert remaining test case to pytest+pexpect + * test: remove some no longer needed old test suite code + * test/chown,sudo: parametrize special case test, improve xfail + targeting + * test/tsig-keygen: require command for test_options + * test/upgradepkg: port remaining test case to pytest+pexpect + * tsig-keygen: new completion + * test: host helper lint and usage fixes + * test: port some _known_hosts_real unit tests to pytest+pexpect + * test: remove some no longer needed tcl/expect code + * test: fix spurious hosts fixture failure without avahi-browse + installed + * test: port some scp test cases to pytest+pexpect + * test: port remaining finger, sftp, ssh, and xhost cases to + pytest+pexpect + * lilo: work around shellcheck false positive + * test/ipcalc: fix tests with busybox ipcalc + * chromium-browser, firefox: complete on *.txt (#379) + * README.md: add introduction + * ipcalc: new completion + * *: complete commands when prefixed with a backslash + * test/wol: don't fail MAC test if test system has /etc/ethers + entries + * test/dnssec-keygen: allow more alternatives in algorithm + completion + * lilo: don't complete on commented out labels + * lilo: honor -C when completing labels + * lilo: add -B and -E completions + + [ beantaxi ] + * Source user completion only if it's a file (#409) + + [ hugoziviani ] + * jarsigner: complete on *.apk too (#386) + * cryptsetup: add luksChangeKey arg completion (#380) + + -- Ville Skyttä Sat, 25 Jul 2020 11:25:09 +0300 + bash-completion (2.10) [ Felix Lechner ] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7f5a0962..9c8292c1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -50,10 +50,10 @@ Also, please bare the following coding guidelines in mind: start interpreters. Use lightweight programs such as grep(1), awk(1) and sed(1). -- Use the full power of bash >= 4.1. We no longer support earlier bash +- Use the full power of bash >= 4.2. We no longer support earlier bash versions, so you may as well use all the features of that version of bash to optimise your code. However, be careful when using features - added since bash 4.1, since not everyone will be able to use them. + added since bash 4.2, since not everyone will be able to use them. For example, extended globs often enable you to avoid the use of external programs, which are expensive to fork and execute, so do @@ -98,6 +98,16 @@ Also, please bare the following coding guidelines in mind: These forms of parameter substitutions can also be used on arrays, which makes them very powerful (if a little slow). +- We want our completions to work in `posix` and `nounset` modes. + + Unfortunately due to a bash < 5.1 bug, toggling POSIX mode interferes + with keybindings and should not be done. This rules out use of + process substitution which causes syntax errors in POSIX mode. + + Instead of toggling `nounset` mode, make sure to test whether + variables are set (e.g. with `[[ -v varname ]]`) or use default + expansion (e.g. `${varname-}`). + - Prefer `compgen -W '...' -- $cur` over embedding `$cur` in external command arguments (often e.g. sed, grep etc) unless there's a good reason to embed it. Embedding user input in command lines can result @@ -150,9 +160,9 @@ Also, please bare the following coding guidelines in mind: use them, do so if there's no other sane way to do what you're doing. The "Shell and Utilities" volume of the POSIX specification is a good starting reference for portable use of various utilities, see - http://pubs.opengroup.org/onlinepubs/9699919799/ + . -- Use an editor that supports EditorConfig, see http://editorconfig.org/, +- Use an editor that supports EditorConfig, see , and format source code according to our settings. - Read the existing source code for examples of how to solve @@ -169,11 +179,10 @@ Also, please bare the following coding guidelines in mind: is intended to do, fixes issues it intends to fix, etc. - In addition to running the test suite, there are a few scripts in the test/ - dir that catch some common issues, see and use for example runLint and - run-shellcheck. + dir that catch some common issues, see and use for example runLint. - File bugs, enhancement, and pull requests at GitHub, - https://github.com/scop/bash-completion. + . Sending them to the developers might work too, but is really strongly discouraged as bits are more likely to fall through the cracks that way compared to the tracker. Just use GitHub. If that's not an diff --git a/README.md b/README.md index e78cf189..11d29404 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,13 @@ [![Build Status](https://travis-ci.org/scop/bash-completion.svg?branch=master)](https://travis-ci.org/scop/bash-completion) +## Introduction + +bash-completion is a collection of command line command completions for the +[Bash shell](https://www.gnu.org/software/bash/), collection of helper +functions to assist in creating new completions, and set of facilities for +loading completions automatically on demand, as well as installing them. + ## Installation The easiest way to install this software is to use a package; refer to @@ -18,7 +25,7 @@ other file sourcing those). You can do this by simply using: . /usr/share/bash-completion/bash_completion ``` -(if you happen to have *only* bash >= 4.1 installed, see further if not) +(if you happen to have *only* bash >= 4.2 installed, see further if not) If you don't have the package readily available for your distribution, or you simply don't want to use one, you can install bash completion using the @@ -27,9 +34,9 @@ standard commands for GNU autotools packages: ```shell autoreconf -i # if not installing from prepared release tarball ./configure -make -make check # optional, requires python3 with pytest >= 3.6 and pexpect, dejagnu, and tcllib -make install # as root +make # GNU make required +make check # optional, requires python3 with pytest >= 3.6, pexpect +make install # as root ``` These commands install the completions and helpers, as well as a @@ -62,7 +69,6 @@ if [ -f /sw/etc/bash_completion ]; then fi ``` - ## Troubleshooting If you find that a given function is producing errors or does not work @@ -77,7 +83,6 @@ on before the debugged completion is attempted the first time. The easiest way to do this is to start a new shell session, and to turn tracing on in it before doing anything else there. - ## Known problems 1. There seems to be some issue with using the bash built-in `cd` within @@ -90,21 +95,6 @@ tracing on in it before doing anything else there. text utilities that they call (e.g. `grep`, `sed`, and `awk`). Your mileage may vary. -3. If you are seeing 'unbound variable' warnings from bash when - hitting <Tab>, this is because you have either `set -u` - or `set -o nounset` somewhere in your start-up files. This causes bash - to flag the use of any uninitialised shell variables as an error. - - Whilst we try to avoid references to uninitialised variables in the - code, there seem to be at least some cases where bash issues this - warning even though the variable in question has been initialised. - - One place this appears to occur is within the `_muttconffiles()` - helper function used by `mutt` completion, where the function calls - itself recursively. This seems to confuse bash and it issues - spurious warnings if `nounset` is set. - - ## FAQ **Q. The bash completion code inhibits some commands from completing on @@ -136,7 +126,8 @@ A. Install a local completion of your own appropriately for the desired A. Put them in the `completions` subdir of `$BASH_COMPLETION_USER_DIR` (defaults to `$XDG_DATA_HOME/bash-completion` or `~/.local/share/bash-completion` - if `$XDG_DATA_HOME` is not set) to have them loaded on demand. + if `$XDG_DATA_HOME` is not set) to have them loaded automatically + on demand when the respective command is being completed. See also the next question's answer for considerations for these files' names, they apply here as well. Alternatively, you can write them directly in `~/.bash_completion` which is loaded eagerly by @@ -151,20 +142,20 @@ A. Install it in one of the directories pointed to by alternatives: - The recommended directory is `completionsdir`, which you can get with - `pkg-config --variable=completionsdir bash-completion`. From this - directory, completions are loaded on-demand based on invoked commands' names, - so be sure to name your completion file accordingly, and to include - (for example) symbolic links in case the file provides completions - for more than one command. + `pkg-config --variable=completionsdir bash-completion`. From this + directory, completions are automatically loaded on demand based on invoked + commands' names, so be sure to name your completion file accordingly, and + to include (for example) symbolic links in case the file provides + completions for more than one command. - The other directory (which only present for backwards compatibility) is `compatdir` (get it with - `pkg-config --variable=compatdir bash-completion`) from which files - are loaded when `bash_completion` is loaded. + `pkg-config --variable=compatdir bash-completion`) from which files + are loaded when `bash_completion` is loaded. For packages using GNU autotools the installation can be handled for example like this in `configure.ac`: - ``` + ```m4 PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir], , bashcompdir="${sysconfdir}/bash_completion.d") AC_SUBST(bashcompdir) @@ -180,7 +171,7 @@ A. Install it in one of the directories pointed to by For cmake we ship the `bash-completion-config.cmake` and `bash-completion-config-version.cmake` files. Example usage: - ``` + ```cmake find_package(bash-completion) if(BASH_COMPLETION_FOUND) message(STATUS @@ -221,7 +212,7 @@ A. Define `$COMP_CONFIGURE_HINTS`. Setting this to anything will **Q. When doing tar completion on a file within a tar file like this:** - ``` + ```shell tar tzvf foo.tar.gz ``` @@ -327,21 +318,21 @@ A. The `readline(3)` library offers a few settings that can make tab For example, try putting the following in either `/etc/inputrc` or `~/.inputrc`: - ``` + ```inputrc set show-all-if-ambiguous on ``` This will allow single tab completion as opposed to requiring a double tab. This makes things much more pleasant, in our opinion. - ``` + ```inputrc set visible-stats on ``` This will suffix each returned file completion with a character denoting its type, in a similar way to `ls(1)` with `-F` or `--classify`. - ``` + ```inputrc set page-completions off ``` @@ -353,4 +344,4 @@ A. The `readline(3)` library offers a few settings that can make tab A. Absolutely not. zsh has an extremely sophisticated completion system that offers many features absent from the bash implementation. Its users often cannot resist pointing this out. More information can - be found at: http://www.zsh.org/ + be found at . diff --git a/bash_completion b/bash_completion index 6ec510e5..1a7f5634 100644 --- a/bash_completion +++ b/bash_completion @@ -1,9 +1,9 @@ # -*- shell-script -*- # -# bash_completion - programmable completion functions for bash 4.1+ +# bash_completion - programmable completion functions for bash 4.2+ # # Copyright © 2006-2008, Ian Macdonald -# © 2009-2019, Bash Completion Maintainers +# © 2009-2020, Bash Completion Maintainers # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ # # https://github.com/scop/bash-completion -BASH_COMPLETION_VERSINFO=(2 10) +BASH_COMPLETION_VERSINFO=(2 11) if [[ $- == *v* ]]; then BASH_COMPLETION_ORIGINAL_V_VALUE="-v" @@ -87,18 +87,18 @@ _userland() { local userland=$(uname -s) [[ $userland == @(Linux|GNU/*) ]] && userland=GNU - [[ $userland == $1 ]] + [[ $userland == "$1" ]] } # This function sets correct SysV init directories # _sysvdirs() { - sysvdirs=( ) - [[ -d /etc/rc.d/init.d ]] && sysvdirs+=( /etc/rc.d/init.d ) - [[ -d /etc/init.d ]] && sysvdirs+=( /etc/init.d ) + sysvdirs=() + [[ -d /etc/rc.d/init.d ]] && sysvdirs+=(/etc/rc.d/init.d) + [[ -d /etc/init.d ]] && sysvdirs+=(/etc/init.d) # Slackware uses /etc/rc.d - [[ -f /etc/slackware-version ]] && sysvdirs=( /etc/rc.d ) + [[ -f /etc/slackware-version ]] && sysvdirs=(/etc/rc.d) return 0 } @@ -138,19 +138,17 @@ quote() # @see _quote_readline_by_ref() quote_readline() { - local quoted + local ret _quote_readline_by_ref "$1" ret printf %s "$ret" } # quote_readline() - # This function shell-dequotes the argument dequote() { eval printf %s "$1" 2>/dev/null } - # Assign variable one scope above the caller # Usage: local "$1" && _upvar $1 "value(s)" # Param: $1 Variable name to assign value to @@ -159,21 +157,20 @@ dequote() # NOTE: For assigning multiple variables, use '_upvars'. Do NOT # use multiple '_upvar' calls, since one '_upvar' call might # reassign a variable to be used by another '_upvar' call. -# See: http://fvue.nl/wiki/Bash:_Passing_variables_by_reference +# See: https://fvue.nl/wiki/Bash:_Passing_variables_by_reference _upvar() { echo "bash_completion: $FUNCNAME: deprecated function," \ "use _upvars instead" >&2 - if unset -v "$1"; then # Unset & validate varname - if (( $# == 2 )); then - eval $1=\"\$2\" # Return single value + if unset -v "$1"; then # Unset & validate varname + if (($# == 2)); then + eval $1=\"\$2\" # Return single value else - eval $1=\(\"\${@:2}\"\) # Return array + eval $1=\(\"\$"{@:2}"\"\) # Return array fi fi } - # Assign variables one scope above the caller # Usage: local varname [varname ...] && # _upvars [-v varname value] | [-aN varname [value ...]] ... @@ -181,43 +178,54 @@ _upvar() # -aN Assign next N values to varname as array # -v Assign single value to varname # Return: 1 if error occurs -# See: http://fvue.nl/wiki/Bash:_Passing_variables_by_reference +# See: https://fvue.nl/wiki/Bash:_Passing_variables_by_reference _upvars() { - if ! (( $# )); then + if ! (($#)); then echo "bash_completion: $FUNCNAME: usage: $FUNCNAME" \ "[-v varname value] | [-aN varname [value ...]] ..." >&2 return 2 fi - while (( $# )); do + while (($#)); do case $1 in -a*) # Error checking - [[ ${1#-a} ]] || { echo "bash_completion: $FUNCNAME:" \ - "\`$1': missing number specifier" >&2; return 1; } - printf %d "${1#-a}" &>/dev/null || { echo bash_completion: \ - "$FUNCNAME: \`$1': invalid number specifier" >&2 - return 1; } + [[ ${1#-a} ]] || { + echo "bash_completion: $FUNCNAME:" \ + "\`$1': missing number specifier" >&2 + return 1 + } + printf %d "${1#-a}" &>/dev/null || { + echo bash_completion: \ + "$FUNCNAME: \`$1': invalid number specifier" >&2 + return 1 + } # Assign array of -aN elements - [[ "$2" ]] && unset -v "$2" && eval $2=\(\"\${@:3:${1#-a}}\"\) && - shift $((${1#-a} + 2)) || { echo bash_completion: \ - "$FUNCNAME: \`$1${2+ }$2': missing argument(s)" \ - >&2; return 1; } + [[ "$2" ]] && unset -v "$2" && eval $2=\(\"\$"{@:3:${1#-a}}"\"\) && + shift $((${1#-a} + 2)) || { + echo bash_completion: \ + "$FUNCNAME: \`$1${2+ }$2': missing argument(s)" \ + >&2 + return 1 + } ;; -v) # Assign single value [[ "$2" ]] && unset -v "$2" && eval $2=\"\$3\" && - shift 3 || { echo "bash_completion: $FUNCNAME: $1:" \ - "missing argument(s)" >&2; return 1; } + shift 3 || { + echo "bash_completion: $FUNCNAME: $1:" \ + "missing argument(s)" >&2 + return 1 + } ;; *) echo "bash_completion: $FUNCNAME: $1: invalid option" >&2 - return 1 ;; + return 1 + ;; esac done } - # Reassemble command line words, excluding specified characters from the # list of word completion separators (COMP_WORDBREAKS). # @param $1 chars Characters out of $COMP_WORDBREAKS which should @@ -234,49 +242,49 @@ __reassemble_comp_words_by_ref() if [[ $1 ]]; then # Yes, exclude word separator characters; # Exclude only those characters, which were really included - exclude="${1//[^$COMP_WORDBREAKS]}" + exclude="[${1//[^$COMP_WORDBREAKS]/}]" fi # Default to cword unchanged printf -v "$3" %s "$COMP_CWORD" # Are characters excluded which were former included? - if [[ $exclude ]]; then + if [[ -v exclude ]]; then # Yes, list of word completion separators has shrunk; line=$COMP_LINE # Re-assemble words to complete - for (( i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do + for ((i = 0, j = 0; i < ${#COMP_WORDS[@]}; i++, j++)); do # Is current word not word 0 (the command itself) and is word not # empty and is word made up of just word separator characters to # be excluded and is current word not preceded by whitespace in # original line? - while [[ $i -gt 0 && ${COMP_WORDS[$i]} == +([$exclude]) ]]; do + while [[ $i -gt 0 && ${COMP_WORDS[i]} == +($exclude) ]]; do # Is word separator not preceded by whitespace in original line # and are we not going to append to word 0 (the command # itself), then append to current word. - [[ $line != [[:blank:]]* ]] && (( j >= 2 )) && ((j--)) + [[ $line != [[:blank:]]* ]] && ((j >= 2)) && ((j--)) # Append word separator to current or new word ref="$2[$j]" - printf -v "$ref" %s "${!ref}${COMP_WORDS[i]}" + printf -v "$ref" %s "${!ref-}${COMP_WORDS[i]}" # Indicate new cword - [[ $i == $COMP_CWORD ]] && printf -v "$3" %s "$j" + ((i == COMP_CWORD)) && printf -v "$3" %s "$j" # Remove optional whitespace + word separator from line copy - line=${line#*"${COMP_WORDS[$i]}"} + line=${line#*"${COMP_WORDS[i]}"} # Start new word if word separator in original line is # followed by whitespace. [[ $line == [[:blank:]]* ]] && ((j++)) # Indicate next word if available, else end *both* while and # for loop - (( $i < ${#COMP_WORDS[@]} - 1)) && ((i++)) || break 2 + ((i < ${#COMP_WORDS[@]} - 1)) && ((i++)) || break 2 done # Append word to current word ref="$2[$j]" - printf -v "$ref" %s "${!ref}${COMP_WORDS[i]}" + printf -v "$ref" %s "${!ref-}${COMP_WORDS[i]}" # Remove optional whitespace + word from line copy line=${line#*"${COMP_WORDS[i]}"} # Indicate new cword - [[ $i == $COMP_CWORD ]] && printf -v "$3" %s "$j" + ((i == COMP_CWORD)) && printf -v "$3" %s "$j" done - [[ $i == $COMP_CWORD ]] && printf -v "$3" %s "$j" + ((i == COMP_CWORD)) && printf -v "$3" %s "$j" else # No, list of word completions separators hasn't changed; for i in "${!COMP_WORDS[@]}"; do @@ -285,7 +293,6 @@ __reassemble_comp_words_by_ref() fi } # __reassemble_comp_words_by_ref() - # @param $1 exclude Characters out of $COMP_WORDBREAKS which should NOT be # considered word breaks. This is useful for things like scp where # we want to return host:path and not only path, so we would pass the @@ -299,45 +306,41 @@ __get_cword_at_cursor_by_ref() local cword words=() __reassemble_comp_words_by_ref "$1" words cword - local i cur index=$COMP_POINT lead=${COMP_LINE:0:$COMP_POINT} + local i cur="" index=$COMP_POINT lead=${COMP_LINE:0:COMP_POINT} # Cursor not at position 0 and not leaded by just space(s)? - if [[ $index -gt 0 && ( $lead && ${lead//[[:space:]]} ) ]]; then + if [[ $index -gt 0 && ($lead && ${lead//[[:space:]]/}) ]]; then cur=$COMP_LINE - for (( i = 0; i <= cword; ++i )); do - while [[ - # Current word fits in $cur? - ${#cur} -ge ${#words[i]} && - # $cur doesn't match cword? - "${cur:0:${#words[i]}}" != "${words[i]}" - ]]; do + for ((i = 0; i <= cword; ++i)); do + # Current word fits in $cur, and $cur doesn't match cword? + while [[ ${#cur} -ge ${#words[i]} && \ + ${cur:0:${#words[i]}} != "${words[i]-}" ]]; do # Strip first character cur="${cur:1}" # Decrease cursor position, staying >= 0 - [[ $index -gt 0 ]] && ((index--)) + ((index > 0)) && ((index--)) done # Does found word match cword? - if [[ $i -lt $cword ]]; then + if ((i < cword)); then # No, cword lies further; local old_size=${#cur} cur="${cur#"${words[i]}"}" local new_size=${#cur} - (( index -= old_size - new_size )) + ((index -= old_size - new_size)) fi done # Clear $cur if just space(s) - [[ $cur && ! ${cur//[[:space:]]} ]] && cur= + [[ $cur && ! ${cur//[[:space:]]/} ]] && cur= # Zero $index if negative - [[ $index -lt 0 ]] && index=0 + ((index < 0)) && index=0 fi - local "$2" "$3" "$4" && _upvars -a${#words[@]} $2 "${words[@]}" \ - -v $3 "$cword" -v $4 "${cur:0:$index}" + local "$2" "$3" "$4" && _upvars -a${#words[@]} $2 ${words+"${words[@]}"} \ + -v $3 "$cword" -v $4 "${cur:0:index}" } - # Get the word to complete and optional previous words. -# This is nicer than ${COMP_WORDS[$COMP_CWORD]}, since it handles cases +# This is nicer than ${COMP_WORDS[COMP_CWORD]}, since it handles cases # where the user is completing in the middle of a word. # (For example, if the line is "ls foobar", # and the cursor is here --------> ^ @@ -376,35 +379,51 @@ _get_comp_words_by_ref() n) exclude=$OPTARG ;; p) vprev=$OPTARG ;; w) vwords=$OPTARG ;; + *) + echo "bash_completion: $FUNCNAME: usage error" >&2 + return 1 + ;; esac done while [[ $# -ge $OPTIND ]]; do case ${!OPTIND} in - cur) vcur=cur ;; - prev) vprev=prev ;; + cur) vcur=cur ;; + prev) vprev=prev ;; cword) vcword=cword ;; words) vwords=words ;; - *) echo "bash_completion: $FUNCNAME: \`${!OPTIND}':" \ - "unknown argument" >&2; return 1 ;; + *) + echo "bash_completion: $FUNCNAME: \`${!OPTIND}':" \ + "unknown argument" >&2 + return 1 + ;; esac - (( OPTIND += 1 )) + ((OPTIND += 1)) done - __get_cword_at_cursor_by_ref "$exclude" words cword cur + __get_cword_at_cursor_by_ref "${exclude-}" words cword cur - [[ $vcur ]] && { upvars+=("$vcur" ); upargs+=(-v $vcur "$cur" ); } - [[ $vcword ]] && { upvars+=("$vcword"); upargs+=(-v $vcword "$cword"); } - [[ $vprev && $cword -ge 1 ]] && { upvars+=("$vprev" ); upargs+=(-v $vprev - "${words[cword - 1]}"); } - [[ $vwords ]] && { upvars+=("$vwords"); upargs+=(-a${#words[@]} $vwords - "${words[@]}"); } + [[ -v vcur ]] && { + upvars+=("$vcur") + upargs+=(-v $vcur "$cur") + } + [[ -v vcword ]] && { + upvars+=("$vcword") + upargs+=(-v $vcword "$cword") + } + [[ -v vprev && $cword -ge 1 ]] && { + upvars+=("$vprev") + upargs+=(-v $vprev "${words[cword - 1]}") + } + [[ -v vwords ]] && { + upvars+=("$vwords") + upargs+=(-a${#words[@]} $vwords ${words+"${words[@]}"}) + } - (( ${#upvars[@]} )) && local "${upvars[@]}" && _upvars "${upargs[@]}" + ((${#upvars[@]})) && local "${upvars[@]}" && _upvars "${upargs[@]}" } - # Get the word to complete. -# This is nicer than ${COMP_WORDS[$COMP_CWORD]}, since it handles cases +# This is nicer than ${COMP_WORDS[COMP_CWORD]}, since it handles cases # where the user is completing in the middle of a word. # (For example, if the line is "ls foobar", # and the cursor is here --------> ^ @@ -422,51 +441,47 @@ _get_cword() { local LC_CTYPE=C local cword words - __reassemble_comp_words_by_ref "$1" words cword + __reassemble_comp_words_by_ref "${1-}" words cword # return previous word offset by $2 - if [[ ${2//[^0-9]/} ]]; then - printf "%s" "${words[cword-$2]}" - elif [[ "${#words[cword]}" -eq 0 || "$COMP_POINT" == "${#COMP_LINE}" ]]; then - printf "%s" "${words[cword]}" + if [[ ${2-} && ${2//[^0-9]/} ]]; then + printf "%s" "${words[cword - $2]}" + elif ((${#words[cword]} == 0 && COMP_POINT == ${#COMP_LINE})); then + : # nothing else local i local cur="$COMP_LINE" local index="$COMP_POINT" - for (( i = 0; i <= cword; ++i )); do - while [[ - # Current word fits in $cur? - "${#cur}" -ge ${#words[i]} && - # $cur doesn't match cword? - "${cur:0:${#words[i]}}" != "${words[i]}" - ]]; do + for ((i = 0; i <= cword; ++i)); do + # Current word fits in $cur, and $cur doesn't match cword? + while [[ ${#cur} -ge ${#words[i]} && \ + ${cur:0:${#words[i]}} != "${words[i]}" ]]; do # Strip first character cur="${cur:1}" # Decrease cursor position, staying >= 0 - [[ $index -gt 0 ]] && ((index--)) + ((index > 0)) && ((index--)) done - # Does found word matches cword? - if [[ "$i" -lt "$cword" ]]; then + # Does found word match cword? + if ((i < cword)); then # No, cword lies further; local old_size="${#cur}" cur="${cur#${words[i]}}" local new_size="${#cur}" - (( index -= old_size - new_size )) + ((index -= old_size - new_size)) fi done - if [[ "${words[cword]:0:${#cur}}" != "$cur" ]]; then + if [[ ${words[cword]:0:${#cur}} != "$cur" ]]; then # We messed up! At least return the whole word so things # keep working printf "%s" "${words[cword]}" else - printf "%s" "${cur:0:$index}" + printf "%s" "${cur:0:index}" fi fi } # _get_cword() - # Get word previous to the current word. # This is a good alternative to `prev=${COMP_WORDS[COMP_CWORD-1]}' because bash4 # will properly return the previous word with respect to any given exclusions to @@ -476,12 +491,11 @@ _get_cword() # _get_pword() { - if [[ $COMP_CWORD -ge 1 ]]; then + if ((COMP_CWORD >= 1)); then _get_cword "${@:-}" 1 fi } - # If the word-to-complete contains a colon (:), left-trim COMPREPLY items with # word-to-complete. # With a colon in COMP_WORDBREAKS, words containing @@ -495,23 +509,22 @@ _get_pword() # COMP_WORDBREAKS=${COMP_WORDBREAKS//:} # # See also: Bash FAQ - E13) Why does filename completion misbehave if a colon -# appears in the filename? - http://tiswww.case.edu/php/chet/bash/FAQ +# appears in the filename? - https://tiswww.case.edu/php/chet/bash/FAQ # @param $1 current word to complete (cur) # @modifies global array $COMPREPLY # __ltrim_colon_completions() { - if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then + if [[ $1 == *:* && $COMP_WORDBREAKS == *:* ]]; then # Remove colon-word prefix from COMPREPLY items local colon_word=${1%"${1##*:}"} local i=${#COMPREPLY[*]} - while [[ $((--i)) -ge 0 ]]; do - COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"} + while ((i-- > 0)); do + COMPREPLY[i]=${COMPREPLY[i]#"$colon_word"} done fi } # __ltrim_colon_completions() - # This function quotes the argument in a way so that readline dequoting # results in the original argument. This is necessary for at least # `compgen' which requires its arguments quoted/escaped: @@ -523,9 +536,8 @@ __ltrim_colon_completions() # a\'b/c # # See also: -# - http://lists.gnu.org/archive/html/bug-bash/2009-03/msg00155.html -# - http://www.mail-archive.com/bash-completion-devel@lists.alioth.\ -# debian.org/msg01944.html +# - https://lists.gnu.org/archive/html/bug-bash/2009-03/msg00155.html +# - https://www.mail-archive.com/bash-completion-devel@lists.alioth.debian.org/msg01944.html # @param $1 Argument to quote # @param $2 Name of variable to return result to _quote_readline_by_ref() @@ -538,12 +550,11 @@ _quote_readline_by_ref() fi # If result becomes quoted like this: $'string', re-evaluate in order to - # drop the additional quoting. See also: http://www.mail-archive.com/ - # bash-completion-devel@lists.alioth.debian.org/msg01942.html + # drop the additional quoting. See also: + # https://www.mail-archive.com/bash-completion-devel@lists.alioth.debian.org/msg01942.html [[ ${!2} == \$* ]] && eval $2=${!2} } # _quote_readline_by_ref() - # This function performs file and directory completion. It's better than # simply using 'compgen -f', because it honours spaces in filenames. # @param $1 If `-d', complete only on directories. Otherwise filter/pick only @@ -554,51 +565,61 @@ _filedir() { local IFS=$'\n' - _tilde "$cur" || return + _tilde "${cur-}" || return local -a toks - local reset + local reset arg=${1-} - if [[ "$1" == -d ]]; then - reset=$(shopt -po noglob); set -o noglob - toks=( $(compgen -d -- "$cur") ) - IFS=' '; $reset; IFS=$'\n' + if [[ $arg == -d ]]; then + reset=$(shopt -po noglob) + set -o noglob + toks=($(compgen -d -- "${cur-}")) + IFS=' ' + $reset + IFS=$'\n' else local quoted - _quote_readline_by_ref "$cur" quoted + _quote_readline_by_ref "${cur-}" quoted # Munge xspec to contain uppercase version too - # http://thread.gmane.org/gmane.comp.shells.bash.bugs/15294/focus=15306 - local xspec=${1:+"!*.@($1|${1^^})"} plusdirs=() + # https://lists.gnu.org/archive/html/bug-bash/2010-09/msg00036.html + # news://news.gmane.io/4C940E1C.1010304@case.edu + local xspec=${arg:+"!*.@($arg|${arg^^})"} plusdirs=() # Use plusdirs to get dir completions if we have a xspec; if we don't, # there's no need, dirs come along with other completions. Don't use # plusdirs quite yet if fallback is in use though, in order to not ruin # the fallback condition with the "plus" dirs. - local opts=( -f -X "$xspec" ) + local opts=(-f -X "$xspec") [[ $xspec ]] && plusdirs=(-o plusdirs) - [[ ${COMP_FILEDIR_FALLBACK-} ]] || opts+=( "${plusdirs[@]}" ) + [[ ${COMP_FILEDIR_FALLBACK-} || -z ${plusdirs-} ]] || + opts+=("${plusdirs[@]}") - reset=$(shopt -po noglob); set -o noglob - toks+=( $(compgen "${opts[@]}" -- $quoted) ) - IFS=' '; $reset; IFS=$'\n' + reset=$(shopt -po noglob) + set -o noglob + toks+=($(compgen "${opts[@]}" -- $quoted)) + IFS=' ' + $reset + IFS=$'\n' # Try without filter if it failed to produce anything and configured to - [[ -n ${COMP_FILEDIR_FALLBACK:-} && -n "$1" && ${#toks[@]} -lt 1 ]] && { - reset=$(shopt -po noglob); set -o noglob - toks+=( $(compgen -f "${plusdirs[@]}" -- $quoted) ) - IFS=' '; $reset; IFS=$'\n' + [[ -n ${COMP_FILEDIR_FALLBACK-} && -n $arg && ${#toks[@]} -lt 1 ]] && { + reset=$(shopt -po noglob) + set -o noglob + toks+=($(compgen -f ${plusdirs+"${plusdirs[@]}"} -- $quoted)) + IFS=' ' + $reset + IFS=$'\n' } fi - if [[ ${#toks[@]} -ne 0 ]]; then + if ((${#toks[@]} != 0)); then # 2>/dev/null for direct invocation, e.g. in the _filedir unit test compopt -o filenames 2>/dev/null - COMPREPLY+=( "${toks[@]}" ) + COMPREPLY+=("${toks[@]}") fi } # _filedir() - # This function splits $cur=--foo=bar into $prev=--foo, $cur=bar, making it # easier to support both "--foo bar" and "--foo=bar" style completions. # `=' should have been removed from COMP_WORDBREAKS when setting $cur for @@ -607,7 +628,7 @@ _filedir() # _split_longopt() { - if [[ "$cur" == --?*=* ]]; then + if [[ $cur == --?*=* ]]; then # Cut also backslash before '=' in case it ended up there # for some reason. prev="${cur%%?(\\)=*}" @@ -625,41 +646,41 @@ _variables() { if [[ $cur =~ ^(\$(\{[!#]?)?)([A-Za-z0-9_]*)$ ]]; then # Completing $var / ${var / ${!var / ${#var - if [[ $cur == \${* ]]; then + if [[ $cur == '${'* ]]; then local arrs vars - vars=( $(compgen -A variable -P ${BASH_REMATCH[1]} -S '}' -- ${BASH_REMATCH[3]}) ) && \ - arrs=( $(compgen -A arrayvar -P ${BASH_REMATCH[1]} -S '[' -- ${BASH_REMATCH[3]}) ) - if [[ ${#vars[@]} -eq 1 && $arrs ]]; then + vars=($(compgen -A variable -P ${BASH_REMATCH[1]} -S '}' -- ${BASH_REMATCH[3]})) + arrs=($(compgen -A arrayvar -P ${BASH_REMATCH[1]} -S '[' -- ${BASH_REMATCH[3]})) + if ((${#vars[@]} == 1 && ${#arrs[@]} != 0)); then # Complete ${arr with ${array[ if there is only one match, and that match is an array variable compopt -o nospace - COMPREPLY+=( ${arrs[*]} ) + COMPREPLY+=(${arrs[*]}) else # Complete ${var with ${variable} - COMPREPLY+=( ${vars[*]} ) + COMPREPLY+=(${vars[*]}) fi else # Complete $var with $variable - COMPREPLY+=( $(compgen -A variable -P '$' -- "${BASH_REMATCH[3]}") ) + COMPREPLY+=($(compgen -A variable -P '$' -- "${BASH_REMATCH[3]}")) fi return 0 elif [[ $cur =~ ^(\$\{[#!]?)([A-Za-z0-9_]*)\[([^]]*)$ ]]; then # Complete ${array[i with ${array[idx]} local IFS=$'\n' - COMPREPLY+=( $(compgen -W '$(printf %s\\n "${!'${BASH_REMATCH[2]}'[@]}")' \ - -P "${BASH_REMATCH[1]}${BASH_REMATCH[2]}[" -S ']}' -- "${BASH_REMATCH[3]}") ) + COMPREPLY+=($(compgen -W '$(printf %s\\n "${!'${BASH_REMATCH[2]}'[@]}")' \ + -P "${BASH_REMATCH[1]}${BASH_REMATCH[2]}[" -S ']}' -- "${BASH_REMATCH[3]}")) # Complete ${arr[@ and ${arr[* if [[ ${BASH_REMATCH[3]} == [@*] ]]; then - COMPREPLY+=( "${BASH_REMATCH[1]}${BASH_REMATCH[2]}[${BASH_REMATCH[3]}]}" ) + COMPREPLY+=("${BASH_REMATCH[1]}${BASH_REMATCH[2]}[${BASH_REMATCH[3]}]}") fi - __ltrim_colon_completions "$cur" # array indexes may have colons + __ltrim_colon_completions "$cur" # array indexes may have colons return 0 elif [[ $cur =~ ^\$\{[#!]?[A-Za-z0-9_]*\[.*\]$ ]]; then # Complete ${array[idx] with ${array[idx]} - COMPREPLY+=( "$cur}" ) + COMPREPLY+=("$cur}") __ltrim_colon_completions "$cur" return 0 else - case $prev in + case ${prev-} in TZ) cur=/usr/share/zoneinfo/$cur _filedir @@ -679,9 +700,9 @@ _variables() _terms return 0 ;; - LANG|LC_*) - COMPREPLY=( $(compgen -W '$(locale -a 2>/dev/null)' \ - -- "$cur" ) ) + LANG | LC_*) + COMPREPLY=($(compgen -W '$(locale -a 2>/dev/null)' \ + -- "$cur")) return 0 ;; esac @@ -714,16 +735,17 @@ _init_completion() e) errx=$OPTARG ;; o) outx=$OPTARG ;; i) inx=$OPTARG ;; - s) split=false ; exclude+== ;; + s) + split=false + exclude+== + ;; + *) + echo "bash_completion: $FUNCNAME: usage error" >&2 + return 1 + ;; esac done - # For some reason completion functions are not invoked at all by - # bash (at least as of 4.1.7) after the command line contains an - # ampersand so we don't get a chance to deal with redirections - # containing them, but if we did, hopefully the below would also - # do the right thing with them... - COMPREPLY=() local redir="@(?([0-9])<|?([0-9&])>?(>)|>&)" _get_comp_words_by_ref -n "$exclude<>&" cur prev words cword @@ -733,17 +755,18 @@ _init_completion() # Complete on files if current is a redirect possibly followed by a # filename, e.g. ">foo", or previous is a "bare" redirect, e.g. ">". - if [[ $cur == $redir* || $prev == $redir ]]; then + # shellcheck disable=SC2053 + if [[ $cur == $redir* || ${prev-} == $redir ]]; then local xspec case $cur in - 2'>'*) xspec=$errx ;; - *'>'*) xspec=$outx ;; - *'<'*) xspec=$inx ;; + 2'>'*) xspec=${errx-} ;; + *'>'*) xspec=${outx-} ;; + *'<'*) xspec=${inx-} ;; *) case $prev in - 2'>'*) xspec=$errx ;; - *'>'*) xspec=$outx ;; - *'<'*) xspec=$inx ;; + 2'>'*) xspec=${errx-} ;; + *'>'*) xspec=${outx-} ;; + *'<'*) xspec=${inx-} ;; esac ;; esac @@ -754,19 +777,20 @@ _init_completion() # Remove all redirections so completions don't have to deal with them. local i skip - for (( i=1; i < ${#words[@]}; )); do + for ((i = 1; i < ${#words[@]}; )); do if [[ ${words[i]} == $redir* ]]; then # If "bare" redirect, remove also the next word (skip=2). + # shellcheck disable=SC2053 [[ ${words[i]} == $redir ]] && skip=2 || skip=1 - words=( "${words[@]:0:i}" "${words[@]:i+skip}" ) - [[ $i -le $cword ]] && (( cword -= skip )) + words=("${words[@]:0:i}" "${words[@]:i+skip}") + ((i <= cword)) && ((cword -= skip)) else - (( i++ )) + ((i++)) fi done - [[ $cword -le 0 ]] && return 1 - prev=${words[cword-1]} + ((cword <= 0)) && return 1 + prev=${words[cword - 1]} [[ ${split-} ]] && _split_longopt && split=true @@ -780,13 +804,16 @@ __parse_options() # Take first found long option, or first one (short) if not found. option= - local -a array=( $1 ) + local -a array=($1) for i in "${array[@]}"; do case "$i" in ---*) break ;; - --?*) option=$i ; break ;; - -?*) [[ $option ]] || option=$i ;; - *) break ;; + --?*) + option=$i + break + ;; + -?*) [[ $option ]] || option=$i ;; + *) break ;; esac done [[ $option ]] || return 0 @@ -811,23 +838,25 @@ __parse_options() # _parse_help() { - eval local cmd=$(quote "$1") + eval local cmd="$(quote "$1")" local line - { case $cmd in - -) cat ;; - *) LC_ALL=C "$(dequote "$cmd")" ${2:---help} 2>&1 ;; - esac } \ - | while read -r line; do - - [[ $line == *([[:blank:]])-* ]] || continue - # transform "-f FOO, --foo=FOO" to "-f , --foo=FOO" etc - while [[ $line =~ \ - ((^|[^-])-[A-Za-z0-9?][[:space:]]+)\[?[A-Z0-9]+([,_-]+[A-Z0-9]+)?(\.\.+)?\]? ]]; do - line=${line/"${BASH_REMATCH[0]}"/"${BASH_REMATCH[1]}"} - done - __parse_options "${line// or /, }" + { + case $cmd in + -) cat ;; + *) LC_ALL=C "$(dequote "$cmd")" ${2:---help} 2>&1 ;; + esac + } | + while read -r line; do + + [[ $line == *([[:blank:]])-* ]] || continue + # transform "-f FOO, --foo=FOO" to "-f , --foo=FOO" etc + while [[ $line =~ \ + ((^|[^-])-[A-Za-z0-9?][[:space:]]+)\[?[A-Z0-9]+([,_-]+[A-Z0-9]+)?(\.\.+)?\]? ]]; do + line=${line/"${BASH_REMATCH[0]}"/"${BASH_REMATCH[1]}"} + done + __parse_options "${line// or /, }" - done + done } # Parse BSD style usage output (options in brackets) of the given command. @@ -836,41 +865,43 @@ _parse_help() # _parse_usage() { - eval local cmd=$(quote "$1") + eval local cmd="$(quote "$1")" local line match option i char - { case $cmd in - -) cat ;; - *) LC_ALL=C "$(dequote "$cmd")" ${2:---usage} 2>&1 ;; - esac } \ - | while read -r line; do - - while [[ $line =~ \[[[:space:]]*(-[^]]+)[[:space:]]*\] ]]; do - match=${BASH_REMATCH[0]} - option=${BASH_REMATCH[1]} - case $option in - -?(\[)+([a-zA-Z0-9?])) - # Treat as bundled short options - for (( i=1; i < ${#option}; i++ )); do - char=${option:i:1} - [[ $char != '[' ]] && printf '%s\n' -$char - done - ;; - *) - __parse_options "$option" - ;; - esac - line=${line#*"$match"} - done + { + case $cmd in + -) cat ;; + *) LC_ALL=C "$(dequote "$cmd")" ${2:---usage} 2>&1 ;; + esac + } | + while read -r line; do + + while [[ $line =~ \[[[:space:]]*(-[^]]+)[[:space:]]*\] ]]; do + match=${BASH_REMATCH[0]} + option=${BASH_REMATCH[1]} + case $option in + -?(\[)+([a-zA-Z0-9?])) + # Treat as bundled short options + for ((i = 1; i < ${#option}; i++)); do + char=${option:i:1} + [[ $char != '[' ]] && printf '%s\n' -$char + done + ;; + *) + __parse_options "$option" + ;; + esac + line=${line#*"$match"} + done - done + done } # This function completes on signal names (minus the SIG prefix) # @param $1 prefix _signals() { - local -a sigs=( $(compgen -P "$1" -A signal "SIG${cur#$1}") ) - COMPREPLY+=( "${sigs[@]/#${1}SIG/${1}}" ) + local -a sigs=($(compgen -P "${1-}" -A signal "SIG${cur#${1-}}")) + COMPREPLY+=("${sigs[@]/#${1-}SIG/${1-}}") } # This function completes on known mac addresses @@ -884,24 +915,28 @@ _mac_addresses() # - ifconfig on Linux: HWaddr or ether # - ifconfig on FreeBSD: ether # - ip link: link/ether - COMPREPLY+=( $(\ - { LC_ALL=C ifconfig -a || ip link show; } 2>/dev/null | command sed -ne \ - "s/.*[[:space:]]HWaddr[[:space:]]\{1,\}\($re\)[[:space:]].*/\1/p" -ne \ - "s/.*[[:space:]]HWaddr[[:space:]]\{1,\}\($re\)[[:space:]]*$/\1/p" -ne \ - "s|.*[[:space:]]\(link/\)\{0,1\}ether[[:space:]]\{1,\}\($re\)[[:space:]].*|\2|p" -ne \ - "s|.*[[:space:]]\(link/\)\{0,1\}ether[[:space:]]\{1,\}\($re\)[[:space:]]*$|\2|p" - ) ) + COMPREPLY+=($( + { + LC_ALL=C ifconfig -a || ip link show + } 2>/dev/null | command sed -ne \ + "s/.*[[:space:]]HWaddr[[:space:]]\{1,\}\($re\)[[:space:]].*/\1/p" -ne \ + "s/.*[[:space:]]HWaddr[[:space:]]\{1,\}\($re\)[[:space:]]*$/\1/p" -ne \ + "s|.*[[:space:]]\(link/\)\{0,1\}ether[[:space:]]\{1,\}\($re\)[[:space:]].*|\2|p" -ne \ + "s|.*[[:space:]]\(link/\)\{0,1\}ether[[:space:]]\{1,\}\($re\)[[:space:]]*$|\2|p" + )) # ARP cache - COMPREPLY+=( $({ arp -an || ip neigh show; } 2>/dev/null | command sed -ne \ + COMPREPLY+=($({ + arp -an || ip neigh show + } 2>/dev/null | command sed -ne \ "s/.*[[:space:]]\($re\)[[:space:]].*/\1/p" -ne \ - "s/.*[[:space:]]\($re\)[[:space:]]*$/\1/p") ) + "s/.*[[:space:]]\($re\)[[:space:]]*$/\1/p")) # /etc/ethers - COMPREPLY+=( $(command sed -ne \ - "s/^[[:space:]]*\($re\)[[:space:]].*/\1/p" /etc/ethers 2>/dev/null) ) + COMPREPLY+=($(command sed -ne \ + "s/^[[:space:]]*\($re\)[[:space:]].*/\1/p" /etc/ethers 2>/dev/null)) - COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur")) __ltrim_colon_completions "$cur" } @@ -911,24 +946,24 @@ _configured_interfaces() { if [[ -f /etc/debian_version ]]; then # Debian system - COMPREPLY=( $(compgen -W "$(command sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p'\ + COMPREPLY=($(compgen -W "$(command sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p' \ /etc/network/interfaces /etc/network/interfaces.d/* 2>/dev/null)" \ - -- "$cur") ) + -- "$cur")) elif [[ -f /etc/SuSE-release ]]; then # SuSE system - COMPREPLY=( $(compgen -W "$(printf '%s\n' \ - /etc/sysconfig/network/ifcfg-* | \ - command sed -ne 's|.*ifcfg-\([^*].*\)$|\1|p')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(printf '%s\n' \ + /etc/sysconfig/network/ifcfg-* | + command sed -ne 's|.*ifcfg-\([^*].*\)$|\1|p')" -- "$cur")) elif [[ -f /etc/pld-release ]]; then # PLD Linux - COMPREPLY=( $(compgen -W "$(command ls -B \ - /etc/sysconfig/interfaces | \ - command sed -ne 's|.*ifcfg-\([^*].*\)$|\1|p')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(command ls -B \ + /etc/sysconfig/interfaces | + command sed -ne 's|.*ifcfg-\([^*].*\)$|\1|p')" -- "$cur")) else # Assume Red Hat - COMPREPLY=( $(compgen -W "$(printf '%s\n' \ - /etc/sysconfig/network-scripts/ifcfg-* | \ - command sed -ne 's|.*ifcfg-\([^*].*\)$|\1|p')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(printf '%s\n' \ + /etc/sysconfig/network-scripts/ifcfg-* | + command sed -ne 's|.*ifcfg-\([^*].*\)$|\1|p')" -- "$cur")) fi } @@ -940,22 +975,25 @@ _configured_interfaces() _ip_addresses() { local n - case $1 in + case ${1-} in -a) n='6\?' ;; -6) n='6' ;; + *) n= ;; esac local PATH=$PATH:/sbin - local addrs=$({ LC_ALL=C ifconfig -a || ip addr show; } 2>/dev/null | + local addrs=$({ + LC_ALL=C ifconfig -a || ip addr show + } 2>/dev/null | command sed -e 's/[[:space:]]addr:/ /' -ne \ "s|.*inet${n}[[:space:]]\{1,\}\([^[:space:]/]*\).*|\1|p") - COMPREPLY+=( $(compgen -W "$addrs" -- "$cur") ) + COMPREPLY+=($(compgen -W "$addrs" -- "${cur-}")) } # This function completes on available kernels # _kernel_versions() { - COMPREPLY=( $(compgen -W '$(command ls /lib/modules)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(command ls /lib/modules)' -- "$cur")) } # This function completes on all available network interfaces @@ -966,7 +1004,7 @@ _available_interfaces() { local PATH=$PATH:/sbin - COMPREPLY=( $({ + COMPREPLY=($({ if [[ ${1:-} == -w ]]; then iwconfig elif [[ ${1:-} == -a ]]; then @@ -975,9 +1013,9 @@ _available_interfaces() ifconfig -a || ip link show fi } 2>/dev/null | awk \ - '/^[^ \t]/ { if ($1 ~ /^[0-9]+:/) { print $2 } else { print $1 } }') ) + '/^[^ \t]/ { if ($1 ~ /^[0-9]+:/) { print $2 } else { print $1 } }')) - COMPREPLY=( $(compgen -W '${COMPREPLY[@]/%[[:punct:]]/}' -- "$cur") ) + COMPREPLY=($(compgen -W '${COMPREPLY[@]/%[[:punct:]]/}' -- "$cur")) } # Echo number of CPUs, falling back to 1 on failure. @@ -996,17 +1034,16 @@ _ncpus() _tilde() { local result=0 - if [[ $1 == \~* && $1 != */* ]]; then + if [[ ${1-} == \~* && $1 != */* ]]; then # Try generate ~username completions - COMPREPLY=( $(compgen -P '~' -u -- "${1#\~}") ) + COMPREPLY=($(compgen -P '~' -u -- "${1#\~}")) result=${#COMPREPLY[@]} # 2>/dev/null for direct invocation, e.g. in the _tilde unit test - [[ $result -gt 0 ]] && compopt -o filenames 2>/dev/null + ((result > 0)) && compopt -o filenames 2>/dev/null fi return $result } - # Expand variable starting with tilde (~) # We want to expand ~foo/... to /home/foo/... to avoid problems when # word-to-complete starting with a tilde is fed to commands and ending up @@ -1031,12 +1068,11 @@ _tilde() # @param $1 Name of variable (not the value of the variable) to expand __expand_tilde_by_ref() { - if [[ ${!1} == \~* ]]; then - eval $1=$(printf ~%q "${!1#\~}") + if [[ ${!1-} == \~* ]]; then + eval $1="$(printf ~%q "${!1#\~}")" fi } # __expand_tilde_by_ref() - # This function expands tildes in pathnames # _expand() @@ -1045,102 +1081,102 @@ _expand() # ~foo/... to /home/foo/... to avoid problems when $cur starting with # a tilde is fed to commands and ending up quoted instead of expanded. - if [[ "$cur" == \~*/* ]]; then - __expand_tilde_by_ref cur - elif [[ "$cur" == \~* ]]; then - _tilde "$cur" || eval COMPREPLY[0]=$(printf ~%q "${COMPREPLY[0]#\~}") - return ${#COMPREPLY[@]} - fi -} - -# This function completes on process IDs. -# AIX and Solaris ps prefers X/Open syntax. -[[ $OSTYPE == *@(solaris|aix)* ]] && -_pids() -{ - COMPREPLY=( $(compgen -W '$(command ps -efo pid | command sed 1d)' -- "$cur") ) -} || -_pids() -{ - COMPREPLY=( $(compgen -W '$(command ps axo pid=)' -- "$cur") ) + case ${cur-} in + ~*/*) + __expand_tilde_by_ref cur + ;; + ~*) + _tilde "$cur" || + eval COMPREPLY[0]="$(printf ~%q "${COMPREPLY[0]#\~}")" + return ${#COMPREPLY[@]} + ;; + esac } -# This function completes on process group IDs. -# AIX and SunOS prefer X/Open, all else should be BSD. -[[ $OSTYPE == *@(solaris|aix)* ]] && -_pgids() -{ - COMPREPLY=( $(compgen -W '$(command ps -efo pgid | command sed 1d)' -- "$cur") ) -} || -_pgids() -{ - COMPREPLY=( $(compgen -W '$(command ps axo pgid=)' -- "$cur") ) -} +# Process ID related functions. +# for AIX and Solaris we use X/Open syntax, BSD for others. +if [[ $OSTYPE == *@(solaris|aix)* ]]; then + # This function completes on process IDs. + _pids() + { + COMPREPLY=($(compgen -W '$(command ps -efo pid | command sed 1d)' -- "$cur")) + } -# This function completes on process names. -# AIX and SunOS prefer X/Open, all else should be BSD. -# @param $1 if -s, don't try to avoid truncated command names -[[ $OSTYPE == *@(solaris|aix)* ]] && -_pnames() -{ - COMPREPLY=( $(compgen -X '' -W '$(command ps -efo comm | \ - command sed -e 1d -e "s:.*/::" -e "s/^-//" | sort -u)' -- "$cur") ) -} || -_pnames() -{ - local -a procs - if [[ "$1" == -s ]]; then - procs=( $(command ps axo comm | command sed -e 1d) ) - else - local line i=-1 OIFS=$IFS - IFS=$'\n' - local -a psout=( $(command ps axo command=) ) - IFS=$OIFS - for line in "${psout[@]}"; do - if [[ $i -eq -1 ]]; then - # First line, see if it has COMMAND column header. For example - # the busybox ps does that, i.e. doesn't respect axo command= - if [[ $line =~ ^(.*[[:space:]])COMMAND([[:space:]]|$) ]]; then - # It does; store its index. - i=${#BASH_REMATCH[1]} - else - # Nope, fall through to "regular axo command=" parsing. - break - fi - else - # - line=${line:$i} # take command starting from found index - line=${line%% *} # trim arguments - procs+=( $line ) - fi - done - if [[ $i -eq -1 ]]; then - # Regular axo command= parsing + _pgids() + { + COMPREPLY=($(compgen -W '$(command ps -efo pgid | command sed 1d)' -- "$cur")) + } + _pnames() + { + COMPREPLY=($(compgen -X '' -W '$(command ps -efo comm | \ + command sed -e 1d -e "s:.*/::" -e "s/^-//" | sort -u)' -- "$cur")) + } +else + _pids() + { + COMPREPLY=($(compgen -W '$(command ps axo pid=)' -- "$cur")) + } + _pgids() + { + COMPREPLY=($(compgen -W '$(command ps axo pgid=)' -- "$cur")) + } + # @param $1 if -s, don't try to avoid truncated command names + _pnames() + { + local -a procs + if [[ ${1-} == -s ]]; then + procs=($(command ps axo comm | command sed -e 1d)) + else + local line i=-1 ifs=$IFS + IFS=$'\n' + local -a psout=($(command ps axo command=)) + IFS=$ifs for line in "${psout[@]}"; do - if [[ $line =~ ^[[(](.+)[])]$ ]]; then - procs+=( ${BASH_REMATCH[1]} ) + if ((i == -1)); then + # First line, see if it has COMMAND column header. For example + # the busybox ps does that, i.e. doesn't respect axo command= + if [[ $line =~ ^(.*[[:space:]])COMMAND([[:space:]]|$) ]]; then + # It does; store its index. + i=${#BASH_REMATCH[1]} + else + # Nope, fall through to "regular axo command=" parsing. + break + fi else - line=${line%% *} # trim arguments - line=${line##@(*/|-)} # trim leading path and - - procs+=( $line ) + # + line=${line:i} # take command starting from found index + line=${line%% *} # trim arguments + procs+=($line) fi done + if ((i == -1)); then + # Regular axo command= parsing + for line in "${psout[@]}"; do + if [[ $line =~ ^[[(](.+)[])]$ ]]; then + procs+=(${BASH_REMATCH[1]}) + else + line=${line%% *} # trim arguments + line=${line##@(*/|-)} # trim leading path and - + procs+=($line) + fi + done + fi fi - fi - COMPREPLY=( $(compgen -X "" -W '${procs[@]}' -- "$cur" ) ) -} + COMPREPLY=($(compgen -X "" -W '${procs[@]}' -- "$cur")) + } +fi # This function completes on user IDs # _uids() { if type getent &>/dev/null; then - COMPREPLY=( $(compgen -W '$(getent passwd | cut -d: -f3)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(getent passwd | cut -d: -f3)' -- "$cur")) elif type perl &>/dev/null; then - COMPREPLY=( $(compgen -W '$(perl -e '"'"'while (($uid) = (getpwent)[2]) { print $uid . "\n" }'"'"')' -- "$cur") ) + COMPREPLY=($(compgen -W '$(perl -e '"'"'while (($uid) = (getpwent)[2]) { print $uid . "\n" }'"'"')' -- "$cur")) else # make do with /etc/passwd - COMPREPLY=( $(compgen -W '$(cut -d: -f3 /etc/passwd)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(cut -d: -f3 /etc/passwd)' -- "$cur")) fi } @@ -1149,12 +1185,12 @@ _uids() _gids() { if type getent &>/dev/null; then - COMPREPLY=( $(compgen -W '$(getent group | cut -d: -f3)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(getent group | cut -d: -f3)' -- "$cur")) elif type perl &>/dev/null; then - COMPREPLY=( $(compgen -W '$(perl -e '"'"'while (($gid) = (getgrent)[2]) { print $gid . "\n" }'"'"')' -- "$cur") ) + COMPREPLY=($(compgen -W '$(perl -e '"'"'while (($gid) = (getgrent)[2]) { print $gid . "\n" }'"'"')' -- "$cur")) else # make do with /etc/group - COMPREPLY=( $(compgen -W '$(cut -d: -f3 /etc/group)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(cut -d: -f3 /etc/group)' -- "$cur")) fi } @@ -1166,12 +1202,14 @@ _backup_glob='@(#*#|*@(~|.@(bak|orig|rej|swp|dpkg*|rpm@(orig|new|save))))' # _xinetd_services() { - local xinetddir=/etc/xinetd.d + local xinetddir=${BASHCOMP_XINETDDIR:-/etc/xinetd.d} if [[ -d $xinetddir ]]; then - local IFS=$' \t\n' reset=$(shopt -p nullglob); shopt -s nullglob - local -a svcs=( $(printf '%s\n' $xinetddir/!($_backup_glob)) ) + local IFS=$' \t\n' reset=$(shopt -p nullglob) + shopt -s nullglob + local -a svcs=($(printf '%s\n' $xinetddir/!($_backup_glob))) $reset - COMPREPLY+=( $(compgen -W '${svcs[@]#$xinetddir/}' -- "$cur") ) + ((!${#svcs[@]})) || + COMPREPLY+=($(compgen -W '${svcs[@]#$xinetddir/}' -- "${cur-}")) fi } @@ -1182,20 +1220,23 @@ _services() local sysvdirs _sysvdirs - local IFS=$' \t\n' reset=$(shopt -p nullglob); shopt -s nullglob - COMPREPLY=( \ - $(printf '%s\n' ${sysvdirs[0]}/!($_backup_glob|functions|README)) ) + local IFS=$' \t\n' reset=$(shopt -p nullglob) + shopt -s nullglob + COMPREPLY=( + $(printf '%s\n' ${sysvdirs[0]}/!($_backup_glob|functions|README))) $reset - COMPREPLY+=( $({ systemctl list-units --full --all || \ - systemctl list-unit-files; } 2>/dev/null | \ - awk '$1 ~ /\.service$/ { sub("\\.service$", "", $1); print $1 }') ) + COMPREPLY+=($({ + systemctl list-units --full --all || + systemctl list-unit-files + } 2>/dev/null | + awk '$1 ~ /\.service$/ { sub("\\.service$", "", $1); print $1 }')) if [[ -x /sbin/upstart-udev-bridge ]]; then - COMPREPLY+=( $(initctl list 2>/dev/null | cut -d' ' -f1) ) + COMPREPLY+=($(initctl list 2>/dev/null | cut -d' ' -f1)) fi - COMPREPLY=( $(compgen -W '${COMPREPLY[@]#${sysvdirs[0]}/}' -- "$cur") ) + COMPREPLY=($(compgen -W '${COMPREPLY[@]#${sysvdirs[0]}/}' -- "$cur")) } # This completes on a list of all available service scripts for the @@ -1208,7 +1249,7 @@ _service() _init_completion || return # don't complete past 2nd token - [[ $cword -gt 2 ]] && return + ((cword > 2)) && return if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then _services @@ -1216,12 +1257,12 @@ _service() else local sysvdirs _sysvdirs - COMPREPLY=( $(compgen -W '`command sed -e "y/|/ /" \ + COMPREPLY=($(compgen -W '`command sed -e "y/|/ /" \ -ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \ - ${sysvdirs[0]}/${prev##*/} 2>/dev/null` start stop' -- "$cur") ) + ${sysvdirs[0]}/${prev##*/} 2>/dev/null` start stop' -- "$cur")) fi } && -complete -F _service service + complete -F _service service _sysvdirs for svcdir in "${sysvdirs[@]}"; do for svc in $svcdir/!($_backup_glob); do @@ -1236,16 +1277,16 @@ _modules() { local modpath modpath=/lib/modules/$1 - COMPREPLY=( $(compgen -W "$(command ls -RL $modpath 2>/dev/null | \ - command sed -ne 's/^\(.*\)\.k\{0,1\}o\(\.[gx]z\)\{0,1\}$/\1/p')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(command ls -RL $modpath 2>/dev/null | + command sed -ne 's/^\(.*\)\.k\{0,1\}o\(\.[gx]z\)\{0,1\}$/\1/p')" -- "$cur")) } # This function completes on installed modules # _installed_modules() { - COMPREPLY=( $(compgen -W "$(PATH="$PATH:/sbin" lsmod | \ - awk '{if (NR != 1) print $1}')" -- "$1") ) + COMPREPLY=($(compgen -W "$(PATH="$PATH:/sbin" lsmod | + awk '{if (NR != 1) print $1}')" -- "$1")) } # This function completes on user or user:group format; as for chown and cpio. @@ -1266,25 +1307,25 @@ _usergroup() # escape to the colon. local prefix prefix=${cur%%*([^:])} - prefix=${prefix//\\} + prefix=${prefix//\\/} local mycur="${cur#*[:]}" - if [[ $1 == -u ]]; then + if [[ ${1-} == -u ]]; then _allowed_groups "$mycur" else local IFS=$'\n' - COMPREPLY=( $(compgen -g -- "$mycur") ) + COMPREPLY=($(compgen -g -- "$mycur")) fi - COMPREPLY=( $(compgen -P "$prefix" -W "${COMPREPLY[@]}") ) + COMPREPLY=($(compgen -P "$prefix" -W "${COMPREPLY[@]}")) elif [[ $cur == *:* ]]; then # Completing group after 'user:gr'. # Reply with a list of unprefixed groups since readline with split on : # and only replace the 'gr' part local mycur="${cur#*:}" - if [[ $1 == -u ]]; then + if [[ ${1-} == -u ]]; then _allowed_groups "$mycur" else local IFS=$'\n' - COMPREPLY=( $(compgen -g -- "$mycur") ) + COMPREPLY=($(compgen -g -- "$mycur")) fi else # Completing a partial 'usernam'. @@ -1292,11 +1333,11 @@ _usergroup() # Don't suffix with a : because readline will escape it and add a # slash. It's better to complete into 'chown username ' than 'chown # username\:'. - if [[ $1 == -u ]]; then + if [[ ${1-} == -u ]]; then _allowed_users "$cur" else local IFS=$'\n' - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) fi fi } @@ -1305,11 +1346,11 @@ _allowed_users() { if _complete_as_root; then local IFS=$'\n' - COMPREPLY=( $(compgen -u -- "${1:-$cur}") ) + COMPREPLY=($(compgen -u -- "${1:-$cur}")) else local IFS=$'\n ' - COMPREPLY=( $(compgen -W \ - "$(id -un 2>/dev/null || whoami 2>/dev/null)" -- "${1:-$cur}") ) + COMPREPLY=($(compgen -W \ + "$(id -un 2>/dev/null || whoami 2>/dev/null)" -- "${1:-$cur}")) fi } @@ -1317,11 +1358,11 @@ _allowed_groups() { if _complete_as_root; then local IFS=$'\n' - COMPREPLY=( $(compgen -g -- "$1") ) + COMPREPLY=($(compgen -g -- "$1")) else local IFS=$'\n ' - COMPREPLY=( $(compgen -W \ - "$(id -Gn 2>/dev/null || groups 2>/dev/null)" -- "$1") ) + COMPREPLY=($(compgen -W \ + "$(id -Gn 2>/dev/null || groups 2>/dev/null)" -- "$1")) fi } @@ -1331,7 +1372,7 @@ _shells() { local shell rest while read -r shell rest; do - [[ $shell == /* && $shell == "$cur"* ]] && COMPREPLY+=( $shell ) + [[ $shell == /* && $shell == "$cur"* ]] && COMPREPLY+=($shell) done 2>/dev/null /dev/null)" -- "$cur") ) + COMPREPLY+=($(compgen -W "$({ + command sed -ne 's/^\([^[:space:]#|]\{2,\}\)|.*/\1/p' /etc/termcap + { + toe -a || toe + } | awk '{ print $1 }' + find /{etc,lib,usr/lib,usr/share}/terminfo/? -type f -maxdepth 1 | + awk -F/ '{ print $NF }' + } 2>/dev/null)" -- "$cur")) +} + +_bashcomp_try_faketty() +{ + if type unbuffer &>/dev/null; then + unbuffer -p "$@" + elif script --version 2>&1 | command grep -qF util-linux; then + # BSD and Solaris "script" do not seem to have required features + script -qaefc "$*" /dev/null + else + "$@" # no can do, fallback + fi } # a little help for FreeBSD ports users @@ -1467,7 +1522,7 @@ _user_at_host() if [[ $cur == *@* ]]; then _known_hosts_real "$cur" else - COMPREPLY=( $(compgen -u -S @ -- "$cur") ) + COMPREPLY=($(compgen -u -S @ -- "$cur")) compopt -o nospace fi } @@ -1483,9 +1538,9 @@ _known_hosts() # NOTE: Using `_known_hosts' as a helper function and passing options # to `_known_hosts' is deprecated: Use `_known_hosts_real' instead. local options - [[ "$1" == -a || "$2" == -a ]] && options=-a - [[ "$1" == -c || "$2" == -c ]] && options+=" -c" - _known_hosts_real $options -- "$cur" + [[ ${1-} == -a || ${2-} == -a ]] && options=-a + [[ ${1-} == -c || ${2-} == -c ]] && options+=" -c" + _known_hosts_real ${options-} -- "$cur" } # _known_hosts() # Helper function to locate ssh included files in configs @@ -1493,18 +1548,24 @@ _known_hosts() # includes them recursively, adding each result to the config variable. _included_ssh_config_files() { - [[ $# -lt 1 ]] && \ + (($# < 1)) && echo "bash_completion: $FUNCNAME: missing mandatory argument CONFIG" >&2 local configfile i f configfile=$1 - local included=( $(command sed -ne 's/^[[:blank:]]*[Ii][Nn][Cc][Ll][Uu][Dd][Ee][[:blank:]]\{1,\}\([^#%]*\)\(#.*\)\{0,1\}$/\1/p' "${configfile}") ) + + local reset=$(shopt -po noglob) + set -o noglob + local included=($(command sed -ne 's/^[[:blank:]]*[Ii][Nn][Cc][Ll][Uu][Dd][Ee][[:blank:]]\(.*\)$/\1/p' "${configfile}")) + $reset + + [[ ${included-} ]] || return for i in "${included[@]}"; do # Check the origin of $configfile to complete relative included paths on included # files according to ssh_config(5): # "[...] Files without absolute paths are assumed to be in ~/.ssh if included in a user # configuration file or /etc/ssh if included from the system configuration file.[...]" - if ! [[ "$i" =~ ^\~.*|^\/.* ]]; then - if [[ "$configfile" =~ ^\/etc\/ssh.* ]]; then + if ! [[ $i =~ ^\~.*|^\/.* ]]; then + if [[ $configfile =~ ^\/etc\/ssh.* ]]; then i="/etc/ssh/$i" else i="$HOME/.ssh/$i" @@ -1512,13 +1573,15 @@ _included_ssh_config_files() fi __expand_tilde_by_ref i # In case the expanded variable contains multiple paths - for f in ${i}; do - if [ -r $f ]; then - config+=( "$f" ) + set +o noglob + for f in $i; do + if [[ -r $f ]]; then + config+=("$f") # The Included file is processed to look for Included files in itself _included_ssh_config_files $f fi done + $reset done } # _included_ssh_config_files() @@ -1538,9 +1601,9 @@ _included_ssh_config_files() # Return: Completions, starting with CWORD, are added to COMPREPLY[] _known_hosts_real() { - local configfile flag prefix OIFS=$IFS - local cur user suffix aliases i host ipv4 ipv6 - local -a kh tmpkh khd config + local configfile flag prefix="" ifs=$IFS + local cur suffix="" aliases i host ipv4 ipv6 + local -a kh tmpkh=() khd=() config=() # TODO remove trailing %foo from entries @@ -1553,75 +1616,96 @@ _known_hosts_real() p) prefix=$OPTARG ;; 4) ipv4=1 ;; 6) ipv6=1 ;; + *) + echo "bash_completion: $FUNCNAME: usage error" >&2 + return 1 + ;; esac done - [[ $# -lt $OPTIND ]] && \ + if (($# < OPTIND)); then echo "bash_completion: $FUNCNAME: missing mandatory argument CWORD" >&2 - cur=${!OPTIND}; (( OPTIND += 1 )) - [[ $# -ge $OPTIND ]] && \ + return 1 + fi + cur=${!OPTIND} + ((OPTIND += 1)) + if (($# >= OPTIND)); then echo "bash_completion: $FUNCNAME($*): unprocessed arguments:" \ - $(while [[ $# -ge $OPTIND ]]; do printf '%s\n' ${!OPTIND}; shift; done) >&2 + "$(while (($# >= OPTIND)); do + printf '%s ' ${!OPTIND} + shift + done)" >&2 + return 1 + fi - [[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@} + [[ $cur == *@* ]] && prefix=$prefix${cur%@*}@ && cur=${cur#*@} kh=() # ssh config files - if [[ -n $configfile ]]; then - [[ -r $configfile ]] && config+=( "$configfile" ) + if [[ -v configfile ]]; then + [[ -r $configfile ]] && config+=("$configfile") else for i in /etc/ssh/ssh_config ~/.ssh/config ~/.ssh2/config; do - [[ -r $i ]] && config+=( "$i" ) + [[ -r $i ]] && config+=("$i") done fi + local reset=$(shopt -po noglob) + set -o noglob + # "Include" keyword in ssh config files - for i in "${config[@]}"; do - _included_ssh_config_files "$i" - done + if ((${#config[@]} > 0)); then + for i in "${config[@]}"; do + _included_ssh_config_files "$i" + done + fi # Known hosts files from configs - if [[ ${#config[@]} -gt 0 ]]; then - local IFS=$'\n' j + if ((${#config[@]} > 0)); then + local IFS=$'\n' # expand paths (if present) to global and user known hosts files # TODO(?): try to make known hosts files with more than one consecutive # spaces in their name work (watch out for ~ expansion # breakage! Alioth#311595) - tmpkh=( $(awk 'sub("^[ \t]*([Gg][Ll][Oo][Bb][Aa][Ll]|[Uu][Ss][Ee][Rr])[Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee][ \t]+", "") { print $0 }' "${config[@]}" | sort -u) ) - IFS=$OIFS + tmpkh=($(awk 'sub("^[ \t]*([Gg][Ll][Oo][Bb][Aa][Ll]|[Uu][Ss][Ee][Rr])[Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee][ \t]+", "") { print $0 }' "${config[@]}" | sort -u)) + IFS=$ifs + fi + if ((${#tmpkh[@]} != 0)); then + local j for i in "${tmpkh[@]}"; do # First deal with quoted entries... while [[ $i =~ ^([^\"]*)\"([^\"]*)\"(.*)$ ]]; do i=${BASH_REMATCH[1]}${BASH_REMATCH[3]} j=${BASH_REMATCH[2]} __expand_tilde_by_ref j # Eval/expand possible `~' or `~user' - [[ -r $j ]] && kh+=( "$j" ) + [[ -r $j ]] && kh+=("$j") done # ...and then the rest. for j in $i; do __expand_tilde_by_ref j # Eval/expand possible `~' or `~user' - [[ -r $j ]] && kh+=( "$j" ) + [[ -r $j ]] && kh+=("$j") done done fi - if [[ -z $configfile ]]; then + if [[ ! -v configfile ]]; then # Global and user known_hosts files for i in /etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2 \ /etc/known_hosts /etc/known_hosts2 ~/.ssh/known_hosts \ ~/.ssh/known_hosts2; do - [[ -r $i ]] && kh+=( "$i" ) + [[ -r $i ]] && kh+=("$i") done for i in /etc/ssh2/knownhosts ~/.ssh2/hostkeys; do - [[ -d $i ]] && khd+=( "$i"/*pub ) + [[ -d $i ]] && khd+=("$i"/*pub) done fi # If we have known_hosts files to use - if [[ ${#kh[@]} -gt 0 || ${#khd[@]} -gt 0 ]]; then - if [[ ${#kh[@]} -gt 0 ]]; then + if ((${#kh[@]} + ${#khd[@]} > 0)); then + if ((${#kh[@]} > 0)); then # https://man.openbsd.org/sshd.8#SSH_KNOWN_HOSTS_FILE_FORMAT for i in "${kh[@]}"; do while read -ra tmpkh; do + ((${#tmpkh[@]} == 0)) && continue set -- "${tmpkh[@]}" # Skip entries starting with | (hashed) and # (comment) [[ $1 == [\|\#]* ]] && continue @@ -1637,78 +1721,84 @@ _known_hosts_real() # Remove trailing ] + optional :port host="${host%]?(:+([0-9]))}" # Add host to candidates - COMPREPLY+=( $host ) + COMPREPLY+=($host) done - IFS=$OIFS + IFS=$ifs done <"$i" done - COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur")) fi - if [[ ${#khd[@]} -gt 0 ]]; then + if ((${#khd[@]} > 0)); then # Needs to look for files called # .../.ssh2/key_22_.pub # dont fork any processes, because in a cluster environment, # there can be hundreds of hostkeys - for i in "${khd[@]}" ; do - if [[ "$i" == *key_22_$cur*.pub && -r "$i" ]]; then + for i in "${khd[@]}"; do + if [[ $i == *key_22_$cur*.pub && -r $i ]]; then host=${i/#*key_22_/} host=${host/%.pub/} - COMPREPLY+=( $host ) + COMPREPLY+=($host) fi done fi # apply suffix and prefix - for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do - COMPREPLY[i]=$prefix$user${COMPREPLY[i]}$suffix + for i in ${!COMPREPLY[*]}; do + COMPREPLY[i]=$prefix${COMPREPLY[i]}$suffix done fi # append any available aliases from ssh config files - if [[ ${#config[@]} -gt 0 && -n "$aliases" ]]; then - local hosts=$(command sed -ne 's/^[[:blank:]]*[Hh][Oo][Ss][Tt][[:blank:]]\{1,\}\([^#*?%]*\)\(#.*\)\{0,1\}$/\1/p' "${config[@]}") - COMPREPLY+=( $(compgen -P "$prefix$user" \ - -S "$suffix" -W "$hosts" -- "$cur") ) + if [[ ${#config[@]} -gt 0 && -v aliases ]]; then + local -a hosts=($(command sed -ne 's/^[[:blank:]]*[Hh][Oo][Ss][Tt][[:blank:]]\(.*\)$/\1/p' "${config[@]}")) + if ((${#hosts[@]} != 0)); then + COMPREPLY+=($(compgen -P "$prefix" \ + -S "$suffix" -W '${hosts[@]%%[*?%]*}' -X '\!*' -- "$cur")) + fi fi # Add hosts reported by avahi-browse, if desired and it's available. - if [[ ${COMP_KNOWN_HOSTS_WITH_AVAHI:-} ]] && \ + if [[ ${COMP_KNOWN_HOSTS_WITH_AVAHI-} ]] && type avahi-browse &>/dev/null; then # The original call to avahi-browse also had "-k", to avoid lookups # into avahi's services DB. We don't need the name of the service, and # if it contains ";", it may mistify the result. But on Gentoo (at # least), -k wasn't available (even if mentioned in the manpage) some # time ago, so... - COMPREPLY+=( $(compgen -P "$prefix$user" -S "$suffix" -W \ - "$(avahi-browse -cpr _workstation._tcp 2>/dev/null | \ - awk -F';' '/^=/ { print $7 }' | sort -u)" -- "$cur") ) + COMPREPLY+=($(compgen -P "$prefix" -S "$suffix" -W \ + "$(avahi-browse -cpr _workstation._tcp 2>/dev/null | + awk -F';' '/^=/ { print $7 }' | sort -u)" -- "$cur")) fi # Add hosts reported by ruptime. - COMPREPLY+=( $(compgen -W \ - "$(ruptime 2>/dev/null | awk '!/^ruptime:/ { print $1 }')" \ - -- "$cur") ) + if type ruptime &>/dev/null; then + COMPREPLY+=($(compgen -W \ + "$(ruptime 2>/dev/null | awk '!/^ruptime:/ { print $1 }')" \ + -- "$cur")) + fi # Add results of normal hostname completion, unless # `COMP_KNOWN_HOSTS_WITH_HOSTFILE' is set to an empty value. if [[ -n ${COMP_KNOWN_HOSTS_WITH_HOSTFILE-1} ]]; then COMPREPLY+=( - $(compgen -A hostname -P "$prefix$user" -S "$suffix" -- "$cur") ) + $(compgen -A hostname -P "$prefix" -S "$suffix" -- "$cur")) fi - if [[ $ipv4 ]]; then - COMPREPLY=( "${COMPREPLY[@]/*:*$suffix/}" ) + $reset + + if [[ -v ipv4 ]]; then + COMPREPLY=("${COMPREPLY[@]/*:*$suffix/}") fi - if [[ $ipv6 ]]; then - COMPREPLY=( "${COMPREPLY[@]/+([0-9]).+([0-9]).+([0-9]).+([0-9])$suffix/}" ) + if [[ -v ipv6 ]]; then + COMPREPLY=("${COMPREPLY[@]/+([0-9]).+([0-9]).+([0-9]).+([0-9])$suffix/}") fi - if [[ $ipv4 || $ipv6 ]]; then + if [[ -v ipv4 || -v ipv6 ]]; then for i in "${!COMPREPLY[@]}"; do - [[ ${COMPREPLY[i]} ]] || unset -v COMPREPLY[i] + [[ ${COMPREPLY[i]} ]] || unset -v "COMPREPLY[i]" done fi - __ltrim_colon_completions "$prefix$user$cur" + __ltrim_colon_completions "$prefix$cur" } # _known_hosts_real() complete -F _known_hosts traceroute traceroute6 \ @@ -1728,7 +1818,7 @@ _cd() # Use standard dir completion if no CDPATH or parameter starts with /, # ./ or ../ - if [[ -z "${CDPATH:-}" || "$cur" == ?(.)?(.)/* ]]; then + if [[ -z ${CDPATH:-} || $cur == ?(.)?(.)/* ]]; then _filedir -d return fi @@ -1741,7 +1831,7 @@ _cd() # create an array of matched subdirs k="${#COMPREPLY[@]}" for j in $(compgen -d -- $i/$cur); do - if [[ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then + if [[ ($mark_symdirs && -L $j || $mark_dirs && ! -L $j) && ! -d ${j#$i/} ]]; then j+="/" fi COMPREPLY[k++]=${j#$i/} @@ -1750,9 +1840,9 @@ _cd() _filedir -d - if [[ ${#COMPREPLY[@]} -eq 1 ]]; then + if ((${#COMPREPLY[@]} == 1)); then i=${COMPREPLY[0]} - if [[ "$i" == "$cur" && $i != "*/" ]]; then + if [[ $i == "$cur" && $i != "*/" ]]; then COMPREPLY[0]="${i}/" fi fi @@ -1765,15 +1855,18 @@ else complete -F _cd -o nospace cd pushd fi -# a wrapper method for the next one, when the offset is unknown +# A _command_offset wrapper function for use when the offset is unknown. +# Only intended to be used as a completion function directly associated +# with a command, not to be invoked from within other completion functions. +# _command() { local offset i # find actual offset, as position of the first non-option offset=1 - for (( i=1; i <= COMP_CWORD; i++ )); do - if [[ "${COMP_WORDS[i]}" != -* ]]; then + for ((i = 1; i <= COMP_CWORD; i++)); do + if [[ ${COMP_WORDS[i]} != -* ]]; then offset=$i break fi @@ -1793,33 +1886,33 @@ _command_offset() # find new first word position, then # rewrite COMP_LINE and adjust COMP_POINT local word_offset=$1 i j - for (( i=0; i < $word_offset; i++ )); do - for (( j=0; j <= ${#COMP_LINE}; j++ )); do - [[ "$COMP_LINE" == "${COMP_WORDS[i]}"* ]] && break + for ((i = 0; i < word_offset; i++)); do + for ((j = 0; j <= ${#COMP_LINE}; j++)); do + [[ $COMP_LINE == "${COMP_WORDS[i]}"* ]] && break COMP_LINE=${COMP_LINE:1} ((COMP_POINT--)) done COMP_LINE=${COMP_LINE#"${COMP_WORDS[i]}"} - ((COMP_POINT-=${#COMP_WORDS[i]})) + ((COMP_POINT -= ${#COMP_WORDS[i]})) done # shift COMP_WORDS elements and adjust COMP_CWORD - for (( i=0; i <= COMP_CWORD - $word_offset; i++ )); do - COMP_WORDS[i]=${COMP_WORDS[i+$word_offset]} + for ((i = 0; i <= COMP_CWORD - word_offset; i++)); do + COMP_WORDS[i]=${COMP_WORDS[i + word_offset]} done - for (( i; i <= COMP_CWORD; i++ )); do + for ((i; i <= COMP_CWORD; i++)); do unset 'COMP_WORDS[i]' done - ((COMP_CWORD -= $word_offset)) + ((COMP_CWORD -= word_offset)) COMPREPLY=() local cur _get_comp_words_by_ref cur - if [[ $COMP_CWORD -eq 0 ]]; then + if ((COMP_CWORD == 0)); then local IFS=$'\n' compopt -o filenames - COMPREPLY=( $(compgen -d -c -- "$cur") ) + COMPREPLY=($(compgen -d -c -- "$cur")) else local cmd=${COMP_WORDS[0]} compcmd=${COMP_WORDS[0]} local cspec=$(complete -p $cmd 2>/dev/null) @@ -1837,17 +1930,17 @@ _command_offset() fi if [[ -n $cspec ]]; then - if [[ ${cspec#* -F } != $cspec ]]; then + if [[ ${cspec#* -F } != "$cspec" ]]; then # complete -F # get function name local func=${cspec#*-F } func=${func%% *} - if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then - $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" "${COMP_WORDS[${#COMP_WORDS[@]}-2]}" + if ((${#COMP_WORDS[@]} >= 2)); then + $func $cmd "${COMP_WORDS[-1]}" "${COMP_WORDS[-2]}" else - $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" + $func $cmd "${COMP_WORDS[-1]}" fi # restore initial compopts @@ -1862,9 +1955,9 @@ _command_offset() else cspec=${cspec#complete} cspec=${cspec%%$compcmd} - COMPREPLY=( $(eval compgen "$cspec" -- '$cur') ) + COMPREPLY=($(eval compgen "$cspec" -- '$cur')) fi - elif [[ ${#COMPREPLY[@]} -eq 0 ]]; then + elif ((${#COMPREPLY[@]} == 0)); then # XXX will probably never happen as long as completion loader loads # *something* for every command thrown at it ($cspec != empty) _minimal @@ -1894,7 +1987,7 @@ _longopt() _init_completion -s || return case "${prev,,}" in - --help|--usage|--version) + --help | --usage | --version) return ;; --!(no-*)dir*) @@ -1913,7 +2006,7 @@ _longopt() _filedir -d return ;; - *file*|*path*) + *file* | *path*) _filedir return ;; @@ -1923,17 +2016,17 @@ _longopt() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W "$(LC_ALL=C $1 --help 2>&1 | \ - while read -r line; do \ - [[ $line =~ --[-A-Za-z0-9]+=? ]] && \ + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W "$(LC_ALL=C $1 --help 2>&1 | + while read -r line; do + [[ $line =~ --[A-Za-z0-9]+([-_][A-Za-z0-9]+)*=? ]] && printf '%s\n' ${BASH_REMATCH[0]} - done)" -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace - elif [[ "$1" == *@(rmdir|chroot) ]]; then + done)" -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace + elif [[ $1 == *@(rmdir|chroot) ]]; then _filedir -d else - [[ "$1" == *mkdir ]] && compopt -o nospace + [[ $1 == *mkdir ]] && compopt -o nospace _filedir fi } @@ -1945,12 +2038,8 @@ complete -F _longopt a2ps awk base64 bash bc bison cat chroot colordiff cp \ sed seq sha{,1,224,256,384,512}sum shar sort split strip sum tac tail tee \ texindex touch tr uname unexpand uniq units vdir wc who -# declare only knows -g in bash >= 4.2. -if [[ ${BASH_VERSINFO[0]} -gt 4 || ${BASH_VERSINFO[1]} -ge 2 ]]; then - declare -Ag _xspecs -else - declare -A _xspecs -fi +declare -Ag _xspecs + _filedir_xspec() { local cur prev words cword @@ -1961,16 +2050,17 @@ _filedir_xspec() local IFS=$'\n' xspec=${_xspecs[${1##*/}]} tmp local -a toks - toks=( $( + toks=($( compgen -d -- "$(quote_readline "$cur")" | { - while read -r tmp; do - printf '%s\n' $tmp - done + while read -r tmp; do + printf '%s\n' $tmp + done } - )) + )) # Munge xspec to contain uppercase version too - # http://thread.gmane.org/gmane.comp.shells.bash.bugs/15294/focus=15306 + # https://lists.gnu.org/archive/html/bug-bash/2010-09/msg00036.html + # news://news.gmane.io/4C940E1C.1010304@case.edu eval xspec="${xspec}" local matchop=! if [[ $xspec == !* ]]; then @@ -1979,24 +2069,27 @@ _filedir_xspec() fi xspec="$matchop($xspec|${xspec^^})" - toks+=( $( - eval compgen -f -X "'!$xspec'" -- "\$(quote_readline "\$cur")" | { - while read -r tmp; do - [[ -n $tmp ]] && printf '%s\n' $tmp - done + toks+=($( + eval compgen -f -X "'!$xspec'" -- '$(quote_readline "$cur")' | { + while read -r tmp; do + [[ -n $tmp ]] && printf '%s\n' $tmp + done } - )) + )) # Try without filter if it failed to produce anything and configured to [[ -n ${COMP_FILEDIR_FALLBACK:-} && ${#toks[@]} -lt 1 ]] && { - local reset=$(shopt -po noglob); set -o noglob - toks+=( $(compgen -f -- "$(quote_readline "$cur")") ) - IFS=' '; $reset; IFS=$'\n' + local reset=$(shopt -po noglob) + set -o noglob + toks+=($(compgen -f -- "$(quote_readline "$cur")")) + IFS=' ' + $reset + IFS=$'\n' } - if [[ ${#toks[@]} -ne 0 ]]; then + if ((${#toks[@]} != 0)); then compopt -o filenames - COMPREPLY=( "${toks[@]}" ) + COMPREPLY=("${toks[@]}") fi } @@ -2010,7 +2103,7 @@ _install_xspec() } # bzcmp, bzdiff, bz*grep, bzless, bzmore intentionally not here, see Debian: #455510 _install_xspec '!*.?(t)bz?(2)' bunzip2 bzcat pbunzip2 pbzcat lbunzip2 lbzcat -_install_xspec '!*.@(zip|[egjswx]ar|exe|pk3|wsz|zargo|xpi|s[tx][cdiw]|sx[gm]|o[dt][tspgfc]|od[bm]|oxt|epub|apk|aab|ipa|do[ct][xm]|p[op]t[mx]|xl[st][xm]|pyz|whl)' unzip zipinfo +_install_xspec '!*.@(zip|[aegjswx]ar|exe|pk3|wsz|zargo|xpi|s[tx][cdiw]|sx[gm]|o[dt][tspgfc]|od[bm]|oxt|epub|apk|aab|ipa|do[ct][xm]|p[op]t[mx]|xl[st][xm]|pyz|whl)' unzip zipinfo _install_xspec '*.Z' compress znew # zcmp, zdiff, z*grep, zless, zmore intentionally not here, see Debian: #455510 _install_xspec '!*.@(Z|[gGd]z|t[ag]z)' gunzip zcat @@ -2036,7 +2129,7 @@ _install_xspec '!*.texi*' makeinfo texi2html _install_xspec '!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)' tex latex slitex jadetex pdfjadetex pdftex pdflatex texi2dvi xetex xelatex luatex lualatex _install_xspec '!*.mp3' mpg123 mpg321 madplay _install_xspec '!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[agmv]|OG[AGMV]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM)|+([0-9]).@(vdr|VDR))?(.@(crdownload|part))' xine aaxine fbxine -_install_xspec '!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[agmv]|OG[AGMV]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM|iso|ISO)|+([0-9]).@(vdr|VDR))?(.@(crdownload|part))' kaffeine dragon +_install_xspec '!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[agmv]|OG[AGMV]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM|iso|ISO)|+([0-9]).@(vdr|VDR))?(.@(crdownload|part))' kaffeine dragon totem _install_xspec '!*.@(avi|asf|wmv)' aviplay _install_xspec '!*.@(rm?(j)|ra?(m)|smi?(l))' realplay _install_xspec '!*.@(mpg|mpeg|avi|mov|qt)' xanim @@ -2076,37 +2169,48 @@ _minimal() _filedir } # Complete the empty string to allow completion of '>', '>>', and '<' on < 4.3 -# http://lists.gnu.org/archive/html/bug-bash/2012-01/msg00045.html +# https://lists.gnu.org/archive/html/bug-bash/2012-01/msg00045.html complete -F _minimal '' - __load_completion() { - local -a dirs=( ${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions ) - local OIFS=$IFS IFS=: dir cmd="${1##*/}" compfile + local -a dirs=(${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions) + local ifs=$IFS IFS=: dir cmd="${1##*/}" compfile [[ -n $cmd ]] || return 1 for dir in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}; do - dirs+=( $dir/bash-completion/completions ) + dirs+=($dir/bash-completion/completions) done - IFS=$OIFS + IFS=$ifs if [[ $BASH_SOURCE == */* ]]; then - dirs+=( "${BASH_SOURCE%/*}/completions" ) + dirs+=("${BASH_SOURCE%/*}/completions") else - dirs+=( ./completions ) + dirs+=(./completions) + fi + + local backslash= + if [[ $cmd == \\* ]]; then + cmd="${cmd:1}" + # If we already have a completion for the "real" command, use it + $(complete -p "$cmd" 2>/dev/null || echo false) "\\$cmd" && return 0 + backslash=\\ fi for dir in "${dirs[@]}"; do - [[ -d "$dir" ]] || continue + [[ -d $dir ]] || continue for compfile in "$cmd" "$cmd.bash" "_$cmd"; do compfile="$dir/$compfile" # Avoid trying to source dirs; https://bugzilla.redhat.com/903540 - [[ -f "$compfile" ]] && . "$compfile" &>/dev/null && return 0 + if [[ -f $compfile ]] && . "$compfile" &>/dev/null; then + [[ $backslash ]] && $(complete -p "$cmd") "\\$cmd" + return 0 + fi done done # Look up simple "xspec" completions - [[ "${_xspecs[$cmd]}" ]] && complete -F _filedir_xspec "$cmd" && return 0 + [[ -v _xspecs[$cmd] ]] && + complete -F _filedir_xspec "$cmd" "$backslash$cmd" && return 0 return 1 } @@ -2122,7 +2226,7 @@ _completion_loader() # Need to define *something*, otherwise there will be no completion at all. complete -F _minimal -- "$cmd" && return 124 } && -complete -D -F _completion_loader + complete -D -F _completion_loader # Function for loading and calling functions from dynamically loaded # completion files that may not have been sourced yet. @@ -2133,9 +2237,7 @@ _xfunc() set -- "$@" local srcfile=$1 shift - declare -F $1 &>/dev/null || { - __load_completion "$srcfile" - } + declare -F $1 &>/dev/null || __load_completion "$srcfile" "$@" } @@ -2143,16 +2245,16 @@ _xfunc() compat_dir=${BASH_COMPLETION_COMPAT_DIR:-/etc/bash_completion.d} if [[ -d $compat_dir && -r $compat_dir && -x $compat_dir ]]; then for i in "$compat_dir"/*; do - [[ ${i##*/} != @($_backup_glob|Makefile*|$_blacklist_glob) \ - && -f $i && -r $i ]] && . "$i" + [[ ${i##*/} != @($_backup_glob|Makefile*|$_blacklist_glob) && -f \ + $i && -r $i ]] && . "$i" done fi unset compat_dir i _blacklist_glob # source user completion file user_completion=${BASH_COMPLETION_USER_FILE:-~/.bash_completion} -[[ ${BASH_SOURCE[0]} != $user_completion && -r $user_completion ]] \ - && . $user_completion +[[ ${BASH_SOURCE[0]} != "$user_completion" && -r $user_completion && -f $user_completion ]] && + . $user_completion unset user_completion unset -f have diff --git a/bash_completion.sh.in b/bash_completion.sh.in index d23198fd..b2a527eb 100644 --- a/bash_completion.sh.in +++ b/bash_completion.sh.in @@ -3,9 +3,9 @@ if [ "x${BASH_VERSION-}" != x -a "x${PS1-}" != x -a "x${BASH_COMPLETION_VERSINFO-}" = x ]; then # Check for recent enough version of bash. - if [ "${BASH_VERSINFO[0]}" -gt 4 ] || \ - [ "${BASH_VERSINFO[0]}" -eq 4 -a "${BASH_VERSINFO[1]}" -ge 1 ]; then - [ -r "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion" ] && \ + if [ "${BASH_VERSINFO[0]}" -gt 4 ] || + [ "${BASH_VERSINFO[0]}" -eq 4 -a "${BASH_VERSINFO[1]}" -ge 2 ]; then + [ -r "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion" ] && . "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion" if shopt -q progcomp && [ -r @datadir@/@PACKAGE@/bash_completion ]; then # Source completion code. diff --git a/completions/.gitignore b/completions/.gitignore index 34167766..5edc1726 100644 --- a/completions/.gitignore +++ b/completions/.gitignore @@ -11,6 +11,7 @@ autoheader automake-1.1[0123456] autossh autoupdate +bmake bsdtar btdownloadcurses.py btdownloadgui.py @@ -163,7 +164,9 @@ pydoc3 pylint-[23] pytest-[23] python2 +python2.7 python3 +python3.[345678] pypy pypy3 pyvenv-3.[45678] diff --git a/completions/2to3 b/completions/2to3 index 049ba65b..7c5b3303 100644 --- a/completions/2to3 +++ b/completions/2to3 @@ -6,19 +6,19 @@ _2to3() _init_completion -s || return case $prev in - -h|--help|--add-suffix) + -h | --help | --add-suffix) return ;; - -f|--fix|-x|--nofix) - COMPREPLY=( $(compgen -W \ - "$($1 --list-fixes 2>/dev/null | command sed -e 1d)" -- "$cur") ) + -f | --fix | -x | --nofix) + COMPREPLY=($(compgen -W \ + "$($1 --list-fixes 2>/dev/null | command sed -e 1d)" -- "$cur")) return ;; - -j|--processes) - COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) + -j | --processes) + COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur")) return ;; - -o|--output-dir) + -o | --output-dir) _filedir -d return ;; @@ -27,13 +27,13 @@ _2to3() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir py } && -complete -F _2to3 2to3 + complete -F _2to3 2to3 # ex: filetype=sh diff --git a/completions/7z b/completions/7z index 96a64f1f..a8acbc59 100644 --- a/completions/7z +++ b/completions/7z @@ -5,8 +5,8 @@ _7z() local cur prev words cword _init_completion -n = || return - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W 'a b d e l t u x' -- "$cur") ) + if ((cword == 1)); then + COMPREPLY=($(compgen -W 'a b d e l t u x' -- "$cur")) return fi @@ -15,7 +15,7 @@ _7z() case $cur in -ao*) - COMPREPLY=( $(compgen -P${cur:0:3} -W 'a s t u' -- "${cur:3}") ) + COMPREPLY=($(compgen -P${cur:0:3} -W 'a s t u' -- "${cur:3}")) return ;; -?(a)[ix]*) @@ -26,74 +26,79 @@ _7z() opt=${cur:0:2} cur=${cur:2} fi if [[ $cur != *[@\!]* ]]; then - COMPREPLY=( $(compgen -P$opt -W '@ ! r@ r-@ r0@ r! r-! r0!' \ - -- "$cur") ) + COMPREPLY=($(compgen -P$opt -W '@ ! r@ r-@ r0@ r! r-! r0!' \ + -- "$cur")) elif [[ $cur == ?(r@(-|0|))@* ]]; then - local IFS=$' \t\n' reset=$(shopt -po noglob); set -o noglob - COMPREPLY=( $(compgen -P"${opt}${cur%%@*}@" -f -- "${cur#*@}") ) + local IFS=$' \t\n' reset=$(shopt -po noglob) + set -o noglob + COMPREPLY=($(compgen -P"${opt}${cur%%@*}@" -f -- "${cur#*@}")) $reset compopt -o filenames fi return ;; - -mhe=*|-mhc=*|-ms=*|-mt=*) - COMPREPLY=( $(compgen -W 'on off' -- "${cur#*=}") ) + -mhe=* | -mhc=* | -ms=* | -mt=*) + COMPREPLY=($(compgen -W 'on off' -- "${cur#*=}")) return ;; -mx=*) - COMPREPLY=( $(compgen -W '0 1 3 5 7 9' -- "${cur#*=}") ) + COMPREPLY=($(compgen -W '0 1 3 5 7 9' -- "${cur#*=}")) return ;; - -o*|-w?*) - local IFS=$' \t\n' reset=$(shopt -po noglob); set -o noglob - COMPREPLY=( $(compgen -P${cur:0:2} -S/ -d -- "${cur:2}") ) + -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 - compopt -o nospace -o filenames + compopt -o nospace return ;; -r?*) - COMPREPLY=( $(compgen -P${cur:0:2} -W '- 0' -- "${cur:2}") ) + COMPREPLY=($(compgen -P${cur:0:2} -W '- 0' -- "${cur:2}")) return ;; -scs*) - COMPREPLY=( $(compgen -P${cur:0:4} -W 'UTF-8 WIN DOS' \ - -- "${cur:4}") ) + COMPREPLY=($(compgen -P${cur:0:4} -W 'UTF-8 WIN DOS' \ + -- "${cur:4}")) return ;; -ssc?*) - COMPREPLY=( $(compgen -P${cur:0:4} -W '-' -- "${cur:4}") ) + COMPREPLY=($(compgen -P${cur:0:4} -W '-' -- "${cur:4}")) return ;; -t*) if [[ $mode == w ]]; then - COMPREPLY=( $(compgen -P${cur:0:2} -W '7z bzip2 gzip swfc - tar wim xz zip' -- "${cur:2}") ) + COMPREPLY=($(compgen -P${cur:0:2} -W '7z bzip2 gzip swfc + tar wim xz zip' -- "${cur:2}")) else - COMPREPLY=( $(compgen -P${cur:0:2} -W '7z apm arj bzip2 cab + 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}") ) + -- "${cur:2}")) fi return ;; - -m*=*|-p*|-u*|-v*) + -m*=* | -p* | -u* | -v*) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '-ai -an -ao -ax -bd -i -m{x,s,f,he,hc,mt}= + 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") ) - [[ $COMPREPLY == -@(an|bd|sfx|si|slt|so|ssc|[rwy]) ]] || + -- "$cur")) + [[ ${COMPREPLY-} == -@(an|bd|sfx|si|slt|so|ssc|[rwy]) ]] || compopt -o nospace return fi local args _count_args = - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _filedir_xspec unzip # TODO: parsing 7z i output? # - how to figure out if the format is input or output? @@ -109,15 +114,15 @@ _7z() else if [[ ${words[1]} == d ]]; then local IFS=$'\n' - COMPREPLY=( $(compgen -W "$(printf '%s\n' $($1 l ${words[2]} \ + 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") ) + 2>/dev/null | tail -n+2)")" -- "$cur")) compopt -o filenames else _filedir fi fi } && -complete -F _7z 7z 7za + complete -F _7z 7z 7za # ex: filetype=sh diff --git a/completions/Makefile.am b/completions/Makefile.am index 8f276d66..723b42f0 100644 --- a/completions/Makefile.am +++ b/completions/Makefile.am @@ -173,6 +173,7 @@ bashcomp_DATA = 2to3 \ invoke-rc.d \ _ionice \ ip \ + ipcalc \ iperf \ ipmitool \ ipsec \ @@ -322,6 +323,7 @@ bashcomp_DATA = 2to3 \ postsuper \ povray \ prelink \ + printenv \ protoc \ psql \ puppet \ @@ -370,6 +372,7 @@ bashcomp_DATA = 2to3 \ sbopkg \ screen \ scrub \ + secret-tool \ sh \ shellcheck \ sitecopy \ @@ -410,6 +413,7 @@ bashcomp_DATA = 2to3 \ tox \ tracepath \ tshark \ + tsig-keygen \ tune2fs \ _udevadm \ ulimit \ @@ -493,6 +497,7 @@ CLEANFILES = \ automake-1.16 \ autossh \ autoupdate \ + bmake \ bsdtar \ btdownloadcurses.py \ btdownloadgui.py \ @@ -662,7 +667,14 @@ CLEANFILES = \ pytest-2 \ pytest-3 \ python2 \ + python2.7 \ python3 \ + python3.3 \ + python3.4 \ + python3.5 \ + python3.6 \ + python3.7 \ + python3.8 \ pyvenv-3.4 \ pyvenv-3.5 \ pyvenv-3.6 \ @@ -837,7 +849,7 @@ symlinks: $(DATA) $(ss) lzip \ clzip pdlzip plzip $(ss) make \ - colormake gmake gnumake pmake + bmake colormake gmake gnumake pmake $(ss) man \ apropos whatis $(ss) mcrypt \ @@ -878,7 +890,7 @@ symlinks: $(DATA) $(ss) pylint \ pylint-2 pylint-3 $(ss) python \ - micropython pypy pypy3 python2 python3 + micropython pypy pypy3 python2 python2.7 python3 python3.3 python3.4 python3.5 python3.6 python3.7 python3.8 $(ss) pyvenv \ pyvenv-3.4 pyvenv-3.5 pyvenv-3.6 pyvenv-3.7 pyvenv-3.8 $(ss) qdbus \ diff --git a/completions/_adb b/completions/_adb index 52b2cb96..e8ebab13 100644 --- a/completions/_adb +++ b/completions/_adb @@ -5,9 +5,9 @@ _adb_command_usage() { - COMPREPLY=( $(compgen -W \ + COMPREPLY=($(compgen -W \ '$("$1" help 2>&1 | command grep "^ *\(adb \)\? *$2 " \ - | command sed -e "s/[]|[]/\n/g" | _parse_help -)' -- "$cur") ) + | command sed -e "s/[]|[]/\n/g" | _parse_help -)' -- "$cur")) } _adb() @@ -16,7 +16,7 @@ _adb() _init_completion || return case $prev in - -s|-p|--algo|--key|--iv) + -s | -p | --algo | --key | --iv) return ;; -f) @@ -26,23 +26,23 @@ _adb() esac local cmd i - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" != -* && "${words[i-1]}" != -[sp] ]]; then + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} != -* && ${words[i - 1]} != -[sp] ]]; then cmd="${words[i]}" break fi done - if [[ ! "$cmd" ]]; then + if [[ ! -v cmd ]]; then local tmp=() if [[ ! $cur || $cur == -* ]]; then - tmp+=( $(compgen -W '$(_parse_help "$1" help)' -- "$cur") ) + tmp+=($(compgen -W '$(_parse_help "$1" help)' -- "$cur")) fi if [[ ! $cur || $cur != -* ]]; then - tmp+=( $($1 help 2>&1 | awk '$1 == "adb" { print $2 }') ) - tmp+=( devices connect disconnect sideload ) + tmp+=($($1 help 2>&1 | awk '$1 == "adb" { print $2 }')) + tmp+=(devices connect disconnect sideload) fi - COMPREPLY=( $(compgen -W '${tmp[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${tmp[@]}' -- "$cur")) return fi @@ -51,19 +51,19 @@ _adb() _adb_command_usage "$1" $cmd case $cmd in - push|restore|sideload) + push | restore | sideload) _filedir ;; forward) - COMPREPLY=( $(compgen -W \ + COMPREPLY=($(compgen -W \ '$("$1" help 2>&1 | command sed -ne "s/^ *adb *forward *-/-/p" | \ - _parse_help -)' -- "$cur") ) + _parse_help -)' -- "$cur")) ;; reboot) - COMPREPLY=( $(compgen -W 'bootloader recovery' -- "$cur") ) + COMPREPLY=($(compgen -W 'bootloader recovery' -- "$cur")) ;; esac } && -complete -F _adb adb + complete -F _adb adb # ex: filetype=sh diff --git a/completions/_cal b/completions/_cal index ed304aa7..1eec2674 100644 --- a/completions/_cal +++ b/completions/_cal @@ -11,28 +11,28 @@ _cal() case $prev in -m) if [[ $OSTYPE == *bsd* ]]; then - COMPREPLY=( $(compgen -W '{1..12}' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..12}' -- "$cur")) return fi ;; -s) [[ $OSTYPE == *bsd* ]] && return ;; - -A|-B|-d|-H) + -A | -B | -d | -H) return ;; esac if [[ $cur == -* ]]; then local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) return fi local args _count_args - [[ $args -eq 1 ]] && COMPREPLY=( $(compgen -W '{1..12}' -- "$cur") ) + ((args == 1)) && COMPREPLY=($(compgen -W '{1..12}' -- "$cur")) } && -complete -F _cal cal ncal + complete -F _cal cal ncal # ex: filetype=sh diff --git a/completions/_chsh b/completions/_chsh index 64ce5a1b..8f8a8077 100644 --- a/completions/_chsh +++ b/completions/_chsh @@ -9,23 +9,23 @@ _chsh() _init_completion || return case $prev in - --list-shells|--help|-v|--version) + --list-shells | --help | -v | --version) return ;; - -s|--shell) + -s | --shell) _shells return ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) else _allowed_users fi } && -complete -F _chsh chsh + complete -F _chsh chsh # ex: filetype=sh diff --git a/completions/_dmesg b/completions/_dmesg index 1dff7db2..83066541 100644 --- a/completions/_dmesg +++ b/completions/_dmesg @@ -11,23 +11,23 @@ _dmesg() _init_completion || return case $prev in - -h|--help|-V|--version|-s|--buffer-size|-M|-N) + -h | --help | -V | --version | -s | --buffer-size | -M | -N) return ;; - -f|--facility) - COMPREPLY=( $(compgen -W 'kern user mail daemon auth syslog lpr - news' -- "$cur") ) + -f | --facility) + COMPREPLY=($(compgen -W 'kern user mail daemon auth syslog lpr + news' -- "$cur")) return ;; - -l|--level|-n|--console-level) - COMPREPLY=( $(compgen -W '{1..8}' -- "$cur") ) + -l | --level | -n | --console-level) + COMPREPLY=($(compgen -W '{1..8}' -- "$cur")) return ;; esac local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) } && -complete -F _dmesg dmesg + complete -F _dmesg dmesg # ex: filetype=sh diff --git a/completions/_eject b/completions/_eject index 3c5838dc..52168f74 100644 --- a/completions/_eject +++ b/completions/_eject @@ -9,17 +9,17 @@ _eject() _init_completion || return case $prev in - -h|--help|-V|--version|-c|--changerslot|-x|--cdspeed) + -h | --help | -V | --version | -c | --changerslot | -x | --cdspeed) return ;; - -a|--auto|-i|--manualeject) - COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) + -a | --auto | -i | --manualeject) + COMPREPLY=($(compgen -W 'on off' -- "$cur")) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return elif [[ $prev == @(-d|--default) ]]; then return @@ -28,6 +28,6 @@ _eject() _cd_devices _dvd_devices } && -complete -F _eject eject + complete -F _eject eject # ex: filetype=sh diff --git a/completions/_hexdump b/completions/_hexdump index a3c2a839..785f5976 100644 --- a/completions/_hexdump +++ b/completions/_hexdump @@ -9,7 +9,7 @@ _hexdump() _init_completion || return case $prev in - -V|-e|-n|-s) + -V | -e | -n | -s) return ;; -f) @@ -20,12 +20,12 @@ _hexdump() if [[ $cur == -* ]]; then local opts="$(_parse_help "$1")" - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) return fi _filedir } && -complete -F _hexdump hexdump hd + complete -F _hexdump hexdump hd # ex: filetype=sh diff --git a/completions/_hwclock b/completions/_hwclock index 86a29346..ef437a26 100644 --- a/completions/_hwclock +++ b/completions/_hwclock @@ -9,18 +9,18 @@ _hwclock() _init_completion || return case $prev in - -h|--help|-V|--version|--date|--epoch) + -h | --help | -V | --version | --date | --epoch) return ;; - -f|--rtc|--adjfile) + -f | --rtc | --adjfile) _filedir return ;; esac COMPREPLY=( - $(PATH="$PATH:/sbin" compgen -W '$(_parse_help "$1")' -- "$cur") ) + $(PATH="$PATH:/sbin" compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _hwclock hwclock + complete -F _hwclock hwclock # ex: filetype=sh diff --git a/completions/_ionice b/completions/_ionice index 1aa51f2a..b0d96a13 100644 --- a/completions/_ionice +++ b/completions/_ionice @@ -9,7 +9,7 @@ _ionice() _init_completion || return local offset=0 i - for (( i=1; i <= cword; i++ )); do + for ((i = 1; i <= cword; i++)); do case ${words[i]} in -h) return @@ -18,8 +18,8 @@ _ionice() offset=0 break ;; - -c|-n) - (( i++ )) + -c | -n) + ((i++)) continue ;; -*) @@ -30,18 +30,18 @@ _ionice() break done - if [[ $offset -gt 0 ]]; then + if ((offset > 0)); then _command_offset $offset return fi case $prev in -c) - COMPREPLY=( $(compgen -W '{0..3}' -- "$cur") ) + COMPREPLY=($(compgen -W '{0..3}' -- "$cur")) return ;; -n) - COMPREPLY=( $(compgen -W '{0..7}' -- "$cur") ) + COMPREPLY=($(compgen -W '{0..7}' -- "$cur")) return ;; -p) @@ -51,10 +51,10 @@ _ionice() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) return fi } && -complete -F _ionice ionice + complete -F _ionice ionice # ex: filetype=sh diff --git a/completions/_look b/completions/_look index 074e924a..9788dec5 100644 --- a/completions/_look +++ b/completions/_look @@ -8,10 +8,10 @@ _look() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W '$(look "$cur" 2>/dev/null)' -- "$cur") ) + if ((cword == 1)); then + COMPREPLY=($(compgen -W '$(look "$cur" 2>/dev/null)' -- "$cur")) fi } && -complete -F _look -o default look + complete -F _look -o default look # ex: filetype=sh diff --git a/completions/_mock b/completions/_mock index e596a4c4..b468148d 100644 --- a/completions/_mock +++ b/completions/_mock @@ -11,27 +11,27 @@ _mock() local plugins='tmpfs root_cache yum_cache bind_mount ccache' local cfgdir=/etc/mock count=0 i - for i in "${words[@]}" ; do - [[ $count -eq $cword ]] && break - if [[ "$i" == --configdir ]]; then - cfgdir="${words[((count+1))]}" - elif [[ "$i" == --configdir=* ]]; then + for i in "${words[@]}"; do + ((count == cword)) && break + if [[ $i == --configdir ]]; then + cfgdir="${words[count + 1]}" + elif [[ $i == --configdir=* ]]; then cfgdir=${i/*=/} fi - (( count++ )) + ((count++)) done case $prev in - -h|--help|--copyin|--copyout|--arch|-D|--define|--with|--without|\ - --uniqueext|--rpmbuild_timeout|--sources|--cwd) + -h | --help | --copyin | --copyout | --arch | -D | --define | --with | --without | \ + --uniqueext | --rpmbuild_timeout | --sources | --cwd) return ;; - -r|--root) - COMPREPLY=( $(compgen -W "$(command ls $cfgdir)" -- "$cur") ) - COMPREPLY=( ${COMPREPLY[@]/%.cfg/} ) + -r | --root) + COMPREPLY=($(compgen -W "$(command ls $cfgdir)" -- "$cur")) + COMPREPLY=(${COMPREPLY[@]/%.cfg/}) return ;; - --configdir|--resultdir) + --configdir | --resultdir) _filedir -d return ;; @@ -44,26 +44,26 @@ _mock() # (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 | \ + COMPREPLY=($(compgen -W "$(command rpm --showrc | command sed -ne 's/^\s*compatible\s\s*archs\s*:\s*\(.*\)/\1/i p')" \ - -- "$cur") ) + -- "$cur")) return ;; - --enable-plugin|--disable-plugin) - COMPREPLY=( $(compgen -W "$plugins" -- "$cur") ) + --enable-plugin | --disable-plugin) + COMPREPLY=($(compgen -W "$plugins" -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _filedir '@(?(no)src.r|s)pm' fi } && -complete -F _mock mock + complete -F _mock mock # ex: filetype=sh diff --git a/completions/_modules b/completions/_modules index 36fffdf6..4f7c4d48 100644 --- a/completions/_modules +++ b/completions/_modules @@ -5,8 +5,8 @@ # # Completion for Environment Modules `module' alias. # -# See http://sourceforge.net/projects/modules/ -# http://modules.sourceforge.net/ +# See https://sourceforge.net/projects/modules/ +# https://modules.sourceforge.net/ # # There are several versions of modules that are commonly used. Older # Cray UNICOS systems and many other sites use 2.2.2b. The latest GPL'd @@ -21,64 +21,65 @@ # being sourced before it and thus before the `module' alias has been defined. [ -f /etc/profile.d/modules.sh ] || return 1 -_module_list () +_module_list() { local modules="$(command sed 's/:/ /g' <<<$LOADEDMODULES | sort)" compgen -W "$modules" -- $1 } -_module_path () +_module_path() { local modules="$(command sed 's/:/ /g' <<<$MODULEPATH | sort)" compgen -W "$modules" -- $1 } -_module_avail () +_module_avail() { - local modules="$(\ - module avail 2>&1 | \ - command grep -E -v '^(-|$)' | \ - xargs printf '%s\n' | command sed -e 's/(default)//g' | sort)" + 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 } # A completion function for the module alias -_module () +_module() { local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then + 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)" + options="$(module help 2>&1 | command grep -E '^[[:space:]]*\+' | + awk '{print $2}' | command sed -e 's/|/ /g' | sort)" - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) - elif [[ $cword -eq 2 ]]; then + elif ((cword == 2)); then case $prev in - add|display|help|load|show|whatis) - COMPREPLY=( $(_module_avail "$cur") ) + add | display | help | load | show | whatis) + COMPREPLY=($(_module_avail "$cur")) ;; - rm|switch|swap|unload|update) - COMPREPLY=( $(_module_list "$cur") ) + rm | switch | swap | unload | update) + COMPREPLY=($(_module_list "$cur")) ;; unuse) - COMPREPLY=( $(_module_path "$cur") ) + COMPREPLY=($(_module_path "$cur")) ;; esac - elif [[ $cword -eq 3 ]]; then + elif ((cword == 3)); then case ${words[1]} in - swap|switch) - COMPREPLY=( $(_module_avail "$cur") ) + swap | switch) + COMPREPLY=($(_module_avail "$cur")) ;; esac fi } && -complete -F _module -o default module + complete -F _module -o default module # ex: filetype=sh diff --git a/completions/_mount b/completions/_mount index 494f97ba..85f54907 100644 --- a/completions/_mount +++ b/completions/_mount @@ -22,44 +22,44 @@ _mount() local sm host case $prev in - -t|--types) + -t | --types) _fstypes return ;; esac - [[ "$cur" == \\ ]] && cur="/" + [[ $cur == \\ ]] && cur="/" - if [[ "$cur" == *:* ]]; then + 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#*:}") ) + COMPREPLY=($(compgen -W "$("$sm" -e ${cur%%:*} | + awk 'NR>1 {print $1}')" -- "${cur#*:}")) return done fi - if [[ "$cur" == //* ]]; then + if [[ $cur == //* ]]; then host=${cur#//} host=${host%%/*} if [[ -n $host ]]; then - COMPREPLY=( $(compgen -P "//$host" -W \ + COMPREPLY=($(compgen -P "//$host" -W \ "$(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 '/^[[:blank:]]*Sharename/,/^$/p' | + command sed -ne '3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p')" \ + -- "${cur#//$host}")) fi elif [[ -r /etc/vfstab ]]; then # Solaris - COMPREPLY=( $(compgen -W "$(awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab)" -- "$cur") ) + COMPREPLY=($(compgen -W "$(awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' /etc/vfstab)" -- "$cur")) elif [[ ! -e /etc/fstab ]]; then # probably Cygwin - COMPREPLY=( $(compgen -W "$($1 | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}')" -- "$cur")) else # probably BSD - COMPREPLY=( $(compgen -W "$(awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' /etc/fstab)" -- "$cur") ) + COMPREPLY=($(compgen -W "$(awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' /etc/fstab)" -- "$cur")) fi } && -complete -F _mount -o default -o dirnames mount + complete -F _mount -o default -o dirnames mount # ex: filetype=sh diff --git a/completions/_mount.linux b/completions/_mount.linux index c74aaec6..f40865ea 100644 --- a/completions/_mount.linux +++ b/completions/_mount.linux @@ -10,239 +10,243 @@ _mount() local split=false case "$prev" in - -t|--types) + -t | --types) # find /lib/modules/$(uname -r)/ -type f -path '*/fs/*.ko' -printf '%f\n' | cut -d. -f1 # FIXME: no - if [[ "$cur" == ?*,* ]]; then + if [[ $cur == ?*,* ]]; then prev="${cur%,*}" cur="${cur##*,}" split=true fi - COMPREPLY=( $(compgen -W 'auto adfs affs autofs btrfs cifs coda + 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") ) + udf ufs umsdos usbfs vfat xfs' -- "$cur")) _fstypes - $split && COMPREPLY=( ${COMPREPLY[@]/#/$prev,} ) + $split && COMPREPLY=(${COMPREPLY[@]/#/$prev,}) return ;; - --bind|-B|--rbind|-R) + --bind | -B | --rbind | -R) _filedir -d return ;; - -p|--pass-fd) - COMPREPLY=( $(compgen -W '{0..9}') ) + -p | --pass-fd) + COMPREPLY=($(compgen -W '{0..9}')) compopt -o nospace return ;; -L) - COMPREPLY=( $(cd "/dev/disk/by-label/" 2>/dev/null || return; \ - compgen -f -- "$cur") ) + COMPREPLY=($( + cd "/dev/disk/by-label/" 2>/dev/null || return + compgen -f -- "$cur" + )) return ;; -U) - COMPREPLY=( $(cd "/dev/disk/by-uuid/" 2>/dev/null || return; \ - compgen -f -- "$cur") ) + COMPREPLY=($( + cd "/dev/disk/by-uuid/" 2>/dev/null || return + compgen -f -- "$cur" + )) return ;; - -O|--test-opts) + -O | --test-opts) # argument required but no completions available return ;; - -o|--options) + -o | --options) local fstype=auto # default fstype - for (( i=${#words[@]}-1; i>0; i-- )); do - if [[ "${words[i]}" == -@(t|-types)* ]]; then - if [[ "${words[i]}" == *=* ]]; then - [[ "${words[i]}" == ?*,* ]] && break + for ((i = ${#words[@]} - 1; i > 0; i--)); do + if [[ ${words[i]} == -@(t|-types)* ]]; then + if [[ ${words[i]} == *=* ]]; then + [[ ${words[i]} == ?*,* ]] && break fstype="${words[i]#-*=}" else - [[ "${words[i+1]}" == ?*,* ]] && break - fstype="${words[i+1]}" + [[ ${words[i + 1]} == ?*,* ]] && break + fstype="${words[i + 1]}" fi break fi done # no is not a real fstype, reset to "auto" - [[ "$fstype" == no?* ]] && fstype=auto + [[ $fstype == no?* ]] && fstype=auto # split options list - if [[ "$cur" == ?*,* ]]; then + if [[ $cur == ?*,* ]]; then prev="${cur%,*}" cur="${cur##*,}" split=true fi # no completion if $cur is opt=smth - [[ "$cur" == *=* ]] && return + [[ $cur == *=* ]] && return # mount options - COMPREPLY=( $(compgen -W 'loop {,a}sync {,no}atime {,no}auto + COMPREPLY=($(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' -- "$cur")) case "$fstype" in - adfs|auto) - COMPREPLY+=( $(compgen -W '{u,g}id= {own,oth}mask=' -- "$cur") ) - ;;& - affs|auto) - COMPREPLY+=( $(compgen -W '{u,g}id= set{u,g}id= mode= protect + adfs | auto) + COMPREPLY+=($(compgen -W '{u,g}id= {own,oth}mask=' -- "$cur")) + ;;& + 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") ) - ;;& - btrfs|auto) - COMPREPLY+=( $(compgen -W 'degraded subvol= subvolid= device= + {,no,usr,grp}quota' -- "$cur")) + ;;& + 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") ) - ;;& - cifs|auto) - COMPREPLY+=( $(compgen -W 'user= password= credentials= {u,g}id= + user_subvol_rm_allowed autodefrag inode_cache' -- "$cur")) + ;;& + 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") ) - ;;& - davfs|auto) - COMPREPLY+=( $(compgen -W 'conf= {file,dir}_mode= {u,g}id= - username=' -- "$cur") ) - ;;& - ext[2-4]|auto) - COMPREPLY+=( $(compgen -W '{,no}acl bsddf minixdf check= debug + rwpidforward backup{u,g}id cache=' -- "$cur")) + ;;& + davfs | auto) + COMPREPLY+=($(compgen -W 'conf= {file,dir}_mode= {u,g}id= + username=' -- "$cur")) + ;;& + 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") ) - ;;& - ext[34]|auto) - COMPREPLY+=( $(compgen -W 'journal= journal_dev= norecovery - noload data= barrier= commit=' -- "$cur") ) - ;;& - ext4|auto) - COMPREPLY+=( $(compgen -W 'journal_checksum journal_async_commit + {,no}user_xattr' -- "$cur")) + ;;& + ext[34] | auto) + COMPREPLY+=($(compgen -W 'journal= journal_dev= norecovery + noload data= barrier= commit=' -- "$cur")) + ;;& + 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") ) - ;;& - msdos|umsdos|vfat|auto) - COMPREPLY+=( $(compgen -W 'blocksize= {u,g}id= {u,d,f}mask= + dioread_{,no}lock max_dir_size_kb= i_version' -- "$cur")) + ;;& + 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") ) - ;;& - vfat|auto) - COMPREPLY+=( $(compgen -W 'uni_xlate posix nonumtail utf8 - shortname=' -- "$cur") ) - ;;& - iso9660|auto) - COMPREPLY+=( $(compgen -W 'norock nojoliet check= {u,g}id= map= + usefree {,no}dots dotsOK=' -- "$cur")) + ;;& + vfat | auto) + COMPREPLY+=($(compgen -W 'uni_xlate posix nonumtail utf8 + shortname=' -- "$cur")) + ;;& + iso9660 | auto) + COMPREPLY+=($(compgen -W 'norock nojoliet check= {u,g}id= map= mode= unhide block= conv= cruft session= sbsector= - iocharset= utf8' -- "$cur") ) - ;;& - jffs2|auto) - COMPREPLY+=( $(compgen -W 'compr= rp_size=' -- "$cur") ) - ;;& - jfs|auto) - COMPREPLY+=( $(compgen -W 'iocharset= resize= {,no}integrity - errors= {,no,usr,grp}quota' -- "$cur") ) - ;;& - nfs|nfs4|auto) - COMPREPLY+=( $(compgen -W 'soft hard timeo= retrans= {r,w}size= + iocharset= utf8' -- "$cur")) + ;;& + jffs2 | auto) + COMPREPLY+=($(compgen -W 'compr= rp_size=' -- "$cur")) + ;;& + jfs | auto) + COMPREPLY+=($(compgen -W 'iocharset= resize= {,no}integrity + errors= {,no,usr,grp}quota' -- "$cur")) + ;;& + 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") ) - ;;& - nfs|auto) - COMPREPLY+=( $(compgen -W 'udp tcp rdma mount{port,proto,host}= + proto= port= {,no}intr {,no}cto {,nfs}vers= ' -- "$cur")) + ;;& + nfs | auto) + COMPREPLY+=($(compgen -W 'udp tcp rdma mount{port,proto,host}= mountvers= namlen={,no}lock {,no}acl {,no}rdirplus - {,no}fsc' -- "$cur") ) - ;;& - nfs4|auto) - COMPREPLY+=( $(compgen -W 'clientaddr= {,no}migration' \ - -- "$cur") ) - ;;& - ntfs-3g) - COMPREPLY+=( $(compgen -W '{u,g}id= {u,f,d}mask= usermapping= + {,no}fsc' -- "$cur")) + ;;& + nfs4 | auto) + COMPREPLY+=($(compgen -W 'clientaddr= {,no}migration' \ + -- "$cur")) + ;;& + 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") ) - ;;& - proc|auto) - COMPREPLY+=( $(compgen -W '{u,g}id=' -- "$cur") ) - ;;& - reiserfs|auto) - COMPREPLY+=( $(compgen -W 'conv hash= {,no_un}hashed_relocation + {,no}compression debug no_detach' -- "$cur")) + ;;& + proc | auto) + COMPREPLY+=($(compgen -W '{u,g}id=' -- "$cur")) + ;;& + reiserfs | auto) + COMPREPLY+=($(compgen -W 'conv hash= {,no_un}hashed_relocation noborder nolog notail replayonly resize= user_xattr acl - barrier=' -- "$cur") ) - ;;& - tmpfs|auto) - COMPREPLY+=( $(compgen -W 'size= nr_blocks= nr_inodes= mode= - {u,g}id= mpol=' -- "$cur") ) - ;;& - udf|auto) - COMPREPLY+=( $(compgen -W '{u,g}id= umask= unhide undelete + barrier=' -- "$cur")) + ;;& + tmpfs | auto) + COMPREPLY+=($(compgen -W 'size= nr_blocks= nr_inodes= mode= + {u,g}id= mpol=' -- "$cur")) + ;;& + udf | auto) + COMPREPLY+=($(compgen -W '{u,g}id= umask= unhide undelete nostrict iocharset bs= novrs session= anchor= volume= - partition= lastblock= fileset= rootdir=' -- "$cur") ) - ;;& - usbfs|auto) - COMPREPLY+=( $(compgen -W 'dev{u,g}id= devmode= bus{u,g}id= - busmode= list{u,g}id= listmode=' -- "$cur") ) - ;;& - xfs|auto) - COMPREPLY+=( $(compgen -W 'allocsize= {,no}attr2 barrier dmapi + partition= lastblock= fileset= rootdir=' -- "$cur")) + ;;& + usbfs | auto) + COMPREPLY+=($(compgen -W 'dev{u,g}id= devmode= bus{u,g}id= + busmode= list{u,g}id= listmode=' -- "$cur")) + ;;& + 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") ) - ;;& + swalloc' -- "$cur")) + ;;& esac # COMP_WORDBREAKS is a real pain in the ass prev="${prev##*[$COMP_WORDBREAKS]}" - $split && COMPREPLY=( ${COMPREPLY[@]/#/"$prev,"} ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + $split && COMPREPLY=(${COMPREPLY[@]/#/"$prev,"}) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--version --help --verbose --all --fork + if [[ $cur == -* ]]; then + COMPREPLY=($(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") ) - [[ $COMPREPLY ]] && return + --move' -- "$cur")) + [[ ${COMPREPLY-} ]] && return fi - [[ "$cur" == \\ ]] && cur="/" + [[ $cur == \\ ]] && cur="/" local sm host - if [[ "$cur" == *:* ]]; then + 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#*:}") ) + COMPREPLY=($(compgen -W "$("$sm" -e ${cur%%:*} | + awk 'NR>1 {print $1}')" -- "${cur#*:}")) return done fi - if [[ "$cur" == //* ]]; then + if [[ $cur == //* ]]; then host=${cur#//} host=${host%%/*} if [[ -n $host ]]; then - COMPREPLY=( $(compgen -P "//$host" -W \ + COMPREPLY=($(compgen -P "//$host" -W \ "$(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 '/^[[:blank:]]*Sharename/,/^$/p' | + command sed -ne '3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p')" \ + -- "${cur#//$host}")) fi fi _filedir } && -complete -F _mount mount + complete -F _mount mount # ex: filetype=sh diff --git a/completions/_newgrp b/completions/_newgrp index 0f0d3f93..a2dc3eda 100644 --- a/completions/_newgrp +++ b/completions/_newgrp @@ -8,12 +8,12 @@ _newgrp() local cur prev words cword _init_completion || return - if [[ "$cur" == "-" ]]; then - COMPREPLY=( - ) + if [[ $cur == "-" ]]; then + COMPREPLY=(-) else _allowed_groups "$cur" fi } && -complete -F _newgrp newgrp + complete -F _newgrp newgrp # ex: filetype=sh diff --git a/completions/_nmcli b/completions/_nmcli index 780a477f..eac285b0 100644 --- a/completions/_nmcli +++ b/completions/_nmcli @@ -5,33 +5,33 @@ _nmcli_list() { - COMPREPLY=( $(compgen -W '$1' -- "$cur") ) + COMPREPLY=($(compgen -W '$1' -- "$cur")) } _nmcli_con_id() { local IFS=$'\n' - COMPREPLY=( $(compgen -W "$(nmcli con list 2>/dev/null | \ - tail -n +2 | awk -F ' {2,}' '{print $1 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(nmcli con list 2>/dev/null | + tail -n +2 | awk -F ' {2,}' '{print $1 }')" -- "$cur")) } _nmcli_con_uuid() { - COMPREPLY=( $(compgen -W "$(nmcli con list 2>/dev/null | \ - tail -n +2 | awk -F ' {2,}' '{print $2}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(nmcli con list 2>/dev/null | + tail -n +2 | awk -F ' {2,}' '{print $2}')" -- "$cur")) } _nmcli_ap_ssid() { local IFS=$'\n' - COMPREPLY=( $(compgen -W "$(nmcli dev wifi list 2>/dev/null | \ - tail -n +2 | awk -F ' {2,}' '{print $1}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(nmcli dev wifi list 2>/dev/null | + tail -n +2 | awk -F ' {2,}' '{print $1}')" -- "$cur")) } _nmcli_ab_bssid() { - COMPREPLY=( $(compgen -W "$(nmcli dev wifi list 2>/dev/null | \ - tail -n +2 | awk -F ' {2,}' '{print $2}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(nmcli dev wifi list 2>/dev/null | + tail -n +2 | awk -F ' {2,}' '{print $2}')" -- "$cur")) } _nmcli() @@ -40,15 +40,15 @@ _nmcli() _init_completion || return case $prev in - -m|--mode) - COMPREPLY=( $(compgen -W 'tabular multiline' -- "$cur") ) + -m | --mode) + COMPREPLY=($(compgen -W 'tabular multiline' -- "$cur")) return ;; - -f|--fields) - COMPREPLY=( $(compgen -W 'all common' -- "$cur") ) + -f | --fields) + COMPREPLY=($(compgen -W 'all common' -- "$cur")) return ;; - -e|--escape) + -e | --escape) _nmcli_list "yes no" return ;; @@ -74,12 +74,12 @@ _nmcli() ;; esac - if [[ $cword -eq 1 ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--terse --pretty --mode --fields - --escape --version --help' -- "$cur") ) + if ((cword == 1)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--terse --pretty --mode --fields + --escape --version --help' -- "$cur")) else - COMPREPLY=( $(compgen -W "nm con dev" -- "$cur") ) + COMPREPLY=($(compgen -W "nm con dev" -- "$cur")) fi else local object=${words[1]} @@ -110,50 +110,50 @@ _nmcli() ;; esac - COMPREPLY=( $(compgen -W 'status permissions enable sleep - wifi wwan wimax' -- "$cur") ) + COMPREPLY=($(compgen -W 'status permissions enable sleep + wifi wwan wimax' -- "$cur")) ;; con) case $command in list) - COMPREPLY=( $(compgen -W 'id uuid' -- "$cur") ) + COMPREPLY=($(compgen -W 'id uuid' -- "$cur")) return ;; up) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--nowait --timeout' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--nowait --timeout' \ + -- "$cur")) else - COMPREPLY=( $(compgen -W 'id uuid iface ap nsp' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'id uuid iface ap nsp' \ + -- "$cur")) fi return ;; down) - COMPREPLY=( $(compgen -W 'id uuid' -- "$cur") ) + COMPREPLY=($(compgen -W 'id uuid' -- "$cur")) return ;; delete) - COMPREPLY=( $(compgen -W 'id uuid' -- "$cur") ) + COMPREPLY=($(compgen -W 'id uuid' -- "$cur")) return ;; esac - COMPREPLY=( $(compgen -W 'list status up down delete' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'list status up down delete' \ + -- "$cur")) ;; dev) case $command in list) - COMPREPLY=( $(compgen -W 'iface' -- "$cur") ) + COMPREPLY=($(compgen -W 'iface' -- "$cur")) return ;; disconnect) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--nowait --timeout' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--nowait --timeout' \ + -- "$cur")) else - COMPREPLY=( $(compgen -W 'iface' -- "$cur") ) + COMPREPLY=($(compgen -W 'iface' -- "$cur")) fi return ;; @@ -162,40 +162,40 @@ _nmcli() case $subcommand in list) - COMPREPLY=( $(compgen -W 'iface bssid' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'iface bssid' \ + -- "$cur")) return ;; connect) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--private - --nowait --timeout' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--private + --nowait --timeout' -- "$cur")) else - if [[ "$prev" == "connect" ]]; then + if [[ $prev == "connect" ]]; then _nmcli_ap_ssid else - COMPREPLY=( $(compgen -W 'password + COMPREPLY=($(compgen -W 'password wep-key-type iface bssid name' \ - -- "$cur") ) + -- "$cur")) fi fi return ;; esac - COMPREPLY=( $(compgen -W 'list connect' -- "$cur") ) + COMPREPLY=($(compgen -W 'list connect' -- "$cur")) return ;; esac - COMPREPLY=( $(compgen -W 'status list disconnect wifi' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'status list disconnect wifi' \ + -- "$cur")) ;; esac fi } && -complete -F _nmcli nmcli + complete -F _nmcli nmcli # ex: filetype=sh diff --git a/completions/_renice b/completions/_renice index 2598533d..a4167440 100644 --- a/completions/_renice +++ b/completions/_renice @@ -11,8 +11,8 @@ _renice() local command=$1 curopt i=0 # walk back through command line and find last option - while [[ $i -le $cword && ${#COMPREPLY[@]} -eq 0 ]]; do - curopt=${words[cword-$i]} + while ((i <= cword && ${#COMPREPLY[@]} == 0)); do + curopt=${words[cword - i]} case "$curopt" in -u) _allowed_users @@ -20,13 +20,13 @@ _renice() -g) _pgids ;; - -p|$command) + -p | "$command") _pids ;; esac - (( i++ )) + ((i++)) done } && -complete -F _renice renice + complete -F _renice renice # ex: filetype=sh diff --git a/completions/_repomanage b/completions/_repomanage index ea27f07e..ba0787e7 100644 --- a/completions/_repomanage +++ b/completions/_repomanage @@ -8,17 +8,17 @@ _repomanage() local cur prev words cword split _init_completion -s || return - [[ "$prev" == -@([hk]|-help|-keep) ]] && return + [[ $prev == -@([hk]|-help|-keep) ]] && return $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _filedir -d fi } && -complete -F _repomanage repomanage + complete -F _repomanage repomanage # ex: filetype=sh diff --git a/completions/_reptyr b/completions/_reptyr index 00cccddd..01d61b2a 100644 --- a/completions/_reptyr +++ b/completions/_reptyr @@ -15,12 +15,12 @@ _reptyr() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi [[ $prev != +([0-9]) ]] && _pids } && -complete -F _reptyr reptyr + complete -F _reptyr reptyr # ex: filetype=sh diff --git a/completions/_rfkill b/completions/_rfkill index a14a3eaf..96a6c098 100644 --- a/completions/_rfkill +++ b/completions/_rfkill @@ -8,24 +8,24 @@ _rfkill() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--version' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--version' -- "$cur")) else case $cword in 1) - COMPREPLY=( $(compgen -W "help event list block unblock" \ - -- "$cur") ) + COMPREPLY=($(compgen -W "help event list block unblock" \ + -- "$cur")) ;; 2) if [[ $prev == block || $prev == unblock ]]; then - COMPREPLY=( $(compgen -W "$($1 list | awk -F: \ + COMPREPLY=($(compgen -W "$($1 list | awk -F: \ '/^[0-9]/ {print $1}') all wifi bluetooth uwb wimax \ - wwan gps" -- "$cur") ) + wwan gps" -- "$cur")) fi ;; esac fi } && -complete -F _rfkill rfkill + complete -F _rfkill rfkill # ex: filetype=sh diff --git a/completions/_rtcwake b/completions/_rtcwake index 43d264c9..4ca452d9 100644 --- a/completions/_rtcwake +++ b/completions/_rtcwake @@ -9,24 +9,24 @@ _rtcwake() _init_completion -s || return case "$prev" in - --help|-h|--version|-V|--seconds|-s|--time|-t) + --help | -h | --version | -V | --seconds | -s | --time | -t) return ;; - --mode|-m) - COMPREPLY=( $(compgen -W 'standby mem disk on no off' -- "$cur") ) + --mode | -m) + COMPREPLY=($(compgen -W 'standby mem disk on no off' -- "$cur")) return ;; - --device|-d) - COMPREPLY=( $(command ls -d /dev/rtc?* 2>/dev/null) ) - COMPREPLY=( $(compgen -W '${COMPREPLY[@]#/dev/}' -- "$cur") ) + --device | -d) + COMPREPLY=($(command ls -d /dev/rtc?* 2>/dev/null)) + COMPREPLY=($(compgen -W '${COMPREPLY[@]#/dev/}' -- "$cur")) return ;; esac $split && return - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _rtcwake rtcwake + complete -F _rtcwake rtcwake # ex: filetype=sh diff --git a/completions/_su b/completions/_su index 9c0f59c1..1a03c8f7 100644 --- a/completions/_su +++ b/completions/_su @@ -8,34 +8,34 @@ if [[ $OSTYPE != *linux* ]]; then return fi -_su() # linux-specific completion -{ +_su() +{ # linux-specific completion local cur prev words cword split _init_completion -s || return case "$prev" in - -s|--shell) + -s | --shell) _shells return ;; - -c|--command|--session-command) + -c | --command | --session-command) local IFS=$'\n' compopt -o filenames - COMPREPLY=( $(compgen -d -c -- "$cur") ) + COMPREPLY=($(compgen -d -c -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) } && -complete -F _su su + complete -F _su su # ex: filetype=sh diff --git a/completions/_svn b/completions/_svn index 42e2dbe7..5d85c2b4 100644 --- a/completions/_svn +++ b/completions/_svn @@ -16,11 +16,11 @@ _svn() proplist plist pl propset pset ps resolved revert \ status stat st switch sw unlock update up' - if [[ $cword -eq 1 ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--version' -- "$cur") ) + if ((cword == 1)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--version' -- "$cur")) else - COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + COMPREPLY=($(compgen -W "$commands" -- "$cur")) fi else @@ -29,7 +29,7 @@ _svn() _filedir -d return ;; - -F|--file|--targets) + -F | --file | --targets) _filedir return ;; @@ -37,17 +37,16 @@ _svn() _xfunc iconv _iconv_charsets return ;; - --editor-cmd|--diff-cmd|--diff3-cmd) - words=(words[0] $cur) - cword=1 - _command + --editor-cmd | --diff-cmd | --diff3-cmd) + compopt -o filenames + COMPREPLY=($(compgen -c -- "$cur")) return ;; esac local command=${words[1]} - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # possible options for the command local options case $command in @@ -55,7 +54,7 @@ _svn() options='--auto-props --no-auto-props --force --targets --no-ignore --non-recursive --quiet' ;; - blame|annotate|ann|praise) + blame | annotate | ann | praise) options='--revision --username --password --no-auth-cache --non-interactive --verbose --incremental --xml' ;; @@ -63,7 +62,7 @@ _svn() options='--revision --username --password --no-auth-cache --non-interactive' ;; - checkout|co) + checkout | co) options='--revision --quiet --non-recursive --username --password --no-auth-cache --non-interactive --ignore-externals' @@ -71,23 +70,23 @@ _svn() cleanup) options='--diff3-cmd' ;; - commit|ci) + commit | ci) options='--message --file --encoding --force-log --quiet --non-recursive --targets --editor-cmd --username --password --no-auth-cache --non-interactive --no-unlock' ;; - copy|cp) + copy | cp) options='--message --file --encoding --force-log --revision --quiet --editor-cmd -username --password --no-auth-cache --non-interactive' ;; - delete|del|remove|rm) + delete | del | remove | rm) options='--force --message --file --encoding --force-log --quiet --targets --editor-cmd --username --password --no-auth-cache --non-interactive' ;; - diff|di) + diff | di) options='--revision --extensions --diff-cmd --no-diff-deleted --non-recursive --username --password --no-auth-cache --non-interactive @@ -109,7 +108,7 @@ _svn() --non-interactive --revision --xml --targets --recursive --incremental' ;; - list|ls) + list | ls) options='--revision --verbose --recursive --username --password --no-auth-cache --non-interactive --incremental --xml' @@ -136,32 +135,32 @@ _svn() --editor-cmd --username --password --no-auth-cache --non-interactive' ;; - move|mv|rename|ren) + move | mv | rename | ren) options='--message --file --encoding --force-log --revision --quiet --force --editor-cmd --username --password --no-auth-cache --non-interactive' ;; - propdel|pdel|pd) + propdel | pdel | pd) options='--quiet --recursive --revision --revprop --username --password --no-auth-cache --non-interactive' ;; - propedit|pedit|pe) + propedit | pedit | pe) options='--revision --revprop --encoding --editor-cmd --username --password --no-auth-cache --non-interactive --force' ;; - propget|pget|pg) + propget | pget | pg) options='--recursive --revision --revprop --strict --username --password --no-auth-cache --non-interactive' ;; - proplist|plist|pl) + proplist | plist | pl) options='--verbose --recursive --revision --revprop --quiet --username --password --no-auth-cache --non-interactive' ;; - propset|pset|ps) + propset | pset | ps) options='--file --quiet --targets --recursive --revprop --encoding --username --password --no-auth-cache --non-interactive --revision --force' @@ -172,13 +171,13 @@ _svn() revert) options='--targets --recursive --quiet' ;; - status|stat|st) + status | stat | st) options='--show-updates --verbose --non-recursive --quiet --username --password --no-auth-cache --non-interactive --no-ignore --ignore-externals --incremental --xml' ;; - switch|sw) + switch | sw) options='--relocate --revision --non-recursive --quiet --username --password --no-auth-cache --non-interactive --diff3-cmd' @@ -187,7 +186,7 @@ _svn() options='--targets --force --username --password --no-auth-cache --non-interactive' ;; - update|up) + update | up) options='--revision --non-recursive --quiet --username --password --no-auth-cache --non-interactive --diff3-cmd --ignore-externals' @@ -195,10 +194,10 @@ _svn() esac options+=" --help --config-dir" - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) else - if [[ "$command" == @(help|[h?]) ]]; then - COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + if [[ $command == @(help|[h?]) ]]; then + COMPREPLY=($(compgen -W "$commands" -- "$cur")) else _filedir fi @@ -206,6 +205,6 @@ _svn() fi } && -complete -F _svn svn + complete -F _svn svn # ex: filetype=sh diff --git a/completions/_svnadmin b/completions/_svnadmin index 7a86c43e..654fd3ec 100644 --- a/completions/_svnadmin +++ b/completions/_svnadmin @@ -12,11 +12,11 @@ _svnadmin() commands='create deltify dump help ? hotcopy list-dblogs list-unused-dblogs load lslocks lstxns recover rmlocks rmtxns setlog verify' - if [[ $cword -eq 1 ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--version' -- "$cur") ) + if ((cword == 1)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--version' -- "$cur")) else - COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + COMPREPLY=($(compgen -W "$commands" -- "$cur")) fi else case $prev in @@ -25,14 +25,14 @@ _svnadmin() return ;; --fs-type) - COMPREPLY=( $(compgen -W 'fsfs bdb' -- "$cur") ) + COMPREPLY=($(compgen -W 'fsfs bdb' -- "$cur")) return ;; esac local command=${words[1]} - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # possible options for the command local options case $command in @@ -62,10 +62,10 @@ _svnadmin() esac options+=" --help" - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) else - if [[ "$command" == @(help|[h?]) ]]; then - COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + if [[ $command == @(help|[h?]) ]]; then + COMPREPLY=($(compgen -W "$commands" -- "$cur")) else _filedir fi @@ -73,6 +73,6 @@ _svnadmin() fi } && -complete -F _svnadmin -o default svnadmin + complete -F _svnadmin -o default svnadmin # ex: filetype=sh diff --git a/completions/_svnlook b/completions/_svnlook index 2cbd134b..36188a57 100644 --- a/completions/_svnlook +++ b/completions/_svnlook @@ -12,20 +12,20 @@ _svnlook() commands='author cat changed date diff dirs-changed help ? h history info lock log propget pget pg proplist plist pl tree uuid youngest' - if [[ $cword -eq 1 ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--version' -- "$cur") ) + if ((cword == 1)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--version' -- "$cur")) else - COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + COMPREPLY=($(compgen -W "$commands" -- "$cur")) fi else local command=${words[1]} - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # possible options for the command local options case $command in - author|cat|date|dirs-changed|info|log) + author | cat | date | dirs-changed | info | log) options='--revision --transaction' ;; changed) @@ -38,7 +38,7 @@ _svnlook() history) options='--revision --show-ids' ;; - propget|proplist) + propget | proplist) options='--revision --transaction --revprop' ;; tree) @@ -47,10 +47,10 @@ _svnlook() esac options+=" --help" - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) else - if [[ "$command" == @(help|[h?]) ]]; then - COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + if [[ $command == @(help|[h?]) ]]; then + COMPREPLY=($(compgen -W "$commands" -- "$cur")) else _filedir fi @@ -58,6 +58,6 @@ _svnlook() fi } && -complete -F _svnlook -o default svnlook + complete -F _svnlook -o default svnlook # ex: filetype=sh diff --git a/completions/_udevadm b/completions/_udevadm index ce43f1ad..19624be9 100644 --- a/completions/_udevadm +++ b/completions/_udevadm @@ -9,7 +9,7 @@ _udevadm() _init_completion -s || return local i udevcmd - for (( i=1; i < cword; i++ )); do + for ((i = 1; i < cword; i++)); do if [[ ${words[i]} != -* ]]; then udevcmd=${words[i]} break @@ -17,19 +17,19 @@ _udevadm() 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") ) + COMPREPLY=($(compgen -W 'err info debug' -- "$cur")) return ;; --query) - COMPREPLY=( $(compgen -W 'name symlink path property all' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'name symlink path property all' \ + -- "$cur")) return ;; --name) @@ -37,41 +37,41 @@ _udevadm() _filedir return ;; - --device-id-of-file|--exit-if-exists) + --device-id-of-file | --exit-if-exists) _filedir return ;; --action) - COMPREPLY=( $(compgen -W 'add change remove' -- "$cur") ) + COMPREPLY=($(compgen -W 'add change remove' -- "$cur")) return ;; --type) - COMPREPLY=( $(compgen -W 'devices subsystems failed' -- "$cur") ) + COMPREPLY=($(compgen -W 'devices subsystems failed' -- "$cur")) return ;; esac $split && return - if [[ -z $udevcmd ]]; then + if [[ ! -v udevcmd ]]; then case $cur in -*) - COMPREPLY=( $(compgen -W '--help --version --debug' -- "$cur") ) + COMPREPLY=($(compgen -W '--help --version --debug' -- "$cur")) ;; *) - COMPREPLY=( $(compgen -W "$("$1" --help 2>/dev/null | - awk '/^[ \t]/ { print $1 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$("$1" --help 2>/dev/null | + awk '/^[ \t]/ { print $1 }')" -- "$cur")) ;; esac return fi if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W \ - '$("$1" $udevcmd --help 2>/dev/null | _parse_help -)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W \ + '$("$1" ${udevcmd-} --help 2>/dev/null | _parse_help -)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _udevadm udevadm + complete -F _udevadm udevadm # ex: filetype=sh diff --git a/completions/_umount b/completions/_umount index a5d338bc..36d5703f 100644 --- a/completions/_umount +++ b/completions/_umount @@ -17,8 +17,8 @@ _umount() _init_completion || return local IFS=$'\n' - COMPREPLY=( $(compgen -W '$(mount | cut -d" " -f 3)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(mount | cut -d" " -f 3)' -- "$cur")) } && -complete -F _umount -o dirnames umount + complete -F _umount -o dirnames umount # ex: filetype=sh diff --git a/completions/_umount.linux b/completions/_umount.linux index 59727b4b..cf8a2595 100644 --- a/completions/_umount.linux +++ b/completions/_umount.linux @@ -15,7 +15,7 @@ _reply_compgen_array() # argument. local i wlist for i in ${!COMPREPLY[*]}; do - local q=$(quote "$(printf %q "${COMPREPLY[$i]}")") + local q=$(quote "$(printf %q "${COMPREPLY[i]}")") wlist+=$q$'\n' done @@ -25,13 +25,14 @@ _reply_compgen_array() ecur=${ecur//\'/\\\'} # Actually generate completions. - local oldifs=$IFS + local ifs=$IFS IFS=$'\n' eval 'COMPREPLY=(`compgen -W "$wlist" -- "${ecur}"`)' - IFS=$oldifs + IFS=$ifs } # Unescape strings in the linux fstab(5) format (with octal escapes). -__linux_fstab_unescape() { +__linux_fstab_unescape() +{ eval $1="'${!1//\'/\\047}'" eval $1="'${!1/%\\/\\\\}'" eval "$1=$'${!1}'" @@ -40,23 +41,24 @@ __linux_fstab_unescape() { # Complete linux fstab entries. # # Reads a file from stdin in the linux fstab(5) format; as used by /etc/fstab -# and /proc/mounts. +# and /proc/mounts. With 1st arg -L, look for entries by label. +# shellcheck disable=SC2120 _linux_fstab() { COMPREPLY=() # Read and unescape values into COMPREPLY local fs_spec fs_file fs_other - local oldifs="$IFS" + 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 [[ ${1-} == -L ]]; then + local fs_label=${fs_spec/#LABEL=/} if [[ $fs_label != "$fs_spec" ]]; then __linux_fstab_unescape fs_label IFS=$'\0' COMPREPLY+=("$fs_label") - IFS=$oldifs + IFS=$ifs fi else __linux_fstab_unescape fs_spec @@ -64,7 +66,7 @@ _linux_fstab() IFS=$'\0' [[ $fs_spec == */* ]] && COMPREPLY+=("$fs_spec") [[ $fs_file == */* ]] && COMPREPLY+=("$fs_file") - IFS=$oldifs + IFS=$ifs fi done @@ -81,12 +83,12 @@ _linux_fstab() dircur="${cur%/*}/" fi basecur=${cur#"$dircur"} - local i n=${#COMPREPLY[@]} - for (( i=0; i < $n; i++ )); do - [[ "${COMPREPLY[i]}" == "$realcur"* ]] && - COMPREPLY+=( $(cd "$dircur" 2>/dev/null && + 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") ) + -X "!${COMPREPLY[i]##"$dirrealcur"}" -- "$basecur")) done fi fi @@ -103,18 +105,18 @@ _umount() -t) # FIXME: no local split=false - if [[ "$cur" == ?*,* ]]; then + if [[ $cur == ?*,* ]]; then prev="${cur%,*}" cur="${cur##*,}" split=true fi - COMPREPLY=( $(compgen -W 'adfs affs autofs btrfs cifs coda + 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") ) + umsdos usbfs vfat xfs' -- "$cur")) _fstypes - $split && COMPREPLY=( ${COMPREPLY[@]/#/$prev,} ) + $split && COMPREPLY=(${COMPREPLY[@]/#/$prev,}) return ;; -O) @@ -123,10 +125,10 @@ _umount() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-V -h -v -n -r -d -i -a -t -O -f -l - --no-canonicalize --fake' -- "$cur") ) - [[ $COMPREPLY ]] && return + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-V -h -v -n -r -d -i -a -t -O -f -l + --no-canonicalize --fake' -- "$cur")) + [[ ${COMPREPLY-} ]] && return fi if [[ -r /proc/mounts ]]; then @@ -135,9 +137,9 @@ _umount() _linux_fstab /dev/null | \ - awk '!/Name|Domain-0/ { print $1 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(xm list 2>/dev/null | + awk '!/Name|Domain-0/ { print $1 }')" -- "$cur")) } _xen_domain_ids() { - COMPREPLY=( $(compgen -W "$(xm list 2>/dev/null | \ - awk '!/Name|Domain-0/ { print $2 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(xm list 2>/dev/null | + awk '!/Name|Domain-0/ { print $2 }')" -- "$cur")) } _xm() @@ -36,16 +36,16 @@ _xm() labels addlabel rmlabel getlabel dry-run resources dumppolicy setpolicy resetpolicy getpolicy shell help' - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + if ((cword == 1)); then + COMPREPLY=($(compgen -W "$commands" -- "$cur")) else - if [[ "$cur" == *=* ]]; then + if [[ $cur == *=* ]]; then prev=${cur/=*/} cur=${cur/*=/} fi command=${words[1]} - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # possible options for the command case $command in create) @@ -66,7 +66,7 @@ _xm() sched-credit) options='-d -w -c' ;; - block-list|network-list|vtpm-list|vnet-list) + block-list | network-list | vtpm-list | vnet-list) options='-l --long' ;; getpolicy) @@ -78,12 +78,12 @@ _xm() -s --skipdtd -p --paused -c --console_autoconnect' ;; esac - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) 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) + 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 2) @@ -93,7 +93,7 @@ _xm() ;; migrate) _count_args - case $args in + case $args in 2) _xen_domain_names ;; @@ -102,7 +102,7 @@ _xm() ;; esac ;; - restore|dry-run|vnet-create) + restore | dry-run | vnet-create) _filedir ;; save) @@ -123,7 +123,7 @@ _xm() _xen_domain_names ;; 3) - COMPREPLY=( $(compgen -W "r s e i u b" -- "$cur") ) + COMPREPLY=($(compgen -W "r s e i u b" -- "$cur")) ;; esac ;; @@ -134,10 +134,10 @@ _xm() _xen_domain_names ;; 3) - COMPREPLY=( $(compgen -W "phy: file:" -- "$cur") ) + COMPREPLY=($(compgen -W "phy: file:" -- "$cur")) ;; 5) - COMPREPLY=( $(compgen -W "w r" -- "$cur") ) + COMPREPLY=($(compgen -W "w r" -- "$cur")) ;; 6) _xen_domain_names @@ -151,9 +151,9 @@ _xm() _xen_domain_names ;; 3) - COMPREPLY=( $(compgen -W "$(xm block-list $prev \ + COMPREPLY=($(compgen -W "$(xm block-list $prev \ 2>/dev/null | awk '!/Vdev/ { print $1 }')" \ - -- "$cur") ) + -- "$cur")) ;; esac ;; @@ -164,8 +164,8 @@ _xm() _xen_domain_names ;; *) - COMPREPLY=( $(compgen -W "script= ip= mac= bridge= - backend=" -- "$cur") ) + COMPREPLY=($(compgen -W "script= ip= mac= bridge= + backend=" -- "$cur")) ;; esac ;; @@ -176,9 +176,9 @@ _xm() _xen_domain_names ;; 3) - COMPREPLY=( $(compgen -W "$(xm network-list $prev \ + COMPREPLY=($(compgen -W "$(xm network-list $prev \ 2>/dev/null | awk '!/Idx/ { print $1 }')" \ - -- "$cur") ) + -- "$cur")) ;; esac ;; @@ -192,13 +192,13 @@ _xm() ;; create) _filedir - COMPREPLY+=( \ + COMPREPLY+=( $(compgen -W '$(command ls /etc/xen 2>/dev/null)' \ - -- "$cur") ) + -- "$cur")) ;; new) case $prev in - -f|-F|--defconfig|--config) + -f | -F | --defconfig | --config) _filedir return ;; @@ -209,7 +209,7 @@ _xm() esac _count_args - case $args in + case $args in 2) _xen_domain_names ;; @@ -219,6 +219,6 @@ _xm() fi fi } && -complete -F _xm xm + complete -F _xm xm # ex: filetype=sh diff --git a/completions/_yum b/completions/_yum index d5e06eca..224ea254 100644 --- a/completions/_yum +++ b/completions/_yum @@ -5,16 +5,16 @@ _yum_list() { - if [[ "$1" == all ]]; then + 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 | \ + 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') ) + -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') ) + COMPREPLY=($(yum -d 0 -C list $1 "$cur*" 2>/dev/null | + command sed -ne 1d -e 's/[[:space:]].*//p')) fi } @@ -23,14 +23,14 @@ _yum_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 | \ + yum --noplugins -C repolist $1 2>/dev/null | command sed -ne '/^repo\s\s*id/d' -e '/^repolist:/d' -e 's/[[:space:]].*//p' } _yum_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 + command ls /usr/lib/yum-plugins/*.py{,c,o} 2>/dev/null | + command sed -ne 's|.*/\([^./]*\)\.py[co]\{0,1\}$|\1|p' | sort -u } _yum() @@ -39,16 +39,17 @@ _yum() _init_completion -s || return local special i - for (( i=0; i < ${#words[@]}-1; i++ )); do + for ((i = 1; i < ${#words[@]} - 1; i++)); do if [[ ${words[i]} == @(install|update|upgrade|remove|erase|deplist|info) ]]; then special=${words[i]} + break fi done - if [[ -n $special ]]; then + if [[ -v special ]]; then # TODO: install|update|upgrade should not match *src.rpm - if [[ "$cur" == @(*/|[.~])* && \ - "$special" == @(deplist|install|update|upgrade) ]]; then + if [[ $cur == @(*/|[.~])* && \ + $special == @(deplist|install|update|upgrade) ]]; then _filedir rpm return fi @@ -57,15 +58,15 @@ _yum() _yum_list available return ;; - deplist|info) + deplist | info) _yum_list all return ;; - upgrade|update) + upgrade | update) _yum_list updates return ;; - remove|erase) + remove | erase) # _rpm_installed_packages is not arch-qualified _yum_list installed return @@ -75,22 +76,22 @@ _yum() case $prev in list) - COMPREPLY=( $(compgen -W 'all available updates installed extras - obsoletes recent' -- "$cur") ) + COMPREPLY=($(compgen -W 'all available updates installed extras + obsoletes recent' -- "$cur")) ;; clean) - COMPREPLY=( $(compgen -W 'packages headers metadata cache dbcache - all' -- "$cur") ) + COMPREPLY=($(compgen -W 'packages headers metadata cache dbcache + all' -- "$cur")) ;; repolist) - COMPREPLY=( $(compgen -W 'all enabled disabled' -- "$cur") ) + COMPREPLY=($(compgen -W 'all enabled disabled' -- "$cur")) ;; - localinstall|localupdate) + localinstall | localupdate) # TODO: should not match *src.rpm _filedir rpm ;; - -d|-e) - COMPREPLY=( $(compgen -W '{0..10}' -- "$cur") ) + -d | -e) + COMPREPLY=($(compgen -W '{0..10}' -- "$cur")) ;; -c) _filedir @@ -99,45 +100,45 @@ _yum() _filedir -d ;; --enablerepo) - COMPREPLY=( $(compgen -W '$(_yum_repolist disabled)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_yum_repolist disabled)' -- "$cur")) ;; --disablerepo) - COMPREPLY=( $(compgen -W '$(_yum_repolist enabled)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_yum_repolist enabled)' -- "$cur")) ;; --disableexcludes) - COMPREPLY=( $(compgen -W '$(_yum_repolist all) all main' \ - -- "$cur") ) + COMPREPLY=($(compgen -W '$(_yum_repolist all) all main' \ + -- "$cur")) ;; - --enableplugin|--disableplugin) - COMPREPLY=( $(compgen -W '$(_yum_plugins)' -- "$cur") ) + --enableplugin | --disableplugin) + COMPREPLY=($(compgen -W '$(_yum_plugins)' -- "$cur")) ;; --color) - COMPREPLY=( $(compgen -W 'always auto never' -- "$cur") ) + COMPREPLY=($(compgen -W 'always auto never' -- "$cur")) ;; - -R|-x|--exclude) + -R | -x | --exclude) # argument required but no completions available return ;; - -h|--help|--version) + -h | --help | --version) # no other options useful with these return ;; *) - COMPREPLY=( $(compgen -W 'install update check-update upgrade + 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") ) + repolist help' -- "$cur")) ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _yum yum + complete -F _yum yum # ex: filetype=sh diff --git a/completions/a2x b/completions/a2x index cf9f9516..b59c7861 100644 --- a/completions/a2x +++ b/completions/a2x @@ -6,15 +6,15 @@ _a2x() _init_completion -s || return case $prev in - --attribute|--asciidoc-opts|--dblatex-opts|--fop-opts|--help|\ - --version|--xsltproc-opts|-!(-*)[ah]) + --attribute | --asciidoc-opts | --dblatex-opts | --fop-opts | --help | \ + --version | --xsltproc-opts | -!(-*)[ah]) return ;; - --destination-dir|--icons-dir|-!(-*)D) + --destination-dir | --icons-dir | -!(-*)D) _filedir -d return ;; - --doctype|-!(-*)d) + --doctype | -!(-*)d) _xfunc asciidoc _asciidoc_doctype return ;; @@ -27,13 +27,13 @@ _a2x() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _a2x a2x + complete -F _a2x a2x # ex: filetype=sh diff --git a/completions/abook b/completions/abook index 29d326b9..42197d10 100644 --- a/completions/abook +++ b/completions/abook @@ -6,12 +6,12 @@ _abook() _init_completion || return # abook only takes options, tabbing after command name adds a single dash - [[ $cword -eq 1 && -z "$cur" ]] && - { - compopt -o nospace - COMPREPLY=( "-" ) - return - } + [[ $cword -eq 1 && -z $cur ]] && + { + compopt -o nospace + COMPREPLY=("-") + return + } case $cur in -*) @@ -22,28 +22,28 @@ _abook() case $prev in --informat) - COMPREPLY=( $(compgen -W "$($1 --formats | \ + COMPREPLY=($(compgen -W "$($1 --formats | command sed -n -e 's/^'$'\t''\([a-z]*\).*/\1/p' -e '/^$/q')" \ - -- "$cur") ) + -- "$cur")) ;; --outformat) - COMPREPLY=( $(compgen -W "$($1 --formats | \ + COMPREPLY=($(compgen -W "$($1 --formats | command sed -n -e '/^$/,$s/^'$'\t''\([a-z]*\).*/\1/p')" \ - -- "$cur") ) + -- "$cur")) ;; --infile) - COMPREPLY=( $(compgen -W stdin -- "$cur") ) + COMPREPLY=($(compgen -W stdin -- "$cur")) _filedir ;; --outfile) - COMPREPLY=( $(compgen -W stdout -- "$cur") ) + COMPREPLY=($(compgen -W stdout -- "$cur")) _filedir ;; - --config|--datafile) + --config | --datafile) _filedir ;; esac } && -complete -F _abook abook + complete -F _abook abook # ex: filetype=sh diff --git a/completions/aclocal b/completions/aclocal index f0cc6114..010862fb 100644 --- a/completions/aclocal +++ b/completions/aclocal @@ -6,10 +6,10 @@ _aclocal() _init_completion -s || return case "$prev" in - --help|--print-ac-dir|--version) + --help | --print-ac-dir | --version) return ;; - --acdir|-I) + --acdir | -I) _filedir -d return ;; @@ -17,19 +17,19 @@ _aclocal() _filedir return ;; - --warnings|-W) - local cats=( syntax unsupported ) - COMPREPLY=( $(compgen -W \ - '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur") ) + --warnings | -W) + local cats=(syntax unsupported) + COMPREPLY=($(compgen -W \ + '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur")) return ;; esac $split && return - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && -complete -F _aclocal aclocal aclocal-1.1{0..6} + complete -F _aclocal aclocal aclocal-1.1{0..6} # ex: filetype=sh diff --git a/completions/acpi b/completions/acpi index 745b8f78..f2c38b21 100644 --- a/completions/acpi +++ b/completions/acpi @@ -6,17 +6,17 @@ _acpi() _init_completion || return case $prev in - --help|--version|-!(-*)[hv]) + --help | --version | -!(-*)[hv]) return ;; - --directory|-!(-*)d) + --directory | -!(-*)d) _filedir -d return ;; esac - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _acpi acpi + complete -F _acpi acpi # ex: filetype=sh diff --git a/completions/add_members b/completions/add_members index 75ae417c..efa4f1e2 100644 --- a/completions/add_members +++ b/completions/add_members @@ -6,26 +6,26 @@ _add_members() _init_completion -s || return case $prev in - -r|-d|--regular-members-file|--digest-members-file) + -r | -d | --regular-members-file | --digest-members-file) _filedir return ;; - -w|-a|--welcome-msg|--admin-notify) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + -w | -a | --welcome-msg | --admin-notify) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--regular-members-file --digest-members-file - --welcome-msg --admin-notify --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--regular-members-file --digest-members-file + --welcome-msg --admin-notify --help' -- "$cur")) else _xfunc list_lists _mailman_lists fi } && -complete -F _add_members add_members + complete -F _add_members add_members # ex: filetype=sh diff --git a/completions/alias b/completions/alias index af39302a..92211d83 100644 --- a/completions/alias +++ b/completions/alias @@ -7,14 +7,14 @@ _alias() case ${words[@]} in *[^=]) - COMPREPLY=( $(compgen -A alias -- "$cur") ) + COMPREPLY=($(compgen -A alias -- "$cur")) ;; *=) - COMPREPLY=( "$(alias ${cur%=} 2>/dev/null | command sed \ - -e 's|^alias '"$cur"'\(.*\)$|\1|')" ) + COMPREPLY=("$(alias ${cur%=} 2>/dev/null | command sed \ + -e 's|^alias '"$cur"'\(.*\)$|\1|')") ;; esac } && -complete -F _alias -o nospace alias + complete -F _alias -o nospace alias # ex: filetype=sh diff --git a/completions/ant b/completions/ant index ba141965..197c0e96 100644 --- a/completions/ant +++ b/completions/ant @@ -31,14 +31,14 @@ _ant() _init_completion || return case $prev in - -h|-help|--h|--help|-projecthelp|-p|-version|-diagnostics) + -h | -help | --h | --help | -projecthelp | -p | -version | -diagnostics) return ;; - -buildfile|-file|-f) + -buildfile | -file | -f) _filedir 'xml' return ;; - -logfile|-l) + -logfile | -l) [[ $1 != *phing || $prev != -l ]] && _filedir return ;; @@ -47,37 +47,37 @@ _ant() return ;; -nice) - COMPREPLY=( $(compgen -W '{1..10}' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..10}' -- "$cur")) return ;; -lib) _filedir -d return ;; - -logger|-listener|-inputhandler|-main|-find|-s) + -logger | -listener | -inputhandler | -main | -find | -s) return ;; esac if [[ $cur == -D* ]]; then return - elif [[ "$cur" == -* ]]; then + elif [[ $cur == -* ]]; then # The /dev/null && \ + complete -F _ant ant phing +type complete-ant-cmd.pl &>/dev/null && complete -C complete-ant-cmd.pl -F _ant ant || : # ex: filetype=sh diff --git a/completions/apache2ctl b/completions/apache2ctl index fe2a2d7b..980b3c58 100644 --- a/completions/apache2ctl +++ b/completions/apache2ctl @@ -6,11 +6,11 @@ _apache2ctl() _init_completion || return local APWORDS - APWORDS=$($1 2>&1 >/dev/null | awk 'NR<2 { print $3; exit }' | \ + APWORDS=$($1 2>&1 >/dev/null | awk 'NR<2 { print $3; exit }' | tr "|" " ") - COMPREPLY=( $(compgen -W "$APWORDS" -- "$cur") ) + COMPREPLY=($(compgen -W "$APWORDS" -- "$cur")) } && -complete -F _apache2ctl apache2ctl + complete -F _apache2ctl apache2ctl # ex: filetype=sh diff --git a/completions/appdata-validate b/completions/appdata-validate index e6c6ddd6..03d8cc9a 100644 --- a/completions/appdata-validate +++ b/completions/appdata-validate @@ -6,13 +6,13 @@ _appdata_validate() _init_completion -s || return case $prev in - -h|--help|--version) + -h | --help | --version) return ;; --output-format) - COMPREPLY=( $(compgen -W "$($1 --help | + COMPREPLY=($(compgen -W "$($1 --help | command sed -ne 's/--output-format.*\[\(.*\)\]/\1/' -e 's/|/ /gp')" \ - -- "$cur") ) + -- "$cur")) return ;; esac @@ -20,13 +20,13 @@ _appdata_validate() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir appdata.xml } && -complete -F _appdata_validate appdata-validate + complete -F _appdata_validate appdata-validate # ex: filetype=sh diff --git a/completions/apt-build b/completions/apt-build index b6cf8eff..713f4c39 100644 --- a/completions/apt-build +++ b/completions/apt-build @@ -6,48 +6,49 @@ _apt_build() _init_completion || return local special i - for (( i=0; i < ${#words[@]}-1; i++ )); do + for ((i = 1; i < ${#words[@]} - 1; i++)); do if [[ ${words[i]} == @(install|remove|source|info|clean) ]]; then special=${words[i]} + break fi done - if [[ -n $special ]]; then + if [[ -v special ]]; then case $special in - install|source|info) - COMPREPLY=( $(apt-cache pkgnames "$cur" 2>/dev/null) ) + install | source | info) + COMPREPLY=($(_xfunc apt-cache _apt_cache_packages)) ;; remove) - COMPREPLY=( \ - $(_xfunc dpkg _comp_dpkg_installed_packages "$cur") ) + COMPREPLY=( + $(_xfunc dpkg _comp_dpkg_installed_packages "$cur")) ;; esac return fi case $prev in - --patch|--build-dir|--repository-dir) + --patch | --build-dir | --repository-dir) _filedir return ;; - -h|--help) + -h | --help) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --show-upgraded -u --build-dir + if [[ $cur == -* ]]; then + COMPREPLY=($(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' -- "$cur")) else - COMPREPLY=( $(compgen -W 'update upgrade install remove source + COMPREPLY=($(compgen -W 'update upgrade install remove source dist-upgrade world clean info clean-build update-repository' \ - -- "$cur") ) + -- "$cur")) fi } && -complete -F _apt_build apt-build + complete -F _apt_build apt-build # ex: filetype=sh diff --git a/completions/apt-cache b/completions/apt-cache index 5bd85e90..61aa07be 100644 --- a/completions/apt-cache +++ b/completions/apt-cache @@ -1,18 +1,21 @@ # Debian apt-cache(8) completion -*- shell-script -*- # List APT binary packages -_apt_cache_packages() { - apt-cache --no-generate pkgnames "$cur" 2>/dev/null +_apt_cache_packages() +{ + apt-cache --no-generate pkgnames "$cur" 2>/dev/null || : } # List APT source packages -_apt_cache_sources() { - compgen -W "$(apt-cache dumpavail | \ +_apt_cache_sources() +{ + compgen -W "$(apt-cache dumpavail | awk '$1 == "Source:" { print $2 }' | sort -u)" -- "$1" } # List APT source packages -_apt_cache_src_packages() { +_apt_cache_src_packages() +{ compgen -W '$(_apt_cache_sources "$cur")' -- "$cur" } @@ -21,63 +24,62 @@ _apt_cache() local cur prev words cword _init_completion || return - local special i + local special ispecial if [[ $cur != show ]]; then - for (( i=0; i < ${#words[@]}-1; i++ )); do - if [[ ${words[i]} == @(add|depends|dotty|madison|policy|rdepends|show?(pkg|src|)) ]]; then - special=${words[i]} + for ((ispecial = 1; ispecial < ${#words[@]} - 1; ispecial++)); do + if [[ ${words[ispecial]} == @(add|depends|dotty|madison|policy|rdepends|show?(pkg|src|)) ]]; then + special=${words[ispecial]} + break fi done fi - - if [[ -n $special ]]; then + if [[ -v special && $ispecial -lt $cword ]]; then case $special in - add) - _filedir - ;; + add) + _filedir + ;; - showsrc) - COMPREPLY=( $(_apt_cache_sources "$cur") ) - ;; + showsrc) + COMPREPLY=($(_apt_cache_sources "$cur")) + ;; - *) - COMPREPLY=( $(_apt_cache_packages) ) - ;; + *) + COMPREPLY=($(_apt_cache_packages)) + ;; esac return fi - case $prev in - --config-file|--pkg-cache|--src-cache|-!(-*)[cps]) + --config-file | --pkg-cache | --src-cache | -!(-*)[cps]) _filedir return ;; search) - if [[ "$cur" != -* ]]; then + if [[ $cur != -* ]]; then return fi ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '-h -v -p -s -q -i -f -a -g -c -o --help + 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") ) - else + --installed' -- "$cur")) + elif [[ ! -v special ]]; then - COMPREPLY=( $(compgen -W 'add gencaches show showpkg showsrc stats + COMPREPLY=($(compgen -W 'add gencaches show showpkg showsrc stats dump dumpavail unmet search search depends rdepends pkgnames - dotty xvcg policy madison' -- "$cur") ) + dotty xvcg policy madison' -- "$cur")) fi } && -complete -F _apt_cache apt-cache + complete -F _apt_cache apt-cache # ex: filetype=sh diff --git a/completions/apt-get b/completions/apt-get index 9c88fe60..4aee2639 100644 --- a/completions/apt-get +++ b/completions/apt-get @@ -6,28 +6,30 @@ _apt_get() _init_completion -n ':=' || return local special i - for (( i=0; i < ${#words[@]}-1; i++ )); do + for ((i = 1; i < ${#words[@]} - 1; i++)); do if [[ ${words[i]} == @(install|remove|autoremove|purge|source|build-dep|download|changelog) ]]; then special=${words[i]} + break fi done - if [[ -n $special ]]; then + if [[ -v special ]]; then case $special in - remove|autoremove|purge) + remove | autoremove | purge) if [[ -f /etc/debian_version ]]; then # Debian system - COMPREPLY=( $(\ - _xfunc dpkg _comp_dpkg_installed_packages $cur) ) + COMPREPLY=($( + _xfunc dpkg _comp_dpkg_installed_packages $cur + )) else # assume RPM based _xfunc rpm _rpm_installed_packages fi ;; source) - COMPREPLY=( $(apt-cache --no-generate pkgnames "$cur" \ - 2>/dev/null) $(compgen -W "$(apt-cache dumpavail | - awk '$1 == "Source:" { print $2 }' | sort -u)" -- "$cur") ) + COMPREPLY=($(_xfunc apt-cache _apt_cache_packages) + $(compgen -W "$(apt-cache dumpavail | + awk '$1 == "Source:" { print $2 }' | sort -u)" -- "$cur")) ;; install) if [[ $cur == */* ]]; then @@ -36,42 +38,46 @@ _apt_get() elif [[ $cur == *=* ]]; then package="${cur%%=*}" cur="${cur#*=}" - COMPREPLY=($(IFS=$'\n' compgen -W "$( \ - apt-cache --no-generate madison "$package" 2>/dev/null | \ - while IFS=' |' read -r _ version _; do - echo "$version" - done )" \ - -- "$cur")) + COMPREPLY=($(IFS=$'\n' compgen -W "$( + apt-cache --no-generate madison "$package" 2>/dev/null | + while IFS=' |' read -r _ version _; do + echo "$version" + done + )" \ + -- "$cur")) __ltrim_colon_completions "$cur" return fi ;;& + build-dep) + _filedir -d + [[ $cur != */* ]] || return + ;;& *) - COMPREPLY=( $(apt-cache --no-generate pkgnames "$cur" \ - 2>/dev/null) ) + COMPREPLY+=($(_xfunc apt-cache _apt_cache_packages)) ;; esac return fi case $prev in - --help|--version|--option|-!(-*)[hvo]) + --help | --version | --option | -!(-*)[hvo]) return ;; - --config-file|-!(-*)c) + --config-file | -!(-*)c) _filedir return ;; - --target-release|--default-release|-!(-*)t) - COMPREPLY=( $(compgen -W "$(apt-cache policy | command sed -ne \ + --target-release | --default-release | -!(-*)t) + COMPREPLY=($(compgen -W "$(apt-cache policy | command sed -ne \ 's/^ *release.*[ ,]o=\(Debian\|Ubuntu\),a=\(\w*\).*/\2/p')" \ - -- "$cur") ) + -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--no-install-recommends --install-suggests + if [[ $cur == -* ]]; then + COMPREPLY=($(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 @@ -84,15 +90,15 @@ _apt_get() --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") ) + --version --config-file --option' -- "$cur")) else - COMPREPLY=( $(compgen -W 'update upgrade dist-upgrade + COMPREPLY=($(compgen -W 'update upgrade dist-upgrade dselect-upgrade install remove purge source build-dep check download clean autoclean autoremove changelog indextargets' \ - -- "$cur") ) + -- "$cur")) fi } && -complete -F _apt_get apt-get + complete -F _apt_get apt-get # ex: filetype=sh diff --git a/completions/aptitude b/completions/aptitude index 3f4e5500..e5ea1636 100644 --- a/completions/aptitude +++ b/completions/aptitude @@ -1,16 +1,16 @@ # 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() + { + 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 }" -} + _comp_dpkg_hold_packages() + { + command grep -B 2 'hold' /var/lib/dpkg/status | + awk "/Package: $1/ { print \$2 }" + } } _aptitude() @@ -18,37 +18,29 @@ _aptitude() local cur prev words cword _init_completion || return - local dashoptions='-S -u -i -h --help --version -s --simulate -d - --download-only -P --prompt -y --assume-yes -F --display-format -O - --sort -w --width -f -r -g --with-recommends -R -G --without-recommends - -t --target-release -V --show-versions -D --show-deps -Z -v --verbose - --purge-unused --schedule-only' - local special i - for (( i=0; i < ${#words[@]}-1; i++ )); do + 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]} + break fi - #exclude some mutually exclusive options - [[ ${words[i]} == '-u' ]] && dashoptions=${dashoptions/-i} - [[ ${words[i]} == '-i' ]] && dashoptions=${dashoptions/-u} done - if [[ -n "$special" ]]; then + if [[ -v 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) ) + 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)) return ;; - purge|remove|reinstall|forbid-version) - COMPREPLY=( \ - $(_xfunc dpkg _comp_dpkg_installed_packages "$cur") ) + purge | remove | reinstall | forbid-version) + COMPREPLY=( + $(_xfunc dpkg _comp_dpkg_installed_packages "$cur")) return ;; unhold) - COMPREPLY=( $(_comp_dpkg_hold_packages "$cur") ) + COMPREPLY=($(_comp_dpkg_hold_packages "$cur")) return ;; esac @@ -56,32 +48,72 @@ _aptitude() case $prev in # don't complete anything if these options are found - autoclean|clean|forget-new|search|upgrade|update|keep-all) + autoclean | clean | forget-new | search | upgrade | update | keep-all) return ;; -!(-*)S) _filedir 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) ) + --display-format | --width | -!(-*)[wFo]) + return + ;; + --sort | -!(-*)O) + COMPREPLY=($(compgen -W 'installsize installsizechange debsize + name priority version' -- "$cur")) + 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)) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W "$dashoptions" -- "$cur") ) + 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' ' ') " + + # Exclude some mutually exclusive options + for i in "${words[@]}"; do + [[ $i == -u ]] && opts=${opts/ -i / } + [[ $i == -i ]] && opts=${opts/ -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 ;; + -s) COMPREPLY[i]=--simulate ;; + -d) COMPREPLY[i]=--download-only ;; + -P) COMPREPLY[i]=--prompt ;; + -y) COMPREPLY[i]=--assume-yes ;; + -F) COMPREPLY[i]=--display-format ;; + -O) COMPREPLY[i]=--sort ;; + -W) COMPREPLY[i]=--show-why ;; + -w) COMPREPLY[i]=--width ;; + -V) COMPREPLY[i]=--show-versions ;; + -D) COMPREPLY[i]=--show-deps ;; + -v) COMPREPLY[i]=--verbose ;; + -t) COMPREPLY[i]=--target-release ;; + -q) COMPREPLY[i]=--quiet ;; + esac + done + + COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur")) else - COMPREPLY=( $(compgen -W 'update upgrade safe-upgrade forget-new + COMPREPLY=($(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' -- "$cur")) fi } && -complete -F _aptitude -o default aptitude aptitude-curses + complete -F _aptitude -o default aptitude aptitude-curses # ex: filetype=sh diff --git a/completions/arch b/completions/arch index e275577b..afeed05d 100644 --- a/completions/arch +++ b/completions/arch @@ -3,44 +3,44 @@ # Try to detect whether this is the mailman "arch" to avoid installing # it for the coreutils/util-linux-ng one. _have mailmanctl && -_arch() -{ - local cur prev words cword split - _init_completion -s || return + _arch() + { + local cur prev words cword split + _init_completion -s || return - case $prev in - -w|-g|-d|--welcome-msg|--goodbye-msg|--digest) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) - return - ;; - -d|--file) - _filedir - return - ;; - esac - - $split && return - - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - else - local args=$cword - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == -* ]]; then - (( args-- )) - fi - done - case $args in - 1) - _xfunc list_lists _mailman_lists + case $prev in + -w | -g | -d | --welcome-msg | --goodbye-msg | --digest) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) + return ;; - 2) + --file) _filedir + return ;; esac - fi -} && -complete -F _arch arch + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + else + local args=$cword + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == -* ]]; then + ((args--)) + fi + done + case $args in + 1) + _xfunc list_lists _mailman_lists + ;; + 2) + _filedir + ;; + esac + fi + + } && + complete -F _arch arch # ex: filetype=sh diff --git a/completions/arp b/completions/arp index e83f05d3..922e800a 100644 --- a/completions/arp +++ b/completions/arp @@ -6,28 +6,28 @@ _arp() _init_completion || return case $prev in - --device|-!(-*)i) + --device | -!(-*)i) _available_interfaces -a return ;; - --protocol|-!(-*)[Ap]) + --protocol | -!(-*)[Ap]) # TODO protocol/address family return ;; - --file|-!(-*)f) + --file | -!(-*)f) _filedir return ;; - --hw-type|-!(-*)[Ht]) + --hw-type | -!(-*)[Ht]) # TODO: parse from --help output? - COMPREPLY=( $(compgen -W 'ash ether ax25 netrom rose arcnet \ - dlci fddi hippi irda x25 eui64' -- "$cur") ) + COMPREPLY=($(compgen -W 'ash ether ax25 netrom rose arcnet \ + dlci fddi hippi irda x25 eui64' -- "$cur")) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi @@ -37,7 +37,7 @@ _arp() 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") ) + COMPREPLY=($(compgen -W '$ips' -- "$cur")) ;; 2) # TODO if -d mode: "pub"; if not -f mode: hw_addr @@ -54,6 +54,6 @@ _arp() ;; esac } && -complete -F _arp arp + complete -F _arp arp # ex: filetype=sh diff --git a/completions/arping b/completions/arping index 6adcde7c..57e1e19b 100644 --- a/completions/arping +++ b/completions/arping @@ -6,7 +6,7 @@ _arping() _init_completion || return case $prev in - -*c|-*w) + -*c | -*w) return ;; -*I) @@ -20,12 +20,12 @@ _arping() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) return fi _known_hosts_real -- "$cur" } && -complete -F _arping arping + complete -F _arping arping # ex: filetype=sh diff --git a/completions/arpspoof b/completions/arpspoof index 6275a667..d1a13735 100644 --- a/completions/arpspoof +++ b/completions/arpspoof @@ -16,13 +16,13 @@ _arpspoof() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) else _known_hosts_real -- "$cur" fi } && -complete -F _arpspoof arpspoof + complete -F _arpspoof arpspoof # ex: filetype=sh diff --git a/completions/asciidoc b/completions/asciidoc index 2ddcdfe9..1ea4abf2 100644 --- a/completions/asciidoc +++ b/completions/asciidoc @@ -2,7 +2,7 @@ _asciidoc_doctype() { - COMPREPLY+=( $(compgen -W 'article book manpage' -- "$cur") ) + COMPREPLY+=($(compgen -W 'article book manpage' -- "$cur")) } _asciidoc() @@ -11,26 +11,26 @@ _asciidoc() _init_completion -s || return case $prev in - --attribute|-!(-*)a) + --attribute | -!(-*)a) return ;; - --backend|-!(-*)b) - COMPREPLY=( $(compgen -W 'docbook html4 xhtml11' -- "$cur") ) + --backend | -!(-*)b) + COMPREPLY=($(compgen -W 'docbook html4 xhtml11' -- "$cur")) return ;; - --conf-file|-!(-*)f) + --conf-file | -!(-*)f) _filedir conf return ;; - --doctype|-!(-*)d) + --doctype | -!(-*)d) _asciidoc_doctype return ;; - --help|-!(-*)h) - COMPREPLY=( $(compgen -W 'manpage syntax topics' -- "$cur") ) + --help | -!(-*)h) + COMPREPLY=($(compgen -W 'manpage syntax topics' -- "$cur")) return ;; - --out-file|-!(-*)o) + --out-file | -!(-*)o) _filedir return ;; @@ -39,14 +39,14 @@ _asciidoc() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" "--help manpage")' \ - -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1" "--help manpage")' \ + -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _asciidoc asciidoc asciidoc.py + complete -F _asciidoc asciidoc asciidoc.py # ex: filetype=sh diff --git a/completions/aspell b/completions/aspell index 040853cb..e080a07d 100644 --- a/completions/aspell +++ b/completions/aspell @@ -5,12 +5,12 @@ _aspell_dictionary() local datadir aspell=${1:-aspell} 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/}" ) + COMPREPLY=($(printf '%s\n' $datadir/*.alias)) + COMPREPLY=("${COMPREPLY[@]%.alias}") + COMPREPLY=("${COMPREPLY[@]#$datadir/}") # Then, add the canonical dicts - COMPREPLY+=( $($aspell dicts 2>/dev/null) ) - COMPREPLY=( $(compgen -X '\*' -W '${COMPREPLY[@]}' -- "$cur") ) + COMPREPLY+=($($aspell dicts 2>/dev/null)) + COMPREPLY=($(compgen -X '\*' -W '${COMPREPLY[@]}' -- "$cur")) } _aspell() @@ -19,47 +19,47 @@ _aspell() _init_completion -s || return case $prev in - -c|-p|check|--conf|--personal|--repl|--per-conf) + -c | -p | check | --conf | --personal | --repl | --per-conf) _filedir return ;; - --conf-dir|--data-dir|--dict-dir|--home-dir|--local-data-dir|--prefix) + --conf-dir | --data-dir | --dict-dir | --home-dir | --local-data-dir | --prefix) _filedir -d return ;; - dump|create|merge) - COMPREPLY=( $(compgen -W 'master personal repl' -- "$cur") ) + dump | create | merge) + COMPREPLY=($(compgen -W 'master personal repl' -- "$cur")) return ;; --mode) - COMPREPLY=( $(compgen -W "$($1 modes 2>/dev/null | \ - awk '{ print $1 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 modes 2>/dev/null | + awk '{ print $1 }')" -- "$cur")) return ;; --sug-mode) - COMPREPLY=( $(compgen -W 'ultra fast normal bad-speller' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'ultra fast normal bad-speller' \ + -- "$cur")) return ;; --keymapping) - COMPREPLY=( $(compgen -W 'aspell ispell' -- "$cur") ) + COMPREPLY=($(compgen -W 'aspell ispell' -- "$cur")) return ;; - -d|--master) + -d | --master) _aspell_dictionary "$1" return ;; - --add-filter|--rem-filter) - COMPREPLY=( $(compgen -W "$($1 filters 2>/dev/null | \ - awk '{ print $1 }')" -- "$cur") ) + --add-filter | --rem-filter) + COMPREPLY=($(compgen -W "$($1 filters 2>/dev/null | + awk '{ print $1 }')" -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--conf= --conf-dir= --data-dir= --dict-dir= + if [[ $cur == -* ]]; then + COMPREPLY=($(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 +76,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") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + --rem-sgml-extension' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else - COMPREPLY=( $(compgen -W 'usage help check pipe list config soundslike - filter version dump create merge' -- "$cur") ) + COMPREPLY=($(compgen -W 'usage help check pipe list config soundslike + filter version dump create merge' -- "$cur")) fi } && -complete -F _aspell aspell + complete -F _aspell aspell # ex: filetype=sh diff --git a/completions/autoconf b/completions/autoconf index 94a014ff..b51e797e 100644 --- a/completions/autoconf +++ b/completions/autoconf @@ -6,20 +6,20 @@ _autoconf() _init_completion -s || return case "$prev" in - --help|-h|--version|-V|--trace|-t) + --help | -h | --version | -V | --trace | -t) return ;; - --output|-o) + --output | -o) _filedir return ;; - --warnings|-W) - local cats=( cross obsolete syntax ) - COMPREPLY=( $(compgen -W \ - '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur") ) + --warnings | -W) + local cats=(cross obsolete syntax) + COMPREPLY=($(compgen -W \ + '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur")) return ;; - --prepend-include|-B|--include|-I) + --prepend-include | -B | --include | -I) _filedir -d return ;; @@ -27,14 +27,14 @@ _autoconf() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir '@(ac|in)' } && -complete -F _autoconf autoconf + complete -F _autoconf autoconf # ex: filetype=sh diff --git a/completions/automake b/completions/automake index ff3d4523..5fe5f4f8 100644 --- a/completions/automake +++ b/completions/automake @@ -6,13 +6,13 @@ _automake() _init_completion -s || return case "$prev" in - --help|--version) + --help | --version) return ;; - --warnings|-W) - local cats=( gnu obsolete override portability syntax unsupported ) - COMPREPLY=( $(compgen -W \ - '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur") ) + --warnings | -W) + local cats=(gnu obsolete override portability syntax unsupported) + COMPREPLY=($(compgen -W \ + '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur")) return ;; --libdir) @@ -23,14 +23,14 @@ _automake() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _automake automake automake-1.1{0..6} + complete -F _automake automake automake-1.1{0..6} # ex: filetype=sh diff --git a/completions/autoreconf b/completions/autoreconf index cf983312..9b0f0dc9 100644 --- a/completions/autoreconf +++ b/completions/autoreconf @@ -6,17 +6,17 @@ _autoreconf() _init_completion -s || return case "$prev" in - --help|-h|--version|-V) + --help | -h | --version | -V) return ;; - --warnings|-W) - local cats=( cross gnu obsolete override portability syntax \ - unsupported ) - COMPREPLY=( $(compgen -W \ - '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur") ) + --warnings | -W) + local cats=(cross gnu obsolete override portability syntax + unsupported) + COMPREPLY=($(compgen -W \ + '${cats[@]} ${cats[@]/#/no-} all none error' -- "$cur")) return ;; - --prepend-include|-B|--include|-I) + --prepend-include | -B | --include | -I) _filedir -d return ;; @@ -24,9 +24,9 @@ _autoreconf() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi @@ -36,6 +36,6 @@ _autoreconf() _filedir -d fi } && -complete -F _autoreconf autoreconf autoheader + complete -F _autoreconf autoreconf autoheader # ex: filetype=sh diff --git a/completions/autorpm b/completions/autorpm index 7a0bbe18..d55322ab 100644 --- a/completions/autorpm +++ b/completions/autorpm @@ -5,10 +5,10 @@ _autorpm() local cur prev words cword _init_completion || return - COMPREPLY=( $(compgen -W '--notty --debug --help --version auto add - fullinfo info help install list remove set' -- "$cur") ) + COMPREPLY=($(compgen -W '--notty --debug --help --version auto add + fullinfo info help install list remove set' -- "$cur")) } && -complete -F _autorpm autorpm + complete -F _autorpm autorpm # ex: filetype=sh diff --git a/completions/autoscan b/completions/autoscan index 5f70a508..e0071437 100644 --- a/completions/autoscan +++ b/completions/autoscan @@ -6,10 +6,10 @@ _autoscan() _init_completion -s || return case "$prev" in - --help|--version|-!(-*)[hV]) + --help | --version | -!(-*)[hV]) return ;; - --prepend-include|--include|-!(-*)[BI]) + --prepend-include | --include | -!(-*)[BI]) _filedir -d return ;; @@ -17,9 +17,9 @@ _autoscan() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi @@ -29,6 +29,6 @@ _autoscan() _filedir -d fi } && -complete -F _autoscan autoscan autoupdate + complete -F _autoscan autoscan autoupdate # ex: filetype=sh diff --git a/completions/avctrl b/completions/avctrl index 2ef499f3..89c24e47 100644 --- a/completions/avctrl +++ b/completions/avctrl @@ -5,16 +5,16 @@ _avctrl() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --quiet' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--help --quiet' -- "$cur")) else local args _count_args - if [[ $args -eq 1 ]]; then - COMPREPLY=( $(compgen -W 'discover switch' -- "$cur") ) + if ((args == 1)); then + COMPREPLY=($(compgen -W 'discover switch' -- "$cur")) fi fi } && -complete -F _avctrl avctrl + complete -F _avctrl avctrl # ex: filetype=sh diff --git a/completions/badblocks b/completions/badblocks index 221f42b9..29c4e00d 100644 --- a/completions/badblocks +++ b/completions/badblocks @@ -15,15 +15,15 @@ _badblocks() ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # Filter out -w (dangerous) and -X (internal use) - COMPREPLY=( $(compgen -X -[wX] -W '$(_parse_usage "$1")' -- "$cur") ) + COMPREPLY=($(compgen -X -[wX] -W '$(_parse_usage "$1")' -- "$cur")) return fi cur=${cur:=/dev/} _filedir } && -complete -F _badblocks badblocks + complete -F _badblocks badblocks # ex: filetype=sh diff --git a/completions/bind b/completions/bind index c06654b1..2ee428b2 100644 --- a/completions/bind +++ b/completions/bind @@ -10,8 +10,8 @@ _bind() return ;; -*m) - COMPREPLY=( $(compgen -W "emacs emacs-standard emacs-meta - emacs-ctlx vi vi-move vi-command vi-insert" -- "$cur") ) + COMPREPLY=($(compgen -W "emacs emacs-standard emacs-meta + emacs-ctlx vi vi-move vi-command vi-insert" -- "$cur")) return ;; -*f) @@ -19,18 +19,18 @@ _bind() return ;; -*[qu]) - COMPREPLY=( $(compgen -W '$("$1" -l)' -- "$cur") ) + COMPREPLY=($(compgen -W '$("$1" -l)' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) return fi - COMPREPLY=( $(compgen -A binding -- "$cur") ) + COMPREPLY=($(compgen -A binding -- "$cur")) } && -complete -F _bind bind + complete -F _bind bind # ex: filetype=sh diff --git a/completions/bk b/completions/bk index 73b5bb1c..4e4d140a 100644 --- a/completions/bk +++ b/completions/bk @@ -6,13 +6,13 @@ _bk() local cur prev words cword _init_completion || return - local BKCMDS="$(bk help topics 2>/dev/null | \ + local BKCMDS="$(bk help topics 2>/dev/null | awk '/^ bk/ { print $2 }' | xargs printf '%s ')" - COMPREPLY=( $(compgen -W "$BKCMDS" -- "$cur") ) + COMPREPLY=($(compgen -W "$BKCMDS" -- "$cur")) _filedir } && -complete -F _bk bk + complete -F _bk bk # ex: filetype=sh diff --git a/completions/brctl b/completions/brctl index 755812d3..14569b64 100644 --- a/completions/brctl +++ b/completions/brctl @@ -9,31 +9,32 @@ _brctl() case $cword in 1) - COMPREPLY=( $(compgen -W "addbr delbr addif delif setageing + COMPREPLY=($(compgen -W "addbr delbr addif delif setageing setbridgeprio setfd sethello setmaxage setpathcost setportprio - show showmacs showstp stp" -- "$cur") ) + show showmacs showstp stp" -- "$cur")) ;; 2) case $command in - show) - ;; + show) ;; + *) - COMPREPLY=( $(compgen -W "$($1 show | \ - awk 'NR>1 {print $1}' )" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 show | + awk 'NR>1 {print $1}')" -- "$cur")) + ;; esac ;; 3) case $command in - addif|delif) + addif | delif) _configured_interfaces ;; stp) - COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) + COMPREPLY=($(compgen -W 'on off' -- "$cur")) ;; esac ;; esac } && -complete -F _brctl -o default brctl + complete -F _brctl -o default brctl # ex: filetype=sh diff --git a/completions/btdownloadheadless.py b/completions/btdownloadheadless.py index c15de1a4..a470e535 100644 --- a/completions/btdownloadheadless.py +++ b/completions/btdownloadheadless.py @@ -6,14 +6,14 @@ _btdownload() _init_completion || return case $prev in - --responsefile|--saveas) + --responsefile | --saveas) _filedir return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--max_uploads --keepalive_interval + if [[ $cur == -* ]]; then + COMPREPLY=($(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 @@ -21,12 +21,12 @@ _btdownload() --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") ) + -- "$cur")) else _filedir fi } && -complete -F _btdownload btdownloadheadless.py btdownloadcurses.py \ - btdownloadgui.py + complete -F _btdownload btdownloadheadless.py btdownloadcurses.py \ + btdownloadgui.py # ex: filetype=sh diff --git a/completions/bts b/completions/bts index c87b51e1..d535d13e 100644 --- a/completions/bts +++ b/completions/bts @@ -1,92 +1,89 @@ # bts completion -*- shell-script -*- # List bug numbers from bugs cache in ~/.devscripts_cache/bts -_cached_bugs() { - [[ -d $HOME/.devscripts_cache/bts ]] && \ +_cached_bugs() +{ + [[ -d $HOME/.devscripts_cache/bts ]] && find $HOME/.devscripts_cache/bts -maxdepth 1 -name "${cur}[0-9]*.html" \ -printf "%f\n" | cut -d'.' -f1 } # List APT source packages prefixed with "src:" -_src_packages_with_prefix() { +_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" } - _bts() { local cur prev words cword split _init_completion -s || return case $prev in - show|bugs) - COMPREPLY=( $(compgen -W 'release-critical RC from: tag: + show | bugs) + COMPREPLY=($(compgen -W 'release-critical RC from: tag: usertag:' -- "$cur") $(_cached_bugs) - $(_src_packages_with_prefix) ) + $(_src_packages_with_prefix)) return ;; select) - COMPREPLY=( $(compgen -W 'package: source: maintainer: submitter: + COMPREPLY=($(compgen -W 'package: source: maintainer: submitter: severity: status: tag: owner: correspondent: affects: bugs: - users: archive:' -- "$cur") ) + users: archive:' -- "$cur")) return ;; status) - COMPREPLY=( $(compgen -W 'file: fields: verbose' -- "$cur") - $(_cached_bugs) ) + COMPREPLY=($(compgen -W 'file: fields: verbose' -- "$cur") + $(_cached_bugs)) return ;; - block|unblock) - COMPREPLY=( $(compgen -W 'by with' -- "$cur") ) + block | unblock) + COMPREPLY=($(compgen -W 'by with' -- "$cur")) return ;; severity) - COMPREPLY=( $(compgen -W 'wishlist minor normal important serious - grave critical' -- "$cur") ) + COMPREPLY=($(compgen -W 'wishlist minor normal important serious + grave critical' -- "$cur")) return ;; limit) - COMPREPLY=( $(compgen -W 'submitter date subject msgid package - source tag severity owner affects archive' -- "$cur") ) + COMPREPLY=($(compgen -W 'submitter date subject msgid package + source tag severity owner affects archive' -- "$cur")) 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) ) + 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)) return ;; package) - COMPREPLY=( $(_xfunc apt-cache _apt_cache_packages) ) + COMPREPLY=($(_xfunc apt-cache _apt_cache_packages)) return ;; cache) - COMPREPLY=( $(_xfunc apt-cache _apt_cache_packages) - $(_src_packages_with_prefix) - $(compgen -W 'from: release-critical RC' -- "$cur") ) + COMPREPLY=($(_xfunc apt-cache _apt_cache_packages) + $(_src_packages_with_prefix) + $(compgen -W 'from: release-critical RC' -- "$cur")) return ;; cleancache) - COMPREPLY=( $(_xfunc apt-cache _apt_cache_packages) - $(_src_packages_with_prefix) - $(compgen -W 'from: tag: usertag: ALL' -- "$cur") ) + COMPREPLY=($(_xfunc apt-cache _apt_cache_packages) + $(_src_packages_with_prefix) + $(compgen -W 'from: tag: usertag: ALL' -- "$cur")) return ;; user) # non-predicible arguments - COMPREPLY=( ) + COMPREPLY=() return ;; :) # Chances are that "src:" is being completed # COMP_WORDS would be: "bts cleancache src : " pos=$((COMP_CWORD - 2)) - if [[ $pos -gt 0 && "${COMP_WORDS[$pos]}" == "src" ]]; then - COMPREPLY=( $(_xfunc apt-cache _apt_cache_src_packages) ) + if [[ $pos -gt 0 && ${COMP_WORDS[pos]} == "src" ]]; then + COMPREPLY=($(_xfunc apt-cache _apt_cache_src_packages)) return fi ;; @@ -94,7 +91,7 @@ _bts() $split && return - COMPREPLY=( $(compgen -W '--offline --online --no-offline + 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 @@ -107,9 +104,9 @@ _bts() 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' -- "$cur")) } && -complete -F _bts bts + complete -F _bts bts # ex: filetype=sh diff --git a/completions/bzip2 b/completions/bzip2 index 8bd72cc9..40e50fe3 100644 --- a/completions/bzip2 +++ b/completions/bzip2 @@ -6,37 +6,37 @@ _bzip2() _init_completion || return case $prev in - --help|-!(-*)[bhp]) + --help | -!(-*)[bhp]) return ;; -!(-*)n) - COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) + COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local helpopts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W "${helpopts//#/} -2 -3 -4 -5 -6 -7 -8 -9" \ - -- "$cur") ) + COMPREPLY=($(compgen -W "${helpopts//#/} -2 -3 -4 -5 -6 -7 -8 -9" \ + -- "$cur")) return fi local IFS=$'\n' xspec="*.?(t)bz2" - if [[ "$prev" == --* ]]; then - [[ "$prev" == --@(decompress|list|test) ]] && xspec="!"$xspec - [[ "$prev" == --compress ]] && xspec= - elif [[ "$prev" == -* ]]; then - [[ "$prev" == -*[dt]* ]] && xspec="!"$xspec - [[ "$prev" == -*z* ]] && xspec= + if [[ $prev == --* ]]; then + [[ $prev == --@(decompress|list|test) ]] && xspec="!"$xspec + [[ $prev == --compress ]] && xspec= + elif [[ $prev == -* ]]; then + [[ $prev == -*[dt]* ]] && xspec="!"$xspec + [[ $prev == -*z* ]] && xspec= fi _tilde "$cur" || return compopt -o filenames - COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) + COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur")) } && -complete -F _bzip2 bzip2 pbzip2 lbzip2 + complete -F _bzip2 bzip2 pbzip2 lbzip2 # ex: filetype=sh diff --git a/completions/cancel b/completions/cancel index b903517b..3e0c1d52 100644 --- a/completions/cancel +++ b/completions/cancel @@ -14,14 +14,14 @@ _cancel() return ;; -u) - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) return ;; esac - COMPREPLY=( $(compgen -W \ - "$(lpstat 2>/dev/null | cut -d' ' -f1)" -- "$cur") ) + COMPREPLY=($(compgen -W \ + "$(lpstat 2>/dev/null | cut -d' ' -f1)" -- "$cur")) } && -complete -F _cancel cancel + complete -F _cancel cancel # ex: filetype=sh diff --git a/completions/cardctl b/completions/cardctl index 588ea467..bb3a0dba 100644 --- a/completions/cardctl +++ b/completions/cardctl @@ -5,11 +5,11 @@ _cardctl() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W 'status config ident suspend resume reset - eject insert scheme' -- "$cur") ) + if ((cword == 1)); then + COMPREPLY=($(compgen -W 'status config ident suspend resume reset + eject insert scheme' -- "$cur")) fi } && -complete -F _cardctl cardctl pccardctl + complete -F _cardctl cardctl pccardctl # ex: filetype=sh diff --git a/completions/carton b/completions/carton index 0cf6e2ca..5d700c89 100644 --- a/completions/carton +++ b/completions/carton @@ -2,15 +2,15 @@ _carton_commands() { - local cmds=$("${1:-carton}" usage 2>&1 | \ - command sed -ne '/.*command.* is one of/{n;p;q}') - COMPREPLY+=( $(IFS="$IFS," compgen -W "$cmds" -- "$cur") ) + local cmds=$("${1:-carton}" usage 2>&1 | + command sed -ne '/.*command.* is one of/{n;p;q;}') + COMPREPLY+=($(IFS="$IFS," compgen -W "$cmds" -- "$cur")) } _carton_command_help() { local help=$(PERLDOC_PAGER=cat PERLDOC=-otext "${1:-carton}" -h $2 2>&1) - COMPREPLY+=( $(compgen -W '$help' -- "$cur") ) + COMPREPLY+=($(compgen -W '$help' -- "$cur")) } _carton() @@ -19,24 +19,27 @@ _carton() _init_completion -s || return local i command - for (( i=1; i < cword; i++ )); do + for ((i = 1; i < cword; i++)); do case ${words[i]} in -*) ;; - *) command=${words[i]}; break ;; + *) + command=${words[i]} + break + ;; esac done - if [[ -z "$command" ]]; then + if [[ ! -v command ]]; then _carton_commands "$1" return fi case $prev in - --version|-v) + --version | -v) return ;; - --help|-h) - [[ -n "$command" ]] || _carton_commands "$1" + --help | -h) + [[ -n $command ]] || _carton_commands "$1" return ;; --cpanfile) @@ -54,7 +57,7 @@ _carton() --without) if [[ $command == install ]]; then local phases="configure build test runtime develop" - COMPREPLY+=( $(compgen -W '$phases' -- "$cur") ) + COMPREPLY+=($(compgen -W '$phases' -- "$cur")) return fi ;; @@ -68,11 +71,11 @@ _carton() fi case $command in - show|update) - : # TODO modules completion + show | update) + : # TODO modules completion ;; esac } && -complete -F _carton carton + complete -F _carton carton # ex: filetype=sh diff --git a/completions/ccache b/completions/ccache index 7dbec9fe..80c39de0 100644 --- a/completions/ccache +++ b/completions/ccache @@ -6,7 +6,7 @@ _ccache() _init_completion -s || return local i - for (( i=1; i <= COMP_CWORD; i++ )); do + for ((i = 1; i <= COMP_CWORD; i++)); do if [[ ${COMP_WORDS[i]} != -* ]]; then _command_offset $i return @@ -15,14 +15,14 @@ _ccache() done case $prev in - --help|--version|--max-files|--max-size|-!(-*)[hVFM]) + --help | --version | --max-files | --max-size | -!(-*)[hVFM]) return ;; - --set-config|-!(-*)o) + --set-config | -!(-*)o) if [[ $cur != *=* ]]; then - COMPREPLY=( $(compgen -S = -W "$($1 -p 2>/dev/null | \ - awk '$3 = "=" { print $2 }')" -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -S = -W "$($1 -p 2>/dev/null | + awk '$3 = "=" { print $2 }')" -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi return ;; @@ -30,9 +30,9 @@ _ccache() $split && return - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && -complete -F _ccache ccache + complete -F _ccache ccache # ex: filetype=sh diff --git a/completions/ccze b/completions/ccze index 7c17f364..35f4c3f3 100644 --- a/completions/ccze +++ b/completions/ccze @@ -6,38 +6,39 @@ _ccze() _init_completion -s || return case $prev in - -'?'|--help|--usage|-V|--version) + -'?' | --help | --usage | -V | --version) return ;; - --argument|--color|-!(-*)[ac]) + --argument | --color | -!(-*)[ac]) # TODO? return ;; - --rcfile|-!(-*)F) + --rcfile | -!(-*)F) _filedir return ;; - --mode|-!(-*)m) - COMPREPLY=( $(compgen -W "curses ansi html" -- "$cur") ) + --mode | -!(-*)m) + COMPREPLY=($(compgen -W "curses ansi html" -- "$cur")) return ;; - --option|-!(-*)o) + --option | -!(-*)o) local -a opts=(scroll wordcolor lookups transparent cssfile) - COMPREPLY=( $(compgen -W '${opts[@]} ${opts[@]/#/no}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts[@]} ${opts[@]/#/no}' -- "$cur")) return ;; - --plugin|-!(-*)p) - COMPREPLY=( $(compgen -W '$("$1" --list-plugins | command \ + --plugin | -!(-*)p) + COMPREPLY=($(compgen -W '$("$1" --list-plugins | command \ sed -ne "s/^\([a-z0-9]\{1,\}\)[[:space:]]\{1,\}|.*/\1/p")' \ - -- "$cur") ) + -- "$cur")) return + ;; esac $split && return - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && -complete -F _ccze ccze + complete -F _ccze ccze # ex: filetype=sh diff --git a/completions/cfagent b/completions/cfagent index 14987723..e7ba04de 100644 --- a/completions/cfagent +++ b/completions/cfagent @@ -6,16 +6,16 @@ _cfagent() _init_completion || return case $prev in - -f|--file) + -f | --file) _filedir return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) fi } && -complete -F _cfagent cfagent + complete -F _cfagent cfagent # ex: filetype=sh diff --git a/completions/cfrun b/completions/cfrun index 0a7d0542..72b61389 100644 --- a/completions/cfrun +++ b/completions/cfrun @@ -6,9 +6,9 @@ _cfrun() _init_completion || return local i section=1 - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == -- ]]; then - (( section++ )) + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == -- ]]; then + ((section++)) fi done @@ -21,27 +21,27 @@ _cfrun() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-f -h -d -S -T -v' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-f -h -d -S -T -v' -- "$cur")) else - hostfile=${CFINPUTS:-/var/lib/cfengine/inputs}/cfrun.hosts - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == -f ]]; then - hostfile=${words[i+1]} + local hostfile=${CFINPUTS:-/var/lib/cfengine/inputs}/cfrun.hosts + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == -f ]]; then + hostfile=${words[i + 1]} break fi done [[ ! -f $hostfile ]] && return - COMPREPLY=( $(compgen -W "$(command grep -v \ - -E '(=|^$|^#)' $hostfile )" -- "$cur") ) + COMPREPLY=($(compgen -W "$(command grep -v \ + -E '(=|^$|^#)' $hostfile)" -- "$cur")) fi ;; 2) - COMPREPLY=( $(compgen -W '$(_parse_help cfagent)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help cfagent)' -- "$cur")) ;; esac } && -complete -F _cfrun cfrun + complete -F _cfrun cfrun # ex: filetype=sh diff --git a/completions/chage b/completions/chage index cb9d8fcf..fcf87cd4 100644 --- a/completions/chage +++ b/completions/chage @@ -6,11 +6,11 @@ _chage() _init_completion -s || return case $prev in - --lastday|--expiredate|--help|--inactive|--mindays|--maxdays|\ - --warndays|-!(-*)[dEhImMW]) + --lastday | --expiredate | --help | --inactive | --mindays | --maxdays | \ + --warndays | -!(-*)[dEhImMW]) return ;; - --root|-!(-*)R) + --root | -!(-*)R) _filedir -d return ;; @@ -18,13 +18,13 @@ _chage() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) } && -complete -F _chage chage + complete -F _chage chage # ex: filetype=sh diff --git a/completions/change_pw b/completions/change_pw index 61c45768..04837ea9 100644 --- a/completions/change_pw +++ b/completions/change_pw @@ -6,7 +6,7 @@ _change_pw() _init_completion -s || return case $prev in - -l|--listname) + -l | --listname) _xfunc list_lists _mailman_lists return ;; @@ -14,12 +14,12 @@ _change_pw() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--all --domain --listname --password --quiet - --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--all --domain --listname --password --quiet + --help' -- "$cur")) fi } && -complete -F _change_pw change_pw + complete -F _change_pw change_pw # ex: filetype=sh diff --git a/completions/check_db b/completions/check_db index ade03a5a..aaec99fd 100644 --- a/completions/check_db +++ b/completions/check_db @@ -5,13 +5,13 @@ _check_db() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--all --verbose --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--all --verbose --help' -- "$cur")) else _xfunc list_lists _mailman_lists fi } && -complete -F _check_db check_db + complete -F _check_db check_db # ex: filetype=sh diff --git a/completions/check_perms b/completions/check_perms index d53b22a6..8ff276ef 100644 --- a/completions/check_perms +++ b/completions/check_perms @@ -5,11 +5,11 @@ _check_perms() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-f -v -h' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-f -v -h' -- "$cur")) fi } && -complete -F _check_perms check_perms + complete -F _check_perms check_perms # ex: filetype=sh diff --git a/completions/checksec b/completions/checksec index e07d07d0..fc2fef79 100644 --- a/completions/checksec +++ b/completions/checksec @@ -6,10 +6,10 @@ _checksec() _init_completion || return case $prev in - --version|--help) + --version | --help) return ;; - --file|--fortify-file) + --file | --fortify-file) _filedir return ;; @@ -21,17 +21,17 @@ _checksec() _pnames return ;; - --proc-libs|--fortify-proc) + --proc-libs | --fortify-proc) _pids return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi } && -complete -F _checksec checksec + complete -F _checksec checksec # ex: filetype=sh diff --git a/completions/chgrp b/completions/chgrp index 0e39739c..4793a457 100644 --- a/completions/chgrp +++ b/completions/chgrp @@ -7,7 +7,7 @@ _chgrp() cur=${cur//\\\\/} - if [[ "$prev" == --reference ]]; then + if [[ $prev == --reference ]]; then _filedir return fi @@ -15,25 +15,25 @@ _chgrp() $split && return # options completion - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local w opts - for w in "${words[@]}" ; do - [[ "$w" == -@(R|-recursive) ]] && opts="-H -L -P" && break + for w in "${words[@]}"; do + [[ $w == -@(R|-recursive) ]] && opts="-H -L -P" && break done - COMPREPLY=( $(compgen -W '-c -h -f -R -v --changes --dereference + COMPREPLY=($(compgen -W '-c -h -f -R -v --changes --dereference --no-dereference --silent --quiet --reference --recursive --verbose - --help --version $opts' -- "$cur") ) + --help --version $opts' -- "$cur")) return fi # first parameter on line or first since an option? - if [[ $cword -eq 1 && "$cur" != -* || "$prev" == -* ]]; then + if [[ $cword -eq 1 && $cur != -* || $prev == -* ]]; then _allowed_groups "$cur" else _filedir fi } && -complete -F _chgrp chgrp + complete -F _chgrp chgrp # ex: filetype=sh diff --git a/completions/chkconfig b/completions/chkconfig index f1ee8704..8ff66376 100644 --- a/completions/chkconfig +++ b/completions/chkconfig @@ -6,32 +6,32 @@ _chkconfig() _init_completion -s || return case $prev in - --level=[1-6]|[1-6]|--list|--add|--del|--override) + --level=[1-6] | [1-6] | --list | --add | --del | --override) _services _xinetd_services return ;; --level) - COMPREPLY=( $(compgen -W '{1..6}' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..6}' -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--list --add --del --override --level' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--list --add --del --override --level' \ + -- "$cur")) else - if [[ $cword -eq 2 || $cword -eq 4 ]]; then - COMPREPLY=( $(compgen -W 'on off reset resetpriorities' \ - -- "$cur") ) + if ((cword == 2 || cword == 4)); then + COMPREPLY=($(compgen -W 'on off reset resetpriorities' \ + -- "$cur")) else _services _xinetd_services fi fi } && -complete -F _chkconfig chkconfig + complete -F _chkconfig chkconfig # ex: filetype=sh diff --git a/completions/chmod b/completions/chmod index 849da851..d3fc3499 100644 --- a/completions/chmod +++ b/completions/chmod @@ -6,7 +6,7 @@ _chmod() _init_completion -s || return case $prev in - --help|--version) + --help | --version) return ;; --reference) @@ -20,10 +20,11 @@ _chmod() # 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") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi @@ -31,10 +32,10 @@ _chmod() _count_args "" "" "$modearg" case $args in - 1) ;; # mode + 1) ;; # mode *) _filedir ;; esac } && -complete -F _chmod chmod + complete -F _chmod chmod # ex: filetype=sh diff --git a/completions/chown b/completions/chown index 6bfa264a..1d746b7a 100644 --- a/completions/chown +++ b/completions/chown @@ -19,28 +19,28 @@ _chown() $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # Complete -options local w opts - for w in "${words[@]}" ; do - [[ "$w" == -@(R|-recursive) ]] && opts="-H -L -P" && break + for w in "${words[@]}"; do + [[ $w == -@(R|-recursive) ]] && opts="-H -L -P" && break done - COMPREPLY=( $(compgen -W '-c -h -f -R -v --changes --dereference + COMPREPLY=($(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' -- "$cur")) else local args # The first argument is an usergroup; the rest are filedir. _count_args : - if [[ $args -eq 1 ]]; then + if ((args == 1)); then _usergroup -u else _filedir fi fi } && -complete -F _chown chown + complete -F _chown chown # ex: filetype=sh diff --git a/completions/chpasswd b/completions/chpasswd index 8c5a4dfd..3abea998 100644 --- a/completions/chpasswd +++ b/completions/chpasswd @@ -6,15 +6,15 @@ _chpasswd() _init_completion -s || return case $prev in - --crypt|-!(-*)c) - COMPREPLY=( $(compgen -W 'DES MD5 NONE SHA256 SHA512' \ - -- "$cur") ) + --crypt | -!(-*)c) + COMPREPLY=($(compgen -W 'DES MD5 NONE SHA256 SHA512' \ + -- "$cur")) return ;; - --sha-rounds|-!(-*)s) + --sha-rounds | -!(-*)s) return ;; - --root|-!(-*)R) + --root | -!(-*)R) _filedir -d return ;; @@ -22,9 +22,9 @@ _chpasswd() $split && return - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && -complete -F _chpasswd chpasswd + complete -F _chpasswd chpasswd # ex: filetype=sh diff --git a/completions/chromium-browser b/completions/chromium-browser index a26b04f2..9ee98962 100644 --- a/completions/chromium-browser +++ b/completions/chromium-browser @@ -6,7 +6,7 @@ _chromium_browser() _init_completion -s -n : || return case $prev in - --help|--app|--proxy-pac-url|-h) + --help | --app | --proxy-pac-url | -h) return ;; --user-data-dir) @@ -18,18 +18,18 @@ _chromium_browser() *://*) local prefix="${cur%%://*}://" _known_hosts_real -- "${cur#*://}" - COMPREPLY=( "${COMPREPLY[@]/#/$prefix}" ) + COMPREPLY=("${COMPREPLY[@]/#/$prefix}") __ltrim_colon_completions "$cur" ;; *) compopt -o nospace - COMPREPLY=( $(compgen -S :// -W 'http socks socks4 socks5' -- "$cur") ) + COMPREPLY=($(compgen -S :// -W 'http socks socks4 socks5' -- "$cur")) ;; esac return ;; --password-store) - COMPREPLY=( $(compgen -W 'basic gnome kwallet' -- "$cur") ) + COMPREPLY=($(compgen -W 'basic gnome kwallet' -- "$cur")) return ;; esac @@ -37,14 +37,14 @@ _chromium_browser() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi - _filedir "@(?([mxs])htm?(l)|pdf)" + _filedir "@(?([mxs])htm?(l)|pdf|txt)" } && -complete -F _chromium_browser chromium-browser google-chrome \ - google-chrome-stable chromium chrome + complete -F _chromium_browser chromium-browser google-chrome \ + google-chrome-stable chromium chrome # ex: filetype=sh diff --git a/completions/chronyc b/completions/chronyc index a59746aa..e6bb8e9d 100644 --- a/completions/chronyc +++ b/completions/chronyc @@ -2,12 +2,13 @@ _chronyc_command_args() { - local -a args=( $(compgen -W "$($1 help 2>/dev/null | \ - awk '/^'$prev'\s[^ []/ { gsub("\\|", " ", $2); print $2 }')") ) + local -a args + args=($(compgen -W "$($1 help 2>/dev/null | + awk '/^'$prev'\s[^ []/ { gsub("\\|", " ", $2); print $2 }')")) case $args in \) _known_hosts_real -- "$cur" ;; \<*) ;; - *) COMPREPLY+=( $(compgen -W '${args[@]}' -- "$cur") ) ;; + *) COMPREPLY+=($(compgen -W '${args[@]}' -- "$cur")) ;; esac } @@ -17,7 +18,7 @@ _chronyc() _init_completion || return case $prev in - --help|-*p) + --help | -*p) return ;; -*h) @@ -27,26 +28,27 @@ _chronyc() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1") -6' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_usage "$1") -6' -- "$cur")) return fi - local i args=0 - for (( i=1; i < cword; i++ )); do - [[ ${words[i]} != -* && ${words[i-1]} != @(-p|-h) ]] && (( args++ )) + local i args + args=0 + for ((i = 1; i < cword; i++)); do + [[ ${words[i]} != -* && ${words[i - 1]} != @(-p|-h) ]] && ((args++)) done case $args in 0) - COMPREPLY=( $(compgen -W "$($1 help 2>/dev/null | \ + COMPREPLY=($(compgen -W "$($1 help 2>/dev/null | awk '!/(^ |: *$)/ { sub("\\|", " ", $1); print $1 }')" \ - -- "$cur") ) + -- "$cur")) ;; 1) _chronyc_command_args "$1" - if [[ ! $COMPREPLY && $prev == sources?(tats) ]]; then + if [[ ! ${COMPREPLY-} && $prev == sources?(tats) ]]; then # [-v] not handled by _chronyc_command_args yet - COMPREPLY=( $(compgen -W '-v' -- "$cur") ) + COMPREPLY=($(compgen -W '-v' -- "$cur")) fi ;; 2) @@ -54,6 +56,6 @@ _chronyc() ;; esac } && -complete -F _chronyc chronyc + complete -F _chronyc chronyc # ex: filetype=sh diff --git a/completions/chrpath b/completions/chrpath index bcd0f91d..2883967b 100644 --- a/completions/chrpath +++ b/completions/chrpath @@ -6,22 +6,22 @@ _chrpath() _init_completion || return case $prev in - --version|--help|-!(-*)[vh]) + --version | --help | -!(-*)[vh]) return ;; - --replace|-!(-*)r) + --replace | -!(-*)r) _filedir -d return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi _filedir } && -complete -F _chrpath chrpath + complete -F _chrpath chrpath # ex: filetype=sh diff --git a/completions/cksfv b/completions/cksfv index 89ccc7b7..da404dda 100644 --- a/completions/cksfv +++ b/completions/cksfv @@ -5,13 +5,13 @@ _cksfv() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if ((cword == 1)); then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi case "$prev" in - -*C|-*g) + -*C | -*g) _filedir -d return ;; @@ -24,6 +24,6 @@ _cksfv() _filedir } && -complete -F _cksfv cksfv + complete -F _cksfv cksfv # ex: filetype=sh diff --git a/completions/cleanarch b/completions/cleanarch index 5e57e5be..0f7d5f57 100644 --- a/completions/cleanarch +++ b/completions/cleanarch @@ -5,12 +5,12 @@ _cleanarch() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--status --dry-run --quiet --help' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--status --dry-run --quiet --help' \ + -- "$cur")) fi } && -complete -F _cleanarch cleanarch + complete -F _cleanarch cleanarch # ex: filetype=sh diff --git a/completions/clisp b/completions/clisp index f9ccfbb8..c4259a00 100644 --- a/completions/clisp +++ b/completions/clisp @@ -8,15 +8,15 @@ _clisp() _init_completion || 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 + 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") ) + -c -l -o -x ' -- "$cur")) else _filedir fi } && -complete -F _clisp -o default clisp + complete -F _clisp -o default clisp # ex: filetype=sh diff --git a/completions/clone_member b/completions/clone_member index 5a0797fe..a3ca2b31 100644 --- a/completions/clone_member +++ b/completions/clone_member @@ -6,7 +6,7 @@ _clone_member() _init_completion -s || return case $prev in - -l|--listname) + -l | --listname) _xfunc list_lists _mailman_lists return ;; @@ -14,12 +14,12 @@ _clone_member() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--listname --remove --admin --quiet - --nomodify --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--listname --remove --admin --quiet + --nomodify --help' -- "$cur")) fi } && -complete -F _clone_member clone_member + complete -F _clone_member clone_member # ex: filetype=sh diff --git a/completions/complete b/completions/complete index 0519744d..a57f366f 100644 --- a/completions/complete +++ b/completions/complete @@ -7,43 +7,43 @@ _complete() case $prev in -*o) - COMPREPLY=( $(compgen -W 'bashdefault default dirnames filenames - nospace plusdirs' -- "$cur") ) + COMPREPLY=($(compgen -W 'bashdefault default dirnames filenames + nospace plusdirs' -- "$cur")) return ;; -*A) - COMPREPLY=( $(compgen -W 'alias arrayvar binding builtin command + COMPREPLY=($(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' -- "$cur")) return ;; -*C) - COMPREPLY=( $(compgen -A command -- "$cur") ) + COMPREPLY=($(compgen -A command -- "$cur")) return ;; -*F) - COMPREPLY=( $(compgen -A function -- "$cur") ) + COMPREPLY=($(compgen -A function -- "$cur")) return ;; - -*p|-*r) - COMPREPLY=( $(complete -p | command sed -e 's|.* ||') ) - COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) + -*p | -*r) + COMPREPLY=($(complete -p | command sed -e 's|.* ||')) + COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then + 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") ) + COMPREPLY=($(compgen -W "$opts" -- "$cur")) else - COMPREPLY=( $(compgen -A command -- "$cur") ) + COMPREPLY=($(compgen -A command -- "$cur")) fi } && -complete -F _complete compgen complete + complete -F _complete compgen complete # ex: filetype=sh diff --git a/completions/config_list b/completions/config_list index f86263d7..1807e338 100644 --- a/completions/config_list +++ b/completions/config_list @@ -6,7 +6,7 @@ _config_list() _init_completion -s || return case $prev in - -i|-o|--inputfile|--outputfile) + -i | -o | --inputfile | --outputfile) _filedir return ;; @@ -14,14 +14,14 @@ _config_list() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--inputfile --outputfile --checkonly - --verbose --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--inputfile --outputfile --checkonly + --verbose --help' -- "$cur")) else _xfunc list_lists _mailman_lists fi } && -complete -F _config_list config_list + complete -F _config_list config_list # ex: filetype=sh diff --git a/completions/configure b/completions/configure index 726c7bda..3f59a012 100644 --- a/completions/configure +++ b/completions/configure @@ -6,15 +6,15 @@ _configure() _init_completion -s || return case $prev in - -h|--help|-V|--version|--program-prefix|--program-suffix|\ - --program-transform-name) + -h | --help | -V | --version | --program-prefix | --program-suffix | \ + --program-transform-name) return ;; --*file) _filedir return ;; - --*prefix|--*dir) + --*prefix | --*dir) _filedir -d return ;; @@ -24,19 +24,19 @@ _configure() # if $COMP_CONFIGURE_HINTS is not null, then completions of the form # --option=SETTING will include 'SETTING' as a contextual hint - [[ "$cur" != -* ]] && return + [[ $cur != -* ]] && return - if [[ -n $COMP_CONFIGURE_HINTS ]]; then - COMPREPLY=( $(compgen -W "$($1 --help 2>&1 | \ + 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") ) - [[ $COMPREPLY == *=* ]] && compopt -o nospace + -- "$cur")) + [[ ${COMPREPLY-} == *=* ]] && compopt -o nospace else - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _configure configure + complete -F _configure configure # ex: filetype=sh diff --git a/completions/convert b/completions/convert index 3ebfc5e9..ef7baea9 100644 --- a/completions/convert +++ b/completions/convert @@ -4,122 +4,122 @@ _ImageMagick() { case $prev in -channel) - COMPREPLY=( $(compgen -W 'Red Green Blue Opacity Matte Cyan - Magenta Yellow Black' -- "$cur") ) + COMPREPLY=($(compgen -W 'Red Green Blue Opacity Matte Cyan + Magenta Yellow Black' -- "$cur")) return ;; -colormap) - COMPREPLY=( $(compgen -W 'shared private' -- "$cur") ) + COMPREPLY=($(compgen -W 'shared private' -- "$cur")) return ;; -colorspace) - COMPREPLY=( $(compgen -W 'GRAY OHTA RGB Transparent XYZ YCbCr YIQ - YPbPr YUV CMYK' -- "$cur") ) + COMPREPLY=($(compgen -W 'GRAY OHTA RGB Transparent XYZ YCbCr YIQ + YPbPr YUV CMYK' -- "$cur")) return ;; -compose) - COMPREPLY=( $(compgen -W 'Over In Out Atop Xor Plus Minus Add + COMPREPLY=($(compgen -W 'Over In Out Atop Xor Plus Minus Add Subtract Difference Multiply Bumpmap Copy CopyRed CopyGreen - CopyBlue CopyOpacity' -- "$cur") ) + CopyBlue CopyOpacity' -- "$cur")) return ;; -compress) - COMPREPLY=( $(compgen -W 'None BZip Fax Group4 JPEG Lossless LZW - RLE Zip' -- "$cur") ) + COMPREPLY=($(compgen -W 'None BZip Fax Group4 JPEG Lossless LZW + RLE Zip' -- "$cur")) return ;; -dispose) - COMPREPLY=( $(compgen -W 'Undefined None Background Previous' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'Undefined None Background Previous' \ + -- "$cur")) return ;; -encoding) - COMPREPLY=( $(compgen -W 'AdobeCustom AdobeExpert AdobeStandard + COMPREPLY=($(compgen -W 'AdobeCustom AdobeExpert AdobeStandard AppleRoman BIG5 GB2312 Latin2 None SJIScode Symbol Unicode - Wansung' -- "$cur") ) + Wansung' -- "$cur")) return ;; -endian) - COMPREPLY=( $(compgen -W 'MSB LSB' -- "$cur") ) + COMPREPLY=($(compgen -W 'MSB LSB' -- "$cur")) return ;; -filter) - COMPREPLY=( $(compgen -W 'Point Box Triangle Hermite Hanning + COMPREPLY=($(compgen -W 'Point Box Triangle Hermite Hanning Hamming Blackman Gaussian Quadratic Cubic Catrom Mitchell - Lanczos Bessel Sinc' -- "$cur") ) + Lanczos Bessel Sinc' -- "$cur")) return ;; -format) - COMPREPLY=( $(compgen -W "$(convert -list format | awk \ + COMPREPLY=($(compgen -W "$(convert -list format | awk \ '/ [r-][w-][+-] / { sub("[*]$","",$1); print tolower($1) }')" \ - -- "$cur") ) + -- "$cur")) return ;; -gravity) - COMPREPLY=( $(compgen -W 'Northwest North NorthEast West Center - East SouthWest South SouthEast' -- "$cur") ) + COMPREPLY=($(compgen -W 'Northwest North NorthEast West Center + East SouthWest South SouthEast' -- "$cur")) return ;; -intent) - COMPREPLY=( $(compgen -W 'Absolute Perceptual Relative - Saturation' -- "$cur") ) + COMPREPLY=($(compgen -W 'Absolute Perceptual Relative + Saturation' -- "$cur")) return ;; -interlace) - COMPREPLY=( $(compgen -W 'None Line Plane Partition' -- "$cur") ) + COMPREPLY=($(compgen -W 'None Line Plane Partition' -- "$cur")) return ;; -limit) - COMPREPLY=( $(compgen -W 'Disk File Map Memory' -- "$cur") ) + COMPREPLY=($(compgen -W 'Disk File Map Memory' -- "$cur")) return ;; -list) - COMPREPLY=( $(compgen -W 'Delegate Format Magic Module Resource - Type' -- "$cur") ) + COMPREPLY=($(compgen -W 'Delegate Format Magic Module Resource + Type' -- "$cur")) return ;; -map) - COMPREPLY=( $(compgen -W 'best default gray red green blue' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'best default gray red green blue' \ + -- "$cur")) _filedir return ;; -noise) - COMPREPLY=( $(compgen -W 'Uniform Gaussian Multiplicative - Impulse Laplacian Poisson' -- "$cur") ) + COMPREPLY=($(compgen -W 'Uniform Gaussian Multiplicative + Impulse Laplacian Poisson' -- "$cur")) return ;; -preview) - COMPREPLY=( $(compgen -W 'Rotate Shear Roll Hue Saturation + 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") ) + CharcoalDrawing JPEG' -- "$cur")) return ;; - -mask|-profile|-texture|-tile|-write) + -mask | -profile | -texture | -tile | -write) _filedir return ;; -type) - COMPREPLY=( $(compgen -W 'Bilevel Grayscale Palette PaletteMatte + COMPREPLY=($(compgen -W 'Bilevel Grayscale Palette PaletteMatte TrueColor TrueColorMatte ColorSeparation ColorSeparationlMatte - Optimize' -- "$cur") ) + Optimize' -- "$cur")) return ;; -units) - COMPREPLY=( $(compgen -W 'Undefined PixelsPerInch - PixelsPerCentimeter' -- "$cur") ) + COMPREPLY=($(compgen -W 'Undefined PixelsPerInch + PixelsPerCentimeter' -- "$cur")) return ;; -virtual-pixel) - COMPREPLY=( $(compgen -W 'Constant Edge mirror tile' -- "$cur") ) + COMPREPLY=($(compgen -W 'Constant Edge mirror tile' -- "$cur")) return ;; -visual) - COMPREPLY=( $(compgen -W 'StaticGray GrayScale StaticColor + COMPREPLY=($(compgen -W 'StaticGray GrayScale StaticColor PseudoColor TrueColor DirectColor defaut visualid' \ - -- "$cur") ) + -- "$cur")) return ;; esac @@ -134,17 +134,17 @@ _convert() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+adjoin +append +compress +contrast +debug + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + 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") ) + +page +raise +render +write' -- "$cur")) else _filedir fi } && -complete -F _convert convert + complete -F _convert convert _mogrify() { @@ -153,16 +153,16 @@ _mogrify() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+compress +contrast +debug +dither +endian - +gamma +label +map +mask +matte +negate +page +raise' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+compress +contrast +debug +dither +endian + +gamma +label +map +mask +matte +negate +page +raise' -- "$cur")) else _filedir fi } && -complete -F _mogrify mogrify + complete -F _mogrify mogrify _display() { @@ -171,16 +171,16 @@ _display() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+compress +contrast +debug +dither +endian - +gamma +label +map +matte +negate +page +raise +write' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+compress +contrast +debug +dither +endian + +gamma +label +map +matte +negate +page +raise +write' -- "$cur")) else _filedir fi } && -complete -F _display display + complete -F _display display _animate() { @@ -189,16 +189,16 @@ _animate() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+debug +dither +gamma +map +matte' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+debug +dither +gamma +map +matte' \ + -- "$cur")) else _filedir fi } && -complete -F _animate animate + complete -F _animate animate _identify() { @@ -207,15 +207,15 @@ _identify() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+debug' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+debug' -- "$cur")) else _filedir fi } && -complete -F _identify identify + complete -F _identify identify _montage() { @@ -224,16 +224,16 @@ _montage() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+adjoin +compress +debug +dither +endian - +gamma +label +matte +page' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+adjoin +compress +debug +dither +endian + +gamma +label +matte +page' -- "$cur")) else _filedir fi } && -complete -F _montage montage + complete -F _montage montage _composite() { @@ -242,16 +242,16 @@ _composite() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+compress +debug +dither +endian +label - +matte +negate +page +write' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+compress +debug +dither +endian +label + +matte +negate +page +write' -- "$cur")) else _filedir fi } && -complete -F _composite composite + complete -F _composite composite _compare() { @@ -260,15 +260,15 @@ _compare() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+debug' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+debug' -- "$cur")) else _filedir fi } && -complete -F _compare compare + complete -F _compare compare _conjure() { @@ -277,15 +277,15 @@ _conjure() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+debug' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+debug' -- "$cur")) else _filedir fi } && -complete -F _conjure conjure + complete -F _conjure conjure _import() { @@ -294,15 +294,15 @@ _import() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+debug' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+debug' -- "$cur")) else _filedir fi } && -complete -F _import import + complete -F _import import _stream() { @@ -311,14 +311,14 @@ _stream() _ImageMagick && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - elif [[ "$cur" == +* ]]; then - COMPREPLY=( $(compgen -W '+debug' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + elif [[ $cur == +* ]]; then + COMPREPLY=($(compgen -W '+debug' -- "$cur")) else _filedir fi } && -complete -F _stream stream + complete -F _stream stream # ex: filetype=sh diff --git a/completions/cowsay b/completions/cowsay index c6cbf813..6ba1d0fb 100644 --- a/completions/cowsay +++ b/completions/cowsay @@ -7,17 +7,17 @@ _cowsay() case $prev in -f) - COMPREPLY=( $(compgen -W \ - '$(cowsay -l 2>/dev/null | tail -n +2)' -- "$cur") ) + COMPREPLY=($(compgen -W \ + '$(cowsay -l 2>/dev/null | tail -n +2)' -- "$cur")) return ;; esac # relevant options completion - COMPREPLY=( $(compgen -W '-b -d -g -p -s -t -w -y -e -f -h -l -n -T -W' \ - -- "$cur") ) + COMPREPLY=($(compgen -W '-b -d -g -p -s -t -w -y -e -f -h -l -n -T -W' \ + -- "$cur")) } && -complete -F _cowsay -o default cowsay cowthink + complete -F _cowsay -o default cowsay cowthink # ex: filetype=sh diff --git a/completions/cpan2dist b/completions/cpan2dist index b24e068c..b5e59dae 100644 --- a/completions/cpan2dist +++ b/completions/cpan2dist @@ -8,30 +8,30 @@ _cpan2dist() case $prev in --format) # should remove ":" from COMP_WORDBREAKS, but doesn't work (?) - COMPREPLY=( $(compgen -W '$(perl -MCPANPLUS::Dist -e \ + COMPREPLY=($(compgen -W '$(perl -MCPANPLUS::Dist -e \ "print map { \"\$_\n\" } CPANPLUS::Dist->dist_types")' \ - -- "$cur") ) + -- "$cur")) return ;; - --banlist|--ignorelist|--modulelist|--logfile) + --banlist | --ignorelist | --modulelist | --logfile) _filedir return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else - local cpandirs=( "$HOME/.cpanplus/" "$HOME/.cpan/source/modules/" ) + local cpandirs=("$HOME/.cpanplus/" "$HOME/.cpan/source/modules/") local packagelist for dir in "${cpandirs[@]}"; do - [[ -d "$dir" && -r "$dir/02packages.details.txt.gz" ]] && \ + [[ -d $dir && -r "$dir/02packages.details.txt.gz" ]] && packagelist="$dir/02packages.details.txt.gz" done - [[ $packagelist ]] && COMPREPLY=( $(zgrep "^${cur//-/::}" \ - $packagelist 2>/dev/null | awk '{print $1}' | command sed -e 's/::/-/g') ) + [[ -v packagelist ]] && COMPREPLY=($(zgrep "^${cur//-/::}" \ + $packagelist 2>/dev/null | awk '{print $1}' | command sed -e 's/::/-/g')) fi } && -complete -F _cpan2dist -o default cpan2dist + complete -F _cpan2dist -o default cpan2dist # ex: filetype=sh diff --git a/completions/cpio b/completions/cpio index bbb1ecf9..d6fde0c3 100644 --- a/completions/cpio +++ b/completions/cpio @@ -7,46 +7,46 @@ _cpio() # --name value style option case $prev in - --format|-!(-*)H) - COMPREPLY=( $(compgen -W \ - 'bin odc newc crc tar ustar hpbin hpodc' -- "$cur") ) + --format | -!(-*)H) + COMPREPLY=($(compgen -W \ + 'bin odc newc crc tar ustar hpbin hpodc' -- "$cur")) return ;; - --file|--pattern-file|-!(-*)[EFI]) + --file | --pattern-file | -!(-*)[EFI]) _filedir return ;; - --owner|-!(-*)R) + --owner | -!(-*)R) _usergroup return ;; --rsh-command) compopt -o filenames - COMPREPLY=( $(compgen -c -- "$cur") ) + COMPREPLY=($(compgen -c -- "$cur")) return ;; esac $split && return - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W '-o --create -i --extract -p --pass-through - -? --help --license --usage --version' -- "$cur") ) + if ((cword == 1)); then + COMPREPLY=($(compgen -W '-o --create -i --extract -p --pass-through + -? --help --license --usage --version' -- "$cur")) 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 | --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") ) + -- "$cur")) fi ;; - -i|--extract) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-b -c -d -f -m -n -r -t -s -u -v + -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 --nonmatching --preserve-modification-time --numeric-uid-gid --rename --list --swap-bytes --swap @@ -55,17 +55,17 @@ _cpio() --owner --no-preserve-owner --message --force-local --no-absolute-filenames --sparse --only-verify-crc --quiet --rsh-command --help --to-stdout --version' \ - -- "$cur") ) + -- "$cur")) fi ;; - -p*|--pass-through) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-0 -a -d -l -m -u -v -L -V -R + -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") ) + -- "$cur")) else _filedir -d fi @@ -73,6 +73,6 @@ _cpio() esac fi } && -complete -F _cpio cpio + complete -F _cpio cpio # ex: filetype=sh diff --git a/completions/cppcheck b/completions/cppcheck index ebc3ba3b..8ea95715 100644 --- a/completions/cppcheck +++ b/completions/cppcheck @@ -6,36 +6,36 @@ _cppcheck() _init_completion -s || return case $prev in - --append|--exitcode-suppressions|--rule-file|--config-excludes-file|\ - --suppressions-list|--includes-file|--include|-i) + --append | --exitcode-suppressions | --rule-file | --config-excludes-file | \ + --suppressions-list | --includes-file | --include | -i) _filedir return ;; - -D|-U|--rule|--suppress|--template|--max-configs|-h|--help|--version|\ - --errorlist|--config-exclude|-l) + -D | -U | --rule | --suppress | --template | --max-configs | -h | --help | --version | \ + --errorlist | --config-exclude | -l) return ;; --enable) # split comma-separated list split=false - if [[ "$cur" == ?*,* ]]; then + if [[ $cur == ?*,* ]]; then prev="${cur%,*}" cur="${cur##*,}" split=true fi - COMPREPLY=( $(compgen -W 'all warning style performance + COMPREPLY=($(compgen -W 'all warning style performance portability information unusedFunction missingInclude' \ - -- "$cur") ) - $split && COMPREPLY=( ${COMPREPLY[@]/#/"$prev,"} ) + -- "$cur")) + $split && COMPREPLY=(${COMPREPLY[@]/#/"$prev,"}) return ;; --error-exitcode) - COMPREPLY=( $(compgen -W '{0..255}' -- "$cur") ) + COMPREPLY=($(compgen -W '{0..255}' -- "$cur")) return ;; --file-list) _filedir - [[ -z $cur || $cur == - ]] && COMPREPLY+=( - ) + [[ -z $cur || $cur == - ]] && COMPREPLY+=(-) return ;; -I) @@ -43,25 +43,25 @@ _cppcheck() return ;; -j) - COMPREPLY=( $(compgen -W "{2..$(_ncpus)}" -- "$cur") ) + COMPREPLY=($(compgen -W "{2..$(_ncpus)}" -- "$cur")) return ;; - --language|-x) - COMPREPLY=( $(compgen -W 'c c++' -- "$cur") ) + --language | -x) + COMPREPLY=($(compgen -W 'c c++' -- "$cur")) return ;; --std) - COMPREPLY=( $(compgen -W 'c89 c99 c11 c++03 c++11 c++14 c++17 - c++20' -- "$cur") ) + COMPREPLY=($(compgen -W 'c89 c99 c11 c++03 c++11 c++14 c++17 + c++20' -- "$cur")) return ;; --platform) _filedir - COMPREPLY+=( $(compgen -W 'unix32 unix64 win32A win32W win64 - native' -- "$cur") ) + COMPREPLY+=($(compgen -W 'unix32 unix64 win32A win32W win64 + native' -- "$cur")) return ;; - -rp|--relative-paths) + -rp | --relative-paths) if $split; then # -rp without argument is allowed _filedir -d return @@ -72,7 +72,7 @@ _cppcheck() return ;; --xml-version) - COMPREPLY=( $(compgen -W '1 2' -- "$cur") ) + COMPREPLY=($(compgen -W '1 2' -- "$cur")) return ;; esac @@ -80,12 +80,12 @@ _cppcheck() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _filedir '@([cht]pp|[cht]xx|cc|[ch]++|[ch])' fi } && -complete -F _cppcheck cppcheck + complete -F _cppcheck cppcheck # ex: filetype=sh diff --git a/completions/crontab b/completions/crontab index a5e5cc58..cac78533 100644 --- a/completions/crontab +++ b/completions/crontab @@ -12,13 +12,13 @@ _crontab() ;; esac - local -A opts=( [-u]= [-l]= [-r]= [-e]= ) + local -A opts=([-u]="" [-l]="" [-r]="" [-e]="") [[ $OSTYPE == *linux* ]] && opts[-i]= [[ -d /sys/fs/selinux || -d /selinux ]] && opts[-s]= local i - for (( i=0; i < ${#words[@]}-1; i++ )); do - [[ ${words[i]} ]] && unset "opts[${words[i]}]" + for i in "${!words[@]}"; do + [[ ${words[i]} && $i -ne $cword ]] && unset "opts[${words[i]}]" case "${words[i]}" in -l) unset 'opts[-r]' 'opts[-e]' 'opts[-i]' 'opts[-s]' @@ -35,14 +35,14 @@ _crontab() esac done - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '${!opts[@]}' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '${!opts[@]}' -- "$cur")) return fi # do filenames only if we did not have -l, -r, or -e - [[ "${words[*]}" == *\ -[lre]* ]] || _filedir + [[ ${words[*]} == *\ -[lre]* ]] || _filedir } && -complete -F _crontab crontab + complete -F _crontab crontab # ex: filetype=sh diff --git a/completions/cryptsetup b/completions/cryptsetup index f8be116f..e73e165e 100644 --- a/completions/cryptsetup +++ b/completions/cryptsetup @@ -2,7 +2,7 @@ _cryptsetup_name() { - COMPREPLY=( $(compgen -X control -W '$(command ls /dev/mapper)' -- "$cur") ) + COMPREPLY=($(compgen -X control -W '$(command ls /dev/mapper)' -- "$cur")) } _cryptsetup_device() @@ -17,16 +17,16 @@ _cryptsetup() _init_completion -s || return case $prev in - --help|--version|--cipher|--hash|--*-size|--key-slot|--size|--offset|\ - --skip|--iter-time|--timeout|--tries|-!(-*)[chslSbopitT]) + --help | --version | --cipher | --hash | --*-size | --key-slot | --size | --offset | \ + --skip | --iter-time | --timeout | --tries | -!(-*)[chslSbopitT]) return ;; - --key-file|--master-key-file|--header-backup-file|-!(-*)d) + --key-file | --master-key-file | --header-backup-file | -!(-*)d) _filedir return ;; - --type|-!(-*)M) - COMPREPLY=( $(compgen -W "luks plain loopaes tcrypt" -- "$cur") ) + --type | -!(-*)M) + COMPREPLY=($(compgen -W "luks plain loopaes tcrypt" -- "$cur")) return ;; esac @@ -36,19 +36,20 @@ _cryptsetup() local arg _get_first_arg if [[ -z $arg ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else - COMPREPLY=( $(compgen -W 'open close resize status benchmark + COMPREPLY=($(compgen -W 'open close resize status benchmark repair erase luksFormat luksAddKey luksRemoveKey luksChangeKey luksKillSlot luksUUID isLuks luksDump tcryptDump luksSuspend - luksResume luksHeaderBackup luksHeaderRestore' -- "$cur") ) + luksResume luksHeaderBackup luksHeaderRestore' -- "$cur")) fi else - local args; _count_args "" "-!(-*)[chslSbopitTdM]" + local args + _count_args "" "-!(-*)[chslSbopitTdM]" case $arg in - open|create|luksOpen|loopaesOpen|tcryptOpen) + open | create | luksOpen | loopaesOpen | tcryptOpen) case $args in 2) _cryptsetup_device @@ -58,15 +59,15 @@ _cryptsetup() ;; esac ;; - close|remove|luksClose|loopaesClose|tcryptClose|status|resize|\ - luksSuspend|luksResume) + close | remove | luksClose | loopaesClose | tcryptClose | status | resize | \ + luksSuspend | luksResume) case $args in 2) _cryptsetup_name ;; esac ;; - luksFormat|luksAddKey|luksRemoveKey) + luksFormat | luksAddKey | luksRemoveKey | luksChangeKey) case $args in 2) _cryptsetup_device @@ -76,27 +77,27 @@ _cryptsetup() ;; esac ;; - luksKillSlot|luksDelKey|luksUUID|isLuks|luksDump) + luksKillSlot | luksDelKey | luksUUID | isLuks | luksDump) case $args in 2) _cryptsetup_device ;; esac ;; - luksHeaderBackup|luksHeaderRestore) + luksHeaderBackup | luksHeaderRestore) case $args in 2) _cryptsetup_device ;; 3) - COMPREPLY=( '--header-backup-file' ) + COMPREPLY=('--header-backup-file') ;; - esac + esac ;; esac fi } && -complete -F _cryptsetup cryptsetup + complete -F _cryptsetup cryptsetup # ex: filetype=sh diff --git a/completions/curl b/completions/curl index d744e49a..6e842697 100644 --- a/completions/curl +++ b/completions/curl @@ -6,24 +6,24 @@ _curl() _init_completion || return 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]) - return - ;; - --config|--cookie|--cookie-jar|--dump-header|--egd-file|\ - --key|--libcurl|--output|--random-file|--upload-file|--trace|\ - --trace-ascii|--netrc-file|-!(-*)[KbcDoT]) + --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]) + return + ;; + --config | --cookie | --cookie-jar | --dump-header | --egd-file | \ + --key | --libcurl | --output | --random-file | --upload-file | --trace | \ + --trace-ascii | --netrc-file | -!(-*)[KbcDoT]) _filedir return ;; - --cacert|--cert|-!(-*)E) + --cacert | --cert | -!(-*)E) _filedir '@(c?(e)rt|cer|pem|der)' return ;; @@ -31,47 +31,47 @@ _curl() _filedir -d return ;; - --cert-type|--key-type) - COMPREPLY=( $(compgen -W 'DER PEM ENG' -- "$cur") ) + --cert-type | --key-type) + COMPREPLY=($(compgen -W 'DER PEM ENG' -- "$cur")) return ;; --crlfile) _filedir crl return ;; - --data|--data-ascii|--data-binary|--data-urlencode|-!(-*)d) + --data | --data-ascii | --data-binary | --data-urlencode | -!(-*)d) if [[ $cur == \@* ]]; then cur=${cur:1} _filedir - if [[ ${#COMPREPLY[@]} -eq 1 && -d "${COMPREPLY[0]}" ]]; then + if [[ ${#COMPREPLY[@]} -eq 1 && -d ${COMPREPLY[0]} ]]; then COMPREPLY[0]+=/ compopt -o nospace fi - COMPREPLY=( "${COMPREPLY[@]/#/@}" ) + COMPREPLY=("${COMPREPLY[@]/#/@}") fi return ;; --delegation) - COMPREPLY=( $(compgen -W 'none policy always' -- "$cur") ) + COMPREPLY=($(compgen -W 'none policy always' -- "$cur")) return ;; --engine) - COMPREPLY=( $(compgen -W 'list' -- "$cur") ) + COMPREPLY=($(compgen -W 'list' -- "$cur")) return ;; --ftp-method) - COMPREPLY=( $(compgen -W 'multicwd nocwd singlecwd' -- "$cur") ) + COMPREPLY=($(compgen -W 'multicwd nocwd singlecwd' -- "$cur")) return ;; --ftp-ssl-ccc-mode) - COMPREPLY=( $(compgen -W 'active passive' -- "$cur") ) + COMPREPLY=($(compgen -W 'active passive' -- "$cur")) return ;; --interface) _available_interfaces -a return ;; - --proxy|--socks4|--socks4a|--socks5|--socks5-hostname|-!(-*)x) + --proxy | --socks4 | --socks4a | --socks5 | --socks5-hostname | -!(-*)x) _known_hosts_real -- "$cur" return ;; @@ -80,20 +80,20 @@ _curl() return ;; --stderr) - COMPREPLY=( $(compgen -W '-' -- "$cur") ) + COMPREPLY=($(compgen -W '-' -- "$cur")) _filedir return ;; --tlsauthtype) - COMPREPLY=( $(compgen -W 'SRP' -- "$cur") ) + COMPREPLY=($(compgen -W 'SRP' -- "$cur")) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) fi } && -complete -F _curl curl + complete -F _curl curl # ex: filetype=sh diff --git a/completions/cvs b/completions/cvs index 0fb49f9c..ba1f0622 100644 --- a/completions/cvs +++ b/completions/cvs @@ -4,9 +4,9 @@ _cvs_entries() { local prefix=${cur%/*}/ IFS=$'\n' [[ -e ${prefix:-}CVS/Entries ]] || prefix="" - entries=( $(cut -d/ -f2 -s ${prefix:-}CVS/Entries 2>/dev/null) ) + entries=($(cut -d/ -f2 -s ${prefix:-}CVS/Entries 2>/dev/null)) if [[ $entries ]]; then - entries=( "${entries[@]/#/${prefix:-}}" ) + entries=("${entries[@]/#/${prefix:-}}") compopt -o filenames fi } @@ -14,9 +14,9 @@ _cvs_entries() _cvs_modules() { if [[ -n $prefix ]]; then - COMPREPLY=( $(command ls -d ${cvsroot}/${prefix}/!(CVSROOT)) ) + COMPREPLY=($(command ls -d ${cvsroot}/${prefix}/!(CVSROOT))) else - COMPREPLY=( $(command ls -d ${cvsroot}/!(CVSROOT)) ) + COMPREPLY=($(command ls -d ${cvsroot}/!(CVSROOT))) fi } @@ -27,21 +27,21 @@ _cvs_commands() _cvs_command_options() { - COMPREPLY=( $(compgen -W '$(_parse_help "$1" "--help $2")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1" "--help $2")' -- "$cur")) } _cvs_kflags() { - COMPREPLY=( $(compgen -W 'kv kvl k o b v' -- "$cur") ) + COMPREPLY=($(compgen -W 'kv kvl k o b v' -- "$cur")) } _cvs_roots() { local -a cvsroots - cvsroots=( $CVSROOT ) - [[ -r ~/.cvspass ]] && cvsroots+=( $(awk '{ print $2 }' ~/.cvspass) ) + [[ -v CVSROOT ]] && cvsroots=("$CVSROOT") + [[ -r ~/.cvspass ]] && cvsroots+=($(awk '{ print $2 }' ~/.cvspass)) [[ -r CVS/Root ]] && mapfile -tO ${#cvsroots[@]} cvsroots /dev/null) ) + [[ -z $cur ]] && files=(!(CVS)) || + files=($(command ls -d ${cur}* 2>/dev/null)) local f for i in "${!files[@]}"; do if [[ ${files[i]} == ?(*/)CVS ]]; then unset 'files[i]' else for f in "${entries[@]}"; do - if [[ ${files[i]} == $f && ! -d $f ]]; then + if [[ ${files[i]} == "$f" && ! -d $f ]]; then unset 'files[i]' break fi done fi done - COMPREPLY=( $(compgen -X "$_backup_glob" -W '${files[@]}' \ - -- "$cur") ) + COMPREPLY=($(compgen -X "$_backup_glob" -W '${files[@]}' \ + -- "$cur")) else _cvs_command_options "$1" $mode fi @@ -189,21 +189,21 @@ _cvs() ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then _cvs_command_options "$1" $mode else _cvs_entries - COMPREPLY=( $(compgen -W '${entries[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${entries[@]}' -- "$cur")) fi ;; annotate) - [[ "$prev" == -[rD] ]] && return + [[ $prev == -[rD] ]] && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then _cvs_command_options "$1" $mode else _cvs_entries - COMPREPLY=( $(compgen -W '${entries[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${entries[@]}' -- "$cur")) fi ;; checkout) @@ -222,11 +222,11 @@ _cvs() ;; esac - if [[ "$cur" != -* ]]; then - [[ -z $cvsroot ]] && cvsroot=$CVSROOT - COMPREPLY=( $(cvs -d "$cvsroot" co -c 2>/dev/null | \ - awk '{print $1}') ) - COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) + if [[ $cur != -* ]]; then + [[ ! -v cvsroot ]] && cvsroot=${CVSROOT-} + COMPREPLY=($(cvs -d "$cvsroot" co -c 2>/dev/null | + awk '{print $1}')) + COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur")) else _cvs_command_options "$1" $mode fi @@ -243,7 +243,7 @@ _cvs() ;; esac - if [[ "$cur" != -* ]]; then + if [[ $cur != -* ]]; then # if $COMP_CVS_REMOTE is not null, 'cvs commit' will # complete on remotely checked-out files (requires # passwordless access to the remote repository @@ -251,15 +251,15 @@ _cvs() # 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=($(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")) else _cvs_entries - COMPREPLY=( $(compgen -W '${entries[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${entries[@]}' -- "$cur")) fi else _cvs_command_options "$1" $mode @@ -268,21 +268,21 @@ _cvs() cvsroot) _cvs_roots ;; - diff|log) - if [[ "$cur" == -* ]]; then + diff | log) + if [[ $cur == -* ]]; then _cvs_command_options "$1" $mode - [[ $COMPREPLY == *= ]] && compopt -o nospace + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _cvs_entries - COMPREPLY=( $(compgen -W '${entries[@]:-}' -- "$cur") ) + COMPREPLY=($(compgen -W '${entries[@]:-}' -- "$cur")) fi ;; - editors|watchers) - if [[ "$cur" == -* ]]; then + editors | watchers) + if [[ $cur == -* ]]; then _cvs_command_options "$1" $mode else _cvs_entries - COMPREPLY=( $(compgen -W '${entries[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${entries[@]}' -- "$cur")) fi ;; export) @@ -301,10 +301,10 @@ _cvs() ;; esac - if [[ "$cur" != -* ]]; then - [[ -z $cvsroot ]] && cvsroot=$CVSROOT - COMPREPLY=( $(cvs -d "$cvsroot" co -c | awk '{print $1}') ) - COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) + if [[ $cur != -* ]]; then + [[ ! -v cvsroot ]] && cvsroot=${CVSROOT-} + COMPREPLY=($(cvs -d "$cvsroot" co -c | awk '{print $1}')) + COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur")) else _cvs_command_options "$1" $mode fi @@ -321,32 +321,32 @@ _cvs() ;; esac - if [[ "$cur" != -* ]]; then + if [[ $cur != -* ]]; then # starts with same algorithm as checkout - [[ -z $cvsroot ]] && cvsroot=$CVSROOT + [[ ! -v cvsroot ]] && cvsroot=${CVSROOT-} local prefix=${cur%/*} if [[ -r ${cvsroot}/${prefix} ]]; then _cvs_modules - COMPREPLY=( ${COMPREPLY[@]#$cvsroot} ) - COMPREPLY=( ${COMPREPLY[@]#\/} ) + COMPREPLY=(${COMPREPLY[@]#$cvsroot}) + COMPREPLY=(${COMPREPLY[@]#\/}) fi pwd=$(pwd) pwd=${pwd##*/} - COMPREPLY=( $(compgen -W '${COMPREPLY[@]} $pwd' -- "$cur") ) + COMPREPLY=($(compgen -W '${COMPREPLY[@]} $pwd' -- "$cur")) else _cvs_command_options "$1" $mode fi ;; remove) - if [[ "$cur" != -* ]]; then + if [[ $cur != -* ]]; then _cvs_entries - if [[ "$prev" != -f ]]; then + 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 'entries[i]' done fi - COMPREPLY=( $(compgen -W '${entries[@]:-}' -- "$cur") ) + COMPREPLY=($(compgen -W '${entries[@]:-}' -- "$cur")) else _cvs_command_options "$1" $mode fi @@ -363,11 +363,11 @@ _cvs() ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then _cvs_command_options "$1" $mode else _cvs_entries - COMPREPLY=( $(compgen -W '${entries[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${entries[@]}' -- "$cur")) fi ;; "") @@ -381,18 +381,18 @@ _cvs() return ;; -*z) - COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..9}' -- "$cur")) return ;; esac - COMPREPLY=( $(compgen -W '$(_cvs_commands) + COMPREPLY=($(compgen -W '$(_cvs_commands) $(_parse_help "$1" --help-options) --help --help-commands - --help-options --version' -- "$cur") ) + --help-options --version' -- "$cur")) ;; esac } && -complete -F _cvs cvs + complete -F _cvs cvs # ex: filetype=sh diff --git a/completions/cvsps b/completions/cvsps index 721a5b73..4fdfefc3 100644 --- a/completions/cvsps +++ b/completions/cvsps @@ -6,27 +6,27 @@ _cvsps() _init_completion -n : || return case $prev in - -h|-z|-f|-d|-l|--diff-opts|--debuglvl) + -h | -z | -f | -d | -l | --diff-opts | --debuglvl) return ;; -s) - COMPREPLY=( $(compgen -W "$($1 2>/dev/null | - awk '/^PatchSet:?[ \t]/ { print $2 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 2>/dev/null | + awk '/^PatchSet:?[ \t]/ { print $2 }')" -- "$cur")) return ;; -a) - COMPREPLY=( $(compgen -W "$($1 2>/dev/null | - awk '/^Author:[ \t]/ { print $2 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 2>/dev/null | + awk '/^Author:[ \t]/ { print $2 }')" -- "$cur")) return ;; -b) - COMPREPLY=( $(compgen -W "$($1 2>/dev/null | - awk '/^Branch:[ \t]/ { print $2 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 2>/dev/null | + awk '/^Branch:[ \t]/ { print $2 }')" -- "$cur")) return ;; -r) - COMPREPLY=( $(compgen -W "$($1 2>/dev/null | - awk '/^Tag:[ \t]+[^(]/ { print $2 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 2>/dev/null | + awk '/^Tag:[ \t]+[^(]/ { print $2 }')" -- "$cur")) return ;; -p) @@ -38,7 +38,7 @@ _cvsps() return ;; -Z) - COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..9}' -- "$cur")) return ;; --root) @@ -47,12 +47,12 @@ _cvsps() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) else _xfunc cvs _cvs_roots fi } && -complete -F _cvsps cvsps + complete -F _cvsps cvsps # ex: filetype=sh diff --git a/completions/dd b/completions/dd index 5384dd5e..04d876a0 100644 --- a/completions/dd +++ b/completions/dd @@ -6,37 +6,37 @@ _dd() _init_completion -n = || return case $cur in - if=*|of=*) + if=* | of=*) cur=${cur#*=} _filedir return ;; conv=*) cur=${cur#*=} - COMPREPLY=( $(compgen -W 'ascii ebcdic ibm block unblock lcase + COMPREPLY=($(compgen -W 'ascii ebcdic ibm block unblock lcase ucase sparse swab sync excl nocreat notrunc noerror fdatasync - fsync' -- "$cur") ) + fsync' -- "$cur")) return ;; - iflag=*|oflag=*) + iflag=* | oflag=*) cur=${cur#*=} - COMPREPLY=( $(compgen -W 'append direct directory dsync sync + COMPREPLY=($(compgen -W 'append direct directory dsync sync fullblock nonblock noatime nocache noctty nofollow count_bytes - skip_bytes seek_bytes' -- "$cur") ) + skip_bytes seek_bytes' -- "$cur")) return ;; status=*) cur=${cur#*=} - COMPREPLY=( $(compgen -W 'none noxfer progress' -- "$cur") ) + COMPREPLY=($(compgen -W 'none noxfer progress' -- "$cur")) 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") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur") + $(compgen -W 'bs cbs conv count ibs if iflag obs of oflag + seek skip status' -S '=' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && -complete -F _dd dd + complete -F _dd dd # ex: filetype=sh diff --git a/completions/deja-dup b/completions/deja-dup index ad3baeb8..1854d6a4 100644 --- a/completions/deja-dup +++ b/completions/deja-dup @@ -6,7 +6,7 @@ _deja_dup() _init_completion -s || return case $prev in - -'?'|--help|--help-*) + -'?' | --help | --help-*) return ;; --restore) @@ -21,12 +21,12 @@ _deja_dup() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi } && -complete -F _deja_dup deja-dup + complete -F _deja_dup deja-dup # ex: filetype=sh diff --git a/completions/desktop-file-validate b/completions/desktop-file-validate index 7d9f05b2..8f4e139d 100644 --- a/completions/desktop-file-validate +++ b/completions/desktop-file-validate @@ -12,12 +12,12 @@ _desktop_file_validate() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi _filedir desktop } && -complete -F _desktop_file_validate desktop-file-validate + complete -F _desktop_file_validate desktop-file-validate # ex: filetype=sh diff --git a/completions/dhclient b/completions/dhclient index b097bbac..ce4b7452 100644 --- a/completions/dhclient +++ b/completions/dhclient @@ -6,11 +6,11 @@ _dhclient() _init_completion || return case $prev in - -p|-e) + -p | -e) return ;; -D) - COMPREPLY=( $(compgen -W 'LL LLT' -- "$cur") ) + COMPREPLY=($(compgen -W 'LL LLT' -- "$cur")) return ;; -*f) @@ -23,12 +23,12 @@ _dhclient() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) else _available_interfaces fi } && -complete -F _dhclient dhclient + complete -F _dhclient dhclient # ex: filetype=sh diff --git a/completions/dict b/completions/dict index c3ea9906..f3426ffd 100644 --- a/completions/dict +++ b/completions/dict @@ -13,35 +13,35 @@ _dict() local host port db i - for (( i=1; i < cword; i++ )); do + for ((i = 1; i < cword; i++)); do case ${words[i]} in - --host|-!(-*)h) + --host | -!(-*)h) host=${words[++i]} [[ -n $host ]] && host="-h $host" ;; - --port|-!(-*)p) + --port | -!(-*)p) port=${words[++i]} [[ -n $port ]] && port="-p $port" ;; - --database|-!(-*)d) + --database | -!(-*)d) db=${words[++i]} [[ -n $db ]] && host="-d $db" ;; esac done - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi case $prev in - --database|-info|-!(-*)[di]) - COMPREPLY=( $(compgen -W '$(_dictdata -D)' -- "$cur") ) + --database | -info | -!(-*)[di]) + COMPREPLY=($(compgen -W '$(_dictdata -D)' -- "$cur")) return ;; - --strategy|-!(-*)s) - COMPREPLY=( $(compgen -W '$(_dictdata -S)' -- "$cur") ) + --strategy | -!(-*)s) + COMPREPLY=($(compgen -W '$(_dictdata -S)' -- "$cur")) return ;; esac @@ -52,13 +52,13 @@ _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") ) + COMPREPLY=($(compgen -W \ + '$(command grep "^${cur//./\\.}" $dictfile)' -- "$cur")) else - COMPREPLY=( $(compgen -W '$(cat $dictfile)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(cat $dictfile)' -- "$cur")) fi fi } && -complete -F _dict -o default dict rdict + complete -F _dict -o default dict rdict # ex: filetype=sh diff --git a/completions/dmypy b/completions/dmypy index a8c07437..5abe37d7 100644 --- a/completions/dmypy +++ b/completions/dmypy @@ -6,7 +6,7 @@ _dmypy() _init_completion || return case $prev in - --help|--version|-[hV]) + --help | --version | -[hV]) return ;; --status-file) @@ -16,32 +16,33 @@ _dmypy() esac local cmd i - for (( i=1; i < cword; i++ )); do - if [[ ${words[i]} != -* && ${words[i-1]} != --status-file ]]; then + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} != -* && ${words[i - 1]} != --status-file ]]; then cmd=${words[i]} break fi done - case $cmd in - check|run) + case ${cmd-} in + check | run) _filedir '@(py|pyi)' return + ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - if [[ ! $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") ) + if [[ ! -v 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")) return fi } && -complete -F _dmypy dmypy + complete -F _dmypy dmypy # ex: filetype=sh diff --git a/completions/dnssec-keygen b/completions/dnssec-keygen index 2ecfcdc5..3f68a687 100644 --- a/completions/dnssec-keygen +++ b/completions/dnssec-keygen @@ -2,11 +2,11 @@ _dnssec_keygen_optarg() { - local args=$("$1" -h 2>&1 | \ + local args=$("$1" -h 2>&1 | command sed -e 's/|/ /g' -e 's/(.*//' \ - -ne '/^[[:space:]]*'$2'/,/^[[:space:]]*[(-]/p' | \ + -ne '/^[[:space:]]*'$2'/,/^[[:space:]]*[(-]/p' | command sed -e 's/^[[:space:]]*'$2'.*://' -e '/^[[:space:]]*-/d') - COMPREPLY+=( $(compgen -W '$args' -- "$cur") ) + COMPREPLY+=($(compgen -W '$args' -- "$cur")) } _dnssec_keygen() @@ -32,17 +32,17 @@ _dnssec_keygen() return ;; -v) - COMPREPLY=( $(compgen -W '{0..10}' -- "$cur") ) + COMPREPLY=($(compgen -W '{0..10}' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" | \ - command sed -e "s/:\$//")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" | \ + command sed -e "s/:\$//")' -- "$cur")) return fi } && -complete -F _dnssec_keygen dnssec-keygen + complete -F _dnssec_keygen dnssec-keygen # ex: filetype=sh diff --git a/completions/dnsspoof b/completions/dnsspoof index e45d48d6..86ade91d 100644 --- a/completions/dnsspoof +++ b/completions/dnsspoof @@ -16,11 +16,11 @@ _dnsspoof() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) fi } && -complete -F _dnsspoof dnsspoof + complete -F _dnsspoof dnsspoof # ex: filetype=sh diff --git a/completions/dot b/completions/dot index bad82f2c..81222292 100644 --- a/completions/dot +++ b/completions/dot @@ -8,38 +8,38 @@ _dot() [[ $prev == -[V?] ]] && return case $cur in - -G*|-N*|-E*|-l?*|-q?*|-s?*|-Ln*|-LU*|-LC*|-LT*) + -G* | -N* | -E* | -l?* | -q?* | -s?* | -Ln* | -LU* | -LC* | -LT*) return ;; -T*) - local langs=( $("$1" -TNON_EXISTENT 2>&1 | \ - command sed -ne 's/.*one of://p') ) - COMPREPLY=( $(compgen -P -T -W '${langs[@]}' -- "${cur#-T}") ) + local langs=($("$1" -TNON_EXISTENT 2>&1 | + command sed -ne 's/.*one of://p')) + COMPREPLY=($(compgen -P -T -W '${langs[@]}' -- "${cur#-T}")) return ;; -K*) - local layouts=( $("$1" -KNON_EXISTENT 2>&1 | \ - command sed -ne 's/.*one of://p') ) - COMPREPLY=( $(compgen -P -K -W '${layouts[@]}' -- "${cur#-K}") ) + local layouts=($("$1" -KNON_EXISTENT 2>&1 | + command sed -ne 's/.*one of://p')) + COMPREPLY=($(compgen -P -K -W '${layouts[@]}' -- "${cur#-K}")) return ;; -o*) cur=${cur#-o} _filedir - COMPREPLY=( $(compgen -P -o -W '${COMPREPLY[@]}' -- "$cur") ) + COMPREPLY=($(compgen -P -o -W '${COMPREPLY[@]}' -- "$cur")) 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") ) - [[ $COMPREPLY == -@([GNETKo]|L[nUCT]) ]] && compopt -o nospace + 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")) + [[ ${COMPREPLY-} == -@([GNETKo]|L[nUCT]) ]] && compopt -o nospace return fi _filedir dot } && -complete -F _dot dot + complete -F _dot dot # ex: filetype=sh diff --git a/completions/dpkg b/completions/dpkg index 827d9cad..0b90b14b 100644 --- a/completions/dpkg +++ b/completions/dpkg @@ -1,35 +1,35 @@ # This function is required by _dpkg and _dpkg-reconfigure -*- 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() + { + 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| \ + _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 -} + -Ee "^Essential: yes" | + awk "/Package: $1/ { print \$2 }" 2>/dev/null + } } _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() + { + 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| \ + _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 -} + -Ee "^Essential: yes" | + awk "/Package: $1/ { print \$2 }" 2>/dev/null + } } # Debian dpkg(1) completion @@ -49,39 +49,47 @@ _dpkg() fi case $prev in - --install|--unpack|--record-avail|--contents|--info|--fsys-tarfile|\ - --field|--control|--extract|--vextract|-!(-*)[ciAIfexW]) + --install | --unpack | --record-avail | --contents | --info | --fsys-tarfile | \ + --field | --control | --extract | --vextract | --raw-extract | -!(-*)[ciAIfexX]) _filedir '?(u|d)deb' return ;; - --build|-!(-*)b) + --build | -!(-*)b) _filedir -d return ;; - --status|--print-avail|--list|--show|-!(-*)[splW]) - COMPREPLY=( $(apt-cache pkgnames "$cur" 2>/dev/null) ) + --status | --print-avail | --list | -!(-*)[spl]) + COMPREPLY=($(_xfunc apt-cache _apt_cache_packages)) + return + ;; + --show | -!(-*)W) + if [[ $1 == *dpkg-query ]]; then + COMPREPLY=($(_xfunc apt-cache _apt_cache_packages)) + else + _filedir '?(u|d)deb' + fi return ;; - --search|-!(-*)S) + --search | -!(-*)S) _filedir return ;; - --remove|--verify|-!(-*)[rV]) - COMPREPLY=( $(_comp_dpkg_installed_packages "$cur") ) + --remove | --verify | -!(-*)[rV]) + COMPREPLY=($(_comp_dpkg_installed_packages "$cur")) return ;; - --listfiles|--purge|-!(-*)[LP]) - COMPREPLY=( $(_comp_dpkg_purgeable_packages "$cur") ) + --listfiles | --purge | -!(-*)[LP]) + COMPREPLY=($(_comp_dpkg_purgeable_packages "$cur")) return ;; esac $split && return - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && -complete -F _dpkg dpkg dpkg-deb dpkg-query + complete -F _dpkg dpkg dpkg-deb dpkg-query # Debian GNU dpkg-reconfigure(8) completion # @@ -93,26 +101,26 @@ _dpkg_reconfigure() local opt 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 | -!(-*)f) + opt=($(printf '%s\n' /usr/share/perl5/Debconf/FrontEnd/*)) + opt=(${opt[@]##*/}) + opt=(${opt[@]%.pm}) + COMPREPLY=($(compgen -W '${opt[@]}' -- "$cur")) return ;; - --priority|-!(-*)p) - COMPREPLY=( $(compgen -W 'low medium high critical' -- "$cur") ) + --priority | -!(-*)p) + COMPREPLY=($(compgen -W 'low medium high critical' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--frontend --priority --all --unseen-only - --help --showold --force --terse' -- "$cur" ) ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--frontend --priority --all --unseen-only + --help --showold --force --terse' -- "$cur")) else - COMPREPLY=( $(_comp_dpkg_installed_packages "$cur") ) + COMPREPLY=($(_comp_dpkg_installed_packages "$cur")) fi } && -complete -F _dpkg_reconfigure -o default dpkg-reconfigure + complete -F _dpkg_reconfigure -o default dpkg-reconfigure # ex: filetype=sh diff --git a/completions/dpkg-source b/completions/dpkg-source index ffc34c41..05fa3a11 100644 --- a/completions/dpkg-source +++ b/completions/dpkg-source @@ -5,7 +5,7 @@ _dpkg_source() local cur prev words cword _init_completion || return - local options work i action packopts unpackopts fields + local options word action packopts unpackopts fields packopts="-c -l -F -V -T -D -U -W -E -sa -i -I -sk -sr -ss -sA -sK -sP \ -sU -sR" @@ -14,13 +14,13 @@ _dpkg_source() fields="Format Source Version Binary Maintainer Uploader Architecture \ Standards-Version Build-Depends Files" - action="options" - for (( i=0; i < ${#words[@]}-1; i++ )); do - if [[ ${words[$i]} == "-x" ]]; then + action=options + for word in "${words[@]:1}"; do + if [[ $word == -x ]]; then action=unpack - elif [[ ${words[$i]} == "-b" ]]; then + elif [[ $word == -b ]]; then action=pack - elif [[ ${words[$i]} == "-h" ]]; then + elif [[ $word == -h ]]; then action=help fi done @@ -33,7 +33,7 @@ _dpkg_source() _filedir 'dsc' ;; *) - COMPREPLY=( $(compgen -W "$unpackopts" -- "$cur") ) + COMPREPLY=($(compgen -W "$unpackopts" -- "$cur")) _filedir -d _filedir ;; @@ -45,7 +45,7 @@ _dpkg_source() -b) _filedir -d ;; - -c|-l|-T|-i|-I) + -c | -l | -T | -i | -I) # -c: get controlfile # -l: get per-version info from this file # -T: read variables here, not debian/substvars @@ -57,9 +57,9 @@ _dpkg_source() ;; -F) # -F: force change log format - COMPREPLY=( $(command ls /usr/lib/dpkg/parsechangelog) ) + COMPREPLY=($(command ls /usr/lib/dpkg/parsechangelog)) ;; - -V|-D) + -V) # -V: set a substitution variable # we don't know anything about possible variables or values # so we don't try to suggest any completion. @@ -68,31 +68,31 @@ _dpkg_source() -D) # -D: override or add a .dsc field and value # if $cur doesn't contain a = yet, suggest variable names - if [[ "$cur" == *=* ]]; then + if [[ $cur == *=* ]]; then # $cur contains a "=" COMPREPLY=() else - COMPREPLY=( $(compgen -W "$fields" -- "$cur") ) + COMPREPLY=($(compgen -W "$fields" -- "$cur")) fi ;; -U) # -U: remove a field # Suggest possible fieldnames - COMPREPLY=( $(compgen -W "$fields" -- "$cur") ) + COMPREPLY=($(compgen -W "$fields" -- "$cur")) ;; *) - COMPREPLY=( $(compgen -W "$packopts $unpackopts" \ - -- "$cur") ) + COMPREPLY=($(compgen -W "$packopts $unpackopts" \ + -- "$cur")) ;; esac return ;; *) - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) return ;; esac } && -complete -F _dpkg_source dpkg-source + complete -F _dpkg_source dpkg-source # ex: filetype=sh diff --git a/completions/dselect b/completions/dselect index 6ad38842..4c180267 100644 --- a/completions/dselect +++ b/completions/dselect @@ -10,20 +10,20 @@ _dselect() _filedir -d return ;; - -D|-debug) + -D | -debug) _filedir return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else - COMPREPLY=( $(compgen -W 'access update select install config remove - quit' -- "$cur") ) + COMPREPLY=($(compgen -W 'access update select install config remove + quit' -- "$cur")) fi } && -complete -F _dselect dselect + complete -F _dselect dselect # ex: filetype=sh diff --git a/completions/dsniff b/completions/dsniff index e8e5bf37..749c533c 100644 --- a/completions/dsniff +++ b/completions/dsniff @@ -6,7 +6,7 @@ _dsniff() _init_completion || return case $prev in - -r|-w|-f|-p) + -r | -w | -f | -p) _filedir return ;; @@ -16,11 +16,11 @@ _dsniff() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1") -r -w -p' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1") -r -w -p' -- "$cur")) fi } && -complete -F _dsniff dsniff + complete -F _dsniff dsniff # ex: filetype=sh diff --git a/completions/dumpdb b/completions/dumpdb index 981211bb..eb1927fa 100644 --- a/completions/dumpdb +++ b/completions/dumpdb @@ -5,14 +5,14 @@ _dumpdb() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--marshal --pickle --noprint --help' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--marshal --pickle --noprint --help' \ + -- "$cur")) else _filedir fi } && -complete -F _dumpdb dumpdb + complete -F _dumpdb dumpdb # ex: filetype=sh diff --git a/completions/dumpe2fs b/completions/dumpe2fs index f44ecc32..413a5bf6 100644 --- a/completions/dumpe2fs +++ b/completions/dumpe2fs @@ -15,14 +15,14 @@ _dumpe2fs() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) return fi cur=${cur:=/dev/} _filedir } && -complete -F _dumpe2fs dumpe2fs + complete -F _dumpe2fs dumpe2fs # ex: filetype=sh diff --git a/completions/e2freefrag b/completions/e2freefrag index 355ebb94..c89dc9cb 100644 --- a/completions/e2freefrag +++ b/completions/e2freefrag @@ -6,19 +6,19 @@ _e2freefrag() _init_completion || return case $prev in - -c|-h) + -c | -h) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" -h)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" -h)' -- "$cur")) return fi cur=${cur:=/dev/} _filedir } && -complete -F _e2freefrag e2freefrag + complete -F _e2freefrag e2freefrag # ex: filetype=sh diff --git a/completions/e2label b/completions/e2label index c145c3a0..ac8e4b5f 100644 --- a/completions/e2label +++ b/completions/e2label @@ -5,11 +5,11 @@ _e2label() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then + if ((cword == 1)); then cur=${cur:=/dev/} _filedir fi } && -complete -F _e2label e2label + complete -F _e2label e2label # ex: filetype=sh diff --git a/completions/ebtables b/completions/ebtables index 325962b5..de6bc549 100644 --- a/completions/ebtables +++ b/completions/ebtables @@ -6,42 +6,42 @@ _ebtables() _init_completion -s || return local table chain='s/^Bridge chain: \([^ ,]\{1,\}\).*$/\1/p' \ - targets='ACCEPT DROP CONTINUE RETURN' + targets='ACCEPT DROP CONTINUE RETURN' - [[ "${words[*]}" =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] \ - && table="-t ${BASH_REMATCH[2]}" + [[ ${words[*]} =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] && + table="-t ${BASH_REMATCH[2]}" case $prev in - -!(-*)[AIDPFXLZ]) - COMPREPLY=( $(compgen -W '`"$1" $table -L 2>/dev/null | \ - command sed -ne "$chain"`' -- "$cur") ) - ;; - -!(-*)t) - COMPREPLY=( $(compgen -W 'nat filter broute' -- "$cur") ) - ;; - -!(-*)j) - if [[ "$table" == "-t filter" || -z "$table" ]]; then - COMPREPLY=( $(compgen -W '$targets + -!(-*)[AIDPFXLZ]) + COMPREPLY=($(compgen -W '`"$1" $table -L 2>/dev/null | \ + command sed -ne "$chain"`' -- "$cur")) + ;; + -!(-*)t) + COMPREPLY=($(compgen -W 'nat filter broute' -- "$cur")) + ;; + -!(-*)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 + -- "$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 + -- "$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") ) - fi - ;; - *) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--802_3-sap --802_3-type --among-dst + -- "$cur")) + fi + ;; + *) + if [[ $cur == -* ]]; then + COMPREPLY=($(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 +67,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") ) - fi - ;; + --vlan-prio --zero' -- "$cur")) + fi + ;; esac } && -complete -F _ebtables ebtables + complete -F _ebtables ebtables # ex: filetype=sh diff --git a/completions/ecryptfs-migrate-home b/completions/ecryptfs-migrate-home index bad0962e..d2eeb381 100644 --- a/completions/ecryptfs-migrate-home +++ b/completions/ecryptfs-migrate-home @@ -9,14 +9,14 @@ _ecryptfs_migrate_home() --help) return ;; - --user|-u) - COMPREPLY=( $(compgen -u -- "$cur") ) + --user | -u) + COMPREPLY=($(compgen -u -- "$cur")) return ;; esac - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _ecryptfs_migrate_home ecryptfs-migrate-home + complete -F _ecryptfs_migrate_home ecryptfs-migrate-home # ex: filetype=sh diff --git a/completions/eog b/completions/eog index d10cbbae..2330e1a2 100644 --- a/completions/eog +++ b/completions/eog @@ -6,7 +6,7 @@ _eog() _init_completion -s || return case $prev in - -'?'|--help|--help-all|--help-gtk) + -'?' | --help | --help-all | --help-gtk) return ;; esac @@ -14,13 +14,13 @@ _eog() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur")) + [[ ${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)' } && -complete -F _eog eog + complete -F _eog eog # ex: filetype=sh diff --git a/completions/ether-wake b/completions/ether-wake index a3e3e406..d9526736 100644 --- a/completions/ether-wake +++ b/completions/ether-wake @@ -16,12 +16,12 @@ _ether_wake() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -u) -V' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1" -u) -V' -- "$cur")) return fi _mac_addresses } && -complete -F _ether_wake ether-wake etherwake + complete -F _ether_wake ether-wake etherwake # ex: filetype=sh diff --git a/completions/evince b/completions/evince index d50f23c3..1c97dd93 100644 --- a/completions/evince +++ b/completions/evince @@ -6,9 +6,9 @@ _evince() _init_completion -s || return 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]) + --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]) return ;; --sm-client-state-file) @@ -20,13 +20,13 @@ _evince() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur")) + [[ ${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)' } && -complete -F _evince evince + complete -F _evince evince # ex: filetype=sh diff --git a/completions/export b/completions/export index 816182f6..8d823614 100644 --- a/completions/export +++ b/completions/export @@ -6,7 +6,7 @@ _export() _init_completion -n = || return local i action=variable remove=false - for (( i=1; i < cword; i++ )); do + for ((i = 1; i < cword; i++)); do case ${words[i]} in -p) return @@ -33,10 +33,10 @@ _export() case $cur in *=) - local pval=$(quote "$(eval printf %s \"\$${cur%=}\")") + local pval=$(quote "$(eval printf %s \"\$\{${cur%=}-\}\")") # Complete previous value if it's not empty. if [[ $pval != \'\' ]]; then - COMPREPLY=( "$pval" ) + COMPREPLY=("$pval") else cur=${cur#*=} _filedir @@ -48,18 +48,18 @@ _export() ;; *) if [[ $cword -eq 1 && $cur == -* ]]; then - COMPREPLY=( $(compgen -W '-p $(_parse_usage "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '-p $(_parse_usage "$1")' -- "$cur")) return fi - local suffix + local suffix="" if ! $remove; then - suffix+== + suffix="=" compopt -o nospace fi - COMPREPLY=( $(compgen -A $action -S "$suffix" -- "$cur") ) + COMPREPLY=($(compgen -A $action -S "$suffix" -- "$cur")) ;; esac } && -complete -F _export export + complete -F _export export # ex: filetype=sh diff --git a/completions/faillog b/completions/faillog index 5e7d2ab2..c8b81bd0 100644 --- a/completions/faillog +++ b/completions/faillog @@ -6,22 +6,22 @@ _faillog() _init_completion -s || return case $prev in - --help|--lock-time|--maximum|--time|-!(-*)[hlmt]) + --help | --lock-time | --maximum | --time | -!(-*)[hlmt]) return ;; - --user|-!(-*)u) - COMPREPLY=( $(compgen -u -- "$cur") ) + --user | -!(-*)u) + COMPREPLY=($(compgen -u -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _faillog faillog + complete -F _faillog faillog # ex: filetype=sh diff --git a/completions/fbgs b/completions/fbgs index 7a3ad7be..1947b872 100644 --- a/completions/fbgs +++ b/completions/fbgs @@ -6,45 +6,45 @@ _fbgs() _init_completion || return case "$prev" in - -f|--font) + -f | --font) local IFS=$'\n' - COMPREPLY=( $(compgen -W '$(fc-list 2>/dev/null)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(fc-list 2>/dev/null)' -- "$cur")) return ;; - -m|--mode) - COMPREPLY=( $(compgen -W '$(command sed \ + -m | --mode) + COMPREPLY=($(compgen -W '$(command sed \ -n "/^mode/{s/^mode \{1,\}\"\([^\"]\{1,\}\)\"/\1/g;p}" \ - /etc/fb.modes 2>/dev/null)' -- "$cur") ) + /etc/fb.modes 2>/dev/null)' -- "$cur")) return ;; - -d|--device) - COMPREPLY=( $(compgen -f -d -- "${cur:-/dev/}") ) + -d | --device) + COMPREPLY=($(compgen -f -d -- "${cur:-/dev/}")) return ;; - -fp|--firstpage|-lp|--lastpage|-r|--resolution|-s|--scroll|-t|\ - --timeout) + -fp | --firstpage | -lp | --lastpage | -r | --resolution | -s | --scroll | -t | \ + --timeout) # expect integer value - COMPREPLY+=( $(compgen -W '{0..9}') ) + COMPREPLY+=($(compgen -W '{0..9}')) compopt -o nospace return ;; - -T|--vt|-p|--password|-g|--gamma) + -T | --vt | -p | --password | -g | --gamma) # argument required but no completions available return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--bell --help --password -fp --firstpage + if [[ $cur == -* ]]; then + COMPREPLY=($(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") ) - [[ $COMPREPLY ]] && return + --device --mode' -- "$cur")) + [[ ${COMPREPLY-} ]] && return fi _filedir '?(e)ps|pdf' } && -complete -F _fbgs fbgs + complete -F _fbgs fbgs # ex: filetype=sh diff --git a/completions/fbi b/completions/fbi index ac92e60f..455887a3 100644 --- a/completions/fbi +++ b/completions/fbi @@ -6,49 +6,49 @@ _fbi() _init_completion || return case "$prev" in - -l|--list) + -l | --list) _filedir return ;; - -r|--resolution) - COMPREPLY+=( $(compgen -W '{1..5}') ) + -r | --resolution) + COMPREPLY+=($(compgen -W '{1..5}')) return ;; - -f|--font) + -f | --font) local IFS=$'\n' - COMPREPLY=( $(compgen -W '$(fc-list 2>/dev/null)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(fc-list 2>/dev/null)' -- "$cur")) return ;; - -m|--mode) - COMPREPLY=( $(compgen -W '$(command sed \ + -m | --mode) + COMPREPLY=($(compgen -W '$(command sed \ -n "/^mode/{s/^mode \{1,\}\"\([^\"]\{1,\}\)\"/\1/g;p}" \ - /etc/fb.modes 2>/dev/null)' -- "$cur") ) + /etc/fb.modes 2>/dev/null)' -- "$cur")) return ;; - -d|--device) - COMPREPLY=( $(compgen -f -d -- "${cur:-/dev/}") ) + -d | --device) + COMPREPLY=($(compgen -f -d -- "${cur:-/dev/}")) return ;; - --cachemem|--blend|-T|--vt|-s|--scroll|-t|--timeout|-g|--gamma) + --cachemem | --blend | -T | --vt | -s | --scroll | -t | --timeout | -g | --gamma) # argument required but no completions available return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --version --store --list --text + 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") ) - [[ $COMPREPLY ]] && return + --device --mode' -- "$cur")) + [[ ${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' } && -complete -F _fbi fbi + complete -F _fbi fbi # ex: filetype=sh diff --git a/completions/feh b/completions/feh index 71e59798..f1d4b18a 100644 --- a/completions/feh +++ b/completions/feh @@ -6,22 +6,22 @@ _feh() _init_completion -s || return case "$prev" in - --image-bg|-B) - COMPREPLY=( $(compgen -W 'checks white black' -- "$cur") ) + --image-bg | -B) + COMPREPLY=($(compgen -W 'checks white black' -- "$cur")) return ;; - --filelist|--output|--output-only|--start-at|-!(-*)[foO\|]) + --filelist | --output | --output-only | --start-at | -!(-*)[foO\|]) _filedir return ;; - --caption-path|--fontpath|--output-dir|-!(-*)[KCj]) + --caption-path | --fontpath | --output-dir | -!(-*)[KCj]) _filedir -d return ;; - --font|--menu-font|--title-font|-!(-*)[eM@]) + --font | --menu-font | --title-font | -!(-*)[eM@]) # expect string like "dejavu.ttf/12" - if [[ "$cur" == */* ]]; then # expect integer value - COMPREPLY=( $(compgen -P "$cur" -W '{0..9}') ) + if [[ $cur == */* ]]; then # expect integer value + COMPREPLY=($(compgen -P "$cur" -W '{0..9}')) compopt -o nospace return fi @@ -29,69 +29,72 @@ _feh() # 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") ) - for (( i=${#words[@]}-1; i>0; i-- )); do + 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") ) + font_path="${words[i + 1]}" + COMPREPLY+=($( + cd "$font_path" 2>/dev/null + compgen -f \ + -X "!*.@([tT][tT][fF])" -S / -- "$cur" + )) fi done compopt -o nospace return ;; - --theme|-!(-*)T) + --theme | -!(-*)T) local conf_path=~/.config/feh/themes local theme_name theme_opts [[ -r $conf_path ]] || return while read theme_name theme_opts; do - if [[ "$theme_name" == '#'* || "$theme_name" == "" ]]; then + if [[ $theme_name == '#'* || $theme_name == "" ]]; then continue fi - COMPREPLY+=( $(compgen -W "$theme_name" -- "$cur") ) + COMPREPLY+=($(compgen -W "$theme_name" -- "$cur")) done <"$conf_path" return ;; - --sort|-!(-*)S) - COMPREPLY=( $(compgen -W 'name filename mtime width height - pixels size format' -- "$cur") ) + --sort | -!(-*)S) + COMPREPLY=($(compgen -W 'name filename mtime width height + pixels size format' -- "$cur")) return ;; - --reload|--limit-height|--limit-width|--thumb-height|--thumb-width|\ - --thumb-redraw|--magick-timeout|-!(-*)[RHWEyJ]) + --reload | --limit-height | --limit-width | --thumb-height | --thumb-width | \ + --thumb-redraw | --magick-timeout | -!(-*)[RHWEyJ]) # expect integer value - COMPREPLY+=( $(compgen -W '{0..9}') ) + COMPREPLY+=($(compgen -W '{0..9}')) compopt -o nospace return ;; --zoom) # expect integer value or "max", "fill" - COMPREPLY=( $(compgen -W 'max fill' -- "$cur") ) - if [[ ! $cur || ! $COMPREPLY ]]; then - COMPREPLY+=( $(compgen -W '{0..9}') ) + COMPREPLY=($(compgen -W 'max fill' -- "$cur")) + if [[ ! $cur || ! ${COMPREPLY-} ]]; then + COMPREPLY+=($(compgen -W '{0..9}')) compopt -o nospace fi return ;; - --alpha|-!(-*)a) - COMPREPLY=( $(compgen -W '{0..255}' -- "$cur") ) + --alpha | -!(-*)a) + COMPREPLY=($(compgen -W '{0..255}' -- "$cur")) return ;; - --bg|-!(-*)b) + --bg | -!(-*)b) _filedir - COMPREPLY+=( $(compgen -W 'trans' -- "$cur") ) + COMPREPLY+=($(compgen -W 'trans' -- "$cur")) return ;; - --geometry|--max-dimension|--min-dimension|-!(-*)g) + --geometry | --max-dimension | --min-dimension | -!(-*)g) # expect string like 640x480 - if [[ $cur && "$cur" != *x* ]]; then - COMPREPLY=( x ) + if [[ $cur && $cur != *x* ]]; then + COMPREPLY=(x) fi - COMPREPLY+=( $(compgen -W "{0..9}") ) + COMPREPLY+=($(compgen -W "{0..9}")) compopt -o nospace return ;; - --customlist|--index-info|--info|--slideshow-delay|--thumb-title|\ - --title|-!(-*)[LD~^]) + --customlist | --index-info | --info | --slideshow-delay | --thumb-title | \ + --title | -!(-*)[LD~^]) # argument required but no completions available return ;; @@ -99,17 +102,19 @@ _feh() $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # Some versions of feh just output "See 'man feh'" for --help :( - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace - [[ $COMPREPLY ]] && return + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur")) + if [[ ${COMPREPLY-} ]]; then + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi fi # 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' } && -complete -F _feh feh + complete -F _feh feh # ex: filetype=sh diff --git a/completions/file b/completions/file index 494c7866..21fbd161 100644 --- a/completions/file +++ b/completions/file @@ -6,27 +6,27 @@ _file() _init_completion || return case $prev in - --help|--version|--separator|-!(-*)[vF]) + --help | --version | --separator | -!(-*)[vF]) return ;; - --magic-file|--files-from|-!(-*)[mf]) + --magic-file | --files-from | -!(-*)[mf]) _filedir return ;; - --exclude|-!(-*)e) - COMPREPLY=( $(compgen -W 'apptype ascii cdf compress elf encoding - soft tar text tokens troff' -- "$cur") ) + --exclude | -!(-*)e) + COMPREPLY=($(compgen -W 'apptype ascii cdf compress elf encoding + soft tar text tokens troff' -- "$cur")) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi _filedir } && -complete -F _file file + complete -F _file file # ex: filetype=sh diff --git a/completions/file-roller b/completions/file-roller index bebf04ee..1d223fd4 100644 --- a/completions/file-roller +++ b/completions/file-roller @@ -8,19 +8,19 @@ _file_roller() 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)' case $prev in - --help|--help-all|--help-gtk|--help-sm-client|-!(-*)'?') + --help | --help-all | --help-gtk | --help-sm-client | -!(-*)'?') return ;; --sm-client-state-file) _filedir return ;; - --add-to|-!(-*)a) + --add-to | -!(-*)a) _filedir_xspec unzip _filedir "$exts" return ;; - --extract-to|--default-dir|-!(-*)e) + --extract-to | --default-dir | -!(-*)e) _filedir -d return ;; @@ -29,14 +29,14 @@ _file_roller() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir_xspec unzip _filedir "$exts" } && -complete -F _file_roller file-roller + complete -F _file_roller file-roller # ex: filetype=sh diff --git a/completions/filefrag b/completions/filefrag index b8b51e3c..d26e8c8a 100644 --- a/completions/filefrag +++ b/completions/filefrag @@ -5,13 +5,13 @@ _filefrag() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) return fi _filedir } && -complete -F _filefrag filefrag + complete -F _filefrag filefrag # ex: filetype=sh diff --git a/completions/filesnarf b/completions/filesnarf index 01766555..f959d80f 100644 --- a/completions/filesnarf +++ b/completions/filesnarf @@ -12,11 +12,11 @@ _snarf() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) fi } && -complete -F _snarf filesnarf mailsnarf msgsnarf + complete -F _snarf filesnarf mailsnarf msgsnarf # ex: filetype=sh diff --git a/completions/find b/completions/find index 80fbe8c0..64121eda 100644 --- a/completions/find +++ b/completions/find @@ -7,20 +7,28 @@ _find() local cur prev words cword _init_completion || return + local i + for i in ${!words[*]}; do + if [[ ${words[i]} == -@(exec|ok)?(dir) ]]; then + _command_offset $((i + 1)) + return + fi + done + case $prev in - -maxdepth|-mindepth) - COMPREPLY=( $(compgen -W '{0..9}' -- "$cur") ) + -maxdepth | -mindepth) + COMPREPLY=($(compgen -W '{0..9}' -- "$cur")) return ;; - -newer|-anewer|-cnewer|-fls|-fprint|-fprint0|-fprintf|-name|-iname|\ - -lname|-ilname|-wholename|-iwholename|-samefile) + -newer | -anewer | -cnewer | -fls | -fprint | -fprint0 | -fprintf | -name | -[il]name | \ + -ilname | -wholename | -[il]wholename | -samefile) _filedir return ;; -fstype) _fstypes - [[ $OSTYPE == *bsd* ]] && \ - COMPREPLY+=( $(compgen -W 'local rdonly' -- "$cur") ) + [[ $OSTYPE == *bsd* ]] && + COMPREPLY+=($(compgen -W 'local rdonly' -- "$cur")) return ;; -gid) @@ -28,11 +36,11 @@ _find() return ;; -group) - COMPREPLY=( $(compgen -g -- "$cur" 2>/dev/null) ) + COMPREPLY=($(compgen -g -- "$cur" 2>/dev/null)) return ;; - -xtype|-type) - COMPREPLY=( $(compgen -W 'b c d p f l s' -- "$cur") ) + -xtype | -type) + COMPREPLY=($(compgen -W 'b c d p f l s' -- "$cur")) return ;; -uid) @@ -40,24 +48,17 @@ _find() return ;; -user) - COMPREPLY=( $(compgen -u -- "$cur") ) - return - ;; - -exec|-execdir|-ok|-okdir) - words=(words[0] "$cur") - cword=1 - _command + COMPREPLY=($(compgen -u -- "$cur")) return ;; - -[acm]min|-[acm]time|-iname|-lname|-wholename|-iwholename|-lwholename|\ - -ilwholename|-inum|-path|-ipath|-regex|-iregex|-links|-perm|-size|\ - -used|-printf|-context) + -[acm]min | -[acm]time | -inum | -path | -ipath | -regex | -iregex | -links | -perm | \ + -size | -used | -printf | -context) # do nothing, just wait for a parameter to be given return ;; -regextype) - COMPREPLY=( $(compgen -W 'emacs posix-awk posix-basic posix-egrep - posix-extended' -- "$cur") ) + COMPREPLY=($(compgen -W 'emacs posix-awk posix-basic posix-egrep + posix-extended' -- "$cur")) return ;; esac @@ -65,17 +66,17 @@ _find() local i exprfound=false # set exprfound to true if there is already an expression present for i in "${words[@]}"; do - [[ "$i" == [-\(\),\!]* ]] && exprfound=true && break + [[ $i == [-\(\),\!]* ]] && exprfound=true && break done # handle case where first parameter is not a dash option - if ! $exprfound && [[ "$cur" != [-\(\),\!]* ]]; then + if ! $exprfound && [[ $cur != [-\(\),\!]* ]]; then _filedir -d return fi # complete using basic options - COMPREPLY=( $(compgen -W '-daystart -depth -follow -help + 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 @@ -84,22 +85,22 @@ _find() -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") ) + -quit' -- "$cur")) - if [[ ${#COMPREPLY[@]} -ne 0 ]]; then + if ((${#COMPREPLY[@]} != 0)); then # this removes any options from the list of completions that have # already been specified somewhere on the command line, as long as # these options can only be used once (in a word, "options", in # opposition to "tests" and "actions", as in the find(1) manpage). - local -A onlyonce=( [-daystart]=1 [-depth]=1 [-follow]=1 [-help]=1 + local -A onlyonce=([-daystart]=1 [-depth]=1 [-follow]=1 [-help]=1 [-ignore_readdir_race]=1 [-maxdepth]=1 [-mindepth]=1 [-mount]=1 [-noignore_readdir_race]=1 [-noleaf]=1 [-nowarn]=1 [-regextype]=1 - [-version]=1 [-warn]=1 [-xdev]=1 ) + [-version]=1 [-warn]=1 [-xdev]=1) local j for i in "${words[@]}"; do - [[ $i && ${onlyonce[$i]} ]] || continue + [[ $i && -v onlyonce["$i"] ]] || continue for j in "${!COMPREPLY[@]}"; do - [[ ${COMPREPLY[j]} == $i ]] && unset 'COMPREPLY[j]' + [[ ${COMPREPLY[j]} == "$i" ]] && unset 'COMPREPLY[j]' done done fi @@ -107,6 +108,6 @@ _find() _filedir } && -complete -F _find find + complete -F _find find # ex: filetype=sh diff --git a/completions/find_member b/completions/find_member index 720e3074..cf30c70d 100644 --- a/completions/find_member +++ b/completions/find_member @@ -6,7 +6,7 @@ _find_member() _init_completion -s || return case $prev in - -l|-x|--listname|--exclude) + -l | -x | --listname | --exclude) _xfunc list_lists _mailman_lists return ;; @@ -14,12 +14,12 @@ _find_member() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--listname --exclude --owners --help' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--listname --exclude --owners --help' \ + -- "$cur")) fi } && -complete -F _find_member find_member + complete -F _find_member find_member # ex: filetype=sh diff --git a/completions/fio b/completions/fio index 7710cf6b..f81a4da7 100644 --- a/completions/fio +++ b/completions/fio @@ -6,28 +6,29 @@ _fio() _init_completion -s || return case $prev in - --help|--version) + --help | --version) return ;; --debug) - local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*}," - COMPREPLY=( $(compgen -W "process file io mem blktrace verify + 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[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} ) + steadystate helperthread" -- "${cur##*,}")) + ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix}) return ;; --output-format) - COMPREPLY=( $(compgen -W "terse json json+ normal" -- "$cur") ) + COMPREPLY=($(compgen -W "terse json json+ normal" -- "$cur")) return ;; --terse-version) - COMPREPLY=( $(compgen -W "2 3" -- "$cur") ) + COMPREPLY=($(compgen -W "2 3" -- "$cur")) return ;; --cmdhelp) # TODO more commands? - COMPREPLY=( $(compgen -W "all" -- "$cur") ) + COMPREPLY=($(compgen -W "all" -- "$cur")) return ;; --enghelp) @@ -36,7 +37,7 @@ _fio() return ;; --eta) - COMPREPLY=( $(compgen -W "always never auto" -- "$cur") ) + COMPREPLY=($(compgen -W "always never auto" -- "$cur")) return ;; --daemonize) @@ -52,7 +53,7 @@ _fio() return ;; --idle-prof) - COMPREPLY=( $(compgen -W "system percpu calibrate" -- "$cur") ) + COMPREPLY=($(compgen -W "system percpu calibrate" -- "$cur")) return ;; --inflate-log) @@ -63,9 +64,9 @@ _fio() _filedir return ;; - --trigger|--trigger-remote) + --trigger | --trigger-remote) compopt -o filenames - COMPREPLY=( $(compgen -c -- "$cur") ) + COMPREPLY=($(compgen -c -- "$cur")) return ;; --aux-path) @@ -77,13 +78,13 @@ _fio() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir job } && -complete -F _fio fio + complete -F _fio fio # ex: filetype=sh diff --git a/completions/firefox b/completions/firefox index eeaca9f6..4656f8df 100644 --- a/completions/firefox +++ b/completions/firefox @@ -8,12 +8,12 @@ _firefox() [[ $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]) + --help | --version | --display | --UILocale | -MOZ_LOG | --new-window | --new-tab | \ + --private-window | --window-size | --search | --start-debugger-server | \ + --recording | --debugger-args | -[hvPa]) return ;; - --profile|--screenshot) + --profile | --screenshot) _filedir -d return ;; @@ -25,8 +25,8 @@ _firefox() _filedir return ;; - --debugger|-d) - COMPREPLY=( $(compgen -c -- "$cur") ) + --debugger | -d) + COMPREPLY=($(compgen -c -- "$cur")) return ;; esac @@ -34,13 +34,13 @@ _firefox() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi - _filedir "@(?([xs])htm?(l)|pdf)" + _filedir "@(?([xs])htm?(l)|pdf|txt)" } && -complete -F _firefox firefox mozilla-firefox iceweasel + complete -F _firefox firefox mozilla-firefox iceweasel # ex: filetype=sh diff --git a/completions/flake8 b/completions/flake8 index f18351e8..045c4095 100644 --- a/completions/flake8 +++ b/completions/flake8 @@ -6,22 +6,22 @@ _flake8() _init_completion -s || return case $prev in - --help|--version|-!(-*)h) + --help | --version | -!(-*)h) return ;; --format) - COMPREPLY=( $(compgen -W 'default pylint' -- "$cur") ) + COMPREPLY=($(compgen -W 'default pylint' -- "$cur")) return ;; - --jobs|-!(-*)j) - COMPREPLY=( $(compgen -W "auto {1..$(_ncpus)}" -- "$cur") ) + --jobs | -!(-*)j) + COMPREPLY=($(compgen -W "auto {1..$(_ncpus)}" -- "$cur")) return ;; - --output-file|--append-config|--config) + --output-file | --append-config | --config) _filedir return ;; - --include-in-doctest|--exclude-from-doctest) + --include-in-doctest | --exclude-from-doctest) _filedir py return ;; @@ -30,13 +30,13 @@ _flake8() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir py } && -complete -F _flake8 flake8 + complete -F _flake8 flake8 # ex: filetype=sh diff --git a/completions/freebsd-update b/completions/freebsd-update index 6ee2438b..d5be8612 100644 --- a/completions/freebsd-update +++ b/completions/freebsd-update @@ -8,7 +8,7 @@ _freebsd_update() _init_completion || return case $prev in - -b|-d) + -b | -d) _filedir -d return ;; @@ -16,14 +16,14 @@ _freebsd_update() _filedir return ;; - -k|-r|-s|-t) + -k | -r | -s | -t) return ;; esac - COMPREPLY=( $(compgen -W "fetch cron upgrade install rollback IDS" -- \ - $cur) ) + COMPREPLY=($(compgen -W "fetch cron upgrade install rollback IDS" -- \ + $cur)) } && -complete -F _freebsd_update freebsd-update + complete -F _freebsd_update freebsd-update # ex: filetype=sh diff --git a/completions/freeciv b/completions/freeciv index 0f475482..01af3118 100644 --- a/completions/freeciv +++ b/completions/freeciv @@ -6,36 +6,36 @@ _freeciv() _init_completion || return case $prev in - --help|--version|--name|--port|-[hvnp]) + --help | --version | --name | --port | -[hvnp]) return ;; - --file|--log|--music|--read|--Sound|--tiles|-[flmrSt]) + --file | --log | --music | --read | --Sound | --tiles | -[flmrSt]) _filedir return ;; - --Announce|-A) - COMPREPLY=( $(compgen -W 'IPv4 IPv6 none' -- "$cur") ) + --Announce | -A) + COMPREPLY=($(compgen -W 'IPv4 IPv6 none' -- "$cur")) return ;; - --debug|-d) - COMPREPLY=( $(compgen -W '{0..3}' -- "$cur") ) + --debug | -d) + COMPREPLY=($(compgen -W '{0..3}' -- "$cur")) return ;; - --Meta|--server|-[Ms]) + --Meta | --server | -[Ms]) _known_hosts_real -- "$cur" return ;; - --Plugin|-P) - COMPREPLY=( $(compgen -W 'none esd sdl' -- "$cur") ) + --Plugin | -P) + COMPREPLY=($(compgen -W 'none esd sdl' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) fi } && -complete -F _freeciv freeciv{,-{gtk{2,3},sdl,xaw}} civclient + complete -F _freeciv freeciv{,-{gtk{2,3},sdl,xaw}} civclient # ex: filetype=sh diff --git a/completions/freeciv-server b/completions/freeciv-server index 08f63158..a34b5a29 100644 --- a/completions/freeciv-server +++ b/completions/freeciv-server @@ -6,17 +6,17 @@ _civserver() _init_completion || return case $prev in - -f|-g|-l|-r|--file|--log|--gamelog|--read) + -f | -g | -l | -r | --file | --log | --gamelog | --read) _filedir return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) fi } && -complete -F _civserver civserver freeciv-server + complete -F _civserver civserver freeciv-server # ex: filetype=sh diff --git a/completions/function b/completions/function index a97b5255..6ae52718 100644 --- a/completions/function +++ b/completions/function @@ -8,30 +8,30 @@ _function() if [[ $1 == @(declare|typeset) ]]; then if [[ $cur == [-+]* ]]; then local opts - opts=( $(_parse_usage "$1") ) + 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") ) + 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") ) + COMPREPLY=($(compgen -A function -- "$cur")) return fi ((i++)) done - if [[ $i -gt 1 ]]; then + 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") ) + COMPREPLY=($(compgen -A variable -- "$cur")) fi fi - elif [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -A function -- "$cur") ) + elif ((cword == 1)); then + COMPREPLY=($(compgen -A function -- "$cur")) else - COMPREPLY=( "() $(type -- ${words[1]} | command sed -e 1,2d)" ) + COMPREPLY=("() $(type -- ${words[1]} | command sed -e 1,2d)") fi } && -complete -F _function function declare typeset + complete -F _function function declare typeset # ex: filetype=sh diff --git a/completions/fusermount b/completions/fusermount index c40c18ce..7e489225 100644 --- a/completions/fusermount +++ b/completions/fusermount @@ -10,19 +10,19 @@ _fusermount() return ;; -*u) - COMPREPLY=( $(compgen -W "$(awk \ + COMPREPLY=($(compgen -W "$(awk \ '{ if ($3 ~ /^fuse(\.|$)/) print $2 }' /etc/mtab \ - 2>/dev/null)" -- "$cur") ) + 2>/dev/null)" -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) else _filedir -d fi } && -complete -F _fusermount fusermount + complete -F _fusermount fusermount # ex: filetype=sh diff --git a/completions/gcc b/completions/gcc index 86d0d095..fa952741 100644 --- a/completions/gcc +++ b/completions/gcc @@ -8,13 +8,13 @@ _gcc() # Test that GCC is recent enough and if not fallback to # parsing of --completion option. if ! $1 --completion=" " 2>/dev/null; then - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local cc=$($1 -print-prog-name=cc1 2>/dev/null) [[ $cc ]] || return - COMPREPLY=($( compgen -W "$($cc --help 2>/dev/null | tr '\t' ' ' |\ + COMPREPLY=($(compgen -W "$($cc --help 2>/dev/null | tr '\t' ' ' | command sed -e '/^ *-/!d' -e 's/ *-\([^][ <>]*\).*/-\1/')" \ - -- "$cur" )) - [[ $COMPREPLY == *= ]] && compopt -o nospace + -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _filedir fi @@ -22,54 +22,54 @@ _gcc() fi # extract also for situations like: -fsanitize=add - if [[ $cword -gt 2 ]]; then - prev2="${COMP_WORDS[$cword - 2]}" + if ((cword > 2)); then + prev2="${COMP_WORDS[cword - 2]}" fi # sample: -fsan - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then argument=$cur prefix="" # sample: -fsanitize= - elif [[ "$cur" == "=" && $prev == -* ]]; then + elif [[ $cur == "=" && $prev == -* ]]; then argument=$prev$cur prefix=$prev$cur # sample: -fsanitize=add - elif [[ "$prev" == "=" && $prev2 == -* ]]; then + elif [[ $prev == "=" && $prev2 == -* ]]; then argument=$prev2$prev$cur prefix=$prev2$prev # sample: --param lto- - elif [[ "$prev" == --param ]]; then + elif [[ $prev == --param ]]; then argument="$prev $cur" prefix="$prev " fi - if [[ -z $argument ]]; then + if [[ ! -v argument ]]; then _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)) + prefix_length=$((${#prefix} + 1)) local flags=$($1 --completion="$argument" | cut -c $prefix_length-) - [[ "${flags}" == "=*" ]] && compopt -o nospace 2>/dev/null - COMPREPLY=( $(compgen -W "$flags" -- "") ) + [[ ${flags} == "=*" ]] && compopt -o nospace 2>/dev/null + COMPREPLY=($(compgen -W "$flags" -- "")) fi } && -complete -F _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 && -{ - 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 -} + complete -F _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 && + { + 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 + } # ex: filetype=sh diff --git a/completions/gcl b/completions/gcl index 9acc813d..73a18b2d 100644 --- a/completions/gcl +++ b/completions/gcl @@ -8,14 +8,14 @@ _gcl() _init_completion || 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") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-eval -load -f -batch -dir -libdir -compile + -o-file -c-file -h-file -data-file -system-p' -- "$cur")) else _filedir fi } && -complete -F _gcl -o default gcl + complete -F _gcl -o default gcl # ex: filetype=sh diff --git a/completions/gdb b/completions/gdb index b37387e1..f78f8a57 100644 --- a/completions/gdb +++ b/completions/gdb @@ -6,41 +6,42 @@ _gdb() _init_completion || return # gdb [options] --args executable-file [inferior-arguments ...] - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == --args ]]; then - _command_offset $((i+1)) + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == --args ]]; then + _command_offset $((i + 1)) return $? fi done # gdb [options] [executable-file [core-file or process-id]] - if [[ $cword -eq 1 ]]; then + if ((cword == 1)); then local IFS compopt -o filenames - if [[ "$cur" == */* ]]; then + if [[ $cur == */* ]]; then # compgen -c works as expected if $cur contains any slashes. IFS=$'\n' - COMPREPLY=( $(PATH="$PATH:." compgen -d -c -- "$cur") ) + COMPREPLY=($(PATH="$PATH:." compgen -d -c -- "$cur")) 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") ) + local path_array=($( + command sed -e 's/:\{2,\}/:/g' -e 's/^://' -e 's/:$//' <<<"$PATH" + )) IFS=$'\n' - COMPREPLY=( $(compgen -d -W '$(find "${path_array[@]}" . \ + COMPREPLY=($(compgen -d -W '$(find "${path_array[@]}" . \ -mindepth 1 -maxdepth 1 -not -type d -executable \ - -printf "%f\\n" 2>/dev/null)' -- "$cur") ) + -printf "%f\\n" 2>/dev/null)' -- "$cur")) fi - elif [[ $cword -eq 2 ]]; then - COMPREPLY=( $(compgen -W "$(command ps axo comm,pid | \ - awk '{if ($1 ~ /^'"${prev##*/}"'/) print $2}')" -- "$cur") ) + elif ((cword == 2)); then + COMPREPLY=($(compgen -W "$(command ps axo comm,pid | + awk '{if ($1 ~ /^'"${prev##*/}"'/) print $2}')" -- "$cur")) compopt -o filenames - COMPREPLY+=( $(compgen -f -X '!?(*/)core?(.?*)' -o plusdirs \ - -- "$cur") ) + COMPREPLY+=($(compgen -f -X '!?(*/)core?(.?*)' -o plusdirs \ + -- "$cur")) fi } && -complete -F _gdb gdb + complete -F _gdb gdb # ex: filetype=sh diff --git a/completions/genaliases b/completions/genaliases index 3bad5c7e..5953b9ef 100644 --- a/completions/genaliases +++ b/completions/genaliases @@ -5,11 +5,11 @@ _genaliases() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--quiet --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--quiet --help' -- "$cur")) fi } && -complete -F _genaliases genaliases + complete -F _genaliases genaliases # ex: filetype=sh diff --git a/completions/gendiff b/completions/gendiff index cb9bab39..d37793f6 100644 --- a/completions/gendiff +++ b/completions/gendiff @@ -5,8 +5,8 @@ _gendiff() local cur prev words cword _init_completion -o '@(diff|patch)' || return - [[ $cword -eq 1 ]] && _filedir -d + ((cword == 1)) && _filedir -d } && -complete -F _gendiff gendiff + complete -F _gendiff gendiff # ex: filetype=sh diff --git a/completions/genisoimage b/completions/genisoimage index 52b66bbe..dfa39c0a 100644 --- a/completions/genisoimage +++ b/completions/genisoimage @@ -6,14 +6,14 @@ _mkisofs() _init_completion || return case $prev in - -o|-abstract|-biblio|-check-session|-copyright|-log-file| \ - -root-info|-prep-boot|-*-list) + -o | -abstract | -biblio | -check-session | -copyright | -log-file | \ + -root-info | -prep-boot | -*-list) _filedir return ;; -*-charset) - COMPREPLY=( $(compgen -W '$(mkisofs -input-charset \ - help 2>&1 | tail -n +3)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(mkisofs -input-charset \ + help 2>&1 | tail -n +3)' -- "$cur")) return ;; -uid) @@ -26,13 +26,13 @@ _mkisofs() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) else _filedir fi } && -complete -F _mkisofs mkisofs genisoimage + complete -F _mkisofs mkisofs genisoimage # ex: filetype=sh diff --git a/completions/geoiplookup b/completions/geoiplookup index 8347728f..c60be898 100644 --- a/completions/geoiplookup +++ b/completions/geoiplookup @@ -6,7 +6,7 @@ _geoiplookup() _init_completion || return case $prev in - -h|-'?'|-v) + -h | -'?' | -v) return ;; -d) @@ -20,7 +20,7 @@ _geoiplookup() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" -h)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_usage "$1" -h)' -- "$cur")) return fi @@ -28,6 +28,6 @@ _geoiplookup() [[ $1 == *6 ]] && ipvx=-6 || ipvx=-4 _known_hosts_real $ipvx -- "$cur" } && -complete -F _geoiplookup geoiplookup geoiplookup6 + complete -F _geoiplookup geoiplookup geoiplookup6 # ex: filetype=sh diff --git a/completions/getconf b/completions/getconf index 6e86e9de..de1ad2d6 100644 --- a/completions/getconf +++ b/completions/getconf @@ -11,22 +11,22 @@ _getconf() return ;; -v) - COMPREPLY=( $(compgen -W \ + COMPREPLY=($(compgen -W \ '$("$1" -a 2>/dev/null | awk "{ print \$1 }")' -- \ - "${cur:-POSIX_V}") ) + "${cur:-POSIX_V}")) return ;; esac - if [[ $prev == PATH_MAX ]]; then # TODO more path vars, better handling + if [[ $prev == PATH_MAX ]]; then # TODO more path vars, better handling _filedir elif [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '-a -v' -- "$cur") ) + COMPREPLY=($(compgen -W '-a -v' -- "$cur")) else - COMPREPLY=( $(compgen -W \ - '$("$1" -a 2>/dev/null | awk "{ print \$1 }")' -- "$cur") ) + COMPREPLY=($(compgen -W \ + '$("$1" -a 2>/dev/null | awk "{ print \$1 }")' -- "$cur")) fi } && -complete -F _getconf getconf + complete -F _getconf getconf # ex: filetype=sh diff --git a/completions/getent b/completions/getent index 9a181f60..4c54a242 100644 --- a/completions/getent +++ b/completions/getent @@ -6,16 +6,16 @@ _getent() _init_completion -s || return local i db - for (( i=1; i < cword; i++ )); do + for ((i = 1; i < cword; i++)); do case ${words[i]} in - --version|--usage|--help|-!(-*)[V?]) + --version | --usage | --help | -!(-*)[V?]) return ;; - --service|-!(-*)s) - (( i++ )) - ;; - -*) + --service | -!(-*)s) + ((i++)) ;; + -*) ;; + *) # First non-option value is the db db=${words[i]} @@ -24,39 +24,39 @@ _getent() esac done - case $db in + case ${db-} in passwd) - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) return ;; group) - COMPREPLY=( $(compgen -g -- "$cur") ) + COMPREPLY=($(compgen -g -- "$cur")) return ;; services) - COMPREPLY=( $(compgen -s -- "$cur") ) + COMPREPLY=($(compgen -s -- "$cur")) return ;; hosts) - COMPREPLY=( $(compgen -A hostname -- "$cur") ) + COMPREPLY=($(compgen -A hostname -- "$cur")) return ;; - protocols|networks|ahosts|ahostsv4|ahostsv6|rpc) - COMPREPLY=( $(compgen -W "$($1 $db | \ - awk '{ print $1 }')" -- "$cur") ) + protocols | networks | ahosts | ahostsv4 | ahostsv6 | rpc) + COMPREPLY=($(compgen -W "$($1 $db | + awk '{ print $1 }')" -- "$cur")) return ;; - aliases|shadow|gshadow) - COMPREPLY=( $(compgen -W "$($1 $db | cut -d: -f1)" -- "$cur") ) + aliases | shadow | gshadow) + COMPREPLY=($(compgen -W "$($1 $db | cut -d: -f1)" -- "$cur")) return ;; - ethers|netgroup) + ethers | netgroup) return ;; esac case $prev in - -s|--service) + -s | --service) return ;; esac @@ -64,14 +64,14 @@ _getent() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace - elif [[ -z $db ]]; then - COMPREPLY=( $(compgen -W 'passwd group hosts services protocols + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${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") ) + shadow gshadow' -- "$cur")) fi } && -complete -F _getent getent + complete -F _getent getent # ex: filetype=sh diff --git a/completions/gkrellm b/completions/gkrellm index 9eb76bcb..c38c5ae1 100644 --- a/completions/gkrellm +++ b/completions/gkrellm @@ -6,34 +6,34 @@ _gkrellm() _init_completion || return case $prev in - -t|--theme) + -t | --theme) _filedir -d return ;; - -p|--plugin) + -p | --plugin) _filedir so return ;; - -s|--server) + -s | --server) _known_hosts_real -- "$cur" return ;; - -l|--logfile) + -l | --logfile) _filedir return ;; - -g|--geometry|-c|--config|-P|--port|-d|--debug-level) + -g | --geometry | -c | --config | -P | --port | -d | --debug-level) # Argument required but no completions available return ;; - -h|--help|-v|--version) + -h | --help | -v | --version) # All other options are noop with these return ;; esac - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _gkrellm gkrellm gkrellm2 + complete -F _gkrellm gkrellm gkrellm2 # ex: filetype=sh diff --git a/completions/gm b/completions/gm index 4ea4f3e9..b86c9cc3 100644 --- a/completions/gm +++ b/completions/gm @@ -2,8 +2,8 @@ _gm_commands() { - COMPREPLY+=( $(compgen -W '$("$1" help | - awk "/^ +[^ ]+ +- / { print \$1 }")' -- "$cur") ) + COMPREPLY+=($(compgen -W '$("$1" help | + awk "/^ +[^ ]+ +- / { print \$1 }")' -- "$cur")) } _gm() @@ -11,7 +11,7 @@ _gm() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then + if ((cword == 1)); then _gm_commands "$1" return elif [[ $cword -eq 2 && ${words[1]} == time ]]; then @@ -35,6 +35,6 @@ _gm() # TODO... defer some commnds to the imagemagick "gm"less completions etc? compopt -o default } && -complete -F _gm gm + complete -F _gm gm # ex: filetype=sh diff --git a/completions/gnatmake b/completions/gnatmake index 383bb9b4..5f4b9639 100644 --- a/completions/gnatmake +++ b/completions/gnatmake @@ -6,21 +6,21 @@ _gnatmake() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then + 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 + 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 -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' -- "$cur")) else # source file completion _filedir '@(adb|ads)' fi } && -complete -F _gnatmake gnatmake + complete -F _gnatmake gnatmake # ex: filetype=sh diff --git a/completions/gnokii b/completions/gnokii index ff43c3d1..039141ae 100644 --- a/completions/gnokii +++ b/completions/gnokii @@ -3,7 +3,7 @@ _gnokii_memory_type() { # TODO: reduce the number of choices - COMPREPLY=( $(compgen -W "IN OU SM ME MT" -- "$cur") ) + COMPREPLY=($(compgen -W "IN OU SM ME MT" -- "$cur")) } _gnokii() @@ -20,123 +20,123 @@ _gnokii() local config_file for config_file in "$XDG_CONFIG_HOME/gnokii/config" \ "$HOME/.config/gnokii/config" "$HOME/.gnokiirc" \ - "$XDG_CONFIG_DIRS/gnokii/config" /etc/gnokiirc ; do + "$XDG_CONFIG_DIRS/gnokii/config" /etc/gnokiirc; do [[ -f $config_file ]] && break done [[ ! -f $config_file ]] && return - COMPREPLY=( $(compgen -W \ + COMPREPLY=($(compgen -W \ "$(command sed -n 's/^\[phone_\(.*\)\]/\1/p' $config_file)" \ - -- "$cur") ) + -- "$cur")) return ;; --help) - COMPREPLY=( $(compgen -W 'all monitor sms mms phonebook calendar + COMPREPLY=($(compgen -W 'all monitor sms mms phonebook calendar todo dial profile settings wap logo ringtone security file - other' -- "$cur") ) + other' -- "$cur")) return ;; - --version|--shell|ping) + --version | --shell | ping) return ;; # MONITOR --monitor) - COMPREPLY=( $(compgen -W 'delay once' -- "$cur") ) + COMPREPLY=($(compgen -W 'delay once' -- "$cur")) return ;; - --getdisplaystatus|--displayoutput) + --getdisplaystatus | --displayoutput) return ;; --netmonitor) - COMPREPLY=( $(compgen -W 'reset off field devel next nr' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'reset off field devel next nr' \ + -- "$cur")) return ;; # SMS --sendsms) - # (how)TODO ? + # (how)TODO ? return ;; --savesms) - COMPREPLY=( $(compgen -W '--sender --smsc --smscno --folder - --location --sent --read --deliver --datetime' -- "$cur") ) + COMPREPLY=($(compgen -W '--sender --smsc --smscno --folder + --location --sent --read --deliver --datetime' -- "$cur")) return ;; - --memory-type|--memory|--getsms|--deletesms|--getmms|--deletemms|\ - --getphonebook|--deletephonebook) + --memory-type | --memory | --getsms | --deletesms | --getmms | --deletemms | \ + --getphonebook | --deletephonebook) _gnokii_memory_type return ;; - --getsmsc|--getcalendarnote|--deletecalendarnote|--gettodo|\ - --getspeeddial) + --getsmsc | --getcalendarnote | --deletecalendarnote | --gettodo | \ + --getspeeddial) # TODO: grab a specific entry ID return ;; - --setsmsc|--smsreader|--createsmsfolder|--deletealltodos|\ - --showsmsfolderstatus) + --setsmsc | --smsreader | --createsmsfolder | --deletealltodos | \ + --showsmsfolderstatus) return ;; - --deletesmsfolder|--folder) + --deletesmsfolder | --folder) # TODO: folderid return ;; --writephonebook) - COMPREPLY=( $(compgen -W '--overwrite --find-free --memory-type - --location --vcard --ldif' -- "$cur") ) + COMPREPLY=($(compgen -W '--overwrite --find-free --memory-type + --location --vcard --ldif' -- "$cur")) return ;; - --writecalendarnote|--writetodo) + --writecalendarnote | --writetodo) _filedir vcf return ;; # DIAL - --setspeeddial|--dialvoice|--senddtmf|--answercall|--hangup) + --setspeeddial | --dialvoice | --senddtmf | --answercall | --hangup) # TODO return ;; --divert) - COMPREPLY=( $(compgen -W '--op' -- "$cur") ) + COMPREPLY=($(compgen -W '--op' -- "$cur")) return ;; # PROFILE - --getprofile|--setactiveprofile) + --getprofile | --setactiveprofile) # TODO return ;; - --setprofile|--getactiveprofile) + --setprofile | --getactiveprofile) return ;; # SETTINGS --reset) - COMPREPLY=( $(compgen -W 'soft hard' -- "$cur") ) + COMPREPLY=($(compgen -W 'soft hard' -- "$cur")) return ;; - --setdatetime|--setalarm) + --setdatetime | --setalarm) # TODO return ;; - --getdatetime|--getalarm) + --getdatetime | --getalarm) return ;; # WAP - --getwapbookmark|--writewapbookmark|--deletewapbookmark|\ - --getwapsetting|--writewapsetting|--activatewapsetting) + --getwapbookmark | --writewapbookmark | --deletewapbookmark | \ + --getwapsetting | --writewapsetting | --activatewapsetting) return ;; # LOGOS --sendlogo) - COMPREPLY=( $(compgen -W 'caller op picture' -- "$cur") ) + COMPREPLY=($(compgen -W 'caller op picture' -- "$cur")) return ;; - --setlogo|--getlogo) - COMPREPLY=( $(compgen -W 'op startup caller dealer text' \ - -- "$cur") ) + --setlogo | --getlogo) + COMPREPLY=($(compgen -W 'op startup caller dealer text' \ + -- "$cur")) return ;; --viewlogo) @@ -145,77 +145,79 @@ _gnokii() ;; --entersecuritycode) - COMPREPLY=( $(compgen -W 'PIN PIN2 PUK PUK2 SEC' -- "$cur") ) + COMPREPLY=($(compgen -W 'PIN PIN2 PUK PUK2 SEC' -- "$cur")) return ;; - # TODO: RINGTONES + # TODO: RINGTONES esac # second level completion - if [[ $((cword-2)) -ge 1 && ${words[cword-2]} =~ --* ]]; then - pprev=${words[cword-2]} + if [[ $((cword - 2)) -ge 1 && ${words[cword - 2]} =~ --* ]]; then + pprev=${words[cword - 2]} case $pprev in --setspeeddial) _gnokii_memory_type return ;; - --getsms|--deletesms|--getmms|--deletemms|--getphonebook|\ - --writetodo|--writecalendarnote) + --getsms | --deletesms | --getmms | --deletemms | --getphonebook | \ + --writetodo | --writecalendarnote) # TODO: start number return ;; - --gettodo|--getcalendarnote) - COMPREPLY=( $(compgen -W '{1..9} end --vCal' -- "$cur") ) + --gettodo | --getcalendarnote) + COMPREPLY=($(compgen -W '{1..9} end --vCal' -- "$cur")) return ;; --deletecalendarnote) - COMPREPLY=( $(compgen -W '{1..9} end' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..9} end' -- "$cur")) return ;; --divert) - COMPREPLY=( $(compgen -W 'register enable query disable - erasure' -- "$cur") ) + COMPREPLY=($(compgen -W 'register enable query disable + erasure' -- "$cur")) return ;; esac fi # third level completion - if [[ $((cword-3)) -ge 1 && ${words[cword-3]} =~ --* ]]; then - tprev=${words[cword-3]} + if [[ $((cword - 3)) -ge 1 && ${words[cword - 3]} =~ --* ]]; then + tprev=${words[cword - 3]} case $tprev in - --deletesms|--deletemms) - COMPREPLY=( $(compgen -W 'end' -- "$cur") ) + --deletesms | --deletemms) + COMPREPLY=($(compgen -W 'end' -- "$cur")) return ;; - --getphonebook|--writetodo|--writecalendarnote) - COMPREPLY=( $(compgen -W '{1..9} end' -- "$cur") ) + --getphonebook | --writetodo | --writecalendarnote) + COMPREPLY=($(compgen -W '{1..9} end' -- "$cur")) return ;; - --gettodo|--getcalendarnote) - [[ ${words[cword-1]} == end ]] && \ - COMPREPLY=( $(compgen -W '--vCal' -- "$cur") ) + --gettodo | --getcalendarnote) + [[ ${words[cword - 1]} == end ]] && + COMPREPLY=($(compgen -W '--vCal' -- "$cur")) return ;; --divert) - COMPREPLY=( $(compgen -W '--type' -- "$cur") ) + COMPREPLY=($(compgen -W '--type' -- "$cur")) return + ;; esac fi # fourth level completion - if [[ $((cword-4)) -ge 1 && ${words[cword-4]} =~ --* ]]; then - fprev=${words[cword-4]} + if [[ $((cword - 4)) -ge 1 && ${words[cword - 4]} =~ --* ]]; then + fprev=${words[cword - 4]} case $fprev in --getphonebook) - COMPREPLY=( $(compgen -W '--raw --vcard --ldif' -- "$cur") ) + COMPREPLY=($(compgen -W '--raw --vcard --ldif' -- "$cur")) return ;; --divert) - COMPREPLY=( $(compgen -W 'all busy noans outofreach notavail' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'all busy noans outofreach notavail' \ + -- "$cur")) return + ;; esac fi @@ -226,10 +228,10 @@ _gnokii() # don't provide main command completions if one is # already on the command line - [[ $COMP_LINE =~ $(tr ' ' '\b|'<<<$main_cmd) ]] && return + [[ $COMP_LINE =~ $(tr ' ' '\b|' <<<$main_cmd) ]] && return - COMPREPLY=( $(compgen -W "$all_cmd" -- "$cur") ) + COMPREPLY=($(compgen -W "$all_cmd" -- "$cur")) } && -complete -F _gnokii gnokii + complete -F _gnokii gnokii # ex: filetype=sh diff --git a/completions/gnome-mplayer b/completions/gnome-mplayer index fa4361df..32d93fc3 100644 --- a/completions/gnome-mplayer +++ b/completions/gnome-mplayer @@ -6,11 +6,11 @@ _gnome_mplayer() _init_completion -s || return case $prev in - -'?'|--help|--help-all|--help-gtk) + -'?' | --help | --help-all | --help-gtk) return ;; - --showcontrols|--showsubtitles|--autostart) - COMPREPLY=( $(compgen -w '0 1' -- "$cur") ) + --showcontrols | --showsubtitles | --autostart) + COMPREPLY=($(compgen -w '0 1' -- "$cur")) return ;; --subtitle) @@ -18,7 +18,7 @@ _gnome_mplayer() return ;; --tvdriver) - COMPREPLY=( $(compgen -W 'v4l v4l2' -- "$cur") ) + COMPREPLY=($(compgen -W 'v4l v4l2' -- "$cur")) return ;; esac @@ -26,13 +26,13 @@ _gnome_mplayer() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help-all)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _gnome_mplayer gnome-mplayer + complete -F _gnome_mplayer gnome-mplayer # ex: filetype=sh diff --git a/completions/gnome-screenshot b/completions/gnome-screenshot index d0270c38..b3594d20 100644 --- a/completions/gnome-screenshot +++ b/completions/gnome-screenshot @@ -6,14 +6,14 @@ _gnome_screenshot() _init_completion -s || return case $prev in - --help|--help-*|--version|--delay|--display|-!(-*)[hd]) + --help | --help-* | --version | --delay | --display | -!(-*)[hd]) return ;; - --border-effect|-!(-*)e) - COMPREPLY=( $(compgen -W 'shadow border vintage none' -- "$cur") ) + --border-effect | -!(-*)e) + COMPREPLY=($(compgen -W 'shadow border vintage none' -- "$cur")) return ;; - --file|-!(-*)f) + --file | -!(-*)f) _filedir '@(jp?(e)|pn)g' return ;; @@ -22,10 +22,10 @@ _gnome_screenshot() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _gnome_screenshot gnome-screenshot + complete -F _gnome_screenshot gnome-screenshot # ex: filetype=sh diff --git a/completions/gpasswd b/completions/gpasswd index 8f27cfec..f1f22003 100644 --- a/completions/gpasswd +++ b/completions/gpasswd @@ -6,20 +6,20 @@ _gpasswd() _init_completion || return case $prev in - --add|--delete|--administrators|--members|-!(-*)[adAM]) - COMPREPLY=( $(compgen -u -- "$cur") ) + --add | --delete | --administrators | --members | -!(-*)[adAM]) + COMPREPLY=($(compgen -u -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # TODO: only -A and -M can be combined - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - COMPREPLY=( $(compgen -g -- "$cur") ) + COMPREPLY=($(compgen -g -- "$cur")) } && -complete -F _gpasswd gpasswd + complete -F _gpasswd gpasswd # ex: filetype=sh diff --git a/completions/gpg b/completions/gpg index cb00fa66..f0ca8845 100644 --- a/completions/gpg +++ b/completions/gpg @@ -6,33 +6,33 @@ _gpg() _init_completion || return case $prev in - --sign|--clearsign|--decrypt-files|--load-extension|-!(-*)s) + --sign | --clearsign | --decrypt-files | --load-extension | -!(-*)s) _filedir return ;; - --export|--sign-key|--lsign-key|--nrsign-key|--nrlsign-key|--edit-key) + --export | --sign-key | --lsign-key | --nrsign-key | --nrlsign-key | --edit-key) # return list of public keys - COMPREPLY=( $(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \ + COMPREPLY=($(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \ 's@^pub.*/\([^ ]*\).*$@\1@p' -ne \ - 's@^.*\(<\([^>]*\)>\).*$@\2@p')" -- "$cur") ) + 's@^.*\(<\([^>]*\)>\).*$@\2@p')" -- "$cur")) return ;; - --recipient|-!(-*)r) - COMPREPLY=( $(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \ - 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur") ) + --recipient | -!(-*)r) + COMPREPLY=($(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \ + 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur")) if [[ -e ~/.gnupg/gpg.conf ]]; then - COMPREPLY+=( $(compgen -W "$(command sed -ne \ + COMPREPLY+=($(compgen -W "$(command sed -ne \ 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \ - ~/.gnupg/gpg.conf)" -- "$cur") ) + ~/.gnupg/gpg.conf)" -- "$cur")) fi return - ;; + ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$($1 --dump-options)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$($1 --dump-options)' -- "$cur")) fi } && -complete -F _gpg -o default gpg + complete -F _gpg -o default gpg # ex: filetype=sh diff --git a/completions/gpg2 b/completions/gpg2 index 45014922..cfa40231 100644 --- a/completions/gpg2 +++ b/completions/gpg2 @@ -10,33 +10,33 @@ _gpg2() _filedir -d return ;; - --sign|--clearsign|--options|--decrypt|-!(-*)s) + --sign | --clearsign | --options | --decrypt | -!(-*)s) _filedir return ;; - --export|--sign-key|--lsign-key|--nrsign-key|--nrlsign-key|--edit-key) + --export | --sign-key | --lsign-key | --nrsign-key | --nrlsign-key | --edit-key) # return list of public keys - COMPREPLY=( $(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \ + COMPREPLY=($(compgen -W "$($1 --list-keys 2>/dev/null | command sed -ne \ 's@^pub.*/\([^ ]*\).*$@\1@p' -ne \ - 's@^.*\(<\([^>]*\)>\).*$@\2@p')" -- "$cur") ) + 's@^.*\(<\([^>]*\)>\).*$@\2@p')" -- "$cur")) return ;; - --recipient|-!(-*)r) - COMPREPLY=( $(compgen -W "$($1 --list-keys 2>/dev/null | \ - command sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur") ) + --recipient | -!(-*)r) + COMPREPLY=($(compgen -W "$($1 --list-keys 2>/dev/null | + command sed -ne 's@^.*<\([^>]*\)>.*$@\1@p')" -- "$cur")) if [[ -e ~/.gnupg/gpg.conf ]]; then - COMPREPLY+=( $(compgen -W "$(command sed -ne \ + COMPREPLY+=($(compgen -W "$(command sed -ne \ 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' \ - ~/.gnupg/gpg.conf)" -- "$cur") ) + ~/.gnupg/gpg.conf)" -- "$cur")) fi - return - ;; + return + ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$($1 --dump-options)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$($1 --dump-options)' -- "$cur")) fi } && -complete -F _gpg2 -o default gpg2 + complete -F _gpg2 -o default gpg2 # ex: filetype=sh diff --git a/completions/gpgv b/completions/gpgv index a3221afc..29315c9c 100644 --- a/completions/gpgv +++ b/completions/gpgv @@ -6,7 +6,7 @@ _gpgv() _init_completion || return case $prev in - --help|--version|--weak-digest|--*-fd|-!(-*)[?h]*) + --help | --version | --weak-digest | --*-fd | -!(-*)[?h]*) return ;; --keyring) @@ -23,15 +23,15 @@ _gpgv() _count_args "" "--@(weak-digest|*-fd|keyring|homedir)" if [[ $cur == -* && $args -eq 1 ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - if [[ $args -gt 1 ]]; then + if ((args > 1)); then if [[ ${COMP_LINE,,} == *.@(asc|sig|sign)\ * ]]; then # Detached signature, only complete one arbitrary file arg and - - if [[ $args -eq 2 ]]; then - COMPREPLY=( $(compgen -W '-' -- "$cur") ) + if ((args == 2)); then + COMPREPLY=($(compgen -W '-' -- "$cur")) _filedir fi else @@ -41,6 +41,6 @@ _gpgv() _filedir "@(asc|gpg|sig|sign)" fi } && -complete -F _gpgv gpgv gpgv2 + complete -F _gpgv gpgv gpgv2 # ex: filetype=sh diff --git a/completions/gphoto2 b/completions/gphoto2 index 89277a95..cbf84c0a 100644 --- a/completions/gphoto2 +++ b/completions/gphoto2 @@ -18,37 +18,38 @@ _gphoto2() _filedir return ;; - -u|--upload-file) + -u | --upload-file) _filedir return ;; --port) - COMPREPLY=( $(compgen -W "$($1 --list-ports 2>/dev/null | \ - awk 'NR>3 { print $1 }')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 --list-ports 2>/dev/null | + awk 'NR>3 { print $1 }')" -- "$cur")) __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") ) + COMPREPLY=($(compgen -W "$($1 --list-cameras 2>/dev/null | + awk -F'"' 'NR>2 { print $2 }')" -- "$cur")) return ;; - --get-config|--set-config|--set-config-index|--set-config-value) - COMPREPLY=( $(compgen -W "$($1 --list-config 2>/dev/null \ - )" -- "$cur") ) + --get-config | --set-config | --set-config-index | --set-config-value) + COMPREPLY=($(compgen -W "$( + $1 --list-config 2>/dev/null + )" -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _gphoto2 gphoto2 + complete -F _gphoto2 gphoto2 # ex: filetype=sh diff --git a/completions/gprof b/completions/gprof index 40a74820..5a4ab2d4 100644 --- a/completions/gprof +++ b/completions/gprof @@ -6,37 +6,37 @@ _gprof() _init_completion -s || return case $cur in - -A*|-C*|-J*|-p*|-P*|-q*|-Q*|-n*|-N*|-d*) + -A* | -C* | -J* | -p* | -P* | -q* | -Q* | -n* | -N* | -d*) return ;; -S*) cur=${cur:2} _filedir - COMPREPLY=( "${COMPREPLY[@]/#/-S}" ) + COMPREPLY=("${COMPREPLY[@]/#/-S}") return ;; -O*) cur=${cur:2} - COMPREPLY=( $(compgen -P -O -W 'auto bsd 4.4bsd magic prof' \ - -- "$cur") ) + COMPREPLY=($(compgen -P -O -W 'auto bsd 4.4bsd magic prof' \ + -- "$cur")) return ;; esac case $prev in - -I|--directory-path) + -I | --directory-path) _filedir -d return ;; - -R|--file-ordering|--external-symbol-table) + -R | --file-ordering | --external-symbol-table) _filedir return ;; - -w|--width|-k|-m|--min-count|-h|--help|-e|-E|-f|-F) + -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") ) + COMPREPLY=($(compgen -W 'auto bsd 4.4bsd magic prof' -- "$cur")) return ;; esac @@ -44,13 +44,13 @@ _gprof() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _gprof gprof + complete -F _gprof gprof # ex: filetype=sh diff --git a/completions/groupadd b/completions/groupadd index 013feaa4..5f67f299 100644 --- a/completions/groupadd +++ b/completions/groupadd @@ -9,18 +9,18 @@ _groupadd() # with -g/--gid case $prev in - --gid|--key|--password|-!(-*)[gKp]) + --gid | --key | --password | -!(-*)[gKp]) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _groupadd groupadd + complete -F _groupadd groupadd # ex: filetype=sh diff --git a/completions/groupdel b/completions/groupdel index fcdd14c1..4d8ca7f7 100644 --- a/completions/groupdel +++ b/completions/groupdel @@ -6,22 +6,22 @@ _groupdel() _init_completion || return case $prev in - -h|--help) + -h | --help) return ;; - -R|--root) + -R | --root) _filedir -d return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - COMPREPLY=( $(compgen -g -- "$cur") ) + COMPREPLY=($(compgen -g -- "$cur")) } && -complete -F _groupdel groupdel + complete -F _groupdel groupdel # ex: filetype=sh diff --git a/completions/groupmems b/completions/groupmems index 6e599a24..2e89a5ab 100644 --- a/completions/groupmems +++ b/completions/groupmems @@ -6,22 +6,22 @@ _groupmems() _init_completion || return case $prev in - -a|--add|-d|--delete) - COMPREPLY=( $(compgen -u -- "$cur") ) + -a | --add | -d | --delete) + COMPREPLY=($(compgen -u -- "$cur")) return ;; - -g|--group) - COMPREPLY=( $(compgen -g -- "$cur") ) + -g | --group) + COMPREPLY=($(compgen -g -- "$cur")) return ;; - -R|--root) + -R | --root) _filedir -d return ;; esac - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _groupmems groupmems + complete -F _groupmems groupmems # ex: filetype=sh diff --git a/completions/groupmod b/completions/groupmod index 2ac62ea3..5516d31c 100644 --- a/completions/groupmod +++ b/completions/groupmod @@ -9,21 +9,21 @@ _groupmod() # with -g/--gid case $prev in - --gid|--help|--new-name|--password|-!(-*)[ghnp]) + --gid | --help | --new-name | --password | -!(-*)[ghnp]) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi - COMPREPLY=( $(compgen -g -- "$cur") ) + COMPREPLY=($(compgen -g -- "$cur")) } && -complete -F _groupmod groupmod + complete -F _groupmod groupmod # ex: filetype=sh diff --git a/completions/growisofs b/completions/growisofs index a0c6de3f..ee09fe6c 100644 --- a/completions/growisofs +++ b/completions/growisofs @@ -6,10 +6,10 @@ _growisofs() _init_completion || return case $prev in - -version|-speed) + -version | -speed) return ;; - -Z|-M) + -Z | -M) compopt -o nospace _dvd_devices return @@ -24,16 +24,16 @@ _growisofs() ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # TODO: mkisofs options - COMPREPLY=( $(compgen -W '-dvd-compat -overburn -speed= -Z -M' \ - -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '-dvd-compat -overburn -speed= -Z -M' \ + -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _growisofs growisofs + complete -F _growisofs growisofs # ex: filetype=sh diff --git a/completions/grpck b/completions/grpck index 9f5eac7b..0fadbedc 100644 --- a/completions/grpck +++ b/completions/grpck @@ -6,20 +6,20 @@ _grpck() _init_completion || return case $prev in - --root|-!(-*)R) + --root | -!(-*)R) _filedir return ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) return fi _filedir } && -complete -F _grpck grpck + complete -F _grpck grpck # ex: filetype=sh diff --git a/completions/gssdp-discover b/completions/gssdp-discover index f0fa6955..8454f52a 100644 --- a/completions/gssdp-discover +++ b/completions/gssdp-discover @@ -6,26 +6,29 @@ _gssdp_discover() _init_completion -s || return case $prev in - --help|--target|--timeout|--rescan-interval|-[htnr]) + --help | --target | --timeout | --rescan-interval | -[htnr]) return ;; - --interface|-i) + --interface | -i) _available_interfaces -a return ;; - --message-type|-m) - local types=$($1 --help 2>&1 | \ + --message-type | -m) + local types=$($1 --help 2>&1 | command sed -ne 's/^.*--message-type=.*(\([^)]*\))$/\1/p') - COMPREPLY=( $(IFS+=,; compgen -W "$types" -- "$cur") ) + COMPREPLY=($( + IFS+=, + compgen -W "$types" -- "$cur" + )) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _gssdp_discover gssdp-discover + complete -F _gssdp_discover gssdp-discover # ex: filetype=sh diff --git a/completions/gzip b/completions/gzip index d3bce282..0144c3a3 100644 --- a/completions/gzip +++ b/completions/gzip @@ -6,38 +6,38 @@ _gzip() _init_completion || return case $prev in - --blocksize|--suffix|--help|--version|-!(-*)[bShV]) + --blocksize | --suffix | --help | --version | -!(-*)[bShV]) return ;; - --processes|-!(-*)p) - COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) + --processes | -!(-*)p) + COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") {-1..-9}' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") {-1..-9}' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi local IFS=$'\n' xspec="*.@(gz|t[ag]z)" [[ ${1##*/} == pigz ]] && xspec="*.@([gz]z|t[ag]z)" - if [[ "$prev" == --* ]]; then - [[ "$prev" == --@(decompress|list|test) ]] && xspec="!"$xspec - [[ "$prev" == --force ]] && xspec= - elif [[ "$prev" == -* ]]; then - [[ "$prev" == -*[dlt]* ]] && xspec="!"$xspec - [[ "$prev" == -*f* ]] && xspec= + if [[ $prev == --* ]]; then + [[ $prev == --@(decompress|list|test) ]] && xspec="!"$xspec + [[ $prev == --force ]] && xspec= + elif [[ $prev == -* ]]; then + [[ $prev == -*[dlt]* ]] && xspec="!"$xspec + [[ $prev == -*f* ]] && xspec= fi _tilde "$cur" || return compopt -o filenames - COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") \ - $(compgen -d -- "$cur") ) + COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") + $(compgen -d -- "$cur")) } && -complete -F _gzip gzip pigz + complete -F _gzip gzip pigz # ex: filetype=sh diff --git a/completions/hcitool b/completions/hcitool index ccc64f18..58bf5a7a 100644 --- a/completions/hcitool +++ b/completions/hcitool @@ -3,28 +3,28 @@ _bluetooth_addresses() { if [[ -n ${COMP_BLUETOOTH_SCAN:-} ]]; then - COMPREPLY+=( $(compgen -W "$(hcitool scan | \ - awk '/^\t/{print $1}')" -- "$cur") ) + COMPREPLY+=($(compgen -W "$(hcitool scan | + awk '/^\t/{print $1}')" -- "$cur")) fi } _bluetooth_devices() { - COMPREPLY+=( $(compgen -W "$(hcitool dev | \ - awk '/^\t/{print $1}')" -- "$cur") ) + COMPREPLY+=($(compgen -W "$(hcitool dev | + awk '/^\t/{print $1}')" -- "$cur")) } _bluetooth_services() { - COMPREPLY=( $(compgen -W 'DID SP DUN LAN FAX OPUSH FTP HS HF HFAG SAP NAP + 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") ) + -- "$cur")) } _bluetooth_packet_types() { - COMPREPLY=( $(compgen -W 'DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3' \ + -- "$cur")) } _hcitool() @@ -38,7 +38,7 @@ _hcitool() return ;; --role) - COMPREPLY=( $(compgen -W 'm s' -- "$cur") ) + COMPREPLY=($(compgen -W 'm s' -- "$cur")) return ;; --pkt-type) @@ -52,60 +52,60 @@ _hcitool() local arg _get_first_arg if [[ -z $arg ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else - COMPREPLY=( $(compgen -W 'dev inq scan name info spinq epinq cmd + 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") ) + clock' -- "$cur")) fi else local args case $arg in - name|info|dc|rssi|lq|afh|auth|key|clkoff|lst) + name | info | dc | rssi | lq | afh | auth | key | clkoff | lst) _count_args - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _bluetooth_addresses fi ;; cc) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--role --pkt-type' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--role --pkt-type' -- "$cur")) else _count_args - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _bluetooth_addresses fi fi ;; sr) _count_args - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _bluetooth_addresses else - COMPREPLY=( $(compgen -W 'master slave' -- "$cur") ) + COMPREPLY=($(compgen -W 'master slave' -- "$cur")) fi ;; cpt) _count_args - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _bluetooth_addresses else _bluetooth_packet_types fi ;; - tpl|enc|clock) + tpl | enc | clock) _count_args - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _bluetooth_addresses else - COMPREPLY=( $(compgen -W '0 1' -- "$cur") ) + COMPREPLY=($(compgen -W '0 1' -- "$cur")) fi ;; esac fi } && -complete -F _hcitool hcitool + complete -F _hcitool hcitool _sdptool() { @@ -124,46 +124,46 @@ _sdptool() local arg _get_first_arg if [[ -z $arg ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else - COMPREPLY=( $(compgen -W 'search browse records add del get - setattr setseq' -- "$cur") ) + COMPREPLY=($(compgen -W 'search browse records add del get + setattr setseq' -- "$cur")) fi else case $arg in search) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--bdaddr --tree --raw --xml' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--bdaddr --tree --raw --xml' \ + -- "$cur")) else _bluetooth_services fi ;; - browse|records) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--tree --raw --xml' -- "$cur") ) + browse | records) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--tree --raw --xml' -- "$cur")) else _bluetooth_addresses fi ;; add) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--handle --channel' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--handle --channel' -- "$cur")) else _bluetooth_services fi ;; get) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--bdaddr --tree --raw --xml' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--bdaddr --tree --raw --xml' \ + -- "$cur")) fi ;; esac fi } && -complete -F _sdptool sdptool + complete -F _sdptool sdptool _l2ping() { @@ -175,18 +175,18 @@ _l2ping() _bluetooth_devices return ;; - -s|-c|-t|-d) + -s | -c | -t | -d) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) else _bluetooth_addresses fi } && -complete -F _l2ping l2ping + complete -F _l2ping l2ping _rfcomm() { @@ -194,7 +194,7 @@ _rfcomm() _init_completion || return case $prev in - -f|--config) + -f | --config) _filedir return ;; @@ -208,21 +208,21 @@ _rfcomm() local arg _get_first_arg if [[ -z $arg ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else - COMPREPLY=( $(compgen -W 'show connect listen watch bind - release' -- "$cur") ) + COMPREPLY=($(compgen -W 'show connect listen watch bind + release' -- "$cur")) fi else local args _count_args - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _bluetooth_devices else case $arg in - connect|bind) - if [[ $args -eq 3 ]]; then + connect | bind) + if ((args == 3)); then _bluetooth_addresses fi ;; @@ -230,7 +230,7 @@ _rfcomm() fi fi } && -complete -F _rfcomm rfcomm + complete -F _rfcomm rfcomm _ciptool() { @@ -248,25 +248,25 @@ _ciptool() local arg _get_first_arg if [[ -z $arg ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else - COMPREPLY=( $(compgen -W 'show search connect release loopback' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'show search connect release loopback' \ + -- "$cur")) fi else local args case $arg in - connect|release|loopback) + connect | release | loopback) _count_args - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _bluetooth_addresses fi ;; esac fi } && -complete -F _ciptool ciptool + complete -F _ciptool ciptool _dfutool() { @@ -274,21 +274,21 @@ _dfutool() _init_completion || return case $prev in - -d|--device) + -d | --device) _bluetooth_devices return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else local args _count_args case $args in 1) - COMPREPLY=( $(compgen -W 'verify modify upgrade archive' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'verify modify upgrade archive' \ + -- "$cur")) ;; 2) _filedir @@ -296,7 +296,7 @@ _dfutool() esac fi } && -complete -F _dfutool dfutool + complete -F _dfutool dfutool _hciconfig() { @@ -306,68 +306,68 @@ _hciconfig() local arg _get_first_arg if [[ -z $arg ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --all' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--help --all' -- "$cur")) else - COMPREPLY=( $(compgen -W 'up down reset rstat auth noauth encrypt + 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") ) + version revision lm' -- "$cur")) fi else local args case $arg in - putkey|delkey) + putkey | delkey) _count_args - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _bluetooth_addresses fi ;; lm) _count_args - if [[ $args -eq 2 ]]; then - COMPREPLY=( $(compgen -W 'MASTER SLAVE NONE ACCEPT' \ - -- "$cur") ) + if ((args == 2)); then + COMPREPLY=($(compgen -W 'MASTER SLAVE NONE ACCEPT' \ + -- "$cur")) fi ;; ptype) _count_args - if [[ $args -eq 2 ]]; then + if ((args == 2)); then _bluetooth_packet_types fi ;; esac fi } && -complete -F _hciconfig hciconfig + complete -F _hciconfig hciconfig _hciattach() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-n -p -t -b -s -l' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-n -p -t -b -s -l' -- "$cur")) else local args _count_args case $args in 1) - COMPREPLY=( $(printf '%s\n' /dev/tty*) ) - COMPREPLY=( $(compgen -W '${COMPREPLY[@]} - ${COMPREPLY[@]#/dev/}' -- "$cur") ) + COMPREPLY=($(printf '%s\n' /dev/tty*)) + COMPREPLY=($(compgen -W '${COMPREPLY[@]} + ${COMPREPLY[@]#/dev/}' -- "$cur")) ;; 2) - COMPREPLY=( $(compgen -W 'any ericsson digi xircom csr bboxes - swave bcsp 0x0105 0x080a 0x0160 0x0002' -- "$cur") ) + COMPREPLY=($(compgen -W 'any ericsson digi xircom csr bboxes + swave bcsp 0x0105 0x080a 0x0160 0x0002' -- "$cur")) ;; 3) - COMPREPLY=( $(compgen -W '9600 19200 38400 57600 115200 230400 - 460800 921600' -- "$cur") ) + COMPREPLY=($(compgen -W '9600 19200 38400 57600 115200 230400 + 460800 921600' -- "$cur")) ;; 4) - COMPREPLY=( $(compgen -W 'flow noflow' -- "$cur") ) + COMPREPLY=($(compgen -W 'flow noflow' -- "$cur")) ;; 5) _bluetooth_addresses @@ -375,6 +375,6 @@ _hciattach() esac fi } && -complete -F _hciattach hciattach + complete -F _hciattach hciattach # ex: filetype=sh diff --git a/completions/hddtemp b/completions/hddtemp index b7487cc9..7b95f0ee 100644 --- a/completions/hddtemp +++ b/completions/hddtemp @@ -6,19 +6,19 @@ _hddtemp() _init_completion -s || return case $prev in - --file|-!(-*)f) + --file | -!(-*)f) _filedir db return ;; - --listen|-!(-*)l) + --listen | -!(-*)l) _ip_addresses return ;; - --unit|-!(-*)u) - COMPREPLY=( $(compgen -W 'C F' -- "$cur") ) + --unit | -!(-*)u) + COMPREPLY=($(compgen -W 'C F' -- "$cur")) return ;; - --port|--separator|--syslog|--version|--help|-!(-*)[psSvh?]) + --port | --separator | --syslog | --version | --help | -!(-*)[psSvh?]) return ;; esac @@ -26,13 +26,13 @@ _hddtemp() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") --help' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1") --help' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else cur=${cur:=/dev/} _filedir fi } && -complete -F _hddtemp hddtemp + complete -F _hddtemp hddtemp # ex: filetype=sh diff --git a/completions/hid2hci b/completions/hid2hci index 9e3305d0..f33a4957 100644 --- a/completions/hid2hci +++ b/completions/hid2hci @@ -5,11 +5,11 @@ _hid2hci() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --quiet -0 --tohci -1 --tohid' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--help --quiet -0 --tohci -1 --tohid' \ + -- "$cur")) fi } && -complete -F _hid2hci hid2hci + complete -F _hid2hci hid2hci # ex: filetype=sh diff --git a/completions/hostname b/completions/hostname index 68f9b4ed..ce1b32e2 100644 --- a/completions/hostname +++ b/completions/hostname @@ -6,18 +6,18 @@ _hostname() _init_completion || return case $prev in - --help|--version|-!(-*)[hV]) + --help | --version | -!(-*)[hV]) return ;; - --file|-!(-*)F) + --file | -!(-*)F) _filedir return ;; esac - [[ $cur == -* ]] && \ - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + [[ $cur == -* ]] && + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _hostname hostname + complete -F _hostname hostname # ex: filetype=sh diff --git a/completions/hping2 b/completions/hping2 index 78d35b05..666838b1 100644 --- a/completions/hping2 +++ b/completions/hping2 @@ -6,30 +6,30 @@ _hping2() _init_completion || return case $prev in - --interface|-!(-*)I) + --interface | -!(-*)I) _available_interfaces return ;; - --spoof|-!(-*)a) + --spoof | -!(-*)a) _known_hosts_real -- "$cur" return ;; - --tos|-!(-*)o) - COMPREPLY=( $(compgen -W '02 04 08 10') ) + --tos | -!(-*)o) + COMPREPLY=($(compgen -W '02 04 08 10')) return ;; - --file|-!(-*)E) + --file | -!(-*)E) _filedir return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) else _known_hosts_real -- "$cur" fi } && -complete -F _hping2 hping hping2 hping3 + complete -F _hping2 hping hping2 hping3 # ex: filetype=sh diff --git a/completions/htop b/completions/htop index 3f1680b5..b4916d5b 100644 --- a/completions/htop +++ b/completions/htop @@ -6,15 +6,15 @@ _htop() _init_completion -s || return case "$prev" in - --sort-key|-!(-*)s) - COMPREPLY=( $(compgen -W '$("$1" -s help)' -- "$cur") ) + --sort-key | -!(-*)s) + COMPREPLY=($(compgen -W '$("$1" -s help)' -- "$cur")) return ;; - --user|-!(-*)u) - COMPREPLY=( $(compgen -u -- "$cur") ) + --user | -!(-*)u) + COMPREPLY=($(compgen -u -- "$cur")) return ;; - --delay|-!(-*)d) + --delay | -!(-*)d) # argument required but no completions available return ;; @@ -22,12 +22,12 @@ _htop() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi } && -complete -F _htop htop + complete -F _htop htop # ex: filetype=sh diff --git a/completions/htpasswd b/completions/htpasswd index 827e6dcc..527684bf 100644 --- a/completions/htpasswd +++ b/completions/htpasswd @@ -6,28 +6,31 @@ _htpasswd() _init_completion || return local i o=0 # $o is index of first non-option argument - for (( i=1; i <= cword; i++ )); do + for ((i = 1; i <= cword; i++)); do case ${words[i]} in - -*n*) return ;; - -*) ;; - *) o=$i ; break ;; + -*n*) return ;; + -*) ;; + *) + o=$i + break + ;; esac done - if [[ $o -eq 0 || $o -eq $cword ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if ((o == 0 || o == cword)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi # Password file (first non-option argument) _filedir - elif [[ $o -eq $cword-1 ]]; then + elif ((o == cword - 1)); then # Username (second non-option argument) - COMPREPLY=( $(compgen -W \ - '$(cut -d: -f1 "${words[o]}" 2>/dev/null)' -- "$cur") ) + COMPREPLY=($(compgen -W \ + '$(cut -d: -f1 "${words[o]}" 2>/dev/null)' -- "$cur")) fi } && -complete -F _htpasswd htpasswd + complete -F _htpasswd htpasswd # ex: filetype=sh diff --git a/completions/hunspell b/completions/hunspell index 627f3e4b..92b4fe84 100644 --- a/completions/hunspell +++ b/completions/hunspell @@ -6,18 +6,19 @@ _hunspell() _init_completion || return case $prev in - --help|--version|-vv|-[hPv]) + --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}" ) + 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") ) + COMPREPLY=($(compgen -W '${dicts[@]}' -- "$cur")) return ;; -i) @@ -31,12 +32,12 @@ _hunspell() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi _filedir } && -complete -F _hunspell hunspell + complete -F _hunspell hunspell # ex: filetype=sh diff --git a/completions/iconv b/completions/iconv index 372c525b..81ae01ba 100644 --- a/completions/iconv +++ b/completions/iconv @@ -2,8 +2,8 @@ _iconv_charsets() { - COMPREPLY+=( $(compgen -X ... -W '$(${1:-iconv} -l | \ - command sed -e "s@/*\$@@" -e "s/[,()]//g")' -- "$cur") ) + COMPREPLY+=($(compgen -X ... -W '$(${1:-iconv} -l | \ + command sed -e "s@/*\$@@" -e "s/[,()]//g")' -- "$cur")) } _iconv() @@ -12,15 +12,15 @@ _iconv() _init_completion -s || return case $prev in - --help|--usage|--version|--unicode-subst|--byte-subst|\ - --widechar-subst|-!(-*)[?V]) + --help | --usage | --version | --unicode-subst | --byte-subst | \ + --widechar-subst | -!(-*)[?V]) return ;; - --from-code|--to-code|-!(-*)[ft]) + --from-code | --to-code | -!(-*)[ft]) _iconv_charsets $1 return ;; - --output|-!(-*)o) + --output | -!(-*)o) _filedir return ;; @@ -28,11 +28,11 @@ _iconv() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _iconv -o default iconv + complete -F _iconv -o default iconv # ex: filetype=sh diff --git a/completions/id b/completions/id index 3f3087cb..a07e51dc 100644 --- a/completions/id +++ b/completions/id @@ -5,14 +5,14 @@ _id() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local opts=$(_parse_help "$1") [[ $opts ]] || opts="-G -g -u" # POSIX fallback - COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) + COMPREPLY=($(compgen -W "$opts" -- "$cur")) else - COMPREPLY=( $(compgen -u "$cur") ) + COMPREPLY=($(compgen -u "$cur")) fi } && -complete -F _id id + complete -F _id id # ex: filetype=sh diff --git a/completions/idn b/completions/idn index 39d13021..8023f8fd 100644 --- a/completions/idn +++ b/completions/idn @@ -6,21 +6,21 @@ _idn() _init_completion -s || return case $prev in - --help|--version|-!(-*)[hV]) + --help | --version | -!(-*)[hV]) return ;; - --profile|-!(-*)p) - COMPREPLY=( $(compgen -W 'Nameprep iSCSI Nodeprep Resourceprep - trace SASLprep' -- "$cur") ) + --profile | -!(-*)p) + COMPREPLY=($(compgen -W 'Nameprep iSCSI Nodeprep Resourceprep + trace SASLprep' -- "$cur")) return ;; esac if ! $split && [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _idn idn + complete -F _idn idn # ex: filetype=sh diff --git a/completions/ifstat b/completions/ifstat index 9fac3d30..629786e4 100644 --- a/completions/ifstat +++ b/completions/ifstat @@ -6,7 +6,7 @@ _ifstat() _init_completion -s || return case $prev in - --help|--version|--scan|--interval|-!(-*)[hvV]) + --help | --version | --scan | --interval | -!(-*)[hvV]) return ;; -!(-*)i) @@ -17,18 +17,22 @@ _ifstat() -!(-*)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") ) + 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")) fi return ;; - --noupdate|-!(-*)s) + --noupdate | -!(-*)s) # iproute2: pass through (skip history update) # traditional: hostnames (snmp) - if ! { "$1" --help 2>&1 || :; } | \ - command grep -q -- '-s.*--noupdate'; then + if ! { + "$1" --help 2>&1 || : + } | + command grep -q -- '-s.*--noupdate'; then _known_hosts_real -- "$cur" return fi @@ -36,27 +40,29 @@ _ifstat() -!(-*)t) # iproute2: no completion (interval) # traditional: pass through (add timestamp) - ! { "$1" --help 2>&1 || :; } | \ + ! { + "$1" --help 2>&1 || : + } | command grep -q -- '-t.*--interval' || return ;; - --extended|-!(-*)x) + --extended | -!(-*)x) # iproute2: parse xstat types - COMPREPLY=( $(compgen -W '$("$1" -x nonexistent-xstat 2>&1 | + COMPREPLY=($(compgen -W '$("$1" -x nonexistent-xstat 2>&1 | awk "found { print \$1 } /supported xstats:/ { found=1 }")' \ - -- "$cur") ) + -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then local opts=$(_parse_help "$1") - COMPREPLY=( $(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi } && -complete -F _ifstat ifstat + complete -F _ifstat ifstat # ex: filetype=sh diff --git a/completions/iftop b/completions/iftop index 6320316d..b73f4b6b 100644 --- a/completions/iftop +++ b/completions/iftop @@ -6,7 +6,7 @@ _iftop() _init_completion || return case $prev in - -h|-f|-F|-m) + -h | -f | -F | -m) return ;; -i) @@ -19,8 +19,8 @@ _iftop() ;; esac - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) } && -complete -F _iftop iftop + complete -F _iftop iftop # ex: filetype=sh diff --git a/completions/ifup b/completions/ifup index db8de8e0..5b35bfb2 100644 --- a/completions/ifup +++ b/completions/ifup @@ -8,10 +8,10 @@ _ifupdown() _init_completion || return case $prev in - --help|--version|--allow|--exclude|--option|-!(-*)[hVXo]) + --help | --version | --allow | --exclude | --option | -!(-*)[hVXo]) return ;; - --interfaces|-!(-*)i) + --interfaces | -!(-*)i) _filedir return ;; @@ -22,18 +22,18 @@ _ifupdown() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi local args _count_args "" "@(--allow|-i|--interfaces|--state-dir|-X|--exclude|-o)" - if [[ $args -eq 1 ]]; then + if ((args == 1)); then _configured_interfaces - COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur")) fi } && -complete -F _ifupdown ifup ifdown ifquery ifstatus + complete -F _ifupdown ifup ifdown ifquery ifstatus # ex: filetype=sh diff --git a/completions/influx b/completions/influx index bbedf10f..e9362e7e 100644 --- a/completions/influx +++ b/completions/influx @@ -6,27 +6,30 @@ _influx() _init_completion || return case $prev in - -version|-port|-database|-password|-username|-execute|-pps) + -version | -port | -database | -password | -username | -execute | -pps) return ;; -host) _known_hosts_real -- "$cur" return ;; - -format|-precision|-consistency) + -format | -precision | -consistency) local args=$($1 --help 2>&1 | awk "\$1 == \"$prev\" { print \$2 }") - COMPREPLY=( $(IFS+="\"'|"; compgen -W "$args" -- "$cur") ) + COMPREPLY=($( + IFS+="\"'|" + compgen -W "$args" -- "$cur" + )) return ;; - -import|-path) + -import | -path) _filedir return ;; esac - [[ "$cur" == -* ]] && - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + [[ $cur == -* ]] && + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) } && -complete -F _influx influx + complete -F _influx influx # ex: filetype=sh diff --git a/completions/info b/completions/info index 87179ac8..f50f8424 100644 --- a/completions/info +++ b/completions/info @@ -6,13 +6,13 @@ _info() _init_completion -s || return # default completion if parameter looks like a path - if [[ "$cur" == @(*/|[.~])* ]]; then + if [[ $cur == @(*/|[.~])* ]]; then _filedir return fi case $prev in - --apropos|--index-search|--node|--help|--version|-!(-*)[knhv]) + --apropos | --index-search | --node | --help | --version | -!(-*)[knhv]) return ;; -!(-*)d) @@ -25,7 +25,7 @@ _info() _filedir -d return ;; - --dribble|--file|--output|--restore|--raw-filename|--rcfile|-!(-*)[for]) + --dribble | --file | --output | --restore | --raw-filename | --rcfile | -!(-*)[for]) _filedir return ;; @@ -34,14 +34,14 @@ _info() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi local i infopath=/usr/share/info - if [[ $INFOPATH == *: ]]; then + if [[ ${INFOPATH-} == *: ]]; then infopath=${INFOPATH}${infopath} elif [[ ${INFOPATH:+set} ]]; then infopath=$INFOPATH @@ -57,18 +57,18 @@ _info() fi # redirect stderr for when path doesn't exist - COMPREPLY=( $(eval command ls "$infopath" 2>/dev/null) ) + COMPREPLY=($(eval command ls "$infopath" 2>/dev/null)) # weed out directory path names and paths to info pages - COMPREPLY=( ${COMPREPLY[@]##*/?(:)} ) + COMPREPLY=(${COMPREPLY[@]##*/?(:)}) # weed out info dir file - for (( i=0 ; i < ${#COMPREPLY[@]} ; ++i )); do - [[ ${COMPREPLY[$i]} == dir ]] && unset "COMPREPLY[$i]" + 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//\\\\/}") ) + COMPREPLY=(${COMPREPLY[@]%.@(gz|bz2|xz|lzma)}) + COMPREPLY=($(compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}")) } && -complete -F _info info pinfo + complete -F _info info pinfo # ex: filetype=sh diff --git a/completions/inject b/completions/inject index 8becf274..fad73a19 100644 --- a/completions/inject +++ b/completions/inject @@ -6,7 +6,7 @@ _inject() _init_completion -s || return case $prev in - -l|--listname) + -l | --listname) _xfunc list_lists _mailman_lists return ;; @@ -14,13 +14,13 @@ _inject() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--listname --queue --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--listname --queue --help' -- "$cur")) else _filedir fi } && -complete -F _inject inject + complete -F _inject inject # ex: filetype=sh diff --git a/completions/inotifywait b/completions/inotifywait index 637d4742..e5608fc6 100644 --- a/completions/inotifywait +++ b/completions/inotifywait @@ -5,10 +5,10 @@ _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 | \ + COMPREPLY+=($(compgen -W "$($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')" \ + -- "$cur")) } _inotifywait() @@ -17,31 +17,31 @@ _inotifywait() _init_completion || return case $prev in - --help|--exclude|--excludei|--format|--timefmt|--timeout|-!(-*)[ht]) + --help | --exclude | --excludei | --format | --timefmt | --timeout | -!(-*)[ht]) return ;; - --fromfile|--outfile|-!(-*)o) + --fromfile | --outfile | -!(-*)o) _filedir return ;; - --event|-!(-*)e) + --event | -!(-*)e) _inotifywait_events "$1" return ;; - --ascending|--descending) - COMPREPLY=( $(compgen -W 'total' -- "$cur") ) + --ascending | --descending) + COMPREPLY=($(compgen -W 'total' -- "$cur")) _inotifywait_events "$1" return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi _filedir } && -complete -F _inotifywait inotifywait inotifywatch + complete -F _inotifywait inotifywait inotifywatch # ex: filetype=sh diff --git a/completions/insmod b/completions/insmod index 36c29dc4..a59e7535 100644 --- a/completions/insmod +++ b/completions/insmod @@ -6,13 +6,13 @@ _insmod() _init_completion || return # do filename completion for first argument - if [[ $cword -eq 1 ]]; then - _filedir '@(?(k)o?(.gz))' + if ((cword == 1)); then + _filedir '@(?(k)o?(.[gx]z))' else # do module parameter completion - COMPREPLY=( $(compgen -W "$(PATH="$PATH:/sbin" modinfo \ - -p ${words[1]} 2>/dev/null | cut -d: -f1)" -- "$cur") ) + COMPREPLY=($(compgen -W "$(PATH="$PATH:/sbin" modinfo \ + -p ${words[1]} 2>/dev/null | cut -d: -f1)" -- "$cur")) fi } && -complete -F _insmod insmod insmod.static + complete -F _insmod insmod insmod.static # ex: filetype=sh diff --git a/completions/installpkg b/completions/installpkg index 3ebf1dfc..7455eb10 100644 --- a/completions/installpkg +++ b/completions/installpkg @@ -11,7 +11,7 @@ _installpkg() return ;; --priority) - COMPREPLY=( $(compgen -W 'ADD REC OPT SKP' -- "$cur") ) + COMPREPLY=($(compgen -W 'ADD REC OPT SKP' -- "$cur")) return ;; --tagfile) @@ -20,14 +20,14 @@ _installpkg() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--warn --md5sum --root --infobox --terse - --menu --ask --priority --tagfile' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--warn --md5sum --root --infobox --terse + --menu --ask --priority --tagfile' -- "$cur")) return fi _filedir 't[bglx]z' } && -complete -F _installpkg installpkg + complete -F _installpkg installpkg # ex: filetype=sh diff --git a/completions/interdiff b/completions/interdiff index e7923751..9933d15d 100644 --- a/completions/interdiff +++ b/completions/interdiff @@ -6,7 +6,7 @@ _interdiff() _init_completion -s || return case $prev in - --unified|--strip-match|--drop-context|-!(-*)[Upd]) + --unified | --strip-match | --drop-context | -!(-*)[Upd]) return ;; esac @@ -14,8 +14,8 @@ _interdiff() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi @@ -28,6 +28,6 @@ _interdiff() done _filedir "$exts" } && -complete -F _interdiff interdiff + complete -F _interdiff interdiff # ex: filetype=sh diff --git a/completions/invoke-rc.d b/completions/invoke-rc.d index e4b2afc9..4a5045a8 100644 --- a/completions/invoke-rc.d +++ b/completions/invoke-rc.d @@ -9,30 +9,30 @@ _invoke_rc_d() local sysvdir services options valid_options - [[ -d /etc/rc.d/init.d ]] && sysvdir=/etc/rc.d/init.d \ - || sysvdir=/etc/init.d + [[ -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 ) + 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=( $(\ - tr " " "\n" <<<"${words[*]} ${options[*]}" \ - | command sed -ne "/$(command sed "s/ /\\\\|/g" <<<"${options[*]}")/p" \ - | sort | uniq -u \ - ) ) - COMPREPLY=( $(compgen -W '${valid_options[@]} ${services[@]}' -- "$cur") ) + if [[ $cword -eq 1 || $prev == --* ]]; then + valid_options=($( + tr " " "\n" <<<"${words[*]} ${options[*]}" | + command sed -ne "/$(command sed 's/ /\\|/g' <<<"${options[*]}")/p" | + sort | uniq -u + )) + COMPREPLY=($(compgen -W '${valid_options[@]} ${services[@]}' -- "$cur")) elif [[ -x $sysvdir/$prev ]]; then - COMPREPLY=( $(compgen -W '`command sed -e "y/|/ /" \ + COMPREPLY=($(compgen -W '`command sed -e "y/|/ /" \ -ne "s/^.*Usage:[ ]*[^ ]*[ ]*{*\([^}\"]*\).*$/\1/p" \ - $sysvdir/$prev`' -- "$cur") ) + $sysvdir/$prev`' -- "$cur")) else COMPREPLY=() fi } && -complete -F _invoke_rc_d invoke-rc.d + complete -F _invoke_rc_d invoke-rc.d # ex: filetype=sh diff --git a/completions/ip b/completions/ip index f7e6e7c2..12ad9aa3 100644 --- a/completions/ip +++ b/completions/ip @@ -2,9 +2,9 @@ _iproute2_etc() { - COMPREPLY+=( $(compgen -W \ + COMPREPLY+=($(compgen -W \ "$(awk '!/#/ { print $2 }' /etc/iproute2/$1 2>/dev/null)" \ - -- "$cur") ) + -- "$cur")) } _ip() @@ -13,100 +13,99 @@ _ip() _init_completion || return case $prev in - -V|-Version|-rc|-rcvbuf) + -V | -Version | -rc | -rcvbuf) return ;; - -f|-family) - COMPREPLY=( $(compgen -W 'inet inet6 ipx dnet link' -- "$cur") ) + -f | -family) + COMPREPLY=($(compgen -W 'inet inet6 ipx dnet link' -- "$cur")) return ;; - -b|-batch) + -b | -batch) _filedir return ;; -force) - COMPREPLY=( $(compgen -W '-batch' -- "$cur") ) + COMPREPLY=($(compgen -W '-batch' -- "$cur")) return ;; esac - local subcword cmd subcmd - for (( subcword=1; subcword < ${#words[@]}-1; subcword++ )); do + local subcword cmd subcmd="" + for ((subcword = 1; subcword < ${#words[@]} - 1; subcword++)); do [[ ${words[subcword]} == -b?(atch) ]] && return - [[ -n $cmd ]] && subcmd=${words[subcword]} && break + [[ -v cmd ]] && subcmd=${words[subcword]} && break [[ ${words[subcword]} != -* && \ - ${words[subcword-1]} != -@(f?(amily)|rc?(vbuf)) ]] && \ + ${words[subcword - 1]} != -@(f?(amily)|rc?(vbuf)) ]] && cmd=${words[subcword]} done - if [[ -z $cmd ]]; then + if [[ ! -v cmd ]]; then case $cur in -*) local c="-Version -statistics -details -resolve -family -oneline -timestamp -batch -rcvbuf" - [[ $cword -eq 1 ]] && c+=" -force" - COMPREPLY=( $(compgen -W "$c" -- "$cur") ) - return + ((cword == 1)) && c+=" -force" + COMPREPLY=($(compgen -W "$c" -- "$cur")) ;; *) - COMPREPLY=( $(compgen -W "help $($1 help 2>&1 | command sed -e \ + COMPREPLY=($(compgen -W "help $($1 help 2>&1 | command sed -e \ '/OBJECT := /,/}/!d' -e \ 's/.*{//' -e \ 's/}.*//' -e \ - 's/|//g')" -- "$cur") ) - return + 's/|//g')" -- "$cur")) ;; esac + return fi [[ $subcmd == help ]] && return case $cmd in - l|link) + l | link) case $subcmd in add) # TODO ;; delete) - case $(($cword-$subcword)) in + case $((cword - subcword)) in 1) _available_interfaces ;; 2) - COMPREPLY=( $(compgen -W 'type' -- "$cur") ) + COMPREPLY=($(compgen -W 'type' -- "$cur")) ;; 3) - [[ $prev == type ]] && \ - COMPREPLY=( $(compgen -W 'vlan veth vcan dummy - ifb macvlan can' -- "$cur") ) + [[ $prev == type ]] && + COMPREPLY=($(compgen -W 'vlan veth vcan dummy + ifb macvlan can' -- "$cur")) ;; esac ;; set) - if [[ $cword-$subcword -eq 1 ]]; then + if ((cword - subcword == 1)); then _available_interfaces else case $prev in - arp|dynamic|multicast|allmulticast|promisc|\ - trailers) - COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) - ;; - txqueuelen|name|address|broadcast|mtu|netns|alias) + arp | dynamic | multicast | allmulticast | promisc | \ + trailers) + COMPREPLY=($(compgen -W 'on off' -- "$cur")) ;; + txqueuelen | name | address | broadcast | mtu | netns | alias) ;; + *) local c="arp dynamic multicast allmulticast promisc trailers txqueuelen name address broadcast mtu netns alias" [[ $prev != @(up|down) ]] && c+=" up down" - COMPREPLY=( $(compgen -W "$c" -- "$cur") ) + COMPREPLY=($(compgen -W "$c" -- "$cur")) ;; esac fi ;; show) - if [[ $cword -eq $subcword+1 ]]; then + if ((cword == subcword + 1)); then _available_interfaces - COMPREPLY+=( $(compgen -W 'dev group up' -- "$cur") ) + COMPREPLY+=($(compgen -W 'dev group up' -- "$cur")) elif [[ $prev == dev ]]; then _available_interfaces elif [[ $prev == group ]]; then @@ -114,16 +113,16 @@ _ip() fi ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help add delete set show' \ - -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help add delete set show' \ + -- "$cur")) ;; esac ;; - a|addr|address) + a | addr | address) case $subcmd in - add|change|replace) + add | change | replace) if [[ $prev == dev ]]; then _available_interfaces elif [[ $prev == scope ]]; then @@ -141,12 +140,12 @@ _ip() : # TODO fi ;; - show|flush) - if [[ $cword -eq $subcword+1 ]]; then + show | flush) + if ((cword == subcword + 1)); then _available_interfaces - COMPREPLY+=( $(compgen -W 'dev scope to label dynamic + COMPREPLY+=($(compgen -W 'dev scope to label dynamic permanent tentative deprecated dadfailed temporary - primary secondary up' -- "$cur") ) + primary secondary up' -- "$cur")) elif [[ $prev == dev ]]; then _available_interfaces elif [[ $prev == scope ]]; then @@ -154,16 +153,16 @@ _ip() fi ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help add change replace del - show flush' -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help add change replace del + show flush' -- "$cur")) ;; esac ;; addrlabel) case $subcmd in - list|add|del|flush) + list | add | del | flush) if [[ $prev == dev ]]; then _available_interfaces else @@ -171,16 +170,16 @@ _ip() fi ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help list add del flush' \ - -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help list add del flush' \ + -- "$cur")) ;; esac ;; - route) + r | route) case $subcmd in - list|flush) + list | flush) if [[ $prev == proto ]]; then _iproute2_etc rt_protos else @@ -190,44 +189,79 @@ _ip() get) # TODO ;; - add|del|change|append|replace|monitor) - # TODO + a | add | d | del | change | append | r | replace | monitor) + if [[ $prev == via ]]; then + COMPREPLY=($(compgen -W "$($1 r | command sed -ne \ + 's/.*via \([0-9.]*\).*/\1/p')" -- "$cur")) + elif [[ $prev == "$subcmd" ]]; then + COMPREPLY=($(compgen -W "table default \ + $($1 r | cut -d ' ' -f 1)" -- "$cur")) + elif [[ $prev == dev ]]; then + _available_interfaces -a + elif [[ $prev == table ]]; then + COMPREPLY=($(compgen -W 'local main default' -- "$cur")) + else + COMPREPLY=($(compgen -W 'via dev weight' -- "$cur")) + fi ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help list flush get add del - change append replace monitor' -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help list flush get add del + change append replace monitor' -- "$cur")) ;; esac ;; rule) case $subcmd in - add|del) - # TODO + add | del | list | lst) + case $prev in + from | to | tos | dsfield | fwmark | uidrange | ipproto | sport | \ + dport | priority | protocol | suppress_prefixlength | \ + suppress_ifgroup | realms | nat | goto) ;; + + iif | oif) + _available_interfaces -a + ;; + table | lookup) + COMPREPLY=($(compgen -W 'local main default' -- "$cur")) + ;; + *) + 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")) + ;; + esac ;; - flush|show|list|lst) + flush | save) + if [[ $prev == protocol ]]; then + : + else + COMPREPLY=($(compgen -W 'protocol' -- "$cur")) + fi ;; + restore | show) ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help list add del flush' \ - -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help add del list flush save + restore show' -- "$cur")) ;; esac ;; neigh) case $subcmd in - add|del|change|replace) + add | del | change | replace) # TODO ;; - show|flush) + show | flush) # TODO ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help add del change replace - show flush' -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help add del change replace + show flush' -- "$cur")) ;; esac ;; @@ -241,45 +275,45 @@ _ip() # TODO ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help change show' \ - -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help change show' \ + -- "$cur")) ;; esac ;; tunnel) case $subcmd in - show) - ;; - add|change|del|prl|6rd) + show) ;; + + add | change | del | prl | 6rd) # TODO ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help add change del show prl - 6rd' -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help add change del show prl + 6rd' -- "$cur")) ;; esac ;; maddr) case $subcmd in - add|del) + add | del) # TODO ;; show) if [[ $cword -eq $subcword+1 || $prev == dev ]]; then _available_interfaces - [[ $prev != dev ]] && \ - COMPREPLY=( $(compgen -W '${COMPREPLY[@]} dev' \ - -- "$cur") ) + [[ $prev != dev ]] && + COMPREPLY=($(compgen -W '${COMPREPLY[@]} dev' \ + -- "$cur")) fi ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help add del show' \ - -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help add del show' \ + -- "$cur")) ;; esac ;; @@ -290,8 +324,8 @@ _ip() # TODO ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help show' -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help show' -- "$cur")) ;; esac ;; @@ -300,26 +334,45 @@ _ip() case $subcmd in all) ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'help all' -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help all' -- "$cur")) + ;; + esac + ;; + + netns) + case $subcmd in + list | monitor) ;; + + add | identify | list-id) + # TODO + ;; + delete | exec | pids | set) + [[ $prev == "$subcmd" ]] && + COMPREPLY=($(compgen -W "$($1 netns list)" -- "$cur")) + ;; + *) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'help add delete exec + identify list list-id monitor pids set' -- "$cur")) ;; esac ;; xfrm) case $subcmd in - state|policy|monitor) + state | policy | monitor) # TODO ;; *) - [[ $cword -eq $subcword ]] && \ - COMPREPLY=( $(compgen -W 'state policy monitor' \ - -- "$cur") ) + ((cword == subcword)) && + COMPREPLY=($(compgen -W 'state policy monitor' \ + -- "$cur")) ;; esac ;; esac } && -complete -F _ip ip + complete -F _ip ip # ex: filetype=sh diff --git a/completions/ipcalc b/completions/ipcalc new file mode 100644 index 00000000..5603c26c --- /dev/null +++ b/completions/ipcalc @@ -0,0 +1,25 @@ +# ipcalc(1) completion -*- shell-script -*- + +_ipcalc() +{ + local cur prev words cword + _init_completion || return + + case $prev in + --help | --version | --split | -[hs]) + return + ;; + esac + + # --split takes 3 args + local i + for i in {1..3}; do + [[ ${words[cword - i]} == -@(-split|s) ]] && return + done + + [[ $cur != -* ]] || + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) +} && + complete -F _ipcalc ipcalc + +# ex: filetype=sh diff --git a/completions/iperf b/completions/iperf index 43f9bcaf..6347fe00 100644 --- a/completions/iperf +++ b/completions/iperf @@ -6,36 +6,36 @@ _iperf() _init_completion -s -n : || return 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]) + --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]) return ;; - --format|-!(-*)f) - COMPREPLY=( $(compgen -W 'k m g K M G' -- "$cur") ) + --format | -!(-*)f) + COMPREPLY=($(compgen -W 'k m g K M G' -- "$cur")) return ;; - --output|--fileinput|-!(-*)[oF]) + --output | --fileinput | -!(-*)[oF]) _filedir return ;; - --bind|-!(-*)B) + --bind | -!(-*)B) _available_interfaces -a _ip_addresses -a __ltrim_colon_completions "$cur" return ;; - --client|-!(-*)c) + --client | -!(-*)c) _known_hosts_real -- "$cur" return ;; - --reportexclude|-!(-*)x) - COMPREPLY=( $(compgen -W 'C D M S V' -- "$cur") ) + --reportexclude | -!(-*)x) + COMPREPLY=($(compgen -W 'C D M S V' -- "$cur")) return ;; - --reportstyle|-!(-*)y) - COMPREPLY=( $(compgen -W 'C' -- "$cur") ) + --reportstyle | -!(-*)y) + COMPREPLY=($(compgen -W 'C' -- "$cur")) return ;; --logfile) @@ -50,20 +50,20 @@ _iperf() local i filter=cat for i in "${words[@]}"; do case $i in - -s|--server) + -s | --server) filter='command sed -e /^Client.specific/,/^\(Server.specific.*\)\?$/d' ;; - -c|--client) + -c | --client) filter='command sed -e /^Server.specific/,/^\(Client.specific.*\)\?$/d' ;; esac done [[ $filter != cat ]] && filter+=' -e /--client/d -e /--server/d' - COMPREPLY=( $(compgen -W \ - '$("$1" --help 2>&1 | $filter | _parse_help -)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W \ + '$("$1" --help 2>&1 | $filter | _parse_help -)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && -complete -F _iperf iperf iperf3 + complete -F _iperf iperf iperf3 # ex: filetype=sh diff --git a/completions/ipmitool b/completions/ipmitool index f6307cfa..920287dd 100644 --- a/completions/ipmitool +++ b/completions/ipmitool @@ -2,8 +2,8 @@ _ipmitool_singleline_help() { - COMPREPLY=( $(compgen -W "$($1 $2 2>&1 | \ - command sed -ne 's/[,\r]//g' -e 's/^.*[Cc]ommands://p')" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 $2 2>&1 | + command sed -ne 's/[,\r]//g' -e 's/^.*[Cc]ommands://p')" -- "$cur")) } _ipmitool() @@ -16,17 +16,18 @@ _ipmitool() return ;; -*d) - COMPREPLY=( $(compgen -W "$(\ + 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") ) + 2>/dev/null | command sed -ne 's/^[^0-9]*\([0-9]\{1,\}\)/\1/p' + )" \ + -- "$cur")) return ;; -*I) - COMPREPLY=( $(compgen -W "$($1 -h 2>&1 | \ + COMPREPLY=($(compgen -W "$($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')" \ + -- "$cur")) return ;; -*H) @@ -38,45 +39,45 @@ _ipmitool() return ;; -*C) - COMPREPLY=( $(compgen -W '{0..14}' -- "$cur") ) + COMPREPLY=($(compgen -W '{0..14}' -- "$cur")) return ;; -*L) - COMPREPLY=( $(compgen -W 'CALLBACK USER OPERATOR ADMINISTRATOR' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'CALLBACK USER OPERATOR ADMINISTRATOR' \ + -- "$cur")) return ;; -*A) - COMPREPLY=( $(compgen -W 'NONE PASSWORD MD2 MD5 OEM' -- "$cur") ) + COMPREPLY=($(compgen -W 'NONE PASSWORD MD2 MD5 OEM' -- "$cur")) return ;; -*o) - COMPREPLY=( $(compgen -W "$($1 -o list 2>&1 | \ - awk '/^[ \t]+/ { print $1 }') list" -- "$cur") ) + COMPREPLY=($(compgen -W "$($1 -o list 2>&1 | + awk '/^[ \t]+/ { print $1 }') list" -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) return fi # Find out command and subcommand - local cmds=( raw i2c spd lan chassis power event mc sdr sensor fru gendev + 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 - [[ -n $cmd ]] && subcmd=${words[i]} && break + for ((i = 1; i < ${#words[@]} - 1; i++)); do + [[ -v cmd ]] && subcmd=${words[i]} && break for c in "${cmds[@]}"; do - [[ ${words[i]} == $c ]] && cmd=$c && break + [[ ${words[i]} == "$c" ]] && cmd=$c && break done done - if [[ -z $cmd ]]; then - COMPREPLY=( $(compgen -W '${cmds[@]}' -- "$cur") ) + if [[ ! -v cmd ]]; then + COMPREPLY=($(compgen -W '${cmds[@]}' -- "$cur")) return fi @@ -84,43 +85,43 @@ _ipmitool() case $cmd in - shell) - ;; + shell) ;; - exec) + \ + exec) _filedir ;; - chassis|power|kontronoem|fwum) + chassis | power | kontronoem | fwum) _ipmitool_singleline_help $1 $cmd ;; lan) case $subcmd in - print|set) - ;; + print | set) ;; + alert) - [[ $prev == alert ]] && \ - COMPREPLY=( $(compgen -W 'print set' -- "$cur") ) + [[ $prev == alert ]] && + COMPREPLY=($(compgen -W 'print set' -- "$cur")) ;; stats) - [[ $prev == stats ]] && \ - COMPREPLY=( $(compgen -W 'print set' -- "$cur") ) + [[ $prev == stats ]] && + COMPREPLY=($(compgen -W 'print set' -- "$cur")) ;; *) - COMPREPLY=( $(compgen -W 'print set alert stats' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'print set alert stats' \ + -- "$cur")) ;; esac ;; sdr) case $subcmd in - get|info|type|list|entity) - ;; + get | info | type | list | entity) ;; + elist) - COMPREPLY=( $(compgen -W 'all full compact event mclog fru - generic' -- "$cur") ) + COMPREPLY=($(compgen -W 'all full compact event mclog fru + generic' -- "$cur")) ;; dump) _filedir @@ -128,7 +129,7 @@ _ipmitool() fill) case $prev in fill) - COMPREPLY=( $(compgen -W 'sensors file' -- "$cur") ) + COMPREPLY=($(compgen -W 'sensors file' -- "$cur")) ;; file) _filedir @@ -136,63 +137,63 @@ _ipmitool() esac ;; *) - COMPREPLY=( $(compgen -W 'get info type list elist entity - dump fill' -- "$cur") ) + COMPREPLY=($(compgen -W 'get info type list elist entity + dump fill' -- "$cur")) ;; esac ;; sensor) case $subcmd in - list|get|thresh) - ;; + list | get | thresh) ;; + *) - COMPREPLY=( $(compgen -W 'list get thresh' -- "$cur") ) + COMPREPLY=($(compgen -W 'list get thresh' -- "$cur")) ;; esac ;; sel) case $subcmd in - info|clear|list|elist|delete) - ;; - add|save|writeraw|readraw) + info | clear | list | elist | delete) ;; + + add | save | writeraw | readraw) _filedir ;; time) - [[ $prev == time ]] && \ - COMPREPLY=( $(compgen -W 'get set' -- "$cur") ) + [[ $prev == time ]] && + COMPREPLY=($(compgen -W 'get set' -- "$cur")) ;; *) - COMPREPLY=( $(compgen -W 'info clear list elist delete add - get save writeraw readraw time' -- "$cur") ) + COMPREPLY=($(compgen -W 'info clear list elist delete add + get save writeraw readraw time' -- "$cur")) ;; esac ;; user) case $subcmd in - summary|list|disable|enable|priv|test) - ;; + summary | list | disable | enable | priv | test) ;; + set) - [[ $prev == set ]] && \ - COMPREPLY=( $(compgen -W 'name password' -- "$cur") ) + [[ $prev == set ]] && + COMPREPLY=($(compgen -W 'name password' -- "$cur")) ;; *) - COMPREPLY=( $(compgen -W 'summary list set disable enable - priv test' -- "$cur") ) + COMPREPLY=($(compgen -W 'summary list set disable enable + priv test' -- "$cur")) ;; esac ;; set) - [[ $prev == set ]] && \ - COMPREPLY=( $(compgen -W 'hostname username password privlvl - authtype localaddr targetaddr port csv verbose' -- "$cur") ) + [[ $prev == set ]] && + COMPREPLY=($(compgen -W 'hostname username password privlvl + authtype localaddr targetaddr port csv verbose' -- "$cur")) ;; esac } && -complete -F _ipmitool ipmitool + complete -F _ipmitool ipmitool # ex: filetype=sh diff --git a/completions/ipsec b/completions/ipsec index 00e6b7ea..4bc8cdf3 100644 --- a/completions/ipsec +++ b/completions/ipsec @@ -8,9 +8,9 @@ _ipsec_connections() local keyword name while read -r keyword name; do if [[ $keyword == [#]* ]]; then continue; fi - [[ $keyword == conn && $name != '%default' ]] && COMPREPLY+=( "$name" ) + [[ $keyword == conn && $name != '%default' ]] && COMPREPLY+=("$name") done - COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") ) + COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur")) } _ipsec_freeswan() @@ -18,31 +18,31 @@ _ipsec_freeswan() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W 'auto barf eroute klipsdebug look manual + if ((cword == 1)); then + COMPREPLY=($(compgen -W 'auto barf eroute klipsdebug look manual pluto ranbits rsasigkey setup showdefaults showhostkey spi spigrp - tncfg whack' -- "$cur") ) + tncfg whack' -- "$cur")) return fi case ${words[1]} in auto) - COMPREPLY=( $(compgen -W '--asynchronous --up --add --delete + COMPREPLY=($(compgen -W '--asynchronous --up --add --delete --replace --down --route --unroute --ready --status - --rereadsecrets' -- "$cur") ) + --rereadsecrets' -- "$cur")) ;; manual) - COMPREPLY=( $(compgen -W '--up --down --route --unroute --union' \ - -- "$cur") ) + COMPREPLY=($(compgen -W '--up --down --route --unroute --union' \ + -- "$cur")) ;; ranbits) - COMPREPLY=( $(compgen -W '--quick --continuous --bytes' -- "$cur") ) + COMPREPLY=($(compgen -W '--quick --continuous --bytes' -- "$cur")) ;; setup) - COMPREPLY=( $(compgen -W '--start --stop --restart' -- "$cur") ) - ;; - *) + COMPREPLY=($(compgen -W '--start --stop --restart' -- "$cur")) ;; + *) ;; + esac } @@ -51,8 +51,8 @@ _ipsec_strongswan() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W 'down irdumm leases listaacerts listacerts + 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 @@ -60,33 +60,33 @@ _ipsec_strongswan() 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") ) + --directory --help --version --versioncode' -- "$cur")) return fi case ${words[1]} in - down|route|status|statusall|unroute|up) + down | route | status | statusall | unroute | up) local confdir=$(ipsec --confdir) _ipsec_connections <"$confdir/ipsec.conf" ;; list*) - COMPREPLY=( $(compgen -W '--utc' -- "$cur") ) + COMPREPLY=($(compgen -W '--utc' -- "$cur")) ;; - restart|start) - COMPREPLY=( $(compgen -W '--attach-gdb --auto-update --debug - --debug-all --debug-more --nofork' -- "$cur") ) + restart | start) + COMPREPLY=($(compgen -W '--attach-gdb --auto-update --debug + --debug-all --debug-more --nofork' -- "$cur")) ;; pki) - COMPREPLY=( $(compgen -W '--gen --issue --keyid --print --pub - --req --self --signcrl --verify' -- "$cur") ) - ;; - pool) + COMPREPLY=($(compgen -W '--gen --issue --keyid --print --pub + --req --self --signcrl --verify' -- "$cur")) ;; + pool) ;; + irdumm) _filedir 'rb' ;; - *) - ;; + *) ;; + esac } diff --git a/completions/iptables b/completions/iptables index 69072613..ffb905b8 100644 --- a/completions/iptables +++ b/completions/iptables @@ -7,45 +7,45 @@ _iptables() local table chain='s/^Chain \([^ ]\{1,\}\).*$/\1/p' - [[ "${words[*]}" =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] \ - && table="-t ${BASH_REMATCH[2]}" + [[ ${words[*]} =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] && + table="-t ${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") ) - ;; - -*t) - COMPREPLY=( $(compgen -W 'nat filter mangle' -- "$cur") ) - ;; - -j) - if [[ "$table" == "-t filter" || -z "$table" ]]; then - COMPREPLY=( $(compgen -W 'ACCEPT DROP LOG ULOG REJECT + -*[AIDRPFXLZ]) + COMPREPLY=($(compgen -W '`"$1" $table -nL 2>/dev/null | \ + command sed -ne "s/^Chain \([^ ]\{1,\}\).*$/\1/p"`' -- "$cur")) + ;; + -*t) + COMPREPLY=($(compgen -W 'nat filter mangle' -- "$cur")) + ;; + -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 + "$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 + -- "$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") ) - fi - ;; - *) - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$("$1" --help 2>&1 | - command sed -e "s/^\[\!\]//" | _parse_help -)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace - fi - ;; + "$cur")) + fi + ;; + *) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$("$1" --help 2>&1 | + command sed -e "s/^\[\!\]//" | _parse_help -)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace + fi + ;; esac } && -complete -F _iptables iptables + complete -F _iptables iptables # ex: filetype=sh diff --git a/completions/ipv6calc b/completions/ipv6calc index 6a5771ef..c452c155 100644 --- a/completions/ipv6calc +++ b/completions/ipv6calc @@ -6,33 +6,33 @@ _ipv6calc() _init_completion -s || return case "$prev" in - --debug|-!(-*)d) + --debug | -!(-*)d) return ;; - --in|--out|--action|-!(-*)[IOA]) + --in | --out | --action | -!(-*)[IOA]) # With ipv6calc < 0.73.0, -m does nothing here, so use sed instead. - COMPREPLY=( $(compgen -W "$($1 "$prev" -h 2>&1 | \ + COMPREPLY=($(compgen -W "$($1 "$prev" -h 2>&1 | command sed -ne 's/^[[:space:]]\{1,\}\([^[:space:]:]\{1,\}\)[[:space:]]*:.*/\1/p')" \ - -- "$cur") ) + -- "$cur")) return ;; - --db-geoip|--db-ip2location-ipv4|--db-ip2location-ipv6) + --db-geoip | --db-ip2location-ipv4 | --db-ip2location-ipv6) _filedir return ;; - --printstart|--printend) + --printstart | --printend) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$("$1" -h 2>&1 | - command sed -e "s/[][]//g" | _parse_help -)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$("$1" -h 2>&1 | + command sed -e "s/[][]//g" | _parse_help -)' -- "$cur")) fi } && -complete -F _ipv6calc ipv6calc + complete -F _ipv6calc ipv6calc # ex: filetype=sh diff --git a/completions/iscsiadm b/completions/iscsiadm index 1fa30db6..7786ddcd 100644 --- a/completions/iscsiadm +++ b/completions/iscsiadm @@ -6,21 +6,21 @@ _iscsiadm() _init_completion -s || return case $prev in - --mode|-!(-*)m) - COMPREPLY=( $(compgen -W 'discovery node session iface fw host' \ - -- "$cur") ) + --mode | -!(-*)m) + COMPREPLY=($(compgen -W 'discovery node session iface fw host' \ + -- "$cur")) return ;; - --op|-!(-*)o) - COMPREPLY=( $(compgen -W 'new delete update show' -- "$cur") ) + --op | -!(-*)o) + COMPREPLY=($(compgen -W 'new delete update show' -- "$cur")) return ;; - --type|-!(-*)t) - COMPREPLY=( $(compgen -W 'sendtargets st slp isns fw' -- "$cur") ) + --type | -!(-*)t) + COMPREPLY=($(compgen -W 'sendtargets st slp isns fw' -- "$cur")) return ;; - --loginall|--logoutall|-!(-*)[LU]) - COMPREPLY=( $(compgen -W 'all manual automatic' -- "$cur") ) + --loginall | --logoutall | -!(-*)[LU]) + COMPREPLY=($(compgen -W 'all manual automatic' -- "$cur")) return ;; esac @@ -28,7 +28,7 @@ _iscsiadm() $split && return local options - if [[ $cword -gt 1 ]]; then + if ((cword > 1)); then case ${words[2]} in discovery) @@ -59,8 +59,8 @@ _iscsiadm() options='--mode' fi - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) } && -complete -F _iscsiadm iscsiadm + complete -F _iscsiadm iscsiadm # ex: filetype=sh diff --git a/completions/isort b/completions/isort index e4a028be..2a84e257 100644 --- a/completions/isort +++ b/completions/isort @@ -6,36 +6,36 @@ _isort() _init_completion || return case $prev in - --help|--add-import|--builtin|--future|--from-first|-ff|\ - --force-grid-wrap|-fgw|--indent|--lines|--lines-after-imports|-lai|\ - --lines-between-types|-lbt|--line-ending|-le|--no-lines-before|-nlb|\ - --dont-skip|-ns|--thirdparty|--project|--remove-import|--skip|\ - --skip-glob|-sg|--settings-path|-sp|--top|--virtual-env|--line-width|\ - --wrap-length|-wl|-[habfiloprstw]) + --help | --add-import | --builtin | --future | --from-first | -ff | \ + --force-grid-wrap | -fgw | --indent | --lines | --lines-after-imports | -lai | \ + --lines-between-types | -lbt | --line-ending | -le | --no-lines-before | -nlb | \ + --dont-skip | -ns | --thirdparty | --project | --remove-import | --skip | \ + --skip-glob | -sg | --settings-path | -sp | --top | --virtual-env | --line-width | \ + --wrap-length | -wl | -[habfiloprstw]) return ;; - --jobs|-j) - COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) + --jobs | -j) + COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur")) return ;; - --multi-line|-m) - COMPREPLY=( $(compgen -W '{0..5}' -- "$cur") ) + --multi-line | -m) + COMPREPLY=($(compgen -W '{0..5}' -- "$cur")) return ;; - --section-default|-sd) - COMPREPLY=( $(compgen -W 'FUTURE STDLIB THIRDPARTY FIRSTPARTY - LOCALFOLDER' -- "$cur") ) + --section-default | -sd) + COMPREPLY=($(compgen -W 'FUTURE STDLIB THIRDPARTY FIRSTPARTY + LOCALFOLDER' -- "$cur")) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi _filedir '@(py|pyi)' } && -complete -F _isort isort + complete -F _isort isort # ex: filetype=sh diff --git a/completions/isql b/completions/isql index 4bd24c41..4258c519 100644 --- a/completions/isql +++ b/completions/isql @@ -6,9 +6,9 @@ _isql() local cur prev words cword _init_completion || return - [[ -f $ODBCINI ]] \ - && COMPREPLY=( $(command grep "\[$cur" "$ODBCINI" | tr -d \[\]) ) + [[ -f $ODBCINI ]] && + COMPREPLY=($(command grep "\[$cur" "$ODBCINI" | tr -d \[\])) } && -complete -F _isql isql + complete -F _isql isql # ex: filetype=sh diff --git a/completions/iwconfig b/completions/iwconfig index 762ec2ea..aa8fbf39 100644 --- a/completions/iwconfig +++ b/completions/iwconfig @@ -7,84 +7,84 @@ _iwconfig() case $prev in mode) - COMPREPLY=( $(compgen -W 'managed ad-hoc master repeater secondary - monitor' -- "$cur") ) + COMPREPLY=($(compgen -W 'managed ad-hoc master repeater secondary + monitor' -- "$cur")) return ;; essid) - COMPREPLY=( $(compgen -W 'on off any' -- "$cur") ) + 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") ) + COMPREPLY+=($(compgen -W \ + "$(iwlist ${words[1]} scan | + awk -F'\"' '/ESSID/ {print $2}')" -- "$cur")) fi return ;; nwid) - COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) + COMPREPLY=($(compgen -W 'on off' -- "$cur")) return ;; channel) - COMPREPLY=( $(compgen -W "$(iwlist ${words[1]} channel | \ - awk '/^[ \t]*Channel/ {print $2}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(iwlist ${words[1]} channel | + awk '/^[ \t]*Channel/ {print $2}')" -- "$cur")) return ;; freq) - COMPREPLY=( $(compgen -W "$(iwlist ${words[1]} channel | \ - awk '/^[ \t]*Channel/ {print $4"G"}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(iwlist ${words[1]} channel | + awk '/^[ \t]*Channel/ {print $4"G"}')" -- "$cur")) return ;; ap) - COMPREPLY=( $(compgen -W 'on off any' -- "$cur") ) + 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") ) + COMPREPLY+=($(compgen -W \ + "$(iwlist ${words[1]} scan | + awk -F ': ' '/Address/ {print $2}')" -- "$cur")) fi return ;; rate) - COMPREPLY=( $(compgen -W 'auto fixed' -- "$cur") ) - COMPREPLY+=( $(compgen -W \ - "$(iwlist ${words[1]} rate | \ - awk '/^[ \t]*[0-9]/ {print $1"M"}')" -- "$cur") ) + COMPREPLY=($(compgen -W 'auto fixed' -- "$cur")) + COMPREPLY+=($(compgen -W \ + "$(iwlist ${words[1]} rate | + awk '/^[ \t]*[0-9]/ {print $1"M"}')" -- "$cur")) return ;; - rts|frag) - COMPREPLY=( $(compgen -W 'auto fixed off' -- "$cur") ) + rts | frag) + COMPREPLY=($(compgen -W 'auto fixed off' -- "$cur")) return ;; - key|enc) - COMPREPLY=( $(compgen -W 'off on open restricted' -- "$cur") ) + key | enc) + COMPREPLY=($(compgen -W 'off on open restricted' -- "$cur")) return ;; power) - COMPREPLY=( $(compgen -W 'period timeout off on' -- "$cur") ) + COMPREPLY=($(compgen -W 'period timeout off on' -- "$cur")) return ;; txpower) - COMPREPLY=( $(compgen -W 'off on auto' -- "$cur") ) + COMPREPLY=($(compgen -W 'off on auto' -- "$cur")) return ;; retry) - COMPREPLY=( $(compgen -W 'limit lifetime' -- "$cur") ) + COMPREPLY=($(compgen -W 'limit lifetime' -- "$cur")) return ;; esac - if [[ $cword -eq 1 ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --version' -- "$cur") ) + if ((cword == 1)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--help --version' -- "$cur")) else _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") ) + COMPREPLY=($(compgen -W 'essid nwid mode freq channel sens mode ap + nick rate rts frag enc key power txpower commit' -- "$cur")) fi } && -complete -F _iwconfig iwconfig + complete -F _iwconfig iwconfig # ex: filetype=sh diff --git a/completions/iwlist b/completions/iwlist index 65e0b2fb..16aa39c9 100644 --- a/completions/iwlist +++ b/completions/iwlist @@ -5,18 +5,18 @@ _iwlist() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --version' -- "$cur") ) + if ((cword == 1)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--help --version' -- "$cur")) else _available_interfaces -w fi else - COMPREPLY=( $(compgen -W 'scan scanning freq frequency channel rate + COMPREPLY=($(compgen -W 'scan scanning freq frequency channel rate bit bitrate key enc encryption power txpower retry ap accesspoint - peers event' -- "$cur") ) + peers event' -- "$cur")) fi } && -complete -F _iwlist iwlist + complete -F _iwlist iwlist # ex: filetype=sh diff --git a/completions/iwpriv b/completions/iwpriv index 83673b4e..4e382463 100644 --- a/completions/iwpriv +++ b/completions/iwpriv @@ -7,25 +7,25 @@ _iwpriv() case $prev in roam) - COMPREPLY=( $(compgen -W 'on off' -- "$cur") ) + COMPREPLY=($(compgen -W 'on off' -- "$cur")) return ;; port) - COMPREPLY=( $(compgen -W 'ad-hoc managed' -- "$cur") ) + COMPREPLY=($(compgen -W 'ad-hoc managed' -- "$cur")) return ;; esac - if [[ $cword -eq 1 ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --version' -- "$cur") ) + if ((cword == 1)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--help --version' -- "$cur")) else _available_interfaces -w fi else - COMPREPLY=( $(compgen -W '--all roam port' -- "$cur") ) + COMPREPLY=($(compgen -W '--all roam port' -- "$cur")) fi } && -complete -F _iwpriv iwpriv + complete -F _iwpriv iwpriv # ex: filetype=sh diff --git a/completions/iwspy b/completions/iwspy index e4805116..38b7868e 100644 --- a/completions/iwspy +++ b/completions/iwspy @@ -5,16 +5,16 @@ _iwspy() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--help --version' -- "$cur") ) + if ((cword == 1)); then + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--help --version' -- "$cur")) else _available_interfaces -w fi else - COMPREPLY=( $(compgen -W 'setthr getthr off' -- "$cur") ) + COMPREPLY=($(compgen -W 'setthr getthr off' -- "$cur")) fi } && -complete -F _iwspy iwspy + complete -F _iwspy iwspy # ex: filetype=sh diff --git a/completions/jar b/completions/jar index c839aa85..22894917 100644 --- a/completions/jar +++ b/completions/jar @@ -5,8 +5,8 @@ _jar() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W 'c t x u' -- "$cur") ) + if ((cword == 1)); then + COMPREPLY=($(compgen -W 'c t x u' -- "$cur")) return fi @@ -22,6 +22,6 @@ _jar() ;; esac } && -complete -F _jar jar + complete -F _jar jar # ex: filetype=sh diff --git a/completions/jarsigner b/completions/jarsigner index 171865b2..1f26c9c2 100644 --- a/completions/jarsigner +++ b/completions/jarsigner @@ -7,51 +7,51 @@ _jarsigner() case $prev in -keystore) - COMPREPLY=( $(compgen -W 'NONE' -- "$cur") ) + COMPREPLY=($(compgen -W 'NONE' -- "$cur")) _filedir '@(jks|ks|p12|pfx)' return ;; - -storepass|-keypass|-sigfile|-digestalg|-sigalg|-tsacert|-tsapolicyid|\ - -tsadigestalg|-altsigner|-altsignerpath|-providerName|-providerClass|\ - -providerArg) + -storepass | -keypass | -sigfile | -digestalg | -sigalg | -tsacert | -tsapolicyid | \ + -tsadigestalg | -altsigner | -altsignerpath | -providerName | -providerClass | \ + -providerArg) return ;; - -certchain|-sigfile|-tsa) + -certchain | -tsa) _filedir return ;; -storetype) - COMPREPLY=( $(compgen -W 'JKS PKCS11 PKCS12' -- "$cur") ) + COMPREPLY=($(compgen -W 'JKS PKCS11 PKCS12' -- "$cur")) return ;; -signedjar) - _filedir jar + _filedir '@(jar|apk)' return ;; esac # Check if a jar was already given. local i jar=false - for (( i=0; i < ${#words[@]}-1; i++ )) ; do - if [[ "${words[i]}" == *.jar && \ - "${words[i-1]}" != -signedjar ]]; then + for ((i = 1; i < ${#words[@]} - 1; i++)); do + if [[ ${words[i]} == *.@(jar|apk) && \ + ${words[i - 1]} != -signedjar ]]; then jar=true break fi done - if ! $jar ; then - if [[ "$cur" == -* ]]; then + if ! $jar; then + if [[ $cur == -* ]]; then # Documented as "should not be used": -internalsf, -sectionsonly - COMPREPLY=( $(compgen -W '-keystore -storepass -storetype + COMPREPLY=($(compgen -W '-keystore -storepass -storetype -keypass -sigfile -signedjar -digestalg -sigalg -verify -verbose -certs -tsa -tsacert -altsigner -altsignerpath -protected -providerName -providerClass -providerArg' \ - -- "$cur") ) + -- "$cur")) fi - _filedir jar + _filedir '@(jar|apk)' fi } && -complete -F _jarsigner jarsigner + complete -F _jarsigner jarsigner # ex: filetype=sh diff --git a/completions/java b/completions/java index 89d207d2..d0f70ae6 100644 --- a/completions/java +++ b/completions/java @@ -13,15 +13,15 @@ _java_find_classpath() local i # search first in current options - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == -@(cp|classpath) ]]; then - classpath=${words[i+1]} + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == -@(cp|classpath) ]]; then + classpath=${words[i + 1]} break fi done # default to environment - [[ -z $classpath ]] && classpath=$CLASSPATH + [[ ! -v classpath ]] && classpath=${CLASSPATH-} # default to current directory [[ -z $classpath ]] && classpath=. @@ -33,15 +33,15 @@ _java_find_sourcepath() local i # search first in current options - for (( i=1; i < cword; i++ )); do - if [[ "${words[i]}" == -sourcepath ]]; then - sourcepath=${words[i+1]} + for ((i = 1; i < cword; i++)); do + if [[ ${words[i]} == -sourcepath ]]; then + sourcepath=${words[i + 1]} break fi done # default to classpath - if [[ -z $sourcepath ]]; then + if [[ ! -v sourcepath ]]; then local classpath _java_find_classpath sourcepath=$classpath @@ -60,27 +60,27 @@ _java_classes() cur=${cur//.//} # parse each classpath element for classes for i in ${classpath//:/ }; do - if [[ "$i" == *.@(jar|zip) && -r $i ]]; then + if [[ $i == *.@(jar|zip) && -r $i ]]; then if type zipinfo &>/dev/null; then - COMPREPLY+=( $(zipinfo -1 "$i" "$cur*" 2>/dev/null | \ - command grep '^[^$]*\.class$') ) + COMPREPLY+=($(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 | \ + COMPREPLY+=($(unzip -lq "$i" "$cur*" 2>/dev/null | awk '$NF ~ /^-+$/ { flag=!flag; next }; - flag && $NF ~ /^[^$]*\.class/ { print $NF }') ) + flag && $NF ~ /^[^$]*\.class/ { print $NF }')) elif type jar &>/dev/null; then - COMPREPLY+=( $(jar tf "$i" "$cur" | \ - command grep '^[^$]*\.class$') ) + COMPREPLY+=($(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/||") + $(compgen -f -X '!*.class' -- "$i/$cur" | + command sed -e '/\$/d' -e "s|^$i/||") ) - [[ $COMPREPLY == *.class ]] || compopt -o nospace + [[ ${COMPREPLY-} == *.class ]] || compopt -o nospace # FIXME: if we have foo.class and foo/, the completion # returns "foo/"... how to give precedence to files @@ -88,10 +88,12 @@ _java_classes() fi done - # remove class extension - COMPREPLY=( ${COMPREPLY[@]%.class} ) - # convert path syntax to package syntax - COMPREPLY=( ${COMPREPLY[@]//\//.} ) + if ((${#COMPREPLY[@]} != 0)); then + # remove class extension + COMPREPLY=(${COMPREPLY[@]%.class}) + # convert path syntax to package syntax + COMPREPLY=(${COMPREPLY[@]//\//.}) + fi } # available packages completion @@ -107,16 +109,18 @@ _java_packages() # parse each sourcepath element for packages for i in ${sourcepath//:/ }; do if [[ -d $i ]]; then - COMPREPLY+=( $(command ls -F -d $i/$cur* 2>/dev/null | \ - command sed -e 's|^'$i'/||') ) + COMPREPLY+=($(command ls -F -d $i/$cur* 2>/dev/null | + command sed -e 's|^'$i'/||')) fi done - # keep only packages - COMPREPLY=( $(tr " " "\n" <<<"${COMPREPLY[@]}" | command grep "/$") ) - # remove packages extension - COMPREPLY=( ${COMPREPLY[@]%/} ) - # convert path syntax to package syntax - cur=${COMPREPLY[@]//\//.} + if ((${#COMPREPLY[@]} != 0)); then + # keep only packages + COMPREPLY=($(tr " " "\n" <<<"${COMPREPLY[@]}" | command grep "/$")) + # remove packages extension + COMPREPLY=(${COMPREPLY[@]%/}) + # convert path syntax to package syntax + cur="${COMPREPLY[*]//\//.}" + fi } # java completion @@ -128,9 +132,9 @@ _java() local i - for ((i=1; i < $cword; i++)); do - case ${words[$i]} in - -cp|-classpath) + for ((i = 1; i < cword; i++)); do + case ${words[i]} in + -cp | -classpath) ((i++)) # skip the classpath string. ;; -*) @@ -147,7 +151,7 @@ _java() case $cur in # standard option completions -verbose:*) - COMPREPLY=( $(compgen -W 'class gc jni' -- "${cur#*:}") ) + COMPREPLY=($(compgen -W 'class gc jni' -- "${cur#*:}")) return ;; -javaagent:*) @@ -171,56 +175,56 @@ _java() return ;; -Xcheck:*) - COMPREPLY=( $(compgen -W 'jni' -- "${cur#*:}") ) + COMPREPLY=($(compgen -W 'jni' -- "${cur#*:}")) return ;; -Xgc:*) - COMPREPLY=( $(compgen -W 'singlecon gencon singlepar genpar' \ - -- "${cur#*:}") ) + COMPREPLY=($(compgen -W 'singlecon gencon singlepar genpar' \ + -- "${cur#*:}")) return ;; -Xgcprio:*) - COMPREPLY=( $(compgen -W 'throughput pausetime deterministic' \ - -- "${cur#*:}") ) + COMPREPLY=($(compgen -W 'throughput pausetime deterministic' \ + -- "${cur#*:}")) return ;; - -Xloggc:*|-Xverboselog:*) + -Xloggc:* | -Xverboselog:*) cur=${cur#*:} _filedir return ;; -Xshare:*) - COMPREPLY=( $(compgen -W 'auto off on' -- "${cur#*:}") ) + COMPREPLY=($(compgen -W 'auto off on' -- "${cur#*:}")) return ;; -Xverbose:*) - COMPREPLY=( $(compgen -W 'memory load jni cpuinfo codegen opt - gcpause gcreport' -- "${cur#*:}") ) + COMPREPLY=($(compgen -W 'memory load jni cpuinfo codegen opt + gcpause gcreport' -- "${cur#*:}")) return ;; -Xverify:*) - COMPREPLY=( $(compgen -W 'all none remote' -- "${cur#*:}") ) + COMPREPLY=($(compgen -W 'all none remote' -- "${cur#*:}")) return ;; # the rest that we have no completions for - -D*|-*:*) + -D* | -*:*) return ;; esac case $prev in - -cp|-classpath) + -cp | -classpath) _java_path return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - [[ $cur == -X* ]] && \ - COMPREPLY+=( $(compgen -W '$(_parse_help "$1" -X)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + [[ $cur == -X* ]] && + COMPREPLY+=($(compgen -W '$(_parse_help "$1" -X)' -- "$cur")) else - if [[ "$prev" == -jar ]]; then + if [[ $prev == -jar ]]; then # jar file completion _filedir '[jw]ar' else @@ -229,11 +233,11 @@ _java() fi fi - [[ $COMPREPLY == -*[:=] ]] && compopt -o nospace + [[ ${COMPREPLY-} == -*[:=] ]] && compopt -o nospace __ltrim_colon_completions "$cur" } && -complete -F _java java + complete -F _java java _javadoc() { @@ -241,42 +245,38 @@ _javadoc() _init_completion || return case $prev in - -overview|-helpfile) + -overview | -helpfile) _filedir '?(x)htm?(l)' return ;; - -doclet|-exclude|-subpackages|-source|-locale|-encoding|-windowtitle|\ - -doctitle|-header|-footer|-top|-bottom|-group|-noqualifier|-tag|\ - -charset|-sourcetab|-docencoding) + -doclet | -exclude | -subpackages | -source | -locale | -encoding | -windowtitle | \ + -doctitle | -header | -footer | -top | -bottom | -group | -noqualifier | -tag | \ + -charset | -sourcetab | -docencoding) return ;; -stylesheetfile) _filedir css return ;; - -d|-link|-linkoffline) + -d | -link | -linkoffline) _filedir -d return ;; - -classpath|-cp|-bootclasspath|-docletpath|-sourcepath|-extdirs|\ - -excludedocfilessubdir) + -classpath | -cp | -bootclasspath | -docletpath | -sourcepath | -extdirs | \ + -excludedocfilessubdir) _java_path return ;; - -helpfile) - _filedir - return - ;; esac # -linkoffline takes two arguments - if [[ $cword -gt 2 && ${words[$cword-2]} == -linkoffline ]]; then + if [[ $cword -gt 2 && ${words[cword - 2]} == -linkoffline ]]; then _filedir -d return fi - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) else # source files completion _filedir java @@ -284,7 +284,7 @@ _javadoc() _java_packages fi } && -complete -F _javadoc javadoc + complete -F _javadoc javadoc _javac() { @@ -296,13 +296,13 @@ _javac() _filedir -d return ;; - -cp|-classpath|-bootclasspath|-sourcepath|-extdirs) + -cp | -classpath | -bootclasspath | -sourcepath | -extdirs) _java_path return ;; esac - if [[ $cur == -+([a-zA-z0-9-_]):* ]]; then + if [[ $cur == -+([a-zA-Z0-9-_]):* ]]; then # Parse required options from -foo:{bar,quux,baz} local helpopt=-help [[ $cur == -X* ]] && helpopt=-X @@ -311,23 +311,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#*:}") ) + COMPREPLY=($(compgen -W "${opts//,/ }" -- "${cur#*:}")) return fi - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") ) - [[ $cur == -X* ]] && \ - COMPREPLY+=( $(compgen -W '$(_parse_help "$1" -X)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur")) + [[ $cur == -X* ]] && + COMPREPLY+=($(compgen -W '$(_parse_help "$1" -X)' -- "$cur")) else # source files completion _filedir java fi - [[ $COMPREPLY == -*[:=] ]] && compopt -o nospace + [[ ${COMPREPLY-} == -*[:=] ]] && compopt -o nospace __ltrim_colon_completions "$cur" } && -complete -F _javac javac + complete -F _javac javac # ex: filetype=sh diff --git a/completions/javaws b/completions/javaws index c21d3ac4..f42a1e55 100644 --- a/completions/javaws +++ b/completions/javaws @@ -6,14 +6,14 @@ _javaws() _init_completion -n = || return case $prev in - -help|-license|-about|-viewer|-arg|-param|-property|-update|-umask) + -help | -license | -about | -viewer | -arg | -param | -property | -update | -umask) return ;; - -basedir|-codebase) + -basedir | -codebase) _filedir -d return ;; - -uninstall|-import) + -uninstall | -import) _filedir jnlp return ;; @@ -22,13 +22,13 @@ _javaws() if [[ $cur == *= ]]; then return elif [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W "$(_parse_help "$1" -help) " -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W "$(_parse_help "$1" -help) " -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir jnlp } && -complete -F _javaws javaws + complete -F _javaws javaws # ex: filetype=sh diff --git a/completions/jpegoptim b/completions/jpegoptim index 044cc753..c3669721 100644 --- a/completions/jpegoptim +++ b/completions/jpegoptim @@ -6,19 +6,19 @@ _jpegoptim() _init_completion -s || return case $prev in - --help|--version|-!(-*)[hV]*) + --help | --version | -!(-*)[hV]*) return ;; - --dest|-!(-*)d) + --dest | -!(-*)d) _filedir -d return ;; - --max|--threshold|-!(-*)[mT]) - COMPREPLY=( $(compgen -W '{0..100}' -- "$cur") ) + --max | --threshold | -!(-*)[mT]) + COMPREPLY=($(compgen -W '{0..100}' -- "$cur")) return ;; - --size|-!(-*)S) - COMPREPLY=( $(compgen -W '{1..99}%' -- "$cur") ) + --size | -!(-*)S) + COMPREPLY=($(compgen -W '{1..99}%' -- "$cur")) return ;; esac @@ -26,13 +26,13 @@ _jpegoptim() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir 'jp?(e)g' } && -complete -F _jpegoptim jpegoptim + complete -F _jpegoptim jpegoptim # ex: filetype=sh diff --git a/completions/jps b/completions/jps index a6a60299..a451eec1 100644 --- a/completions/jps +++ b/completions/jps @@ -6,7 +6,7 @@ _jps() _init_completion || return case $prev in - -J*|-help) + -J* | -help) return ;; esac @@ -14,12 +14,12 @@ _jps() 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") ) - [[ $COMPREPLY == -J* ]] && compopt -o nospace + COMPREPLY=($(compgen -W "-q -m -l -v -V -J -help" -- "$cur")) + [[ ${COMPREPLY-} == -J* ]] && compopt -o nospace else _known_hosts_real -- "$cur" fi } && -complete -F _jps jps + complete -F _jps jps # ex: filetype=sh diff --git a/completions/jq b/completions/jq index 3fdbfb0c..2d99c391 100644 --- a/completions/jq +++ b/completions/jq @@ -6,14 +6,14 @@ _jq() _init_completion || return case $prev in - --help|--version|--arg|--argjson|--slurpfile|--argfile) + --help | --version | --arg | --argjson | --slurpfile | --argfile) return ;; --indent) - COMPREPLY=( $(compgen -W '{1..8}' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..8}' -- "$cur")) return ;; - --from-file|--run-tests|-!(-*)f) + --from-file | --run-tests | -!(-*)f) _filedir return ;; @@ -23,19 +23,19 @@ _jq() ;; esac - (( cword > 2 )) && \ - case ${words[cword-2]} in - --arg|--argjson) - return - ;; - --slurpfile|--argfile) - _filedir json - return - ;; - esac + ((cword > 2)) && + case ${words[cword - 2]} in + --arg | --argjson) + return + ;; + --slurpfile | --argfile) + _filedir json + return + ;; + esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi @@ -44,11 +44,11 @@ _jq() _count_args "" "@(--arg|--arg?(json|file)|--?(slurp|from-)file|--indent|--run-tests|-!(-*)[fL])" # 1st arg is filter - [[ $args -eq 1 ]] && return + ((args == 1)) && return # 2... are input files _filedir json } && -complete -F _jq jq + complete -F _jq jq # ex: filetype=sh diff --git a/completions/jshint b/completions/jshint index ee89070a..3622cecf 100644 --- a/completions/jshint +++ b/completions/jshint @@ -6,19 +6,19 @@ _jshint() _init_completion -s || return case $prev in - -v|--version|-h|--help|--exclude|--filename|-e|--extra-ext) + -v | --version | -h | --help | --exclude | --filename | -e | --extra-ext) return ;; - -c|--config) + -c | --config) _filedir return ;; --reporter) - COMPREPLY=( $(compgen -W "jslint checkstyle unix" -- "$cur") ) + COMPREPLY=($(compgen -W "jslint checkstyle unix" -- "$cur")) return ;; --extract) - COMPREPLY=( $(compgen -W "auto always never" -- "$cur") ) + COMPREPLY=($(compgen -W "auto always never" -- "$cur")) return ;; esac @@ -26,13 +26,13 @@ _jshint() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir js } && -complete -F _jshint jshint + complete -F _jshint jshint # ex: filetype=sh diff --git a/completions/json_xs b/completions/json_xs index 98d0ba63..c93ba864 100644 --- a/completions/json_xs +++ b/completions/json_xs @@ -7,15 +7,15 @@ _json_xs() case $prev in -*f) - COMPREPLY=( $(compgen -W 'json cbor storable storable-file bencode - clzf eval yaml string none' -- "$cur") ) + COMPREPLY=($(compgen -W 'json cbor storable storable-file bencode + clzf eval yaml string none' -- "$cur")) return ;; -*t) - COMPREPLY=( $(compgen -W 'json json-utf-8 json-pretty + 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") ) + string none' -- "$cur")) return ;; -*e) @@ -24,8 +24,8 @@ _json_xs() esac [[ $cur == -* ]] && - COMPREPLY=( $(compgen -W '$(_parse_usage "$1") -f' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_usage "$1") -f' -- "$cur")) } && -complete -F _json_xs json_xs + complete -F _json_xs json_xs # ex: filetype=sh diff --git a/completions/jsonschema b/completions/jsonschema index 441977e4..8a36ed36 100644 --- a/completions/jsonschema +++ b/completions/jsonschema @@ -6,24 +6,25 @@ _jsonschema() _init_completion || return case $prev in - --help|--error-format|--validator|-[hFV]) + --help | --error-format | --validator | -[hFV]) return ;; - --instance|-i) + --instance | -i) _filedir json return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - local args; _count_args "" "-*" - [[ $args -eq 1 ]] || return + local args + _count_args "" "-*" + ((args == 1)) || return _filedir '@(json|schema)' } && -complete -F _jsonschema jsonschema + complete -F _jsonschema jsonschema # ex: filetype=sh diff --git a/completions/k3b b/completions/k3b index b52e6de0..87d26cdc 100644 --- a/completions/k3b +++ b/completions/k3b @@ -6,23 +6,23 @@ _k3b() _init_completion || return case $prev in - --help*|--author|-v|--version|--license|--lang) + --help* | --author | -v | --version | --license | --lang) return ;; - --datacd|--audiocd|--videocd|--mixedcd|--emovixcd|--videodvd) + --datacd | --audiocd | --videocd | --mixedcd | --emovixcd | --videodvd) _filedir return ;; - --copydvd|--formatdvd|--videodvdrip) + --copydvd | --formatdvd | --videodvdrip) _dvd_devices return ;; - --copycd|--erasecd|--cddarip|--videocdrip) + --copycd | --erasecd | --cddarip | --videocdrip) _cd_devices _dvd_devices return ;; - --cdimage|--image) + --cdimage | --image) _filedir '@(cue|iso|toc)' return ;; @@ -31,18 +31,18 @@ _k3b() return ;; --ao) - COMPREPLY=( $(compgen -W 'alsa arts' -- "$cur") ) + COMPREPLY=($(compgen -W 'alsa arts' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W "$(_parse_help "$1")" -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W "$(_parse_help "$1")" -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _filedir fi } && -complete -F _k3b k3b + complete -F _k3b k3b # ex: filetype=sh diff --git a/completions/kcov b/completions/kcov index 8490a969..672967af 100644 --- a/completions/kcov +++ b/completions/kcov @@ -6,21 +6,21 @@ _kcov() _init_completion -s -n : || return case "$prev" in - --pid|-p) + --pid | -p) _pids return ;; - --sort-type|-s) - COMPREPLY=( $(compgen -W 'filename percent reverse lines - uncovered' -- "$cur") ) + --sort-type | -s) + COMPREPLY=($(compgen -W 'filename percent reverse lines + uncovered' -- "$cur")) return ;; - --include-path|--exclude-path) + --include-path | --exclude-path) _filedir return ;; --replace-src-path) - if [[ "$cur" == ?*:* ]]; then + if [[ $cur == ?*:* ]]; then cur="${cur##*:}" _filedir else @@ -29,21 +29,21 @@ _kcov() fi return ;; - --limits|-l) - if [[ "$cur" == ?*,* ]]; then + --limits | -l) + if [[ $cur == ?*,* ]]; then prev="${cur%,*}" cur="${cur##*,}" - COMPREPLY=( $(compgen -W "{0..100}" -- "$cur") ) - [[ ${#COMPREPLY[@]} -eq 1 ]] && \ - COMPREPLY=( ${COMPREPLY/#/$prev,} ) + COMPREPLY=($(compgen -W "{0..100}" -- "$cur")) + ((${#COMPREPLY[@]} == 1)) && + COMPREPLY=(${COMPREPLY/#/$prev,}) else - COMPREPLY=( $(compgen -W "{0..100}" -- "$cur") ) - [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/%/,} ) + COMPREPLY=($(compgen -W "{0..100}" -- "$cur")) + ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/%/,}) compopt -o nospace fi return ;; - --title|-t|--include-pattern|--exclude-pattern|--path-strip-level) + --title | -t | --include-pattern | --exclude-pattern | --path-strip-level) # argument required but no completions available return ;; @@ -51,14 +51,14 @@ _kcov() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi _filedir } && -complete -F _kcov kcov + complete -F _kcov kcov # ex: filetype=sh diff --git a/completions/kill b/completions/kill index 4cd5f911..25cddbad 100644 --- a/completions/kill +++ b/completions/kill @@ -15,15 +15,15 @@ _kill() ;; esac - if [[ $cword -eq 1 && "$cur" == -* ]]; then + if [[ $cword -eq 1 && $cur == -* ]]; then # return list of available signals _signals - - COMPREPLY+=( $(compgen -W "-s -l" -- "$cur") ) + COMPREPLY+=($(compgen -W "-s -l" -- "$cur")) else # return list of available PIDs _pids fi } && -complete -F _kill kill + complete -F _kill kill # ex: filetype=sh diff --git a/completions/killall b/completions/killall index e1b56ce1..c7c0b0fc 100644 --- a/completions/killall +++ b/completions/killall @@ -8,14 +8,14 @@ _killall() _init_completion -s || return case $prev in - --context|--older-than|--younger-than|--version|-!(-*)@([Zoy]|V*)) + --context | --older-than | --younger-than | --version | -!(-*)@([Zoy]|V*)) return ;; - --signal|-!(-*)s) + --signal | -!(-*)s) _signals return ;; - --user|-!(-*)u) + --user | -!(-*)u) _allowed_users return ;; @@ -24,13 +24,13 @@ _killall() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $cword -eq 1 ]] && _signals - + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + ((cword == 1)) && _signals - return fi _pnames } && -complete -F _killall killall + complete -F _killall killall # ex: filetype=sh diff --git a/completions/kldload b/completions/kldload index 4817679e..f5111584 100644 --- a/completions/kldload +++ b/completions/kldload @@ -11,11 +11,11 @@ _kldload() [[ -d $moddir ]] || moddir=/boot/kernel/ compopt -o filenames - COMPREPLY=( $(compgen -f "$moddir$cur") ) - COMPREPLY=( ${COMPREPLY[@]#$moddir} ) - COMPREPLY=( ${COMPREPLY[@]%.ko} ) + COMPREPLY=($(compgen -f "$moddir$cur")) + COMPREPLY=(${COMPREPLY[@]#$moddir}) + COMPREPLY=(${COMPREPLY[@]%.ko}) } && -complete -F _kldload kldload + complete -F _kldload kldload # ex: filetype=sh diff --git a/completions/kldunload b/completions/kldunload index e1462677..2e12282c 100644 --- a/completions/kldunload +++ b/completions/kldunload @@ -7,9 +7,9 @@ _kldunload() local cur prev words cword _init_completion || return - COMPREPLY=( $(compgen -W '$(kldstat)' -X 'kernel' -X '!*.ko' -- "$cur") ) - COMPREPLY=( ${COMPREPLY[@]%.ko} ) + COMPREPLY=($(compgen -W '$(kldstat)' -X 'kernel' -X '!*.ko' -- "$cur")) + COMPREPLY=(${COMPREPLY[@]%.ko}) } && -complete -F _kldunload kldunload + complete -F _kldunload kldunload # ex: filetype=sh diff --git a/completions/koji b/completions/koji index be43f0a2..8efef9a7 100644 --- a/completions/koji +++ b/completions/koji @@ -2,8 +2,8 @@ _koji_search() { - COMPREPLY+=( $(compgen -W \ - '$("$1" -q search $2 "$cur*" 2>/dev/null)' -- "$cur") ) + COMPREPLY+=($(compgen -W \ + '$("$1" -q search $2 "$cur*" 2>/dev/null)' -- "$cur")) } _koji_build() @@ -23,13 +23,13 @@ _koji_user() _koji_tag() { - COMPREPLY+=( $(compgen -W '$("$1" -q list-tags 2>/dev/null)' -- "$cur") ) + COMPREPLY+=($(compgen -W '$("$1" -q list-tags 2>/dev/null)' -- "$cur")) } _koji_target() { - COMPREPLY+=( $(compgen -W '$("$1" -q list-targets 2>/dev/null | - awk "{ print \$1 }")' -- "$cur") ) + COMPREPLY+=($(compgen -W '$("$1" -q list-targets 2>/dev/null | + awk "{ print \$1 }")' -- "$cur")) } _koji() @@ -38,7 +38,7 @@ _koji() _init_completion -s || return local commandix command - for (( commandix=1; commandix < cword; commandix++ )); do + for ((commandix = 1; commandix < cword; commandix++)); do if [[ ${words[commandix]} != -* ]]; then command=${words[commandix]} break @@ -46,19 +46,19 @@ _koji() done case $prev in - --help|--help-commands|-!(-*)h*) + --help | --help-commands | -!(-*)h*) return ;; - --config|--keytab|-!(-*)[co]) + --config | --keytab | -!(-*)[co]) _filedir return ;; - --runas|--user|--editor|--by) + --runas | --user | --editor | --by) _koji_user "$1" return ;; --authtype) - COMPREPLY=( $(compgen -W 'noauth ssl password kerberos' -- "$cur") ) + COMPREPLY=($(compgen -W 'noauth ssl password kerberos' -- "$cur")) return ;; --topdir) @@ -66,15 +66,15 @@ _koji() return ;; --type) - case $command in - latest-pkg|list-tagged) - COMPREPLY=( $(compgen -W 'maven' -- "$cur") ) + case ${command-} in + latest-pkg | list-tagged) + COMPREPLY=($(compgen -W 'maven' -- "$cur")) ;; esac return ;; --name) - case $command in + case ${command-} in list-targets) _koji_target "$1" ;; @@ -85,7 +85,7 @@ _koji() _koji_user "$1" return ;; - --tag|--latestfrom) + --tag | --latestfrom) _koji_tag "$1" return ;; @@ -105,22 +105,22 @@ _koji() $split && return - if [[ $command ]]; then + if [[ -v command ]]; then if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W \ - '$(_parse_help "$1" "$command --help")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W \ + '$(_parse_help "$1" "$command --help")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi # How many'th non-option arg (1-based) for $command are we completing? local i nth=1 - for (( i=commandix+1; i < cword; i++ )); do - [[ ${words[i]} == -* ]] || (( nth++ )) + for ((i = commandix + 1; i < cword; i++)); do + [[ ${words[i]} == -* ]] || ((nth++)) done case $command in - build|maven-build|win-build) + build | maven-build | win-build) case $nth in 1) _koji_target "$1" @@ -160,7 +160,7 @@ _koji() latest-by-tag) _koji_package "$1" ;; - latest-pkg|list-groups|list-tag-inheritance|show-groups) + latest-pkg | list-groups | list-tag-inheritance | show-groups) case $nth in 1) _koji_tag "$1" @@ -186,7 +186,7 @@ _koji() ;; move-pkg) case $nth in - 1|2) + 1 | 2) _koji_tag "$1" ;; *) @@ -197,12 +197,12 @@ _koji() search) case $nth in 1) - COMPREPLY=( $(compgen -W 'package build tag target - user host rpm' -- "$cur") ) + COMPREPLY=($(compgen -W 'package build tag target + user host rpm' -- "$cur")) ;; esac ;; - tag-pkg|untag-pkg) + tag-pkg | untag-pkg) case $nth in 1) _koji_tag "$1" @@ -218,7 +218,7 @@ _koji() wait-repo) case $nth in 1) - for (( i=commandix+1; i < cword; i++ )); do + for ((i = commandix + 1; i < cword; i++)); do if [[ ${words[i]} == --target ]]; then _koji_target "$1" return @@ -233,13 +233,13 @@ _koji() fi if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace - elif [[ ! $command ]]; then - COMPREPLY=( $(compgen -W '$("$1" --help-commands 2>/dev/null | \ - awk "/^( +|\t)/ { print \$1 }")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace + elif [[ ! -v command ]]; then + COMPREPLY=($(compgen -W '$("$1" --help-commands 2>/dev/null | \ + awk "/^( +|\t)/ { print \$1 }")' -- "$cur")) fi } && -complete -F _koji koji arm-koji ppc-koji s390-koji sparc-koji + complete -F _koji koji arm-koji ppc-koji s390-koji sparc-koji # ex: filetype=sh diff --git a/completions/ktutil b/completions/ktutil index 572a2ec4..6030a474 100644 --- a/completions/ktutil +++ b/completions/ktutil @@ -2,21 +2,21 @@ _heimdal_principals() { - COMPREPLY=( $(compgen -W "$(kadmin -l dump 2>/dev/null | \ - awk '{print $1}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(kadmin -l dump 2>/dev/null | + awk '{print $1}')" -- "$cur")) } _heimdal_realms() { - COMPREPLY=( $(compgen -W "$(kadmin -l dump 2>/dev/null | \ - awk '{print $1}' | awk -F@ '{print $2}')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(kadmin -l dump 2>/dev/null | + awk '{print $1}' | awk -F@ '{print $2}')" -- "$cur")) } _heimdal_encodings() { - COMPREPLY=( $(compgen -W 'des-cbc-mcrc des-cbc-md4 des-cbc-md5 + 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") ) + aes256-cts-hmac-sha1-96' -- "$cur")) } _ktutil() @@ -27,23 +27,23 @@ _ktutil() local command commands i options case $prev in - -p|--principal) + -p | --principal) _heimdal_principals return ;; - -e|--enctype) + -e | --enctype) _heimdal_encodings return ;; - -a|--admin-server) + -a | --admin-server) _known_hosts_real -- "$cur" return ;; - -r|--realm) + -r | --realm) _heimdal_realms return ;; - -s|-k|--srvtab|--keytab) + -s | -k | --srvtab | --keytab) _filedir return ;; @@ -54,13 +54,13 @@ _ktutil() commands='add change copy get list remove rename purge srvconvert srv2keytab srvcreate key2srvtab' - for (( i=1; i < cword; i++ )); do + for ((i = 1; i < cword; i++)); do case ${words[i]} in - -k|--keytab) - (( i++ )) - ;; - -*) + -k | --keytab) + ((i++)) ;; + -*) ;; + *) command=${words[i]} break @@ -68,15 +68,15 @@ _ktutil() esac done - if [[ "$cur" == -* ]]; then - case $command in + if [[ $cur == -* ]]; then + case ${command-} in add) options='-p --principal -V -e --enctype -w --password -r --random -s --no-salt -h --hex' - ;; + ;; change) options='-r --realm -a --admin-server -s --server-port' - ;; + ;; get) options='-p --principal -e --enctype -r --realm -a --admin-server -s server --server-port' @@ -90,16 +90,16 @@ _ktutil() purge) options='--age' ;; - srv2keytab|key2srvtab) + srv2keytab | key2srvtab) options='-s --srvtab' ;; *) options='-k --keytab -v --verbose --version -v --help' ;; esac - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) else - case $command in + case ${command-} in copy) _filedir ;; @@ -110,11 +110,11 @@ _ktutil() _heimdal_principals ;; *) - COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + COMPREPLY=($(compgen -W "$commands" -- "$cur")) ;; esac fi } && -complete -F _ktutil ktutil + complete -F _ktutil ktutil # ex: filetype=sh diff --git a/completions/larch b/completions/larch index 0773c2da..7ed9ca20 100644 --- a/completions/larch +++ b/completions/larch @@ -6,8 +6,8 @@ _larch() local cur prev words cword _init_completion || return - if [[ $cword -eq 1 || "$prev" == -* ]]; then - COMPREPLY=( $(compgen -W ' \ + if [[ $cword -eq 1 || $prev == -* ]]; then + COMPREPLY=($(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 \ @@ -30,10 +30,10 @@ _larch() 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") ) + "$cur")) fi } && -complete -F _larch -o default larch + complete -F _larch -o default larch # ex: filetype=sh diff --git a/completions/lastlog b/completions/lastlog index 19e928c2..214a174d 100644 --- a/completions/lastlog +++ b/completions/lastlog @@ -6,20 +6,20 @@ _lastlog() _init_completion -s || return case $prev in - --before|--help|--time|-!(-*)@([bt]|h*)) + --before | --help | --time | -!(-*)@([bt]|h*)) return ;; - --user|-!(-*)u) - COMPREPLY=( $(compgen -u -- "$cur") ) + --user | -!(-*)u) + COMPREPLY=($(compgen -u -- "$cur")) return ;; esac $split && return - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace } && -complete -F _lastlog lastlog + complete -F _lastlog lastlog # ex: filetype=sh diff --git a/completions/ldapsearch b/completions/ldapsearch index a0bdcb9d..6dc415e6 100644 --- a/completions/ldapsearch +++ b/completions/ldapsearch @@ -2,12 +2,12 @@ _ldap_uris() { - COMPREPLY=( $(compgen -W 'ldap:// ldaps://' -- "$cur") ) + COMPREPLY=($(compgen -W 'ldap:// ldaps://' -- "$cur")) } _ldap_protocols() { - COMPREPLY=( $(compgen -W '2 3' -- "$cur") ) + COMPREPLY=($(compgen -W '2 3' -- "$cur")) } _ldapsearch() @@ -33,11 +33,11 @@ _ldapsearch() return ;; -*s) - COMPREPLY=( $(compgen -W 'base one sub children' -- "$cur") ) + COMPREPLY=($(compgen -W 'base one sub children' -- "$cur")) return ;; -*a) - COMPREPLY=( $(compgen -W 'never always search find' -- "$cur") ) + COMPREPLY=($(compgen -W 'never always search find' -- "$cur")) return ;; -*P) @@ -46,11 +46,11 @@ _ldapsearch() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur")) fi } && -complete -F _ldapsearch ldapsearch + complete -F _ldapsearch ldapsearch _ldapaddmodify() { @@ -76,11 +76,11 @@ _ldapaddmodify() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur")) fi } && -complete -F _ldapaddmodify ldapadd ldapmodify + complete -F _ldapaddmodify ldapadd ldapmodify _ldapdelete() { @@ -106,11 +106,11 @@ _ldapdelete() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur")) fi } && -complete -F _ldapdelete ldapdelete + complete -F _ldapdelete ldapdelete _ldapcompare() { @@ -136,11 +136,11 @@ _ldapcompare() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur")) fi } && -complete -F _ldapcompare ldapcompare + complete -F _ldapcompare ldapcompare _ldapmodrdn() { @@ -166,11 +166,11 @@ _ldapmodrdn() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") -ZZ -MM' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") -ZZ -MM' -- "$cur")) fi } && -complete -F _ldapmodrdn ldapmodrdn + complete -F _ldapmodrdn ldapmodrdn _ldapwhoami() { @@ -196,11 +196,11 @@ _ldapwhoami() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur")) fi } && -complete -F _ldapwhoami ldapwhoami + complete -F _ldapwhoami ldapwhoami _ldappasswd() { @@ -222,10 +222,10 @@ _ldappasswd() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") -MM -ZZ' -- "$cur")) fi } && -complete -F _ldappasswd ldappasswd + complete -F _ldappasswd ldappasswd # ex: filetype=sh diff --git a/completions/ldapvi b/completions/ldapvi index a7b55fcc..cb01ac8d 100644 --- a/completions/ldapvi +++ b/completions/ldapvi @@ -6,46 +6,46 @@ _ldapvi() _init_completion || return case $prev in - --host|-!(-*)h) + --host | -!(-*)h) _known_hosts_real -- "$cur" return ;; - --sasl-mech|-!(-*)Y) - COMPREPLY=( $(compgen -W 'EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 - PLAIN ANONYMOUS' -- "$cur") ) + --sasl-mech | -!(-*)Y) + COMPREPLY=($(compgen -W 'EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 + PLAIN ANONYMOUS' -- "$cur")) return ;; --bind) - COMPREPLY=( $(compgen -W 'simple sasl' -- "$cur") ) + COMPREPLY=($(compgen -W 'simple sasl' -- "$cur")) return ;; --bind-dialog) - COMPREPLY=( $(compgen -W 'never auto always' -- "$cur") ) + COMPREPLY=($(compgen -W 'never auto always' -- "$cur")) return ;; --scope) - COMPREPLY=( $(compgen -W 'base one sub' -- "$cur") ) + COMPREPLY=($(compgen -W 'base one sub' -- "$cur")) return ;; --deref) - COMPREPLY=( $(compgen -W 'never searching finding always' \ - -- "$cur") ) + COMPREPLY=($(compgen -W 'never searching finding always' \ + -- "$cur")) return ;; --encoding) - COMPREPLY=( $(compgen -W 'ASCII UTF-8 binary' -- "$cur") ) + COMPREPLY=($(compgen -W 'ASCII UTF-8 binary' -- "$cur")) return ;; --tls) - COMPREPLY=( $(compgen -W 'never allow try strict' -- "$cur") ) + COMPREPLY=($(compgen -W 'never allow try strict' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) fi } && -complete -F _ldapvi ldapvi + complete -F _ldapvi ldapvi # ex: filetype=sh diff --git a/completions/lftp b/completions/lftp index 41fb1356..72dedb42 100644 --- a/completions/lftp +++ b/completions/lftp @@ -10,20 +10,19 @@ _lftp() _filedir return ;; - --help|--version|-!(-*)[chveups]) + --help | --version | -!(-*)[chveups]) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - COMPREPLY=( $(compgen -W \ - '$(cut -f 1 -s ~/.lftp/bookmarks ${XDG_DATA_HOME:-$HOME/.local/share}/lftp/bookmarks 2>/dev/null)' -- "$cur") ) + COMPREPLY=($(compgen -W '$("$1" -c "bookmark list" 2>/dev/null)' -- "$cur")) _known_hosts_real -- "$cur" } && -complete -F _lftp lftp + complete -F _lftp lftp # ex: filetype=sh diff --git a/completions/lftpget b/completions/lftpget index 1583500c..d21622eb 100644 --- a/completions/lftpget +++ b/completions/lftpget @@ -5,10 +5,10 @@ _lftpget() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-c -d -v' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-c -d -v' -- "$cur")) fi } && -complete -F _lftpget lftpget + complete -F _lftpget lftpget # ex: filetype=sh diff --git a/completions/lilo b/completions/lilo index 03e3ee29..af8539aa 100644 --- a/completions/lilo +++ b/completions/lilo @@ -2,8 +2,9 @@ _lilo_labels() { - COMPREPLY=( $(compgen -W "$(awk -F'=' '/label/ {print $2}' \ - /etc/lilo.conf | command sed -e 's/\"//g')" -- "$cur") ) + COMPREPLY=($(compgen -W "$(awk -F= '$1 ~ /^[ \t]*label$/ {print $2}' \ + ${1:-/etc/lilo.conf} 2>/dev/null | command sed -e 's/\"//g')" \ + -- "$cur")) } _lilo() @@ -12,7 +13,7 @@ _lilo() _init_completion || return case $prev in - -C|-i|-m|-s|-S) + -C | -i | -m | -s | -S) _filedir return ;; @@ -20,12 +21,19 @@ _lilo() _filedir -d return ;; - -I|-D|-R) + -I | -D | -R) # label completion - _lilo_labels + local i conf + for i in "${!words[@]}"; do + if [[ ${words[i]} == -C ]]; then + conf=${words[i + 1]} + break + fi + done + _lilo_labels $conf return ;; - -A|-b|-M|-u|-U) + -A | -b | -M | -u | -U) # device completion cur=${cur:=/dev/} _filedir @@ -33,18 +41,26 @@ _lilo() ;; -T) # topic completion - COMPREPLY=( $(compgen -W 'help ChRul EBDA geom geom= table= - video' -- "$cur") ) + COMPREPLY=($(compgen -W 'help ChRul EBDA geom geom= table= + video' -- "$cur")) + return + ;; + -B) + _filedir bmp + return + ;; + -E) + _filedir '@(bmp|dat)' return ;; esac - if [[ "$cur" == -* ]]; then + if [[ $cur == -* ]]; then # relevant options completion - COMPREPLY=( $(compgen -W '-A -b -c -C -d -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") ) + 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")) fi } && -complete -F _lilo lilo + complete -F _lilo lilo # ex: filetype=sh diff --git a/completions/links b/completions/links index 6bfee654..e0c28e21 100644 --- a/completions/links +++ b/completions/links @@ -6,20 +6,20 @@ _links() _init_completion -n : || return case $prev in - -html-t-text-color|-html-t-link-color) - COMPREPLY=( $(compgen -W '{0..15}' -- "$cur") ) + -html-t-text-color | -html-t-link-color) + COMPREPLY=($(compgen -W '{0..15}' -- "$cur")) return ;; - -http.fake-firefox|-html-[gt]-ignore-document-color) - COMPREPLY=( $(compgen -W '0 1' -- "$cur") ) + -http.fake-firefox | -html-[gt]-ignore-document-color) + COMPREPLY=($(compgen -W '0 1' -- "$cur")) return ;; - --help|-help|-mode|-display|-source|-dump|-width|-max-connections|\ - -max-connections-to-host|-retries|-receive-timeout|\ - -unrestartable-receive-timeout|-*-size|-*-proxy|\ - -append-text-to-dns-lookups|-ssl.client-cert-passwd|-http.fake-*|\ - -http.extra-header|-ftp.anonymous-passwd|-*-color|-*-gamma|\ - -bfu-aspect|-html-image-scale|-html-margin) + --help | -help | -mode | -display | -source | -dump | -width | -max-connections | \ + -max-connections-to-host | -retries | -receive-timeout | \ + -unrestartable-receive-timeout | -*-size | -*-proxy | \ + -append-text-to-dns-lookups | -ssl.client-cert-passwd | -http.fake-* | \ + -http.extra-header | -ftp.anonymous-passwd | -*-color | -*-gamma | \ + -bfu-aspect | -html-image-scale | -html-margin) return ;; -lookup) @@ -30,10 +30,10 @@ _links() 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") ) + COMPREPLY=($(compgen -W "$drivers" -- "$cur")) return ;; - -codepage|-bookmarks-codepage|-http-assume-codepage) + -codepage | -bookmarks-codepage | -http-assume-codepage) _xfunc iconv _iconv_charsets return ;; @@ -50,19 +50,19 @@ _links() __ltrim_colon_completions "$cur" 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") ) + -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")) return ;; - -address-preference|-http.referer) - COMPREPLY=( $(compgen -W '{0..4}' -- "$cur") ) + -address-preference | -http.referer) + COMPREPLY=($(compgen -W '{0..4}' -- "$cur")) return ;; - -ssl-certificates|-display-optimize|-gamma-correction) - COMPREPLY=( $(compgen -W '{0..2}' -- "$cur") ) + -ssl-certificates | -display-optimize | -gamma-correction) + COMPREPLY=($(compgen -W '{0..2}' -- "$cur")) return ;; -ssl.client-cert-key) @@ -80,21 +80,21 @@ _links() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1" | - command grep -vF -- "->")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1" | + command grep -vF -- "->")' -- "$cur")) return fi local dir for dir in .links .links2; do if [[ -r ~/$dir/links.his ]]; then - COMPREPLY+=( $(compgen -W '$(cat ~/$dir/links.his)' -- "$cur") ) + COMPREPLY+=($(compgen -W '$(cat ~/$dir/links.his)' -- "$cur")) __ltrim_colon_completions "$cur" fi done _filedir '@(htm|html)' } && -complete -F _links links links2 + complete -F _links links links2 # ex: filetype=sh diff --git a/completions/lintian b/completions/lintian index d62d8373..93438325 100644 --- a/completions/lintian +++ b/completions/lintian @@ -5,18 +5,18 @@ _lintian_tags() local match search tags tags=$(awk '/^Tag/ { print $2 }' /usr/share/lintian/checks/*.desc) - if [[ "$cur" == *, ]]; then + 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) done - COMPREPLY+=( $(compgen -W "$tags") ) - elif [[ "$cur" == *,* ]]; then - COMPREPLY+=( $(compgen -P "${cur%,*}," -W "$tags" -- "${cur##*,}") ) + COMPREPLY+=($(compgen -W "$tags")) + elif [[ $cur == *,* ]]; then + COMPREPLY+=($(compgen -P "${cur%,*}," -W "$tags" -- "${cur##*,}")) else - COMPREPLY+=( $(compgen -W "$tags" -- "$cur") ) + COMPREPLY+=($(compgen -W "$tags" -- "$cur")) fi } @@ -26,7 +26,7 @@ _lintian_checks() checks=$(awk '/^(Check-Script|Abbrev)/ { print $2 }' \ /usr/share/lintian/checks/*.desc) - if [[ "$cur" == *, ]]; then + if [[ $cur == *, ]]; then search=${cur//,/ } for item in $search; do match=$(command grep -nE "^(Check-Script|Abbrev): $item$" \ @@ -36,11 +36,11 @@ _lintian_checks() checks=$(command sed -e "s/\<$name\>//g" <<<$checks) done done - COMPREPLY+=( $(compgen -W "$checks") ) - elif [[ "$cur" == *,* ]]; then - COMPREPLY+=( $(compgen -P "${cur%,*}," -W "$checks" -- "${cur##*,}") ) + COMPREPLY+=($(compgen -W "$checks")) + elif [[ $cur == *,* ]]; then + COMPREPLY+=($(compgen -P "${cur%,*}," -W "$checks" -- "${cur##*,}")) else - COMPREPLY+=( $(compgen -W "$checks" -- "$cur") ) + COMPREPLY+=($(compgen -W "$checks" -- "$cur")) fi } @@ -50,18 +50,18 @@ _lintian_infos() infos=$(awk '/^Collector/ { print $2 }' \ /usr/share/lintian/collection/*.desc) - if [[ "$cur" == *, ]]; then + 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) done - COMPREPLY+=( $(compgen -W "$infos") ) - elif [[ "$cur" == *,* ]]; then - COMPREPLY+=( $(compgen -P "${cur%,*}," -W "$infos" -- "${cur##*,}") ) + COMPREPLY+=($(compgen -W "$infos")) + elif [[ $cur == *,* ]]; then + COMPREPLY+=($(compgen -P "${cur%,*}," -W "$infos" -- "${cur##*,}")) else - COMPREPLY+=( $(compgen -W "$infos" -- "$cur") ) + COMPREPLY+=($(compgen -W "$infos" -- "$cur")) fi } @@ -70,8 +70,7 @@ _lintian() local cur prev words cword _init_completion || return - local action lint_actions general_opts behaviour_opts \ - configuration_opts selection_opts + local lint_actions general_opts behaviour_opts configuration_opts lint_actions="--setup-lab --remove-lab --check --check-part --tags --tags-from-file --ftp-master-rejects --dont-check-part --unpack @@ -83,34 +82,33 @@ _lintian() --allow-root --fail-on-warnings --keep-lab" configuration_opts="--cfg --lab --archivedir --dist --area --section --arch --root" - selection_opts="--all --binary --source --udeb --packages-file" - if [[ "$prev" == -* ]]; then + if [[ $prev == -* ]]; then case $prev in - -C|--check-part|-X|--dont-check-part) + -C | --check-part | -X | --dont-check-part) _lintian_checks ;; - -T|--tags|--suppress-tags) + -T | --tags | --suppress-tags) _lintian_tags ;; - --tags-from-file|--suppress-tags-from-file|--cfg|-p|\ - --packages-file) + --tags-from-file | --suppress-tags-from-file | --cfg | -p | \ + --packages-file) _filedir ;; - --lab|--archivedir|--dist|--root) + --lab | --archivedir | --dist | --root) _filedir -d ;; --color) COMPREPLY=($(compgen -W "never always auto html" -- "$cur")) ;; - -U|--unpack-info) + -U | --unpack-info) _lintian_infos ;; - --area|--section) + --area | --section) COMPREPLY=($(compgen -W "main contrib non-free" -- "$cur")) ;; - --arch) - ;; + --arch) ;; + esac fi @@ -124,24 +122,25 @@ _lintian() # --action tag,tag, # Only few actions permit that, re-complete them now. case "$prev" in - -C|--check-part|-X|--dont-check-part) + -C | --check-part | -X | --dont-check-part) _lintian_checks ;; - -T|--tags|--suppress-tags) + -T | --tags | --suppress-tags) _lintian_tags ;; - -U|--unpack-info) + -U | --unpack-info) _lintian_infos ;; esac ;; *) - _filedir '@(?(u)deb|changes|dsc)' + # in Ubuntu, dbgsym packages end in .ddeb, lintian >= 2.57.0 groks + _filedir '@(?(u|d)deb|changes|dsc|buildinfo)' ;; esac return 0 } && -complete -F _lintian lintian + complete -F _lintian lintian _lintian_info() { @@ -149,10 +148,10 @@ _lintian_info() _init_completion || return case "$prev" in - --help|--profile) + --help | --profile) return ;; - -t|--tags) + -t | --tags) _lintian_tags return ;; @@ -164,7 +163,7 @@ _lintian_info() case "$cur" in --*) - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) ;; *) _filedir @@ -172,6 +171,6 @@ _lintian_info() esac return 0 } && -complete -F _lintian_info lintian-info + complete -F _lintian_info lintian-info # ex: filetype=sh diff --git a/completions/lisp b/completions/lisp index f9f68275..098567bc 100644 --- a/completions/lisp +++ b/completions/lisp @@ -8,15 +8,15 @@ _lisp() _init_completion || 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 + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-core -lib -batch -quit -edit -eval -init -dynamic-space-size -hinit -noinit -nositeinit -load -slave' \ - -- "$cur") ) + -- "$cur")) else _filedir fi } && -complete -F _lisp -o default lisp + complete -F _lisp -o default lisp # ex: filetype=sh diff --git a/completions/list_admins b/completions/list_admins index 11f7414d..57081797 100644 --- a/completions/list_admins +++ b/completions/list_admins @@ -5,13 +5,13 @@ _list_admins() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--all-vhost --all --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--all-vhost --all --help' -- "$cur")) else _xfunc list_lists _mailman_lists fi } && -complete -F _list_admins list_admins + complete -F _list_admins list_admins # ex: filetype=sh diff --git a/completions/list_lists b/completions/list_lists index c0807178..c5b9ba71 100644 --- a/completions/list_lists +++ b/completions/list_lists @@ -2,7 +2,7 @@ _mailman_lists() { - COMPREPLY=( $(compgen -W '$(list_lists -b 2>/dev/null)' -- "$cur") ) + COMPREPLY=($(compgen -W '$(list_lists -b 2>/dev/null)' -- "$cur")) } _list_lists() @@ -10,12 +10,12 @@ _list_lists() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--advertised --virtual-host-overview --bare - --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--advertised --virtual-host-overview --bare + --help' -- "$cur")) fi } && -complete -F _list_lists list_lists + complete -F _list_lists list_lists # ex: filetype=sh diff --git a/completions/list_members b/completions/list_members index 90db5cba..639344c7 100644 --- a/completions/list_members +++ b/completions/list_members @@ -6,31 +6,31 @@ _list_members() _init_completion -s || return case $prev in - -o|--output) + -o | --output) _filedir return ;; - -d|--digest) - COMPREPLY=( $(compgen -W 'mime plain' -- "$cur") ) + -d | --digest) + COMPREPLY=($(compgen -W 'mime plain' -- "$cur")) return ;; - -n|--nomail) - COMPREPLY=( $(compgen -W 'byadmin byuser bybounce unknown' \ - -- "$cur") ) + -n | --nomail) + COMPREPLY=($(compgen -W 'byadmin byuser bybounce unknown' \ + -- "$cur")) return ;; esac $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--output --regular --digest --nomail - --fullnames --preserve --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--output --regular --digest --nomail + --fullnames --preserve --help' -- "$cur")) else _xfunc list_lists _mailman_lists fi } && -complete -F _list_members list_members + complete -F _list_members list_members # ex: filetype=sh diff --git a/completions/list_owners b/completions/list_owners index 18b52476..445be0bd 100644 --- a/completions/list_owners +++ b/completions/list_owners @@ -5,14 +5,14 @@ _list_owners() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--with-listnames --moderators --help' \ - -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--with-listnames --moderators --help' \ + -- "$cur")) else _xfunc list_lists _mailman_lists fi } && -complete -F _list_owners list_owners + complete -F _list_owners list_owners # ex: filetype=sh diff --git a/completions/locale-gen b/completions/locale-gen index 3dae76ff..40682013 100644 --- a/completions/locale-gen +++ b/completions/locale-gen @@ -6,7 +6,7 @@ _locale_gen() _init_completion -s || return case $prev in - --help|-h) + --help | -h) return ;; --aliases) @@ -18,15 +18,15 @@ _locale_gen() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi - COMPREPLY=( $(compgen -W \ + COMPREPLY=($(compgen -W \ '$(awk "{ print \$1 }" /usr/share/i18n/SUPPORTED 2>/dev/null)' \ - -- "$cur") ) + -- "$cur")) } && -complete -F _locale_gen locale-gen + complete -F _locale_gen locale-gen # ex: filetype=sh diff --git a/completions/lpq b/completions/lpq index a1223268..36729d22 100644 --- a/completions/lpq +++ b/completions/lpq @@ -7,22 +7,22 @@ _lpq() case $prev in -P) - COMPREPLY=( $(compgen -W "$(lpstat -a 2>/dev/null | cut -d' ' -f1)" -- "$cur") ) + COMPREPLY=($(compgen -W "$(lpstat -a 2>/dev/null | cut -d' ' -f1)" -- "$cur")) return ;; -U) - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) return ;; esac - if [[ "$cur" == - ]]; then - COMPREPLY=( $(compgen -W '-E -P -U -a -h -l' -- "$cur") ) + if [[ $cur == - ]]; then + COMPREPLY=($(compgen -W '-E -P -U -a -h -l' -- "$cur")) return fi _filedir } && -complete -F _lpq lpq + complete -F _lpq lpq # ex: filetype=sh diff --git a/completions/lpr b/completions/lpr index 9a9e8639..554f0534 100644 --- a/completions/lpr +++ b/completions/lpr @@ -7,27 +7,27 @@ _lpr() case $prev in -P) - COMPREPLY=( $(compgen -W "$(lpstat -a 2>/dev/null | cut -d' ' -f1)" -- "$cur") ) + COMPREPLY=($(compgen -W "$(lpstat -a 2>/dev/null | cut -d' ' -f1)" -- "$cur")) return ;; -U) - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) 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") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W "media= landscape orientation-requested= sides= fitplot number-up= scaling= cpi= lpi= page-bottom= page-top= page-left= page-right=" -- "$cur")) + [[ ${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") ) + if [[ $cur == - ]]; then + COMPREPLY=($(compgen -W '-E -H -C -J -T -P -U -h -l -m -o -p -q -r' -- "$cur")) return fi _filedir } && -complete -F _lpr lpr + complete -F _lpr lpr # ex: filetype=sh diff --git a/completions/lrzip b/completions/lrzip index 5eb2445b..eb2904c6 100644 --- a/completions/lrzip +++ b/completions/lrzip @@ -23,21 +23,21 @@ _lrzip() return ;; -*L) - COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") ) + COMPREPLY=($(compgen -W '{1..9}' -- "$cur")) return ;; -*N) - COMPREPLY=( $(compgen -W '{-20..19}' -- "$cur") ) + COMPREPLY=($(compgen -W '{-20..19}' -- "$cur")) return ;; -*p) - COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) + COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi @@ -45,8 +45,8 @@ _lrzip() local IFS=$'\n' compopt -o filenames - COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) + COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur")) } && -complete -F _lrzip lrzip + complete -F _lrzip lrzip # ex: filetype=sh diff --git a/completions/lsof b/completions/lsof index e904f406..eb1e967d 100644 --- a/completions/lsof +++ b/completions/lsof @@ -6,23 +6,23 @@ _lsof() _init_completion || return case $prev in - -'?'|-h|+c|-c|-d|-F|-i|+r|-r|-s|-S|-T) + -'?' | -h | +c | -c | -d | -F | -i | +r | -r | -s | -S | -T) return ;; - -A|-k|-m|+m|-o) + -A | -k | -m | +m | -o) _filedir return ;; - +d|+D) + +d | +D) _filedir -d return ;; -D) - COMPREPLY=( $(compgen -W '? b i r u' -- "$cur") ) + COMPREPLY=($(compgen -W '? b i r u' -- "$cur")) return ;; -f) - COMPREPLY=( $(compgen -W 'c f g G n' -- "$cur") ) + COMPREPLY=($(compgen -W 'c f g G n' -- "$cur")) return ;; -g) @@ -37,20 +37,20 @@ _lsof() ;; -u) # TODO: handle ^foo exclusions, comma separated lists - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) return ;; esac - if [[ "$cur" == [-+]* ]]; then - COMPREPLY=( $(compgen -W '-h -a -A -b -c +c -C +d -d +D -D +f -f -F -g + 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") ) + -u -U -v -V +w -w -x -X -z -Z' -- "$cur")) return fi _filedir } && -complete -F _lsof lsof + complete -F _lsof lsof # ex: filetype=sh diff --git a/completions/lspci b/completions/lspci index e31a5b57..d50783c9 100644 --- a/completions/lspci +++ b/completions/lspci @@ -18,12 +18,12 @@ _lspci() return ;; -*A) - COMPREPLY+=( $(compgen -W '$($1 -A help | command grep -vF :)' \ - -- "$cur") ) + COMPREPLY+=($(compgen -W '$($1 -A help | command grep -vF :)' \ + -- "$cur")) return ;; -*H) - COMPREPLY+=( $(compgen -W "1 2" -- "$cur") ) + COMPREPLY+=($(compgen -W "1 2" -- "$cur")) return ;; -*F) @@ -33,9 +33,9 @@ _lspci() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) fi } && -complete -F _lspci lspci + complete -F _lspci lspci # ex: filetype=sh diff --git a/completions/lsscsi b/completions/lsscsi index b401c8ab..bcbc430a 100644 --- a/completions/lsscsi +++ b/completions/lsscsi @@ -6,10 +6,10 @@ _lsscsi() _init_completion -s || return case $prev in - --help|--version|-!(-*)[hV]*) + --help | --version | -!(-*)[hV]*) return ;; - --sysfsroot|-!(-*)y) + --sysfsroot | -!(-*)y) _filedir -d return ;; @@ -18,10 +18,10 @@ _lsscsi() $split && return if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace fi } && -complete -F _lsscsi lsscsi + complete -F _lsscsi lsscsi # ex: filetype=sh diff --git a/completions/lsusb b/completions/lsusb index c315abd1..63cff54c 100644 --- a/completions/lsusb +++ b/completions/lsusb @@ -6,15 +6,15 @@ _lsusb() _init_completion || return case $prev in - --help|--version|-!(-*)@([sD]|[hV]*)) + --help | --version | -!(-*)@([sD]|[hV]*)) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) fi } && -complete -F _lsusb lsusb + complete -F _lsusb lsusb # ex: filetype=sh diff --git a/completions/lua b/completions/lua index 775eae20..3c4df901 100644 --- a/completions/lua +++ b/completions/lua @@ -6,18 +6,18 @@ _lua() _init_completion || return case $prev in - -e|-l|-v|-) + -e | -l | -v | -) return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W "$(_parse_help "$1")" -- "$cur") ) + COMPREPLY=($(compgen -W "$(_parse_help "$1")" -- "$cur")) return fi _filedir 'l@(ua|?(ua)c)' } && -complete -F _lua lua + complete -F _lua lua # ex: filetype=sh diff --git a/completions/luac b/completions/luac index 15b562ae..c763deb2 100644 --- a/completions/luac +++ b/completions/luac @@ -6,7 +6,7 @@ _luac() _init_completion || return case $prev in - -v|-) + -v | -) return ;; -o) @@ -16,12 +16,12 @@ _luac() esac if [[ $cur == -* ]]; then - COMPREPLY=( $(compgen -W "$(_parse_help "$1")" -- "$cur") ) + COMPREPLY=($(compgen -W "$(_parse_help "$1")" -- "$cur")) return fi _filedir lua } && -complete -F _luac luac + complete -F _luac luac # ex: filetype=sh diff --git a/completions/luseradd b/completions/luseradd index 2fa336db..4d66385b 100644 --- a/completions/luseradd +++ b/completions/luseradd @@ -6,20 +6,20 @@ _luseradd() _init_completion -s || return case $prev in - --help|--usage|--gecos|--uid|--login|--plainpassword|--password|\ - --commonname|--givenname|--surname|--roomnumber|--telephonenumber|\ - --homephone|-!(-*)@([culPp]|[?]*)) + --help | --usage | --gecos | --uid | --login | --plainpassword | --password | \ + --commonname | --givenname | --surname | --roomnumber | --telephonenumber | \ + --homephone | -!(-*)@([culPp]|[?]*)) return ;; - --directory|--skeleton|-!(-*)[dk]) + --directory | --skeleton | -!(-*)[dk]) _filedir -d return ;; - --shell|-!(-*)s) + --shell | -!(-*)s) _shells return ;; - --gid|-!(-*)g) + --gid | -!(-*)g) _gids return ;; @@ -27,14 +27,14 @@ _luseradd() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi - [[ ${1##*/} == luseradd ]] || COMPREPLY=( $(compgen -u -- "$cur") ) + [[ ${1##*/} == luseradd ]] || COMPREPLY=($(compgen -u -- "$cur")) } && -complete -F _luseradd luseradd lusermod + complete -F _luseradd luseradd lusermod # ex: filetype=sh diff --git a/completions/luserdel b/completions/luserdel index ee2b4fdb..e36bda9f 100644 --- a/completions/luserdel +++ b/completions/luserdel @@ -6,18 +6,18 @@ _luserdel() _init_completion || return case $prev in - --help|--usage|-!(-*)[?]*) + --help | --usage | -!(-*)[?]*) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) return fi - COMPREPLY=( $(compgen -u -- "$cur") ) + COMPREPLY=($(compgen -u -- "$cur")) } && -complete -F _luserdel luserdel + complete -F _luserdel luserdel # ex: filetype=sh diff --git a/completions/lvm b/completions/lvm index 712838c8..e70ecc3a 100644 --- a/completions/lvm +++ b/completions/lvm @@ -8,26 +8,26 @@ _lvm_filedir() _lvm_volumegroups() { - COMPREPLY=( $(compgen -W "$(vgscan 2>/dev/null | \ - command sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- "$cur") ) + COMPREPLY=($(compgen -W "$(vgscan 2>/dev/null | + command sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p')" -- "$cur")) } _lvm_physicalvolumes_all() { - COMPREPLY=( $(compgen -W "$(pvscan 2>/dev/null | \ - command sed -n -e 's|^.*PV \([^ ]*\) .*|\1|p' )" -- "$cur") ) + COMPREPLY=($(compgen -W "$(pvscan 2>/dev/null | + command sed -n -e 's|^.*PV \([^ ]*\) .*|\1|p')" -- "$cur")) } _lvm_physicalvolumes() { - COMPREPLY=( $(compgen -W "$(pvscan 2>/dev/null | \ - command sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p' )" -- "$cur") ) + COMPREPLY=($(compgen -W "$(pvscan 2>/dev/null | + command sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p')" -- "$cur")) } _lvm_logicalvolumes() { - COMPREPLY=( $(compgen -W "$(lvscan 2>/dev/null | \ - command sed -n -e "s|^.*'\(.*\)'.*$|\1|p" )" -- "$cur") ) + COMPREPLY=($(compgen -W "$(lvscan 2>/dev/null | + command sed -n -e "s|^.*'\(.*\)'.*$|\1|p")" -- "$cur")) if [[ $cur == /dev/mapper/* ]]; then _filedir local i @@ -39,12 +39,12 @@ _lvm_logicalvolumes() _lvm_units() { - COMPREPLY=( $(compgen -W 'h s b k m g t H K M G T' -- "$cur") ) + COMPREPLY=($(compgen -W 'h s b k m g t H K M G T' -- "$cur")) } _lvm_sizes() { - COMPREPLY=( $(compgen -W 'k K m M g G t T' -- "$cur") ) + COMPREPLY=($(compgen -W 'k K m M g G t T' -- "$cur")) } # @param $1 glob matching args known to take an argument @@ -52,13 +52,14 @@ _lvm_count_args() { args=0 local offset=1 - if [[ "${words[0]}" == lvm ]]; then + if [[ ${words[0]} == lvm ]]; then offset=2 fi - local i prev=${words[$offset-1]} - for (( i=$offset; i < cword; i++ )); do - if [[ "${words[i]}" != -* && $prev != $1 ]]; then - (( args++ )) + local i prev=${words[offset - 1]} + for ((i = offset; i < cword; i++)); do + # shellcheck disable=SC2053 + if [[ ${words[i]} != -* && $prev != $1 ]]; then + ((args++)) fi prev=${words[i]} done @@ -69,22 +70,22 @@ _lvmdiskscan() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) fi } && -complete -F _lvmdiskscan lvmdiskscan + complete -F _lvmdiskscan lvmdiskscan _pvscan() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) fi } && -complete -F _pvscan pvscan + complete -F _pvscan pvscan _pvs() { @@ -92,9 +93,9 @@ _pvs() _init_completion || return 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 | -!(-*)[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")) return ;; --units) @@ -103,13 +104,13 @@ _pvs() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_physicalvolumes_all fi } && -complete -F _pvs pvs + complete -F _pvs pvs _pvdisplay() { @@ -123,13 +124,13 @@ _pvdisplay() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_physicalvolumes_all fi } && -complete -F _pvdisplay pvdisplay + complete -F _pvdisplay pvdisplay _pvchange() { @@ -137,19 +138,19 @@ _pvchange() _init_completion || return case $prev in - --autobackup|--allocatable|-!(-*)[Ax]) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | --allocatable | -!(-*)[Ax]) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_physicalvolumes_all fi } && -complete -F _pvchange pvchange + complete -F _pvchange pvchange _pvcreate() { @@ -161,27 +162,27 @@ _pvcreate() _filedir return ;; - --metadatatype|-!(-*)M) - COMPREPLY=( $(compgen -W '1 2' -- "$cur") ) + --metadatatype | -!(-*)M) + COMPREPLY=($(compgen -W '1 2' -- "$cur")) return ;; --metadatacopies) - COMPREPLY=( $(compgen -W '0 1 2' -- "$cur") ) + COMPREPLY=($(compgen -W '0 1 2' -- "$cur")) return ;; - --metadatasize|--setphysicalvolumesize) + --metadatasize | --setphysicalvolumesize) _lvm_sizes return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_filedir fi } && -complete -F _pvcreate pvcreate + complete -F _pvcreate pvcreate _pvmove() { @@ -189,46 +190,47 @@ _pvmove() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - --name|-!(-*)n) + --name | -!(-*)n) _lvm_logicalvolumes return + ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_physicalvolumes fi } && -complete -F _pvmove pvmove + complete -F _pvmove pvmove _pvremove() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_physicalvolumes_all fi } && -complete -F _pvremove pvremove + complete -F _pvremove pvremove _vgscan() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) fi } && -complete -F _vgscan vgscan + complete -F _vgscan vgscan _vgs() { @@ -236,11 +238,11 @@ _vgs() _init_completion || return case $prev in - --options|--sort|-!(-*)[oO]) - COMPREPLY=( $(compgen -W 'vg_fmt vg_uuid vg_name vg_attr vg_size + --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") ) + -- "$cur")) return ;; --units) @@ -249,13 +251,13 @@ _vgs() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgs vgs + complete -F _vgs vgs _vgdisplay() { @@ -269,13 +271,13 @@ _vgdisplay() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgdisplay vgdisplay + complete -F _vgdisplay vgdisplay _vgchange() { @@ -283,19 +285,19 @@ _vgchange() _init_completion || return case $prev in - --available|--autobackup|--resizeable|-!(-*)[aAx]) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --available | --autobackup | --resizeable | -!(-*)[aAx]) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgchange vgchange + complete -F _vgchange vgchange _vgcreate() { @@ -303,46 +305,46 @@ _vgcreate() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - --metadatatype|-!(-*)M) - COMPREPLY=( $(compgen -W '1 2' -- "$cur") ) + --metadatatype | -!(-*)M) + COMPREPLY=($(compgen -W '1 2' -- "$cur")) return ;; - --physicalextentsize|-!(-*)s) + --physicalextentsize | -!(-*)s) _lvm_sizes return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else local args _lvm_count_args '@(-A|--autobackup|-M|--metadatatype|-s|--physicalextentsize)' - if [[ $args -eq 0 ]]; then + if ((args == 0)); then _lvm_volumegroups else _lvm_physicalvolumes_all fi fi } && -complete -F _vgcreate vgcreate + complete -F _vgcreate vgcreate _vgremove() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgremove vgremove + complete -F _vgremove vgremove _vgrename() { @@ -350,19 +352,19 @@ _vgrename() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgrename vgrename + complete -F _vgrename vgrename _vgreduce() { @@ -370,26 +372,26 @@ _vgreduce() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else local args _lvm_count_args '@(-A|--autobackup)' - if [[ $args -eq 0 ]]; then + if ((args == 0)); then _lvm_volumegroups else _lvm_physicalvolumes fi fi } && -complete -F _vgreduce vgreduce + complete -F _vgreduce vgreduce _vgextend() { @@ -397,55 +399,55 @@ _vgextend() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - --size|-!(-*)L) + --size | -!(-*)L) _lvm_sizes return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else local args _lvm_count_args '@(-A|--autobackup|-L|--size)' - if [[ $args -eq 0 ]]; then + if ((args == 0)); then _lvm_volumegroups else _lvm_physicalvolumes_all fi fi } && -complete -F _vgextend vgextend + complete -F _vgextend vgextend _vgport() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgport vgimport vgexport + complete -F _vgport vgimport vgexport _vgck() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgck vgck + complete -F _vgck vgck _vgconvert() { @@ -453,12 +455,12 @@ _vgconvert() _init_completion || return case $prev in - --metadatatype|-!(-*)M) - COMPREPLY=( $(compgen -W '1 2' -- "$cur") ) + --metadatatype | -!(-*)M) + COMPREPLY=($(compgen -W '1 2' -- "$cur")) return ;; --metadatacopies) - COMPREPLY=( $(compgen -W '0 1 2' -- "$cur") ) + COMPREPLY=($(compgen -W '0 1 2' -- "$cur")) return ;; --metadatasize) @@ -467,13 +469,13 @@ _vgconvert() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgconvert vgconvert + complete -F _vgconvert vgconvert _vgcfgbackup() { @@ -481,19 +483,19 @@ _vgcfgbackup() _init_completion || return case $prev in - --file|-!(-*)f) + --file | -!(-*)f) _filedir return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgcfgbackup vgcfgbackup + complete -F _vgcfgbackup vgcfgbackup _vgcfgrestore() { @@ -501,27 +503,27 @@ _vgcfgrestore() _init_completion || return case $prev in - --file|-!(-*)f) + --file | -!(-*)f) _filedir return ;; - --metadatatype|-!(-*)M) - COMPREPLY=( $(compgen -W '1 2' -- "$cur") ) + --metadatatype | -!(-*)M) + COMPREPLY=($(compgen -W '1 2' -- "$cur")) return ;; - --name|-!(-*)n) + --name | -!(-*)n) _lvm_volumegroups return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgcfgrestore vgcfgrestore + complete -F _vgcfgrestore vgcfgrestore _vgmerge() { @@ -529,19 +531,19 @@ _vgmerge() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgmerge vgmerge + complete -F _vgmerge vgmerge _vgsplit() { @@ -549,53 +551,53 @@ _vgsplit() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - --metadatatype|-!(-*)M) - COMPREPLY=( $(compgen -W '1 2' -- "$cur") ) + --metadatatype | -!(-*)M) + COMPREPLY=($(compgen -W '1 2' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else local args _lvm_count_args '@(-A|--autobackup|-M|--metadatatype)' - if [[ $args -eq 0 || $args -eq 1 ]]; then + if ((args == 0 || args == 1)); then _lvm_volumegroups else _lvm_physicalvolumes fi fi } && -complete -F _vgsplit vgsplit + complete -F _vgsplit vgsplit _vgmknodes() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_volumegroups fi } && -complete -F _vgmknodes vgmknodes + complete -F _vgmknodes vgmknodes _lvscan() { local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) fi } && -complete -F _lvscan lvscan + complete -F _lvscan lvscan _lvs() { @@ -603,10 +605,10 @@ _lvs() _init_completion || return case $prev in - --options|--sort|-!(-*)[oO]) - COMPREPLY=( $(compgen -W 'lv_uuid lv_name lv_attr lv_minor lv_size + --options | --sort | -!(-*)[oO]) + COMPREPLY=($(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' -- "$cur")) return ;; --units) @@ -615,13 +617,13 @@ _lvs() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_logicalvolumes fi } && -complete -F _lvs lvs + complete -F _lvs lvs _lvdisplay() { @@ -635,13 +637,13 @@ _lvdisplay() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_logicalvolumes fi } && -complete -F _lvdisplay lvdisplay + complete -F _lvdisplay lvdisplay _lvchange() { @@ -649,23 +651,23 @@ _lvchange() _init_completion || return case $prev in - --available|--autobackup|--contiguous|--persistent|-!(-*)[aACM]) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --available | --autobackup | --contiguous | --persistent | -!(-*)[aACM]) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - --permission|-!(-*)p) - COMPREPLY=( $(compgen -W 'r rw' -- "$cur") ) + --permission | -!(-*)p) + COMPREPLY=($(compgen -W 'r rw' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_logicalvolumes fi } && -complete -F _lvchange lvchange + complete -F _lvchange lvchange _lvcreate() { @@ -673,37 +675,37 @@ _lvcreate() _init_completion || return case $prev in - --autobackup|--contiguous|--persistent|--zero|-!(-*)[ACMZ]) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | --contiguous | --persistent | --zero | -!(-*)[ACMZ]) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - --size|-!(-*)L) + --size | -!(-*)L) _lvm_sizes return ;; - --permission|-!(-*)p) - COMPREPLY=( $(compgen -W 'r rw' -- "$cur") ) + --permission | -!(-*)p) + COMPREPLY=($(compgen -W 'r rw' -- "$cur")) return ;; - --name|-!(-*)n) + --name | -!(-*)n) _lvm_logicalvolumes return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else local args _lvm_count_args '@(-A|-C|-M|-Z|--autobackup|--contiguous|--persistent|--zero|-L|--size|-p|--permission|-n|--name)' - if [[ $args -eq 0 ]]; then + if ((args == 0)); then _lvm_volumegroups else _lvm_physicalvolumes fi fi } && -complete -F _lvcreate lvcreate + complete -F _lvcreate lvcreate _lvremove() { @@ -711,19 +713,19 @@ _lvremove() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_logicalvolumes fi } && -complete -F _lvremove lvremove + complete -F _lvremove lvremove _lvrename() { @@ -731,19 +733,19 @@ _lvrename() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_logicalvolumes fi } && -complete -F _lvrename lvrename + complete -F _lvrename lvrename _lvreduce() { @@ -751,23 +753,23 @@ _lvreduce() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - --size|-!(-*)L) + --size | -!(-*)L) _lvm_sizes return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else _lvm_logicalvolumes fi } && -complete -F _lvreduce lvreduce + complete -F _lvreduce lvreduce _lvresize() { @@ -775,29 +777,29 @@ _lvresize() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - --size|-!(-*)L) + --size | -!(-*)L) _lvm_sizes return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else local args _lvm_count_args '@(-A|--autobackup|-L|--size)' - if [[ $args -eq 0 ]]; then + if ((args == 0)); then _lvm_logicalvolumes else _lvm_physicalvolumes fi fi } && -complete -F _lvresize lvresize + complete -F _lvresize lvresize _lvextend() { @@ -805,55 +807,55 @@ _lvextend() _init_completion || return case $prev in - --autobackup|-!(-*)A) - COMPREPLY=( $(compgen -W 'y n' -- "$cur") ) + --autobackup | -!(-*)A) + COMPREPLY=($(compgen -W 'y n' -- "$cur")) return ;; - --size|-!(-*)L) + --size | -!(-*)L) _lvm_sizes return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur")) else local args _lvm_count_args '@(-A|--autobackup|-L|--size)' - if [[ $args -eq 0 ]]; then + if ((args == 0)); then _lvm_logicalvolumes else _lvm_physicalvolumes fi fi } && -complete -F _lvextend lvextend + complete -F _lvextend lvextend _lvm() { local cur prev words cword _init_completion || return - if [[ $cword -eq 1 ]]; then - COMPREPLY=( $(compgen -W 'dumpconfig help lvchange lvcreate lvdisplay + if ((cword == 1)); then + COMPREPLY=($(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' -- "$cur")) else case "${words[1]}" in - pvchange|pvcreate|pvdisplay|pvmove|pvremove|pvresize|pvs|pvscan|\ - vgcfgbackup|vgcfgrestore|vgchange|vgck|vgconvert|vgcreate|\ - vgdisplay|vgexport|vgextend|vgimport|vgmerge|vgmknodes|vgreduce|\ - vgremove|vgrename|vgs|vgscan|vgsplit|lvchange|lvcreate|lvdisplay|\ - lvextend|lvreduce|lvremove|lvrename|lvresize|lvscan) + pvchange | pvcreate | pvdisplay | pvmove | pvremove | pvresize | pvs | pvscan | \ + vgcfgbackup | vgcfgrestore | vgchange | vgck | vgconvert | vgcreate | \ + vgdisplay | vgexport | vgextend | vgimport | vgmerge | vgmknodes | vgreduce | \ + vgremove | vgrename | vgs | vgscan | vgsplit | lvchange | lvcreate | lvdisplay | \ + lvextend | lvreduce | lvremove | lvrename | lvresize | lvscan) _${words[1]} ;; esac fi } && -complete -F _lvm lvm + complete -F _lvm lvm # ex: filetype=sh diff --git a/completions/lz4 b/completions/lz4 index 76c24bfa..f297b5d8 100644 --- a/completions/lz4 +++ b/completions/lz4 @@ -12,22 +12,22 @@ _lz4() ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -X '-*#*' -W \ - '$(_parse_help "$1" -h) -B{4..7} -i{1..9}' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -X '-*#*' -W \ + '$(_parse_help "$1" -h) -B{4..7} -i{1..9}' -- "$cur")) return fi local args word xspec="*.?(t)lz4" _count_args - [[ $args -gt 2 ]] && return + ((args > 2)) && return for word in "${words[@]}"; do case $word in -*[dt]*) case $args in 1) xspec="!"$xspec ;; - 2) [[ $word == *t* ]] && return + 2) [[ $word == *t* ]] && return ;; esac break ;; @@ -45,8 +45,8 @@ _lz4() local IFS=$'\n' compopt -o filenames - COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) + COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur")) } && -complete -F _lz4 lz4 lz4c + complete -F _lz4 lz4 lz4c # ex: filetype=sh diff --git a/completions/lzip b/completions/lzip index 0f95722c..05f169c9 100644 --- a/completions/lzip +++ b/completions/lzip @@ -8,15 +8,15 @@ _lzip() local decompress=false case $prev in - --help|--version|--member-size|--match-length|--dictionary-size|\ - --volume-size|--data-size|-!(-*)@([bmsSB]|[hV]*)) + --help | --version | --member-size | --match-length | --dictionary-size | \ + --volume-size | --data-size | -!(-*)@([bmsSB]|[hV]*)) return ;; --decompress-!(-*)d) decompress=true ;; --threads-!(-*)n) - COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") ) + COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur")) return ;; --output-!(-*)o) @@ -27,9 +27,9 @@ _lzip() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") {-1..-9}' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") {-1..-9}' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi @@ -40,8 +40,8 @@ _lzip() local IFS=$'\n' compopt -o filenames - COMPREPLY=( $(compgen -f -X "*.lz" -- "$cur") $(compgen -d -- "$cur") ) + COMPREPLY=($(compgen -f -X "*.lz" -- "$cur") $(compgen -d -- "$cur")) } && -complete -F _lzip clzip lzip pdlzip plzip + complete -F _lzip clzip lzip pdlzip plzip # ex: filetype=sh diff --git a/completions/lzma b/completions/lzma index 81a626f5..34fba89f 100644 --- a/completions/lzma +++ b/completions/lzma @@ -8,27 +8,27 @@ _lzma() $split && return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_help "$1") -{1..9}' -- "$cur") ) - [[ $COMPREPLY == *= ]] && compopt -o nospace + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1") -{1..9}' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace return fi local IFS=$'\n' xspec="*.@(lzma|tlz)" - if [[ "$prev" == --* ]]; then - [[ "$prev" == --@(decompress|list|test) ]] && xspec="!"$xspec - [[ "$prev" == --compress ]] && xspec= - elif [[ "$prev" == -* ]]; then - [[ "$prev" == -*[dt]* ]] && xspec="!"$xspec - [[ "$prev" == -*z* ]] && xspec= + if [[ $prev == --* ]]; then + [[ $prev == --@(decompress|list|test) ]] && xspec="!"$xspec + [[ $prev == --compress ]] && xspec= + elif [[ $prev == -* ]]; then + [[ $prev == -*[dt]* ]] && xspec="!"$xspec + [[ $prev == -*z* ]] && xspec= fi _tilde "$cur" || return compopt -o filenames - COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) + COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur")) } && -complete -F _lzma lzma + complete -F _lzma lzma # ex: filetype=sh diff --git a/completions/lzop b/completions/lzop index bedc122e..2642742a 100644 --- a/completions/lzop +++ b/completions/lzop @@ -6,7 +6,7 @@ _lzop() _init_completion || return case $prev in - --output|-!(-*)o) + --output | -!(-*)o) _filedir return ;; @@ -14,32 +14,32 @@ _lzop() _filedir -d return ;; - --suffix|-!(-*)S) + --suffix | -!(-*)S) return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-1 -2 -3 -4 -5 -6 -7 -8 -9 -P + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '-1 -2 -3 -4 -5 -6 -7 -8 -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") ) + -- "$cur")) return fi local xspec="*.?(t)lzo" case $prev in - --decompress|--uncompress|--extract|--list|--ls|--info|--test) + --decompress | --uncompress | --extract | --list | --ls | --info | --test) xspec="!"$xspec ;; --force) xspec= ;; - --*) - ;; + --*) ;; + -*f*) xspec= ;; @@ -52,8 +52,8 @@ _lzop() local IFS=$'\n' compopt -o filenames - COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") ) + COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur")) } && -complete -F _lzop lzop + complete -F _lzop lzop # ex: filetype=sh diff --git a/completions/macof b/completions/macof index c92a3864..ad29f58f 100644 --- a/completions/macof +++ b/completions/macof @@ -12,12 +12,11 @@ _macof() ;; esac - - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) fi } && -complete -F _macof macof + complete -F _macof macof # ex: filetype=sh diff --git a/completions/mailmanctl b/completions/mailmanctl index dac1c5bf..3bbc2f24 100644 --- a/completions/mailmanctl +++ b/completions/mailmanctl @@ -5,14 +5,14 @@ _mailmanctl() local cur prev words cword _init_completion || return - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '--no-restart --run-as-user - --stale-lock-cleanup --quiet --help' -- "$cur") ) + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '--no-restart --run-as-user + --stale-lock-cleanup --quiet --help' -- "$cur")) else - COMPREPLY=( $(compgen -W 'start stop restart reopen' -- "$cur") ) + COMPREPLY=($(compgen -W 'start stop restart reopen' -- "$cur")) fi } && -complete -F _mailmanctl mailmanctl + complete -F _mailmanctl mailmanctl # ex: filetype=sh diff --git a/completions/make b/completions/make index f119dcc3..96517c21 100644 --- a/completions/make +++ b/completions/make @@ -8,7 +8,7 @@ _make_target_extract_script() local prefix="$1" local prefix_pat=$(command sed 's/[][\,.*^$(){}?+|/]/\\&/g' <<<"$prefix") local basename=${prefix##*/} - local dirname_len=$(( ${#prefix} - ${#basename} )) + local dirname_len=$((${#prefix} - ${#basename})) if [[ $mode == -d ]]; then # display mode, only output current path component to the next slash @@ -67,8 +67,8 @@ _make_target_extract_script() EOF # don't complete with hidden targets unless we are doing a partial completion - if [[ -z "${prefix_pat}" || "${prefix_pat}" = */ ]]; then - cat <