summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel F. T. Gomes <gabriel@inconstante.net.br>2020-08-03 18:43:13 -0300
committerGabriel F. T. Gomes <gabriel@inconstante.net.br>2020-08-03 18:43:13 -0300
commit95623d39d6029ba78ec96ad5ea08e9ac12629b91 (patch)
treeea0fe36eb5e6f40e0a1f765d44c4b0c0b2bfb089
parent019f3cc463db63abc6460f97deb488deec43840b (diff)
downloadbash-completion-upstream.tar.gz
New upstream version 2.11upstream/2.11upstream
-rw-r--r--.dir-locals.el2
-rw-r--r--.editorconfig5
-rw-r--r--.gitignore4
-rw-r--r--.markdownlint.yaml4
-rw-r--r--.perltidyrc1
-rw-r--r--.pre-commit-config.yaml97
-rw-r--r--.shellcheckrc14
-rw-r--r--.travis.yml36
-rw-r--r--CHANGES371
-rw-r--r--CONTRIBUTING.md23
-rw-r--r--README.md63
-rw-r--r--bash_completion1164
-rw-r--r--bash_completion.sh.in6
-rw-r--r--completions/.gitignore3
-rw-r--r--completions/2to320
-rw-r--r--completions/7z65
-rw-r--r--completions/Makefile.am16
-rw-r--r--completions/_adb30
-rw-r--r--completions/_cal10
-rw-r--r--completions/_chsh10
-rw-r--r--completions/_dmesg16
-rw-r--r--completions/_eject10
-rw-r--r--completions/_hexdump6
-rw-r--r--completions/_hwclock8
-rw-r--r--completions/_ionice16
-rw-r--r--completions/_look6
-rw-r--r--completions/_mock40
-rw-r--r--completions/_modules49
-rw-r--r--completions/_mount28
-rw-r--r--completions/_mount.linux264
-rw-r--r--completions/_newgrp6
-rw-r--r--completions/_nmcli96
-rw-r--r--completions/_renice10
-rw-r--r--completions/_repomanage10
-rw-r--r--completions/_reptyr4
-rw-r--r--completions/_rfkill14
-rw-r--r--completions/_rtcwake16
-rw-r--r--completions/_su20
-rw-r--r--completions/_svn59
-rw-r--r--completions/_svnadmin20
-rw-r--r--completions/_svnlook22
-rw-r--r--completions/_udevadm38
-rw-r--r--completions/_umount4
-rw-r--r--completions/_umount.linux52
-rw-r--r--completions/_xm58
-rw-r--r--completions/_yum77
-rw-r--r--completions/a2x14
-rw-r--r--completions/abook28
-rw-r--r--completions/aclocal18
-rw-r--r--completions/acpi8
-rw-r--r--completions/add_members14
-rw-r--r--completions/alias8
-rw-r--r--completions/ant30
-rw-r--r--completions/apache2ctl6
-rw-r--r--completions/appdata-validate12
-rw-r--r--completions/apt-build29
-rw-r--r--completions/apt-cache62
-rw-r--r--completions/apt-get60
-rw-r--r--completions/aptitude108
-rw-r--r--completions/arch66
-rw-r--r--completions/arp18
-rw-r--r--completions/arping6
-rw-r--r--completions/arpspoof6
-rw-r--r--completions/asciidoc26
-rw-r--r--completions/aspell50
-rw-r--r--completions/autoconf22
-rw-r--r--completions/automake18
-rw-r--r--completions/autoreconf22
-rw-r--r--completions/autorpm6
-rw-r--r--completions/autoscan12
-rw-r--r--completions/avctrl10
-rw-r--r--completions/badblocks6
-rw-r--r--completions/bind14
-rw-r--r--completions/bk6
-rw-r--r--completions/brctl19
-rw-r--r--completions/btdownloadheadless.py12
-rw-r--r--completions/bts69
-rw-r--r--completions/bzip226
-rw-r--r--completions/cancel8
-rw-r--r--completions/cardctl8
-rw-r--r--completions/carton31
-rw-r--r--completions/ccache18
-rw-r--r--completions/ccze27
-rw-r--r--completions/cfagent8
-rw-r--r--completions/cfrun26
-rw-r--r--completions/chage14
-rw-r--r--completions/change_pw10
-rw-r--r--completions/check_db6
-rw-r--r--completions/check_perms6
-rw-r--r--completions/checksec10
-rw-r--r--completions/chgrp16
-rw-r--r--completions/chkconfig18
-rw-r--r--completions/chmod11
-rw-r--r--completions/chown14
-rw-r--r--completions/chpasswd16
-rw-r--r--completions/chromium-browser18
-rw-r--r--completions/chronyc28
-rw-r--r--completions/chrpath8
-rw-r--r--completions/cksfv8
-rw-r--r--completions/cleanarch8
-rw-r--r--completions/clisp8
-rw-r--r--completions/clone_member10
-rw-r--r--completions/complete26
-rw-r--r--completions/config_list10
-rw-r--r--completions/configure22
-rw-r--r--completions/convert202
-rw-r--r--completions/cowsay10
-rw-r--r--completions/cpan2dist20
-rw-r--r--completions/cpio44
-rw-r--r--completions/cppcheck44
-rw-r--r--completions/crontab14
-rw-r--r--completions/cryptsetup43
-rw-r--r--completions/curl58
-rw-r--r--completions/cvs184
-rw-r--r--completions/cvsps26
-rw-r--r--completions/dd24
-rw-r--r--completions/deja-dup10
-rw-r--r--completions/desktop-file-validate4
-rw-r--r--completions/dhclient10
-rw-r--r--completions/dict28
-rw-r--r--completions/dmypy25
-rw-r--r--completions/dnssec-keygen16
-rw-r--r--completions/dnsspoof6
-rw-r--r--completions/dot24
-rw-r--r--completions/dpkg102
-rw-r--r--completions/dpkg-source34
-rw-r--r--completions/dselect12
-rw-r--r--completions/dsniff8
-rw-r--r--completions/dumpdb8
-rw-r--r--completions/dumpe2fs6
-rw-r--r--completions/e2freefrag8
-rw-r--r--completions/e2label4
-rw-r--r--completions/ebtables58
-rw-r--r--completions/ecryptfs-migrate-home8
-rw-r--r--completions/eog8
-rw-r--r--completions/ether-wake4
-rw-r--r--completions/evince12
-rw-r--r--completions/export16
-rw-r--r--completions/faillog14
-rw-r--r--completions/fbgs32
-rw-r--r--completions/fbi32
-rw-r--r--completions/feh81
-rw-r--r--completions/file14
-rw-r--r--completions/file-roller12
-rw-r--r--completions/filefrag6
-rw-r--r--completions/filesnarf6
-rw-r--r--completions/find63
-rw-r--r--completions/find_member10
-rw-r--r--completions/fio31
-rw-r--r--completions/firefox20
-rw-r--r--completions/flake818
-rw-r--r--completions/freebsd-update10
-rw-r--r--completions/freeciv24
-rw-r--r--completions/freeciv-server8
-rw-r--r--completions/function20
-rw-r--r--completions/fusermount10
-rw-r--r--completions/gcc60
-rw-r--r--completions/gcl8
-rw-r--r--completions/gdb33
-rw-r--r--completions/genaliases6
-rw-r--r--completions/gendiff4
-rw-r--r--completions/genisoimage14
-rw-r--r--completions/geoiplookup6
-rw-r--r--completions/getconf14
-rw-r--r--completions/getent48
-rw-r--r--completions/gkrellm16
-rw-r--r--completions/gm8
-rw-r--r--completions/gnatmake8
-rw-r--r--completions/gnokii134
-rw-r--r--completions/gnome-mplayer14
-rw-r--r--completions/gnome-screenshot14
-rw-r--r--completions/gpasswd12
-rw-r--r--completions/gpg26
-rw-r--r--completions/gpg228
-rw-r--r--completions/gpgv12
-rw-r--r--completions/gphoto225
-rw-r--r--completions/gprof22
-rw-r--r--completions/groupadd10
-rw-r--r--completions/groupdel12
-rw-r--r--completions/groupmems14
-rw-r--r--completions/groupmod12
-rw-r--r--completions/growisofs14
-rw-r--r--completions/grpck8
-rw-r--r--completions/gssdp-discover21
-rw-r--r--completions/gzip30
-rw-r--r--completions/hcitool178
-rw-r--r--completions/hddtemp16
-rw-r--r--completions/hid2hci8
-rw-r--r--completions/hostname10
-rw-r--r--completions/hping216
-rw-r--r--completions/htop18
-rw-r--r--completions/htpasswd25
-rw-r--r--completions/hunspell19
-rw-r--r--completions/iconv20
-rw-r--r--completions/id8
-rw-r--r--completions/idn14
-rw-r--r--completions/ifstat38
-rw-r--r--completions/iftop6
-rw-r--r--completions/ifup12
-rw-r--r--completions/influx17
-rw-r--r--completions/info26
-rw-r--r--completions/inject8
-rw-r--r--completions/inotifywait22
-rw-r--r--completions/insmod10
-rw-r--r--completions/installpkg10
-rw-r--r--completions/interdiff8
-rw-r--r--completions/invoke-rc.d32
-rw-r--r--completions/ip237
-rw-r--r--completions/ipcalc25
-rw-r--r--completions/iperf38
-rw-r--r--completions/ipmitool123
-rw-r--r--completions/ipsec54
-rw-r--r--completions/iptables58
-rw-r--r--completions/ipv6calc20
-rw-r--r--completions/iscsiadm24
-rw-r--r--completions/isort30
-rw-r--r--completions/isql6
-rw-r--r--completions/iwconfig64
-rw-r--r--completions/iwlist12
-rw-r--r--completions/iwpriv14
-rw-r--r--completions/iwspy10
-rw-r--r--completions/jar6
-rw-r--r--completions/jarsigner32
-rw-r--r--completions/java154
-rw-r--r--completions/javaws12
-rw-r--r--completions/jpegoptim18
-rw-r--r--completions/jps8
-rw-r--r--completions/jq32
-rw-r--r--completions/jshint14
-rw-r--r--completions/json_xs12
-rw-r--r--completions/jsonschema15
-rw-r--r--completions/k3b20
-rw-r--r--completions/kcov36
-rw-r--r--completions/kill6
-rw-r--r--completions/killall12
-rw-r--r--completions/kldload8
-rw-r--r--completions/kldunload6
-rw-r--r--completions/koji68
-rw-r--r--completions/ktutil50
-rw-r--r--completions/larch8
-rw-r--r--completions/lastlog12
-rw-r--r--completions/ldapsearch50
-rw-r--r--completions/ldapvi28
-rw-r--r--completions/lftp11
-rw-r--r--completions/lftpget6
-rw-r--r--completions/lilo40
-rw-r--r--completions/links50
-rw-r--r--completions/lintian73
-rw-r--r--completions/lisp8
-rw-r--r--completions/list_admins6
-rw-r--r--completions/list_lists10
-rw-r--r--completions/list_members20
-rw-r--r--completions/list_owners8
-rw-r--r--completions/locale-gen12
-rw-r--r--completions/lpq10
-rw-r--r--completions/lpr14
-rw-r--r--completions/lrzip14
-rw-r--r--completions/lsof20
-rw-r--r--completions/lspci10
-rw-r--r--completions/lsscsi10
-rw-r--r--completions/lsusb6
-rw-r--r--completions/lua6
-rw-r--r--completions/luac6
-rw-r--r--completions/luseradd22
-rw-r--r--completions/luserdel10
-rw-r--r--completions/lvm412
-rw-r--r--completions/lz414
-rw-r--r--completions/lzip16
-rw-r--r--completions/lzma22
-rw-r--r--completions/lzop20
-rw-r--r--completions/macof7
-rw-r--r--completions/mailmanctl10
-rw-r--r--completions/make48
-rw-r--r--completions/makepkg12
-rw-r--r--completions/man51
-rw-r--r--completions/mc12
-rw-r--r--completions/mcrypt44
-rw-r--r--completions/mdadm89
-rw-r--r--completions/mdtool27
-rw-r--r--completions/medusa10
-rw-r--r--completions/mii-diag12
-rw-r--r--completions/mii-tool20
-rw-r--r--completions/minicom28
-rw-r--r--completions/mkinitrd14
-rw-r--r--completions/mktemp12
-rw-r--r--completions/mmsitepass6
-rw-r--r--completions/modinfo24
-rw-r--r--completions/modprobe66
-rw-r--r--completions/monodevelop8
-rw-r--r--completions/mplayer177
-rw-r--r--completions/mr41
-rw-r--r--completions/msynctool26
-rw-r--r--completions/mtx22
-rw-r--r--completions/munin-node-configure10
-rw-r--r--completions/munin-run14
-rw-r--r--completions/munin-update8
-rw-r--r--completions/munindoc6
-rw-r--r--completions/mussh24
-rw-r--r--completions/mutt95
-rw-r--r--completions/mypy20
-rw-r--r--completions/mysql53
-rw-r--r--completions/mysqladmin30
-rw-r--r--completions/nc19
-rw-r--r--completions/ncftp12
-rw-r--r--completions/nethogs8
-rw-r--r--completions/newlist10
-rw-r--r--completions/newusers14
-rw-r--r--completions/ngrep14
-rw-r--r--completions/nmap52
-rw-r--r--completions/nproc8
-rw-r--r--completions/nslookup32
-rw-r--r--completions/nsupdate12
-rw-r--r--completions/ntpdate10
-rw-r--r--completions/oggdec20
-rw-r--r--completions/op35
-rw-r--r--completions/openssl202
-rw-r--r--completions/opera26
-rw-r--r--completions/optipng22
-rw-r--r--completions/p434
-rw-r--r--completions/pack20048
-rw-r--r--completions/passwd8
-rw-r--r--completions/patch34
-rw-r--r--completions/pdftotext19
-rw-r--r--completions/perl44
-rw-r--r--completions/perlcritic24
-rw-r--r--completions/perltidy20
-rw-r--r--completions/pgrep26
-rw-r--r--completions/pidof8
-rw-r--r--completions/pine18
-rw-r--r--completions/ping20
-rw-r--r--completions/pkg-config30
-rw-r--r--completions/pkg-get72
-rw-r--r--completions/pkg_delete8
-rw-r--r--completions/pkgadd34
-rw-r--r--completions/pkgrm20
-rw-r--r--completions/pkgtool12
-rw-r--r--completions/pkgutil48
-rw-r--r--completions/plague-client8
-rw-r--r--completions/pm-hibernate4
-rw-r--r--completions/pm-is-supported6
-rw-r--r--completions/pm-powersave4
-rw-r--r--completions/pngfix12
-rw-r--r--completions/portinstall18
-rw-r--r--completions/portsnap8
-rw-r--r--completions/portupgrade10
-rw-r--r--completions/postcat14
-rw-r--r--completions/postconf10
-rw-r--r--completions/postfix16
-rw-r--r--completions/postmap16
-rw-r--r--completions/postsuper24
-rw-r--r--completions/povray28
-rw-r--r--completions/prelink14
-rw-r--r--completions/printenv23
-rw-r--r--completions/protoc24
-rw-r--r--completions/psql86
-rw-r--r--completions/puppet129
-rw-r--r--completions/pv12
-rw-r--r--completions/pwck6
-rw-r--r--completions/pwd10
-rw-r--r--completions/pwdx6
-rw-r--r--completions/pwgen10
-rw-r--r--completions/pycodestyle10
-rw-r--r--completions/pydoc19
-rw-r--r--completions/pydocstyle14
-rw-r--r--completions/pyflakes6
-rw-r--r--completions/pylint79
-rw-r--r--completions/pytest90
-rw-r--r--completions/python29
-rw-r--r--completions/pyvenv6
-rw-r--r--completions/qdbus8
-rw-r--r--completions/qemu71
-rw-r--r--completions/qrunner8
-rw-r--r--completions/querybts22
-rw-r--r--completions/quota68
-rw-r--r--completions/radvdump10
-rw-r--r--completions/rcs20
-rw-r--r--completions/rdesktop38
-rw-r--r--completions/remove_members10
-rw-r--r--completions/removepkg14
-rw-r--r--completions/reportbug67
-rw-r--r--completions/resolvconf8
-rw-r--r--completions/ri56
-rw-r--r--completions/rmlist6
-rw-r--r--completions/rmmod6
-rw-r--r--completions/route10
-rw-r--r--completions/rpcdebug18
-rw-r--r--completions/rpm174
-rw-r--r--completions/rpm2tgz6
-rw-r--r--completions/rpmcheck8
-rw-r--r--completions/rrdtool10
-rw-r--r--completions/rsync28
-rw-r--r--completions/sbcl8
-rw-r--r--completions/sbopkg41
-rw-r--r--completions/screen177
-rw-r--r--completions/scrub16
-rw-r--r--completions/secret-tool50
-rw-r--r--completions/sh18
-rw-r--r--completions/shellcheck38
-rw-r--r--completions/sitecopy22
-rw-r--r--completions/slackpkg67
-rw-r--r--completions/slapt-get41
-rw-r--r--completions/slapt-src35
-rw-r--r--completions/smartctl88
-rw-r--r--completions/smbclient139
-rw-r--r--completions/snownews6
-rw-r--r--completions/sqlite316
-rw-r--r--completions/ss27
-rw-r--r--completions/ssh273
-rw-r--r--completions/ssh-add6
-rw-r--r--completions/ssh-copy-id6
-rw-r--r--completions/ssh-keygen86
-rw-r--r--completions/sshfs10
-rw-r--r--completions/sshmitm6
-rw-r--r--completions/sshow6
-rw-r--r--completions/strace36
-rw-r--r--completions/strings24
-rw-r--r--completions/sudo48
-rw-r--r--completions/svcadm71
-rw-r--r--completions/svk82
-rw-r--r--completions/sync_members14
-rw-r--r--completions/synclient10
-rw-r--r--completions/sysbench77
-rw-r--r--completions/sysctl14
-rw-r--r--completions/tar252
-rw-r--r--completions/tcpdump30
-rw-r--r--completions/tcpkill6
-rw-r--r--completions/tcpnice6
-rw-r--r--completions/timeout14
-rw-r--r--completions/tipc385
-rw-r--r--completions/tox25
-rw-r--r--completions/tracepath6
-rw-r--r--completions/tshark80
-rw-r--r--completions/tsig-keygen28
-rw-r--r--completions/tune2fs18
-rw-r--r--completions/ulimit18
-rw-r--r--completions/unace8
-rw-r--r--completions/unpack20032
-rw-r--r--completions/unrar10
-rw-r--r--completions/unshunt6
-rw-r--r--completions/update-alternatives36
-rw-r--r--completions/update-rc.d60
-rw-r--r--completions/upgradepkg18
-rw-r--r--completions/urlsnarf6
-rw-r--r--completions/uscan10
-rw-r--r--completions/useradd29
-rw-r--r--completions/userdel12
-rw-r--r--completions/usermod31
-rw-r--r--completions/valgrind54
-rw-r--r--completions/vipw8
-rw-r--r--completions/vmstat16
-rw-r--r--completions/vncviewer47
-rw-r--r--completions/vpnc45
-rw-r--r--completions/watch24
-rw-r--r--completions/webmitm6
-rw-r--r--completions/wget107
-rw-r--r--completions/wine10
-rw-r--r--completions/withlist8
-rw-r--r--completions/wodim66
-rw-r--r--completions/wol22
-rw-r--r--completions/wsimport12
-rw-r--r--completions/wtf24
-rw-r--r--completions/wvdial16
-rw-r--r--completions/xdg-mime41
-rw-r--r--completions/xdg-settings18
-rw-r--r--completions/xfreerdp50
-rw-r--r--completions/xgamma36
-rw-r--r--completions/xhost6
-rw-r--r--completions/xmllint14
-rw-r--r--completions/xmlwf10
-rw-r--r--completions/xmms12
-rw-r--r--completions/xmodmap8
-rw-r--r--completions/xrandr40
-rw-r--r--completions/xrdb10
-rw-r--r--completions/xsltproc18
-rw-r--r--completions/xvfb-run14
-rw-r--r--completions/xxd6
-rw-r--r--completions/xz34
-rw-r--r--completions/xzdec12
-rw-r--r--completions/ypmatch10
-rw-r--r--completions/yum-arch6
-rw-r--r--completions/zopfli12
-rw-r--r--completions/zopflipng18
-rw-r--r--configure.ac2
-rw-r--r--doc/styleguide.txt25
-rw-r--r--doc/testing.txt61
-rwxr-xr-xextra/git-post-commit.sh4
-rwxr-xr-xextra/git-pre-push.sh9
-rwxr-xr-xextra/make-changelog.py34
-rw-r--r--helpers/python2
-rwxr-xr-xsetup-symlinks.sh6
-rw-r--r--test/.gitignore5
-rw-r--r--test/Makefile.am15
-rw-r--r--test/completion/alias.exp1
-rw-r--r--test/completion/cd.exp1
-rw-r--r--test/completion/chown.exp1
-rw-r--r--test/completion/finger.exp1
-rw-r--r--test/completion/scp.exp1
-rw-r--r--test/completion/sftp.exp1
-rw-r--r--test/completion/slapt-get.exp1
-rw-r--r--test/completion/slapt-src.exp1
-rw-r--r--test/completion/ssh.exp1
-rw-r--r--test/completion/sudo.exp1
-rw-r--r--test/completion/umount.exp1
-rw-r--r--test/completion/upgradepkg.exp1
-rw-r--r--test/completion/xhost.exp1
-rw-r--r--test/config/bashrc17
-rw-r--r--test/config/default.exp21
-rw-r--r--test/config/inputrc18
-rwxr-xr-xtest/docker/docker-script.sh18
-rw-r--r--test/fixtures/_known_hosts_real/.ssh/config_asterisk_11
-rw-r--r--test/fixtures/_known_hosts_real/.ssh/config_asterisk_21
-rw-r--r--test/fixtures/_known_hosts_real/.ssh/config_question_mark1
-rw-r--r--test/fixtures/_known_hosts_real/config6
-rw-r--r--test/fixtures/_known_hosts_real/config_include2
-rw-r--r--test/fixtures/_known_hosts_real/config_tilde4
-rw-r--r--test/fixtures/_known_hosts_real/gee-filename-canary (renamed from test/fixtures/slackware/etc/slapt-get/slapt-getrc)0
-rw-r--r--test/fixtures/_known_hosts_real/localhost_config2
-rw-r--r--test/fixtures/_known_hosts_real/spaced conf7
-rw-r--r--test/fixtures/_longopt/various.txt5
-rw-r--r--test/fixtures/ant/.gitignore3
-rw-r--r--test/fixtures/dpkg/bash-completion-test-nonsubject.txt (renamed from test/fixtures/slackware/etc/slapt-get/slapt-srcrc)0
-rw-r--r--test/fixtures/lftp/.lftp/bookmarks2
-rw-r--r--test/fixtures/lilo/lilo.conf34
-rw-r--r--test/fixtures/nmap/nmap-h.txt114
-rw-r--r--test/fixtures/perl/Devel/BashCompletion.pm2
-rw-r--r--test/fixtures/perldoc/BashCompletionModule.pm4
-rw-r--r--test/fixtures/pytest/test_async.py17
-rw-r--r--test/fixtures/ssh-copy-id/.ssh/id_rsa0
-rw-r--r--test/lib/completion.exp24
-rw-r--r--test/lib/completions/alias.exp32
-rw-r--r--test/lib/completions/cd.exp31
-rw-r--r--test/lib/completions/chown.exp43
-rw-r--r--test/lib/completions/finger.exp41
-rw-r--r--test/lib/completions/scp.exp117
-rw-r--r--test/lib/completions/sftp.exp60
-rw-r--r--test/lib/completions/slapt-get.exp32
-rw-r--r--test/lib/completions/slapt-src.exp29
-rw-r--r--test/lib/completions/ssh.exp61
-rw-r--r--test/lib/completions/sudo.exp42
-rw-r--r--test/lib/completions/umount.exp95
-rw-r--r--test/lib/completions/upgradepkg.exp26
-rw-r--r--test/lib/completions/xhost.exp95
-rw-r--r--test/lib/library.exp970
-rw-r--r--test/lib/library.sh38
-rw-r--r--test/lib/unit.exp25
-rw-r--r--test/requirements-dev.txt4
-rw-r--r--test/requirements.txt2
-rwxr-xr-xtest/run67
-rwxr-xr-xtest/run-shellcheck4
-rwxr-xr-xtest/runCompletion8
-rwxr-xr-xtest/runInstall7
-rwxr-xr-xtest/runLint14
-rwxr-xr-xtest/runUnit8
-rw-r--r--test/setup.cfg9
-rw-r--r--test/t/Makefile.am9
-rw-r--r--test/t/conftest.py367
-rw-r--r--test/t/test_2to3.py2
-rw-r--r--test/t/test_7z.py5
-rw-r--r--test/t/test_alias.py4
-rw-r--r--test/t/test_ant.py13
-rw-r--r--test/t/test_apt_cache.py6
-rw-r--r--test/t/test_apt_get.py6
-rw-r--r--test/t/test_aptitude.py16
-rw-r--r--test/t/test_arpspoof.py7
-rw-r--r--test/t/test_bmake.py7
-rw-r--r--test/t/test_ccache.py6
-rw-r--r--test/t/test_cd.py6
-rw-r--r--test/t/test_chown.py34
-rw-r--r--test/t/test_complete.py4
-rw-r--r--test/t/test_cpan2dist.py4
-rw-r--r--test/t/test_cpio.py12
-rw-r--r--test/t/test_cppcheck.py6
-rw-r--r--test/t/test_crontab.py9
-rw-r--r--test/t/test_curl.py8
-rw-r--r--test/t/test_cvs.py2
-rw-r--r--test/t/test_dd.py2
-rw-r--r--test/t/test_dmypy.py6
-rw-r--r--test/t/test_dnssec_keygen.py2
-rw-r--r--test/t/test_dpkg_deb.py4
-rw-r--r--test/t/test_dpkg_query.py18
-rw-r--r--test/t/test_feh.py4
-rw-r--r--test/t/test_find.py13
-rw-r--r--test/t/test_finger.py24
-rw-r--r--test/t/test_gcc.py11
-rw-r--r--test/t/test_ip.py4
-rw-r--r--test/t/test_ipcalc.py23
-rw-r--r--test/t/test_irb.py2
-rw-r--r--test/t/test_iscsiadm.py4
-rw-r--r--test/t/test_isort.py2
-rw-r--r--test/t/test_jsonschema.py4
-rw-r--r--test/t/test_kcov.py2
-rw-r--r--test/t/test_ldd.py4
-rw-r--r--test/t/test_less.py4
-rw-r--r--test/t/test_lftp.py14
-rw-r--r--test/t/test_lilo.py9
-rw-r--r--test/t/test_ls.py2
-rw-r--r--test/t/test_lspci.py4
-rw-r--r--test/t/test_make.py19
-rw-r--r--test/t/test_man.py26
-rw-r--r--test/t/test_mkdir.py3
-rw-r--r--test/t/test_modprobe.py2
-rw-r--r--test/t/test_mount.py2
-rw-r--r--test/t/test_mr.py13
-rw-r--r--test/t/test_mypy.py2
-rw-r--r--test/t/test_nmap.py44
-rw-r--r--test/t/test_openssl.py5
-rw-r--r--test/t/test_perl.py2
-rw-r--r--test/t/test_pgrep.py22
-rw-r--r--test/t/test_postfix.py16
-rw-r--r--test/t/test_printenv.py19
-rw-r--r--test/t/test_protoc.py9
-rw-r--r--test/t/test_pydocstyle.py4
-rw-r--r--test/t/test_pylint.py2
-rw-r--r--test/t/test_pytest.py39
-rw-r--r--test/t/test_python.py4
-rw-r--r--test/t/test_python3.py4
-rw-r--r--test/t/test_ri.py2
-rw-r--r--test/t/test_sbcl.py3
-rw-r--r--test/t/test_sbcl_mt.py3
-rw-r--r--test/t/test_scp.py79
-rw-r--r--test/t/test_screen.py8
-rw-r--r--test/t/test_secret_tool.py12
-rw-r--r--test/t/test_sftp.py37
-rw-r--r--test/t/test_slapt_get.py28
-rw-r--r--test/t/test_slapt_src.py31
-rw-r--r--test/t/test_ssh.py28
-rw-r--r--test/t/test_ssh_keygen.py51
-rw-r--r--test/t/test_sudo.py36
-rw-r--r--test/t/test_tar.py20
-rw-r--r--test/t/test_totem.py7
-rw-r--r--test/t/test_tshark.py9
-rw-r--r--test/t/test_tsig_keygen.py12
-rw-r--r--test/t/test_umount.py78
-rw-r--r--test/t/test_upgradepkg.py17
-rw-r--r--test/t/test_userdel.py4
-rw-r--r--test/t/test_valgrind.py4
-rw-r--r--test/t/test_wol.py7
-rw-r--r--test/t/test_write.py4
-rw-r--r--test/t/test_xfreerdp.py32
-rw-r--r--test/t/test_xgamma.py2
-rw-r--r--test/t/test_xhost.py22
-rw-r--r--test/t/unit/Makefile.am5
-rw-r--r--test/t/unit/test_unit_count_args.py4
-rw-r--r--test/t/unit/test_unit_expand.py20
-rw-r--r--test/t/unit/test_unit_expand_tilde_by_ref.py32
-rw-r--r--test/t/unit/test_unit_filedir.py138
-rw-r--r--test/t/unit/test_unit_get_comp_words_by_ref.py101
-rw-r--r--test/t/unit/test_unit_get_cword.py25
-rw-r--r--test/t/unit/test_unit_init_completion.py16
-rw-r--r--test/t/unit/test_unit_known_hosts_real.py158
-rw-r--r--test/t/unit/test_unit_longopt.py18
-rw-r--r--test/t/unit/test_unit_quote.py2
-rw-r--r--test/t/unit/test_unit_quote_readline.py15
-rw-r--r--test/t/unit/test_unit_variables.py10
-rw-r--r--test/t/unit/test_unit_xinetd_services.py22
-rw-r--r--test/test-cmd-list.txt687
-rw-r--r--test/unit/__expand_tilde_by_ref.exp65
-rw-r--r--test/unit/_expand.exp33
-rw-r--r--test/unit/_filedir.exp124
-rw-r--r--test/unit/_get_comp_words_by_ref.exp91
-rw-r--r--test/unit/_get_cword.exp37
-rw-r--r--test/unit/_known_hosts_real.exp171
-rwxr-xr-xtest/update-test-cmd-list13
663 files changed, 11133 insertions, 10371 deletions
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ä <ville.skytta@iki.fi> 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/
+ <https://pubs.opengroup.org/onlinepubs/9699919799/>.
-- Use an editor that supports EditorConfig, see http://editorconfig.org/,
+- Use an editor that supports EditorConfig, see <https://editorconfig.org/>,
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.
+ <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 <kbd>&lt;Tab></kbd>, 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 <Tab>
```
@@ -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 <https://www.zsh.org/>.
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 <ian@caliban.org>
-# © 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 '<defunct>' -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 '<defunct>' -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 "<defunct>" -W '${procs[@]}' -- "$cur" ) )
-}
+ COMPREPLY=($(compgen -X "<defunct>" -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<TAB>'.
# 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<TAB>'.
@@ -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 </etc/shells
}
@@ -1354,7 +1395,7 @@ _fstypes()
$([[ -d /etc/fs ]] && command ls /etc/fs)"
fi
- [[ -n $fss ]] && COMPREPLY+=( $(compgen -W "$fss" -- "$cur") )
+ [[ -n $fss ]] && COMPREPLY+=($(compgen -W "$fss" -- "$cur"))
}
# Get real command.
@@ -1385,15 +1426,14 @@ _get_first_arg()
local i
arg=
- 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
arg=${COMP_WORDS[i]}
break
fi
done
}
-
# This function counts the number of args, excluding options
# @param $1 chars Characters out of $COMP_WORDBREAKS which should
# NOT be considered word breaks. See __reassemble_comp_words_by_ref.
@@ -1402,13 +1442,14 @@ _get_first_arg()
_count_args()
{
local i cword words
- __reassemble_comp_words_by_ref "$1" words cword
+ __reassemble_comp_words_by_ref "${1-}" words cword
args=1
- for (( i=1; i < cword; i++ )); do
- if [[ ${words[i]} != -* && ${words[i-1]} != $2 ||
- ${words[i]} == $3 ]]; then
- (( args++ ))
+ for ((i = 1; i < cword; i++)); do
+ # shellcheck disable=SC2053
+ if [[ ${words[i]} != -* && ${words[i - 1]} != ${2-} || \
+ ${words[i]} == ${3-} ]]; then
+ ((args++))
fi
done
}
@@ -1417,39 +1458,53 @@ _count_args()
#
_pci_ids()
{
- COMPREPLY+=( $(compgen -W \
- "$(PATH="$PATH:/sbin" lspci -n | awk '{print $3}')" -- "$cur") )
+ COMPREPLY+=($(compgen -W \
+ "$(PATH="$PATH:/sbin" lspci -n | awk '{print $3}')" -- "$cur"))
}
# This function completes on USB IDs
#
_usb_ids()
{
- COMPREPLY+=( $(compgen -W \
- "$(PATH="$PATH:/sbin" lsusb | awk '{print $6}')" -- "$cur") )
+ COMPREPLY+=($(compgen -W \
+ "$(PATH="$PATH:/sbin" lsusb | awk '{print $6}')" -- "$cur"))
}
# CD device names
_cd_devices()
{
- COMPREPLY+=( $(compgen -f -d -X "!*/?([amrs])cd*" -- "${cur:-/dev/}") )
+ COMPREPLY+=($(compgen -f -d -X "!*/?([amrs])cd*" -- "${cur:-/dev/}"))
}
# DVD device names
_dvd_devices()
{
- COMPREPLY+=( $(compgen -f -d -X "!*/?(r)dvd*" -- "${cur:-/dev/}") )
+ COMPREPLY+=($(compgen -f -d -X "!*/?(r)dvd*" -- "${cur:-/dev/}"))
}
# TERM environment variable values
_terms()
{
- 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") )
+ 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_<hostname>.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 <function>
# 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<fstype>
- 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<fstype> 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<fstype>
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 </proc/mounts
else
local IFS=$'\n'
- COMPREPLY=( $(compgen -W '$(mount | cut -d" " -f 3)' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(mount | cut -d" " -f 3)' -- "$cur"))
fi
} &&
-complete -F _umount -o dirnames umount
+ complete -F _umount -o dirnames umount
# ex: filetype=sh
diff --git a/completions/_xm b/completions/_xm
index d7b74b89..06b25d3c 100644
--- a/completions/_xm
+++ b/completions/_xm
@@ -6,14 +6,14 @@
_xen_domain_names()
{
- COMPREPLY=( $(compgen -W "$(xm list 2>/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 prevents "phing -" weirdness/getting just a literal
# tab displayed on complete on CentOS 6 with phing 2.6.1.
COMPREPLY=(
- $(compgen -W '$(_parse_help "$1" -h </dev/null)' -- "$cur") )
+ $(compgen -W '$(_parse_help "$1" -h </dev/null)' -- "$cur"))
else
# available targets completion
# find which buildfile to use
local buildfile=build.xml i
- for (( i=1; i < cword; i++ )); do
- if [[ "${words[i]}" == -@(?(build)file|f) ]]; then
- buildfile=${words[i+1]}
+ for ((i = 1; i < cword; i++)); do
+ if [[ ${words[i]} == -@(?(build)file|f) ]]; then
+ buildfile=${words[i + 1]}
break
fi
done
- if [[ $i -eq $cword ]]; then
- for i in $ANT_ARGS; do
+ if ((i == cword)); then
+ for i in ${ANT_ARGS-}; do
if [[ $prev == -@(?(build)file|f) ]]; then
buildfile=$i
break
@@ -92,11 +92,11 @@ _ant()
# fill targets
_ant_parse_targets $buildfile
- COMPREPLY=( $(compgen -W '$targets' -- "$cur") )
+ COMPREPLY=($(compgen -W '$targets' -- "$cur"))
fi
} &&
-complete -F _ant ant phing
-type complete-ant-cmd.pl &>/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:<src_package>" is being completed
# COMP_WORDS would be: "bts cleancache src : <partial_pkg_name>"
pos=$((COMP_CWORD - 2))
- if [[ $pos -gt 0 && "${COMP_WORDS[$pos]}" == "src" ]]; then
- COMPREPLY=( $(_xfunc apt-cache _apt_cache_src_packages) )
+ 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
\<address\>) _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 <CVS/Root
- COMPREPLY=( $(compgen -W '${cvsroots[@]}' -- "$cur") )
+ COMPREPLY=($(compgen -W '${cvsroots[@]}' -- "$cur"))
__ltrim_colon_completions "$cur"
}
@@ -55,89 +55,89 @@ _cvs()
count=0
for i in "${words[@]}"; do
- [[ $count -eq $cword ]] && break
+ ((count == cword)) && break
# Last parameter was the CVSROOT, now go back to mode selection
- if [[ "${words[((count))]}" == "$cvsroot" && "$mode" == cvsroot ]]; then
+ if [[ ${words[count]} == "${cvsroot-}" && ${mode-} == cvsroot ]]; then
mode=""
fi
- if [[ -z $mode ]]; then
+ if [[ ! -v mode ]]; then
case $i in
- --help|-!(-*)H)
- COMPREPLY=( $(compgen -W "$(_cvs_commands)" -- "$cur") )
+ --help | -!(-*)H)
+ COMPREPLY=($(compgen -W "$(_cvs_commands)" -- "$cur"))
return
;;
-!(-*)d)
mode=cvsroot
- cvsroot=${words[((count+1))]}
+ cvsroot=${words[count + 1]}
;;
- add|ad|new)
+ add | ad | new)
mode=add
;;
- admin|adm|rcs)
- mode=admin
+ admin | adm | rcs)
+ mode="admin"
;;
- annotate|ann|blame|rannotate|rann|ra)
+ annotate | ann | blame | rannotate | rann | ra)
mode=annotate
;;
- checkout|co|get)
+ checkout | co | get)
mode=checkout
;;
- commit|ci|com)
+ commit | ci | com)
mode=commit
;;
- diff|di|dif)
- mode=diff
+ diff | di | dif)
+ mode="diff"
;;
- export|ex|exp)
- mode=export
+ export | ex | exp)
+ mode="export"
;;
- edit|unedit|editors|logout|pserver|server|watch|watchers)
+ edit | unedit | editors | logout | pserver | server | watch | watchers)
mode=$i
;;
- history|hi|his)
+ history | hi | his)
mode=history
;;
- import|im|imp)
+ import | im | imp)
mode=import
;;
- log|lo|rlog|rl)
+ log | lo | rlog | rl)
mode=log
;;
- login|logon|lgn)
+ login | logon | lgn)
mode=login
;;
- rdiff|patch|pa)
+ rdiff | patch | pa)
mode=rdiff
;;
- release|re|rel)
+ release | re | rel)
mode=release
;;
- remove|rm|delete)
+ remove | rm | delete)
mode=remove
;;
- rtag|rt|rfreeze)
+ rtag | rt | rfreeze)
mode=rtag
;;
- status|st|stat)
+ status | st | stat)
mode=status
;;
- tag|ta|freeze)
+ tag | ta | freeze)
mode=tag
;;
- update|up|upd)
+ update | up | upd)
mode=update
;;
- version|ve|ver)
+ version | ve | ver)
mode=version
;;
esac
- elif [[ "$i" == -* ]]; then
- flags+=( $i )
+ elif [[ $i == -* ]]; then
+ flags+=($i)
fi
- (( count++ ))
+ ((count++))
done
- case $mode in
+ case ${mode-} in
add)
case $prev in
--*) ;;
@@ -150,25 +150,25 @@ _cvs()
;;
esac
- if [[ "$cur" != -* ]]; then
+ if [[ $cur != -* ]]; then
_cvs_entries
- [[ -z $cur ]] && files=( !(CVS) ) || \
- files=( $(command ls -d ${cur}* 2>/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,<TAB>
# 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 <<EOF
+ if [[ -z ${prefix_pat} || ${prefix_pat} == */ ]]; then
+ cat <<EOF
/^${prefix_pat}[^a-zA-Z0-9]/d; # convention for hidden tgt
EOF
fi
@@ -86,37 +86,37 @@ _make()
local cur prev words cword split
_init_completion -s || return
- local file makef makef_dir=( "-C" "." ) makef_inc i
+ local makef makef_dir=("-C" ".") i
case $prev in
- --file|--makefile|--old-file|--assume-old|--what-if| --new-file|\
- --assume-new|-!(-*)[foW])
+ --file | --makefile | --old-file | --assume-old | --what-if | --new-file | \
+ --assume-new | -!(-*)[foW])
_filedir
return
;;
- --include-dir|--directory|-!(-*)[ICm])
+ --include-dir | --directory | -!(-*)[ICm])
_filedir -d
return
;;
-!(-*)E)
- COMPREPLY=( $(compgen -v -- "$cur") )
+ COMPREPLY=($(compgen -v -- "$cur"))
return
;;
- --eval|-!(-*)[DVx])
+ --eval | -!(-*)[DVx])
return
;;
- --jobs|-!(-*)j)
- COMPREPLY=( $(compgen -W "{1..$(( $(_ncpus)*2 ))}" -- "$cur") )
+ --jobs | -!(-*)j)
+ COMPREPLY=($(compgen -W "{1..$(($(_ncpus) * 2))}" -- "$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
elif [[ $cur == *=* ]]; then
prev=${cur%%=*}
cur=${cur#*=}
@@ -126,20 +126,20 @@ _make()
else
# before we check for makefiles, see if a path was specified
# with -C/--directory
- for (( i=0; i < ${#words[@]}; i++ )); do
+ for ((i = 1; i < ${#words[@]}; i++)); do
if [[ ${words[i]} == -@(C|-directory) ]]; then
# eval for tilde expansion
- eval "makef_dir=( -C \"${words[i+1]}\" )"
+ eval "makef_dir=( -C \"${words[i + 1]}\" )"
break
fi
done
# before we scan for targets, see if a Makefile name was
# specified with -f/--file/--makefile
- for (( i=0; i < ${#words[@]}; i++ )); do
+ for ((i = 1; i < ${#words[@]}; i++)); do
if [[ ${words[i]} == -@(f|-?(make)file) ]]; then
# eval for tilde expansion
- eval "makef=( -f \"${words[i+1]}\" )"
+ eval "makef=( -f \"${words[i + 1]}\" )"
break
fi
done
@@ -147,24 +147,24 @@ _make()
# recognise that possible completions are only going to be displayed
# so only the base name is shown
local mode=--
- if (( COMP_TYPE != 9 )); then
+ if ((COMP_TYPE != 9)); then
mode=-d # display-only mode
fi
local IFS=$' \t\n' script=$(_make_target_extract_script $mode "$cur")
- COMPREPLY=( $(LC_ALL=C \
+ COMPREPLY=($(LC_ALL=C \
$1 -npq __BASH_MAKE_COMPLETION__=1 \
- "${makef[@]}" "${makef_dir[@]}" .DEFAULT 2>/dev/null | \
- command sed -ne "$script") )
+ ${makef+"${makef[@]}"} "${makef_dir[@]}" .DEFAULT 2>/dev/null |
+ command sed -ne "$script"))
if [[ $mode != -d ]]; then
# Completion will occur if there is only one suggestion
# so set options for completion based on the first one
- [[ $COMPREPLY == */ ]] && compopt -o nospace
+ [[ ${COMPREPLY-} == */ ]] && compopt -o nospace
fi
fi
} &&
-complete -F _make make gmake gnumake pmake colormake
+ complete -F _make make gmake gnumake pmake colormake bmake
# ex: filetype=sh
diff --git a/completions/makepkg b/completions/makepkg
index 71d4f76d..23ac7848 100644
--- a/completions/makepkg
+++ b/completions/makepkg
@@ -7,16 +7,16 @@ _makepkg_slackware()
_init_completion || return
case "$prev" in
- -l|--linkadd|-c|--chown)
- COMPREPLY=( $(compgen -W 'y n' -- "$cur") )
+ -l | --linkadd | -c | --chown)
+ COMPREPLY=($(compgen -W 'y n' -- "$cur"))
return
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W \
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W \
'$($1 | command sed -e "s/^options://" | _parse_help -)' \
- -- "$cur") )
+ -- "$cur"))
return
fi
@@ -43,6 +43,6 @@ _makepkg_bootstrap()
complete -F $fname makepkg
$fname
} &&
-complete -F _makepkg_bootstrap makepkg
+ complete -F _makepkg_bootstrap makepkg
# ex: filetype=sh
diff --git a/completions/man b/completions/man
index e5a47361..81d06f51 100644
--- a/completions/man
+++ b/completions/man
@@ -10,29 +10,29 @@ _man()
local mansect="@([0-9lnp]|[0-9][px]|3?(gl|pm))"
case $prev in
- --config-file|-!(-*)C)
+ --config-file | -!(-*)C)
_filedir conf
return
;;
- --local-file|-!(-*)l)
+ --local-file | -!(-*)l)
_filedir "$manext"
return
;;
- --manpath|-!(-*)M)
+ --manpath | -!(-*)M)
_filedir -d
return
;;
- --pager|-!(-*)P)
+ --pager | -!(-*)P)
compopt -o filenames
- COMPREPLY=( $(compgen -c -- "$cur") )
+ COMPREPLY=($(compgen -c -- "$cur"))
return
;;
- --preprocessor|-!(-*)p)
- COMPREPLY=( $(compgen -W 'e p t g r v' -- "$cur") )
+ --preprocessor | -!(-*)p)
+ COMPREPLY=($(compgen -W 'e p t g r v' -- "$cur"))
return
;;
- --locale|--systems|--extension|--prompt|--recode|--encoding|\
- -!(-*)[LmerRE])
+ --locale | --systems | --extension | --prompt | --recode | --encoding | \
+ -!(-*)[LmerRE])
return
;;
esac
@@ -41,13 +41,13 @@ _man()
if [[ $cur == -* ]]; then
local opts=$(_parse_help "$1" -h)
- 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
# file based completion if parameter looks like a path
- if [[ "$cur" == @(*/|[.~])* ]]; then
+ if [[ $cur == @(*/|[.~])* ]]; then
_filedir "$manext"
return
fi
@@ -57,7 +57,8 @@ _man()
# determine manual section to search
local sect
- [[ "$prev" == $mansect ]] && sect=$prev || sect='*'
+ # shellcheck disable=SC2053
+ [[ $prev == $mansect ]] && sect=$prev || sect='*'
_expand || return
@@ -68,29 +69,33 @@ _man()
manpath="${manpath//://*man$sect/ } ${manpath//://*cat$sect/ }"
fi
- local IFS=$' \t\n' reset=$(shopt -p failglob); shopt -u failglob
+ local IFS=$' \t\n' reset=$(shopt -p failglob)
+ shopt -u failglob
# redirect stderr for when path doesn't exist
- COMPREPLY=( $(eval command ls "$manpath" 2>/dev/null) )
+ COMPREPLY=($(eval command ls "$manpath" 2>/dev/null))
$reset
- # weed out directory path names and paths to man pages
- COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
- # strip suffix from man pages
- COMPREPLY=( ${COMPREPLY[@]%$comprsuffix} )
- COMPREPLY=( $(compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}") )
+ if ((${#COMPREPLY[@]} != 0)); then
+ # weed out directory path names and paths to man pages
+ COMPREPLY=(${COMPREPLY[@]##*/?(:)})
+ # strip suffix from man pages
+ COMPREPLY=(${COMPREPLY[@]%$comprsuffix})
+ COMPREPLY=($(compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}"))
+ fi
- if [[ "$prev" != $mansect ]]; then
+ # shellcheck disable=SC2053
+ if [[ $prev != $mansect ]]; then
# File based completion for the rest, prepending ./ if needed
# (man 1.6f needs that for man pages in current dir)
local i start=${#COMPREPLY[@]}
_filedir "$manext"
- for (( i=$start; i < ${#COMPREPLY[@]}; i++ )); do
+ for ((i = start; i < ${#COMPREPLY[@]}; i++)); do
[[ ${COMPREPLY[i]} == */* ]] || COMPREPLY[i]=./${COMPREPLY[i]}
done
fi
__ltrim_colon_completions "$cur"
} &&
-complete -F _man man apropos whatis
+ complete -F _man man apropos whatis
# ex: filetype=sh
diff --git a/completions/mc b/completions/mc
index 8e96dd97..cf38821c 100644
--- a/completions/mc
+++ b/completions/mc
@@ -6,24 +6,24 @@ _mc()
_init_completion -s || return
case $prev in
- --edit|--view|--ftplog|--printwd|-!(-*)[evlP])
+ --edit | --view | --ftplog | --printwd | -!(-*)[evlP])
_filedir
return
;;
- --help|--help-*|--version|--colors|--debuglevel|-!(-*)[hVCD])
+ --help | --help-* | --version | --colors | --debuglevel | -!(-*)[hVCD])
return
;;
esac
$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
else
_filedir -d
fi
} &&
-complete -F _mc mc
+ complete -F _mc mc
# ex: filetype=sh
diff --git a/completions/mcrypt b/completions/mcrypt
index f6094a22..0c3ab5e6 100644
--- a/completions/mcrypt
+++ b/completions/mcrypt
@@ -7,61 +7,61 @@ _mcrypt()
_init_completion || return
case $prev in
- -g|--openpgp-z)
- COMPREPLY=( $(compgen -W '{0..9}' -- "$cur") )
+ -g | --openpgp-z)
+ COMPREPLY=($(compgen -W '{0..9}' -- "$cur"))
return
;;
- -o|--keymode)
- COMPREPLY=( $(compgen -W '$($1 --list-keymodes 2>/dev/null )' \
- -- "$cur") )
+ -o | --keymode)
+ COMPREPLY=($(compgen -W '$($1 --list-keymodes 2>/dev/null )' \
+ -- "$cur"))
return
;;
- -m|--mode)
- COMPREPLY=( $(compgen -W "$($1 --list 2>/dev/null | cut -d: -f2-)" \
- -- "$cur") )
+ -m | --mode)
+ COMPREPLY=($(compgen -W "$($1 --list 2>/dev/null | cut -d: -f2-)" \
+ -- "$cur"))
return
;;
- -a|--algorithm)
- COMPREPLY=( $(compgen -W "$($1 --list 2>/dev/null | \
- awk '{print $1}')" -- "$cur") )
+ -a | --algorithm)
+ COMPREPLY=($(compgen -W "$($1 --list 2>/dev/null |
+ awk '{print $1}')" -- "$cur"))
return
;;
- -h|--hash)
- COMPREPLY=( $(compgen -W '$($1 --list-hash 2>/dev/null | \
- command sed -e 1d)' -- "$cur") )
+ -h | --hash)
+ COMPREPLY=($(compgen -W '$($1 --list-hash 2>/dev/null | \
+ command sed -e 1d)' -- "$cur"))
return
;;
- -k|-s|--key|--keysize)
+ -k | -s | --key | --keysize)
return
;;
- -f|-c|--keyfile|--config)
+ -f | -c | --keyfile | --config)
_filedir
return
;;
- --algorithms-directory|--modes-directory)
+ --algorithms-directory | --modes-directory)
_filedir -d
return
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
elif [[ ${words[0]} == mdecrypt ]]; then
_filedir nc
else
local i decrypt=0
- for (( i=1; i < ${#words[@]}-1; i++ )); do
+ for ((i = 1; i < ${#words[@]} - 1; i++)); do
if [[ ${words[i]} == -@(d|-decrypt) ]]; then
_filedir nc
decrypt=1
break
fi
done
- if [[ $decrypt -eq 0 ]]; then
+ if ((decrypt == 0)); then
_filedir
fi
fi
} &&
-complete -F _mcrypt mcrypt mdecrypt
+ complete -F _mcrypt mcrypt mdecrypt
# ex: filetype=sh
diff --git a/completions/mdadm b/completions/mdadm
index 5fbd9bf3..37effd96 100644
--- a/completions/mdadm
+++ b/completions/mdadm
@@ -4,13 +4,13 @@ _mdadm_raid_level()
{
local mode
- for (( i=1; i < cword; i++ )); do
+ for ((i = 1; i < cword; i++)); do
case ${words[i]} in
- -!(-*)C*|--create)
+ -!(-*)C* | --create)
mode=create
break
;;
- -!(-*)B*|--build)
+ -!(-*)B* | --build)
mode=build
break
;;
@@ -19,13 +19,13 @@ _mdadm_raid_level()
case $mode in
create)
- COMPREPLY=( $(compgen -W 'linear raid0 0 stripe raid1 1 mirror
+ COMPREPLY=($(compgen -W 'linear raid0 0 stripe raid1 1 mirror
raid4 4 raid5 5 raid6 6 raid10 10 multipath mp faulty' \
- -- "$cur") )
+ -- "$cur"))
;;
build)
- COMPREPLY=( $(compgen -W 'linear stripe raid0 0 raid1 multipath mp
- faulty' -- "$cur") )
+ COMPREPLY=($(compgen -W 'linear stripe raid0 0 raid1 multipath mp
+ faulty' -- "$cur"))
;;
esac
}
@@ -33,64 +33,63 @@ _mdadm_raid_level()
_mdadm_raid_layout()
{
local level
- for (( i=1; i < cword; i++ )); do
- if [[ "${words[i]}" == -@(l|-level) ]]; then
- level=${words[i+1]}
+ for ((i = 1; i < cword; i++)); do
+ if [[ ${words[i]} == -@(l|-level) ]]; then
+ level=${words[i + 1]}
break
fi
done
case $level in
raid5)
- COMPREPLY=( $(compgen -W 'left-asymmetric left-symmetric
- right-asymmetric right-symmetric la ra ls rs' -- "$cur") )
+ COMPREPLY=($(compgen -W 'left-asymmetric left-symmetric
+ right-asymmetric right-symmetric la ra ls rs' -- "$cur"))
;;
raid10)
- COMPREPLY=( $(compgen -W 'n o p' -- "$cur") )
+ COMPREPLY=($(compgen -W 'n o p' -- "$cur"))
;;
faulty)
- COMPREPLY=( $(compgen -W 'write-transient wt read-transient rt
+ COMPREPLY=($(compgen -W 'write-transient wt read-transient rt
write-persistent wp read-persistent rp write-all read-fixable
- rf clear flush none' -- "$cur") )
+ rf clear flush none' -- "$cur"))
;;
esac
}
_mdadm_auto_flag()
{
- COMPREPLY=( $(compgen -W 'no yes md mdp part p' -- "$cur") )
+ COMPREPLY=($(compgen -W 'no yes md mdp part p' -- "$cur"))
}
_mdadm_update_flag()
{
- COMPREPLY=( $(compgen -W 'sparc2.2 summaries uuid name homehost resync
- byteorder super-minor' -- "$cur") )
+ COMPREPLY=($(compgen -W 'sparc2.2 summaries uuid name homehost resync
+ byteorder super-minor' -- "$cur"))
}
-
_mdadm()
{
local cur prev words cword split
_init_completion -s || return
case $prev in
- --config|--bitmap|--backup-file|-!(-*)[cb])
+ --config | --bitmap | --backup-file | -!(-*)[cb])
_filedir
return
;;
- --level|-!(-*)l)
+ --level | -!(-*)l)
_mdadm_raid_level
return
;;
- --layout|--parity|-!(-*)p)
+ --layout | --parity | -!(-*)p)
_mdadm_raid_layout
return
;;
- --auto|-!(-*)a)
+ --auto | -!(-*)a)
_mdadm_auto_flag
return
;;
- --update|-!(-*)U)
+ --update | -!(-*)U)
_mdadm_update_flag
return
;;
@@ -101,50 +100,50 @@ _mdadm()
local options='--help --help-options --version --verbose --quiet --brief
--force --config= --scan --metadata= --homehost='
- if [[ "$cur" == -* ]]; then
- if [[ $cword -eq 1 ]]; then
- COMPREPLY=( $(compgen -W "$options --assemble --build --create
- --monitor --grow" -- "$cur") )
+ if [[ $cur == -* ]]; then
+ if ((cword == 1)); then
+ COMPREPLY=($(compgen -W "$options --assemble --build --create
+ --monitor --grow" -- "$cur"))
else
- case ${words[cword-1]} in
- --assemble|-!(-*)A*)
- COMPREPLY=( $(compgen -W "$options --uuid= --super-minor=
+ case ${words[cword - 1]} in
+ --assemble | -!(-*)A*)
+ COMPREPLY=($(compgen -W "$options --uuid= --super-minor=
--name= --force --run --no-degraded --auto= --bitmap=
--backup-file= --update= --auto-update-homehost" \
- -- "$cur") )
+ -- "$cur"))
;;
- --build|--create|--grow|-!(-*)[BCG]*)
- COMPREPLY=( $(compgen -W "$options --raid-devices=
+ --build | --create | --grow | -!(-*)[BCG]*)
+ COMPREPLY=($(compgen -W "$options --raid-devices=
--spare-devices= --size= --chunk= --rounding= --level=
--layout= --parity= --bitmap= --bitmap-chunk=
--write-mostly --write-behind= --assume-clean
--backup-file= --name= --run --force --auto=" \
- -- "$cur") )
+ -- "$cur"))
;;
- --follow|--monitor|-!(-*)F)
- COMPREPLY=( $(compgen -W "$options --mail --program
+ --follow | --monitor | -!(-*)F)
+ COMPREPLY=($(compgen -W "$options --mail --program
--alert --syslog --delay --daemonise --pid-file
- --oneshot --test" -- "$cur") )
+ --oneshot --test" -- "$cur"))
;;
- /dev/*|--add|--fail|--remove)
- COMPREPLY=( $(compgen -W "$options --add --re-add
- --remove --fail --set-faulty" -- "$cur") )
+ /dev/* | --add | --fail | --remove)
+ COMPREPLY=($(compgen -W "$options --add --re-add
+ --remove --fail --set-faulty" -- "$cur"))
;;
*)
- COMPREPLY=( $(compgen -W "$options --query --detail
+ COMPREPLY=($(compgen -W "$options --query --detail
--examine --sparc2.2 --examine-bitmap --run --stop
--readonly --readwrite --zero-superblock --test" \
- -- "$cur") )
+ -- "$cur"))
;;
esac
fi
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
cur=${cur:=/dev/}
_filedir
fi
} &&
-complete -F _mdadm mdadm
+ complete -F _mdadm mdadm
# ex: filetype=sh
diff --git a/completions/mdtool b/completions/mdtool
index 67a3c7c3..428e33b7 100644
--- a/completions/mdtool
+++ b/completions/mdtool
@@ -7,17 +7,18 @@ _mdtool()
local command i
- for (( i=0; i < ${#words[@]}-1; i++ )); do
+ for ((i = 1; i < ${#words[@]} - 1; i++)); do
if [[ ${words[i]} == @(build|generate-makefiles|setup) ]]; then
command=${words[i]}
+ break
fi
done
- if [[ -n "$command" ]]; then
+ if [[ -v command ]]; then
case $command in
"build")
- COMPREPLY=( $(compgen -W '--f --buildfile --p --project' \
- -S":" -- "$cur") )
+ COMPREPLY=($(compgen -W '--f --buildfile --p --project' \
+ -S":" -- "$cur"))
# TODO: This does not work :(
#if [[ "$prev" == *: ]]; then
# case $prev in
@@ -33,29 +34,29 @@ _mdtool()
;;
"generate-makefiles")
compopt -o filenames
- COMPREPLY=( $(compgen -o filenames -G"*.mds" -- "$cur") )
- if [[ "$prev" == *mds ]]; then
- COMPREPLY=( $(compgen -W '--simple-makefiles --s --d:' \
- -- "$cur") )
+ COMPREPLY=($(compgen -o filenames -G"*.mds" -- "$cur"))
+ if [[ $prev == *mds ]]; then
+ COMPREPLY=($(compgen -W '--simple-makefiles --s --d:' \
+ -- "$cur"))
fi
return
;;
"setup")
# TODO: at least return filenames after these options.
- COMPREPLY=( $(compgen -W 'install i uninstall u check-install
+ COMPREPLY=($(compgen -W 'install i uninstall u check-install
ci update up list l list-av la list-update lu rep-add ra
rep-remove rr rep-update ru rep-list rl reg-update
reg-build rgu info rep-build rb pack p help h dump-file' \
- -- "$cur") )
+ -- "$cur"))
return
;;
esac
fi
- COMPREPLY=( $(compgen -W 'gsetup build dbgen project-export
- generate-makefiles gettext-update setup -q' -- "$cur") )
+ COMPREPLY=($(compgen -W 'gsetup build dbgen project-export
+ generate-makefiles gettext-update setup -q' -- "$cur"))
} &&
-complete -F _mdtool mdtool
+ complete -F _mdtool mdtool
# ex: filetype=sh
diff --git a/completions/medusa b/completions/medusa
index f0ca7022..45129879 100644
--- a/completions/medusa
+++ b/completions/medusa
@@ -15,16 +15,16 @@ _medusa()
return
;;
-*M)
- COMPREPLY=( $(compgen -W "$($1 -d | awk '/^ +\+/ {print $2}' \
- | command sed -e 's/\.mod$//')") )
+ COMPREPLY=($(compgen -W "$($1 -d | awk '/^ +\+/ {print $2}' |
+ command sed -e 's/\.mod$//')"))
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 _medusa medusa
+ complete -F _medusa medusa
# ex: filetype=sh
diff --git a/completions/mii-diag b/completions/mii-diag
index b62174e7..c433a7a2 100644
--- a/completions/mii-diag
+++ b/completions/mii-diag
@@ -6,21 +6,21 @@ _mii_diag()
_init_completion -s || return
case $prev in
- -F|-A|--advertise|--fixed-speed)
- COMPREPLY=( $(compgen -W '100baseT4 100baseTx 100baseTx-FD
- 100baseTx-HD 10baseT 10baseT-FD 10baseT-HD' -- "$cur") )
+ -F | -A | --advertise | --fixed-speed)
+ COMPREPLY=($(compgen -W '100baseT4 100baseTx 100baseTx-FD
+ 100baseTx-HD 10baseT 10baseT-FD 10baseT-HD' -- "$cur"))
return
;;
esac
$split && return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
else
_available_interfaces -a
fi
} &&
-complete -F _mii_diag -o default mii-diag
+ complete -F _mii_diag -o default mii-diag
# ex: filetype=sh
diff --git a/completions/mii-tool b/completions/mii-tool
index 9c88ba14..1b80202b 100644
--- a/completions/mii-tool
+++ b/completions/mii-tool
@@ -6,27 +6,27 @@ _mii_tool()
_init_completion -s || return
case $prev in
- --force|-!(-*)F)
- COMPREPLY=( $(compgen -W '100baseTx-FD 100baseTx-HD 10baseT-FD
- 10baseT-HD' -- "$cur") )
+ --force | -!(-*)F)
+ COMPREPLY=($(compgen -W '100baseTx-FD 100baseTx-HD 10baseT-FD
+ 10baseT-HD' -- "$cur"))
return
;;
- --advertise|-!(-*)A)
- COMPREPLY=( $(compgen -W '100baseT4 100baseTx-FD 100baseTx-HD
- 10baseT-FD 10baseT-HD' -- "$cur") )
+ --advertise | -!(-*)A)
+ COMPREPLY=($(compgen -W '100baseT4 100baseTx-FD 100baseTx-HD
+ 10baseT-FD 10baseT-HD' -- "$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
_available_interfaces -a
fi
} &&
-complete -F _mii_tool -o default mii-tool
+ complete -F _mii_tool -o default mii-tool
# ex: filetype=sh
diff --git a/completions/minicom b/completions/minicom
index 2e98229a..57510e98 100644
--- a/completions/minicom
+++ b/completions/minicom
@@ -6,35 +6,35 @@ _minicom()
_init_completion -s || return
case $prev in
- --attrib|--color|-!(-*)[ac])
- COMPREPLY=( $(compgen -W 'on off' -- "$cur") )
+ --attrib | --color | -!(-*)[ac])
+ COMPREPLY=($(compgen -W 'on off' -- "$cur"))
return
;;
- --script|--capturefile|-!(-*)[SC])
+ --script | --capturefile | -!(-*)[SC])
_filedir
return
;;
- --ptty|-!(-*)p)
- COMPREPLY=( $(printf '%s\n' /dev/tty*) )
- COMPREPLY=( $(compgen -W '${COMPREPLY[@]} ${COMPREPLY[@]#/dev/}' \
- -- "$cur") )
+ --ptty | -!(-*)p)
+ COMPREPLY=($(printf '%s\n' /dev/tty*))
+ COMPREPLY=($(compgen -W '${COMPREPLY[@]} ${COMPREPLY[@]#/dev/}' \
+ -- "$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
return
fi
COMPREPLY=(
- $(printf '%s\n' /etc/minirc.* /etc/minicom/minirc.* ~/.minirc.* \
- | command sed -e '/\*$/d' -e 's/^.*minirc\.//' \
- | command grep "^${cur}") )
+ $(printf '%s\n' /etc/minirc.* /etc/minicom/minirc.* ~/.minirc.* |
+ command sed -e '/\*$/d' -e 's/^.*minirc\.//' |
+ command grep "^${cur}"))
} &&
-complete -F _minicom -o default minicom
+ complete -F _minicom -o default minicom
# ex: filetype=sh
diff --git a/completions/mkinitrd b/completions/mkinitrd
index 2e131227..bcb7e075 100644
--- a/completions/mkinitrd
+++ b/completions/mkinitrd
@@ -6,11 +6,11 @@ _mkinitrd()
_init_completion -s || return
case $prev in
- --preload|--with|--builtin)
+ --preload | --with | --builtin)
_modules
return
;;
- --fstab|--dsdt)
+ --fstab | --dsdt)
_filedir
return
;;
@@ -22,14 +22,14 @@ _mkinitrd()
$split && return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '--version --help -v -f --preload \
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '--version --help -v -f --preload \
--force-scsi-probe --omit-scsi-modules \
--omit-ide-modules --image-version --force-raid-probe \
--omit-raid-modules --with= --force-lvm-probe \
--omit-lvm-modules --builtin --omit-dmraid --net-dev \
- --fstab --nocompress --dsdt --bootchart' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ --fstab --nocompress --dsdt --bootchart' -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
local args
_count_args
@@ -45,6 +45,6 @@ _mkinitrd()
fi
} &&
-complete -F _mkinitrd mkinitrd
+ complete -F _mkinitrd mkinitrd
# ex: filetype=sh
diff --git a/completions/mktemp b/completions/mktemp
index 96c7a118..e063810d 100644
--- a/completions/mktemp
+++ b/completions/mktemp
@@ -6,10 +6,10 @@ _mktemp()
_init_completion -s || return
case "$prev" in
- --help|--version|--suffix)
+ --help | --version | --suffix)
return
;;
- --tmpdir|-!(-*)p)
+ --tmpdir | -!(-*)p)
_filedir -d
return
;;
@@ -17,13 +17,13 @@ _mktemp()
$split && return
- if [[ "$cur" == -* ]]; then
+ if [[ $cur == -* ]]; then
local opts=$(_parse_help "$1")
[[ $opts ]] || opts="-d -u -q -p -t" # non-GNU fallback
- COMPREPLY=( $(compgen -W "$opts" -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ COMPREPLY=($(compgen -W "$opts" -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
-complete -F _mktemp mktemp
+ complete -F _mktemp mktemp
# ex: filetype=sh
diff --git a/completions/mmsitepass b/completions/mmsitepass
index fc938d82..49daae61 100644
--- a/completions/mmsitepass
+++ b/completions/mmsitepass
@@ -5,11 +5,11 @@ _mmsitepass()
local cur prev words cword
_init_completion || return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '--listcreator --help' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '--listcreator --help' -- "$cur"))
fi
} &&
-complete -F _mmsitepass mmsitepass
+ complete -F _mmsitepass mmsitepass
# ex: filetype=sh
diff --git a/completions/modinfo b/completions/modinfo
index c151fad4..009bcf32 100644
--- a/completions/modinfo
+++ b/completions/modinfo
@@ -6,13 +6,13 @@ _modinfo()
_init_completion -s || return
case "$prev" in
- --field|-!(-*)F)
- COMPREPLY=( $(compgen -W 'alias author depends description
+ --field | -!(-*)F)
+ COMPREPLY=($(compgen -W 'alias author depends description
filename firmware license parm srcversion staging vermagic
- version' -- "${cur,,}") )
+ version' -- "${cur,,}"))
return
;;
- --set-version|-!(-*)k)
+ --set-version | -!(-*)k)
_kernel_versions
return
;;
@@ -20,28 +20,28 @@ _modinfo()
$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
local i version=$(uname -r)
- for (( i=${#words[@]}-1; i>0; i-- )); do
+ for ((i = ${#words[@]} - 1; i > 0; i--)); do
if [[ ${words[i]} == -@(!(-*)k*|-set-version) ]]; then
- version=${words[i+1]}
+ version=${words[i + 1]}
break
fi
done
# do filename completion if we're giving a path to a module
- if [[ "$cur" == @(*/|[.~])* ]]; then
- _filedir '@(?(k)o?(.gz))'
+ if [[ $cur == @(*/|[.~])* ]]; then
+ _filedir '@(?(k)o?(.[gx]z))'
else
_modules $version
fi
} &&
-complete -F _modinfo modinfo
+ complete -F _modinfo modinfo
# ex: filetype=sh
diff --git a/completions/modprobe b/completions/modprobe
index 16c8453a..36cb5882 100644
--- a/completions/modprobe
+++ b/completions/modprobe
@@ -6,18 +6,18 @@ _modprobe()
_init_completion -s || return
case "$prev" in
- --help|--version|-!(-*)[hV])
+ --help | --version | -!(-*)[hV])
return
;;
- --config|-!(-*)C)
+ --config | -!(-*)C)
_filedir
return
;;
- --dirname|--type|-!(-*)[dt])
+ --dirname | --type | -!(-*)[dt])
_filedir -d
return
;;
- --set-version|-!(-*)S)
+ --set-version | -!(-*)S)
_kernel_versions
return
;;
@@ -25,44 +25,44 @@ _modprobe()
$split && return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
- if [[ ! $COMPREPLY ]]; then
- COMPREPLY=( $(compgen -W '-a --all -b --use-blacklist -C --config
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ if [[ ! ${COMPREPLY-} ]]; then
+ COMPREPLY=($(compgen -W '-a --all -b --use-blacklist -C --config
-c --showconfig --dump-modversions -d --dirname --first-time
--force-vermagic --force-modversion -f --force -i
--ignore-install --ignore-remove -l --list -n --dry-run -q
--quiet -R --resolve-alias -r --remove -S --set-version
--show-depends -s --syslog -t --type -V --version -v
- --verbose' -- "$cur") )
+ --verbose' -- "$cur"))
fi
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
local i mode=insert module="" version=$(uname -r)
- for (( i=1; i < $cword; i++ )); do
+ for ((i = 1; i < cword; i++)); do
case "${words[i]}" in
- --remove|-!(-*)r*)
+ --remove | -!(-*)r*)
mode=remove
;;
- --list|-!(-*)l*)
+ --list | -!(-*)l*)
mode=list
;;
--dump-modversions)
- mode=file
+ mode="file"
;;
- --set-version|-!(-*)S)
- version=${words[i+1]} # -S is not $prev and not $cur
+ --set-version | -!(-*)S)
+ version=${words[i + 1]} # -S is not $prev and not $cur
;;
- --config|--dirname|--type|-!(-*)[Cdt])
+ --config | --dirname | --type | -!(-*)[Cdt])
((i++)) # skip option and its argument
;;
-*)
# skip all other options
;;
*)
- [ -z "$module" ] && module=${words[i]}
+ [[ -z $module ]] && module=${words[i]}
;;
esac
done
@@ -79,45 +79,45 @@ _modprobe()
;;
insert)
# do filename completion if we're giving a path to a module
- if [[ "$cur" == @(*/|[.~])* ]]; then
- _filedir '@(?(k)o?(.gz))'
- elif [[ -n "$module" ]]; then
+ if [[ $cur == @(*/|[.~])* ]]; then
+ _filedir '@(?(k)o?(.[gx]z))'
+ elif [[ -n $module ]]; then
# do module parameter completion
if [[ $cur == *=* ]]; then
prev=${cur%%=*}
cur=${cur#*=}
- if PATH="$PATH:/sbin" modinfo -p "$module" 2>/dev/null \
- | command grep -q "^$prev:.*(bool)"; then
+ if PATH="$PATH:/sbin" modinfo -p "$module" 2>/dev/null |
+ command grep -q "^$prev:.*(bool)"; then
local choices="on off"
[[ $cur ]] && choices="1 0 y Y n N on off"
- COMPREPLY=( $(compgen -W "$choices" -- "$cur") )
+ COMPREPLY=($(compgen -W "$choices" -- "$cur"))
fi
else
- COMPREPLY=( $(compgen -S = -W "$(PATH="$PATH:/sbin" \
- modinfo -p "$module" 2>/dev/null | \
- awk -F: '!/^[ \t]/ { print $1 }')" -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ COMPREPLY=($(compgen -S = -W "$(PATH="$PATH:/sbin" \
+ modinfo -p "$module" 2>/dev/null |
+ awk -F: '!/^[ \t]/ { print $1 }')" -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
else
_modules $version
- if [[ $COMPREPLY ]]; then
+ if [[ ${COMPREPLY-} ]]; then
# filter out already installed modules
- local -a mods=( "${COMPREPLY[@]}" )
+ local -a mods=("${COMPREPLY[@]}")
_installed_modules "$cur"
for i in "${!mods[@]}"; do
for module in "${COMPREPLY[@]}"; do
- if [[ ${mods[i]} == $module ]]; then
+ if [[ ${mods[i]} == "$module" ]]; then
unset 'mods[i]'
break
fi
done
done
- COMPREPLY=( "${mods[@]}" )
+ COMPREPLY=("${mods[@]}")
fi
fi
;;
esac
} &&
-complete -F _modprobe modprobe
+ complete -F _modprobe modprobe
# ex: filetype=sh
diff --git a/completions/monodevelop b/completions/monodevelop
index 4aa213b7..1c5b5ba4 100644
--- a/completions/monodevelop
+++ b/completions/monodevelop
@@ -7,13 +7,13 @@ _monodevelop()
$split && return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
_filedir
fi
} &&
-complete -F _monodevelop monodevelop
+ complete -F _monodevelop monodevelop
# ex: filetype=sh
diff --git a/completions/mplayer b/completions/mplayer
index 525c63e2..d71ebb8e 100644
--- a/completions/mplayer
+++ b/completions/mplayer
@@ -3,9 +3,9 @@
_mplayer_options_list()
{
cur=${cur%\\}
- COMPREPLY=( $(compgen -W "$($1 -noconfig all $2 help 2>/dev/null | \
- command sed -e '/^Available/,/^$/!d' -e '/^Available/d' | awk '{print $1}' | \
- command sed -e 's/:$//' -e 's/^'${2#-}'$//' -e 's/<.*//')" -- "$cur") )
+ COMPREPLY=($(compgen -W "$($1 -noconfig all $2 help 2>/dev/null |
+ command sed -e '/^Available/,/^$/!d' -e '/^Available/d' | awk '{print $1}' |
+ command sed -e 's/:$//' -e 's/^'${2#-}'$//' -e 's/<.*//')" -- "$cur"))
}
_mplayer()
@@ -16,8 +16,8 @@ _mplayer()
local cmd=${words[0]} i j k=0
case $prev in
- -[av][cfo]|-[av]fm|-vop|-fstype|-demuxer|-o[av]c|-of|-profile| \
- -audio-demuxer|-sub-demuxer)
+ -[av][cfo] | -[av]fm | -vop | -fstype | -demuxer | -o[av]c | -of | -profile | \
+ -audio-demuxer | -sub-demuxer)
_mplayer_options_list $cmd $prev
return
;;
@@ -25,43 +25,43 @@ _mplayer()
_mplayer_options_list $cmd -profile
return
;;
- -audiofile|-audio-file)
+ -audiofile | -audio-file)
_filedir '@(mp3|mpg|og[ag]|w?(a)v|mid|flac|mka|ac3|ape)'
return
;;
- -font|-subfont)
+ -font | -subfont)
if [[ $prev == -font ]]; then
_filedir '@(desc|ttf)'
else
_filedir ttf
fi
local IFS=$'\n'
- COMPREPLY+=( $(compgen -W '$(fc-list 2>/dev/null)' -- "$cur") )
+ COMPREPLY+=($(compgen -W '$(fc-list 2>/dev/null)' -- "$cur"))
return
;;
- -sub|-sub-file)
+ -sub | -sub-file)
_filedir '@(srt|sub|txt|utf|rar|mpsub|smi|js|ssa|ass)'
return
;;
-vobsub)
_filedir '@(idx|ifo|sub)'
local IFS=$'\n'
- COMPREPLY=( $(for i in "${COMPREPLY[@]}"; do
- if [[ -f $i && -r $i ]]; then
- printf '%s\n' ${i%.*}
- else
- printf '%s\n' $i
- fi
- done) )
+ COMPREPLY=($(for i in "${COMPREPLY[@]}"; do
+ if [[ -f $i && -r $i ]]; then
+ printf '%s\n' ${i%.*}
+ else
+ printf '%s\n' $i
+ fi
+ done))
return
;;
- -subcp|-msgcharset)
+ -subcp | -msgcharset)
local cp
- cp=( $(iconv --list 2>/dev/null | command sed -e "s@//@@;" 2>/dev/null) )
- if [[ "$cur" == "${cur,,}" ]]; then
- COMPREPLY=( $(compgen -W '${cp[@],,}' -- "$cur") )
+ cp=($(iconv --list 2>/dev/null | command sed -e "s@//@@;" 2>/dev/null))
+ if [[ $cur == "${cur,,}" ]]; then
+ COMPREPLY=($(compgen -W '${cp[@],,}' -- "$cur"))
else
- COMPREPLY=( $(compgen -W '${cp[@]^^}' -- "$cur") )
+ COMPREPLY=($(compgen -W '${cp[@]^^}' -- "$cur"))
fi
return
;;
@@ -107,53 +107,52 @@ _mplayer()
_filedir -d
return
;;
- -mixer|-dvdauth|-fb|-zrdev)
+ -mixer | -dvdauth | -fb | -zrdev)
cur=${cur:=/dev/}
_filedir
return
;;
- -edl|-edlout|-lircconf|-menu-cfg|-playlist|-csslib|-dumpfile| \
- -subfile|-vobsub|-aofile|-fbmodeconfig|-include|-o|-dvdkey| \
- -passlogfile)
+ -edl | -edlout | -lircconf | -menu-cfg | -playlist | -csslib | -dumpfile | \
+ -subfile | -aofile | -fbmodeconfig | -include | -o | -dvdkey | -passlogfile)
_filedir
return
;;
- -autoq|-autosync|-loop|-menu-root|-speed|-sstep|-aid|-alang| \
- -bandwidth|-bluray-angle|-bluray-chapter|-cache|-chapter|-dvd-speed| \
- -dvdangle|-fps|-frames|-mc|-passwd|-user|-sb|-srate|-ss|-vcd| \
- -vi|-vid|-vivo|-ffactor|-sid|-slang|-spualign|-spuaa|-spugauss| \
- -vobsubid|-delay|-bpp|-brightness|-contrast|-dfbopts|-display| \
- -fbmode|-geometry|-guiwid|-hue|-icelayer|-screen[wh]|-wid| \
- -monitor-dotclock|-monitor-[hv]freq|-panscan| \
- -saturation|-xineramascreen|-zrcrop|-zrnorm|-zrquality| \
- -zr[xy]doff|-zr[vh]dec|-pp|-x|-y|-xy|-z|-stereo| \
- -audio-density|-audio-delay|-audio-preload|-endpos|-osdlevel| \
- -ffourcc|-sws|-skiplimit|-format|-ofps|-aadriver| \
- -aaosdcolor|-aasubcolor|-vobsubout|-vobsuboutid|-vobsuboutindex| \
- -sub-bg-alpha|-sub-bg-color|-subdelay|-subfps|-subpos| \
- -subalign|-subwidth|-subfont-blur|-subfont-outline| \
- -subfont-autoscale|-subfont-encoding|-subfont-osd-scale| \
- -subfont-text-scale)
+ -autoq | -autosync | -loop | -menu-root | -speed | -sstep | -aid | -alang | \
+ -bandwidth | -bluray-angle | -bluray-chapter | -cache | -chapter | -dvd-speed | \
+ -dvdangle | -fps | -frames | -mc | -passwd | -user | -sb | -srate | -ss | -vcd | \
+ -vi | -vid | -vivo | -ffactor | -sid | -slang | -spualign | -spuaa | -spugauss | \
+ -vobsubid | -delay | -bpp | -brightness | -contrast | -dfbopts | -display | \
+ -fbmode | -geometry | -guiwid | -hue | -icelayer | -screen[wh] | -wid | \
+ -monitor-dotclock | -monitor-[hv]freq | -panscan | \
+ -saturation | -xineramascreen | -zrcrop | -zrnorm | -zrquality | \
+ -zr[xy]doff | -zr[vh]dec | -pp | -x | -y | -xy | -z | -stereo | \
+ -audio-density | -audio-delay | -audio-preload | -endpos | -osdlevel | \
+ -ffourcc | -sws | -skiplimit | -format | -ofps | -aadriver | \
+ -aaosdcolor | -aasubcolor | -vobsubout | -vobsuboutid | -vobsuboutindex | \
+ -sub-bg-alpha | -sub-bg-color | -subdelay | -subfps | -subpos | \
+ -subalign | -subwidth | -subfont-blur | -subfont-outline | \
+ -subfont-autoscale | -subfont-encoding | -subfont-osd-scale | \
+ -subfont-text-scale)
return
;;
-channels)
- COMPREPLY=( $(compgen -W '2 4 6 8' -- "$cur") )
+ COMPREPLY=($(compgen -W '2 4 6 8' -- "$cur"))
return
;;
- -aspect|-monitoraspect)
- COMPREPLY=( $(compgen -W '1:1 3:2 4:3 5:4 14:9 14:10 16:9 16:10
- 2.35:1' -- "$cur") )
+ -aspect | -monitoraspect)
+ COMPREPLY=($(compgen -W '1:1 3:2 4:3 5:4 14:9 14:10 16:9 16:10
+ 2.35:1' -- "$cur"))
__ltrim_colon_completions "$cur"
return
;;
-lavdopts)
- COMPREPLY=( $(compgen -W 'bitexact bug= debug= ec= er= fast gray
+ COMPREPLY=($(compgen -W 'bitexact bug= debug= ec= er= fast gray
idct= lowres= sb= st= skiploopfilter= skipidct= skipframe=
- threads= vismv= vstats' -- "$cur") )
+ threads= vismv= vstats' -- "$cur"))
return
;;
-lavcopts)
- COMPREPLY=( $(compgen -W 'vcodec= vqmin= vqscale= vqmax= mbqmin=
+ COMPREPLY=($(compgen -W 'vcodec= vqmin= vqscale= vqmax= mbqmin=
mbqmax= vqdiff= vmax_b_frames= vme= vhq v4mv keyint=
vb_strategy= vpass= aspect= vbitrate= vratetol= vrc_maxrate=
vrc_minrate= vrc_buf_size= vb_qfactor= vi_qfactor= vb_qoffset=
@@ -162,120 +161,120 @@ _mplayer()
vpsize= gray vfdct= idct= lumi_mask= dark_mask= tcplx_mask=
scplx_mask= naq ildct format= pred qpel precmp= cmp= subcmp=
predia= dia= trell last_pred= preme= subq= psnr mpeg_quant aic
- umv' -- "$cur") )
+ umv' -- "$cur"))
return
;;
-ssf)
- COMPREPLY=( $(compgen -W 'lgb= cgb= ls= cs= chs= cvs=' -- "$cur") )
+ COMPREPLY=($(compgen -W 'lgb= cgb= ls= cs= chs= cvs=' -- "$cur"))
return
;;
-jpeg)
- COMPREPLY=( $(compgen -W 'noprogressive progressive nobaseline
- baseline optimize= smooth= quality= outdir=' -- "$cur") )
+ COMPREPLY=($(compgen -W 'noprogressive progressive nobaseline
+ baseline optimize= smooth= quality= outdir=' -- "$cur"))
return
;;
-xvidopts)
- COMPREPLY=( $(compgen -W 'dr2 nodr2' -- "$cur") )
+ COMPREPLY=($(compgen -W 'dr2 nodr2' -- "$cur"))
return
;;
-xvidencopts)
- COMPREPLY=( $(compgen -W 'pass= bitrate= fixed_quant= me_quality=
+ COMPREPLY=($(compgen -W 'pass= bitrate= fixed_quant= me_quality=
4mv rc_reaction_delay_factor= rc_averaging_period= rc_buffer=
quant_range= min_key_interval= max_key_interval= mpeg_quant
mod_quant lumi_mask hintedme hintfile debug keyframe_boost=
- kfthreshold= kfreduction=' -- "$cur") )
+ kfthreshold= kfreduction=' -- "$cur"))
return
;;
-divx4opts)
- COMPREPLY=( $(compgen -W 'br= key= deinterlace q= min_quant=
+ COMPREPLY=($(compgen -W 'br= key= deinterlace q= min_quant=
max_quant= rc_period= rc_reaction_period= crispness=
- rc_reaction_ratio= pass= vbrpass= help' -- "$cur") )
+ rc_reaction_ratio= pass= vbrpass= help' -- "$cur"))
return
;;
-info)
- COMPREPLY=( $(compgen -W 'name= artist= genre= subject=
- copyright= srcform= comment= help' -- "$cur") )
+ COMPREPLY=($(compgen -W 'name= artist= genre= subject=
+ copyright= srcform= comment= help' -- "$cur"))
return
;;
-lameopts)
- COMPREPLY=( $(compgen -W 'vbr= abr cbr br= q= aq= ratio= vol=
- mode= padding= fast preset= help' -- "$cur") )
+ COMPREPLY=($(compgen -W 'vbr= abr cbr br= q= aq= ratio= vol=
+ mode= padding= fast preset= help' -- "$cur"))
return
;;
-rawaudio)
- COMPREPLY=( $(compgen -W 'on channels= rate= samplesize= format=' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W 'on channels= rate= samplesize= format=' \
+ -- "$cur"))
return
;;
-rawvideo)
- COMPREPLY=( $(compgen -W 'on fps= sqcif qcif cif 4cif pal ntsc w=
- h= y420 yv12 yuy2 y8 format= size=' -- "$cur") )
+ COMPREPLY=($(compgen -W 'on fps= sqcif qcif cif 4cif pal ntsc w=
+ h= y420 yv12 yuy2 y8 format= size=' -- "$cur"))
return
;;
-aop)
- COMPREPLY=( $(compgen -W 'list= delay= format= fout= volume= mul=
- softclip' -- "$cur") )
+ COMPREPLY=($(compgen -W 'list= delay= format= fout= volume= mul=
+ softclip' -- "$cur"))
return
;;
-dxr2)
- COMPREPLY=( $(compgen -W 'ar-mode= iec958-encoded iec958-decoded
+ COMPREPLY=($(compgen -W 'ar-mode= iec958-encoded iec958-decoded
mute ucode= 75ire bw color interlaced macrovision= norm=
square-pixel ccir601-pixel cr-left= cr-right= cr-top= cr-bot=
ck-rmin= ck-gmin= ck-bmin= ck-rmax= ck-gmax= ck-bmax= ck-r=
ck-g= ck-b= ignore-cache= ol-osd= olh-cor= olw-cor= olx-cor=
- oly-cor= overlay overlay-ratio= update-cache' -- "$cur") )
+ oly-cor= overlay overlay-ratio= update-cache' -- "$cur"))
return
;;
-tv)
- COMPREPLY=( $(compgen -W 'on noaudio driver= device= input= freq=
+ COMPREPLY=($(compgen -W 'on noaudio driver= device= input= freq=
outfmt= width= height= buffersize= norm= channel= chanlist=
audiorate= forceaudio alsa amode= forcechan= adevice= audioid=
volume= bass= treble= balance= fps= channels= immediatemode=' \
- -- "$cur") )
+ -- "$cur"))
return
;;
-mf)
- COMPREPLY=( $(compgen -W 'on w= h= fps= type=' -- "$cur") )
+ COMPREPLY=($(compgen -W 'on w= h= fps= type=' -- "$cur"))
return
;;
-cdda)
- COMPREPLY=( $(compgen -W 'speed= paranoia= generic-dev=
+ COMPREPLY=($(compgen -W 'speed= paranoia= generic-dev=
sector-size= overlap= toc-bias toc-offset= skip noskip' \
- -- "$cur") )
+ -- "$cur"))
return
;;
-input)
- COMPREPLY=( $(compgen -W 'conf= ar-delay ar-rate keylist cmdlist
- js-dev file' -- "$cur") )
+ COMPREPLY=($(compgen -W 'conf= ar-delay ar-rate keylist cmdlist
+ js-dev file' -- "$cur"))
return
;;
-af-adv)
- COMPREPLY=( $(compgen -W 'force= list=' -- "$cur") )
+ COMPREPLY=($(compgen -W 'force= list=' -- "$cur"))
return
;;
-noconfig)
- COMPREPLY=( $(compgen -W 'all gui system user' -- "$cur") )
+ COMPREPLY=($(compgen -W 'all gui system user' -- "$cur"))
return
;;
-*)
# Assume arg is required for everything else except options
# for which -list-options says Type is Flag or Print.
- $cmd -noconfig all -list-options 2>/dev/null \
- | while read -r i j k; do
- if [[ $i == ${prev#-} ]]; then
- [[ ${j,,} != @(flag|print) ]] && return 1
- break
- fi
- done || return
+ $cmd -noconfig all -list-options 2>/dev/null |
+ while read -r i j k; do
+ if [[ $i == "${prev#-}" ]]; then
+ [[ ${j,,} != @(flag|print) ]] && return 1
+ break
+ fi
+ done || return
;;
esac
case $cur in
-*)
- COMPREPLY=( $(compgen -W '$($cmd -noconfig all -list-options 2>/dev/null | \
- command sed -ne '1,/^[[:space:]]*Name/d' \
+ COMPREPLY=($(compgen -W '$($cmd -noconfig all -list-options 2>/dev/null | \
+ command sed -ne "1,/^[[:space:]]*Name/d" \
-e "s/^[[:space:]]*/-/" -e "s/[[:space:]:].*//" \
- -e "/^-\(Total\|.*\*\)\{0,1\}$/!p")' -- "$cur") )
+ -e "/^-\(Total\|.*\*\)\{0,1\}$/!p")' -- "$cur"))
;;
*)
_filedir '@(m?(j)p?(e)g|M?(J)P?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|vob|VOB|bin|BIN|dat|DAT|vcd|VCD|ps|PS|pes|PES|fl[iv]|FL[IV]|fxm|FXM|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|og[gmavx]|OG[GMAVX]|w?(a)v|W?(A)V|dump|DUMP|mk[av]|MK[AV]|aac|AAC|m2v|M2V|dv|DV|rmvb|RMVB|mid|MID|t[ps]|T[PS]|3g[p2]|3gpp?(2)|mpc|MPC|flac|FLAC|vro|VRO|divx|DIVX|aif?(f)|AIF?(F)|m2t?(s)|M2T?(S)|mts|MTS|vdr|VDR|xvid|XVID|ape|APE|gif|GIF|nut|NUT|bik|BIK|web[am]|WEB[AM]|amr|AMR|awb|AWB|iso|ISO|opus|OPUS|m[eo]d|M[EO]D|xm|XM|it|IT|s[t3]m|S[T3]M|mtm|MTM|w64|W64)?(.@(crdownload|part))'
@@ -283,6 +282,6 @@ _mplayer()
esac
} &&
-complete -F _mplayer mplayer mplayer2 mencoder gmplayer kplayer
+ complete -F _mplayer mplayer mplayer2 mencoder gmplayer kplayer
# ex: filetype=sh
diff --git a/completions/mr b/completions/mr
index 15f634a3..930e3c96 100644
--- a/completions/mr
+++ b/completions/mr
@@ -1,6 +1,7 @@
# mr completion -*- shell-script -*-
-_mr() {
+_mr()
+{
local cur prev words cword
_init_completion || return
@@ -8,7 +9,11 @@ _mr() {
help="$(PERLDOC_PAGER=cat PERLDOC=-otext "${1}" help 2>/dev/null)"
- commands="$(awk '/\[options\]/ { print $3 }' <<<"${help}")"
+ commands="$(
+ printf %s "$help" | while read -r _ options cmd _; do
+ [[ $options != "[options]" ]] || printf "%s\n" "$cmd"
+ done
+ )"
# Split [online|offline] and remove `action` placeholder.
commands="${commands//@(action|[\[\|\]])/$'\n'}"
# Add standard aliases.
@@ -17,7 +22,7 @@ _mr() {
# Determine if user has entered an `mr` command. Used to block top-level
# (option and command) completions.
local cmd i
- for (( i=0; i < ${#words[@]}-1; i++ )); do
+ for ((i = 1; i < ${#words[@]} - 1; i++)); do
if [[ $commands == *"${words[i]}"* ]]; then
cmd="${words[i]}"
break
@@ -25,30 +30,30 @@ _mr() {
done
# Complete options for specific commands.
- if [[ -n $cmd ]]; then
+ if [[ -v cmd ]]; then
case $cmd in
bootstrap)
_filedir
# Also complete stdin (-) as a potential bootstrap source.
- if [[ -z "${cur}" || $cur == - ]] && [[ $prev != - ]]; then
- COMPREPLY+=( - )
+ if [[ -z ${cur} || $cur == - ]] && [[ $prev != - ]]; then
+ COMPREPLY+=(-)
fi
return
;;
clean)
- if [[ "${cur}" == -* ]]; then
- COMPREPLY=( $(compgen -W '-f' -- "${cur}") )
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=($(compgen -W '-f' -- "${cur}"))
fi
return
;;
- commit|ci|record)
- if [[ "${cur}" == -* ]]; then
- COMPREPLY=( $(compgen -W '-m' -- "${cur}") )
+ commit | ci | record)
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=($(compgen -W '-m' -- "${cur}"))
fi
return
;;
run)
- COMPREPLY=( $(compgen -c -- "${cur}") )
+ COMPREPLY=($(compgen -c -- "${cur}"))
return
;;
*)
@@ -60,27 +65,27 @@ _mr() {
# Complete top-level options and commands.
case $prev in
- --config|-!(-*)c)
+ --config | -!(-*)c)
_filedir
return
;;
- --directory|-!(-*)d)
+ --directory | -!(-*)d)
_filedir -d
return
;;
esac
if [[ $cur == -* ]]; then
- options="$(_parse_help - <<<"${help}")"
+ options="$(printf '%s\n' "$help" | _parse_help -)"
# Remove short options (all have compatible long options).
options="${options//-[a-z]$'\n'/}"
# Remove deprecated options.
options="${options//--path/}"
- COMPREPLY=( $(compgen -W "${options}" -- "${cur}") )
+ COMPREPLY=($(compgen -W "${options}" -- "${cur}"))
else
- COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+ COMPREPLY=($(compgen -W "${commands}" -- "${cur}"))
fi
} &&
-complete -F _mr mr
+ complete -F _mr mr
# ex: filetype=sh
diff --git a/completions/msynctool b/completions/msynctool
index 4fd51618..4de37f5b 100644
--- a/completions/msynctool
+++ b/completions/msynctool
@@ -7,36 +7,36 @@ _msynctool()
case $words in
--configure)
- COMPREPLY=( $(compgen -W "$($1 --showgroup \
+ COMPREPLY=($(compgen -W "$($1 --showgroup \
$prev | awk '/^Member/ {print $2}' | command sed \
- -e 's/:$//')" -- "$cur") )
+ -e 's/:$//')" -- "$cur"))
return
;;
--addmember)
- COMPREPLY=( $(compgen -W '$($1 --listplugins \
- | command sed -e 1d)' -- "$cur") )
+ COMPREPLY=($(compgen -W '$($1 --listplugins \
+ | command sed -e 1d)' -- "$cur"))
return
;;
esac
case $prev in
- --configure|--addgroup|--delgroup|--showgroup|--sync|--addmember)
- COMPREPLY=( $(compgen -W '$($1 --listgroups \
- | command sed -e 1d)' -- "$cur") )
+ --configure | --addgroup | --delgroup | --showgroup | --sync | --addmember)
+ COMPREPLY=($(compgen -W '$($1 --listgroups \
+ | command sed -e 1d)' -- "$cur"))
return
;;
- --showformats|--filter-objtype|--slow-sync)
- COMPREPLY=( $(compgen -W '$($1 --listobjects \
- | command sed -e 1d)' -- "$cur") )
+ --showformats | --filter-objtype | --slow-sync)
+ COMPREPLY=($(compgen -W '$($1 --listobjects \
+ | command sed -e 1d)' -- "$cur"))
return
;;
esac
- COMPREPLY=( $(compgen -W '--listgroups --listplugins --listobjects
+ COMPREPLY=($(compgen -W '--listgroups --listplugins --listobjects
--showformats --showgroup --sync --filter-objtype --slow-sync --wait
--multi --addgroup --delgroup --addmember --configure --manual
- --configdir --conflict' -- "$cur") )
+ --configdir --conflict' -- "$cur"))
} &&
-complete -F _msynctool msynctool
+ complete -F _msynctool msynctool
# ex: filetype=sh
diff --git a/completions/mtx b/completions/mtx
index 9266687c..b5c270bd 100644
--- a/completions/mtx
+++ b/completions/mtx
@@ -11,22 +11,22 @@ _mtx()
options="-f nobarcode invert noattach --version inquiry noattach \
inventory status load unload eepos first last next"
- tapes=$(mtx status 2>/dev/null | \
+ tapes=$(mtx status 2>/dev/null |
awk '/Storage Element [0-9]+:Full/ { printf "%s ", $3 }')
- tapes=${tapes//:Full}
+ tapes=${tapes//:Full/}
- drives=$(mtx status 2>/dev/null | \
+ drives=$(mtx status 2>/dev/null |
awk '/Data Transfer Element [0-9]+:(Full|Empty)/ { printf "%s ", $4 }')
- drives=${drives//:Full}
- drives=${drives//:Empty}
+ drives=${drives//:Full/}
+ drives=${drives//:Empty/}
- if [[ $cword -gt 1 ]]; then
+ if ((cword > 1)); then
case $prev in
load)
- COMPREPLY=( $(compgen -W "$tapes" -- "$cur") )
+ COMPREPLY=($(compgen -W "$tapes" -- "$cur"))
;;
- unload|first|last|next)
- COMPREPLY=( $(compgen -W "$drives" -- "$cur") )
+ unload | first | last | next)
+ COMPREPLY=($(compgen -W "$drives" -- "$cur"))
;;
-f)
true
@@ -36,9 +36,9 @@ _mtx()
;;
esac
else
- COMPREPLY=( $(compgen -W "$options" -- "$cur") )
+ COMPREPLY=($(compgen -W "$options" -- "$cur"))
fi
} &&
-complete -F _mtx mtx
+ complete -F _mtx mtx
# ex: filetype=sh
diff --git a/completions/munin-node-configure b/completions/munin-node-configure
index 1d564d3f..39d8d64b 100644
--- a/completions/munin-node-configure
+++ b/completions/munin-node-configure
@@ -10,7 +10,7 @@ _munin_node_configure()
_filedir
return
;;
- --servicedir|--libdir)
+ --servicedir | --libdir)
_filedir -d
return
;;
@@ -19,15 +19,15 @@ _munin_node_configure()
return
;;
--snmpversion)
- COMPREPLY=( $(compgen -W '1 2c 3' -- "$cur") )
+ COMPREPLY=($(compgen -W '1 2c 3' -- "$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 _munin_node_configure munin-node-configure
+ complete -F _munin_node_configure munin-node-configure
# ex: filetype=sh
diff --git a/completions/munin-run b/completions/munin-run
index 6855e02d..97e526aa 100644
--- a/completions/munin-run
+++ b/completions/munin-run
@@ -6,23 +6,23 @@ _munin_run()
_init_completion || return
case $prev in
- --config|--sconffile)
+ --config | --sconffile)
_filedir
return
;;
- --servicedir|--sconfdir)
+ --servicedir | --sconfdir)
_filedir -d
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 \
- '$(command ls /etc/munin/plugins 2>/dev/null)' -- "$cur") )
+ COMPREPLY=($(compgen -W \
+ '$(command ls /etc/munin/plugins 2>/dev/null)' -- "$cur"))
fi
} &&
-complete -F _munin_run munin-run
+ complete -F _munin_run munin-run
# ex: filetype=sh
diff --git a/completions/munin-update b/completions/munin-update
index ac770a6b..8766eaee 100644
--- a/completions/munin-update
+++ b/completions/munin-update
@@ -16,12 +16,12 @@ _munin_update()
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '--force-root --noforce-root --service --host
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '--force-root --noforce-root --service --host
--config --help --debug --nodebug --fork --nofork --stdout
- --nostdout --timeout' -- "$cur") )
+ --nostdout --timeout' -- "$cur"))
fi
} &&
-complete -F _munin_update munin-update
+ complete -F _munin_update munin-update
# ex: filetype=sh
diff --git a/completions/munindoc b/completions/munindoc
index a08399ba..5c7644a6 100644
--- a/completions/munindoc
+++ b/completions/munindoc
@@ -5,9 +5,9 @@ _munindoc()
local cur prev words cword
_init_completion || return
- COMPREPLY=( $(compgen -W \
- '$(command ls /usr/share/munin/plugins 2>/dev/null)' -- "$cur") )
+ COMPREPLY=($(compgen -W \
+ '$(command ls /usr/share/munin/plugins 2>/dev/null)' -- "$cur"))
} &&
-complete -F _munindoc munindoc
+ complete -F _munindoc munindoc
# ex: filetype=sh
diff --git a/completions/mussh b/completions/mussh
index e76817c7..c2f7a522 100644
--- a/completions/mussh
+++ b/completions/mussh
@@ -6,47 +6,47 @@ _mussh()
_init_completion || return
case $prev in
- --help|-V|-m|-t)
+ --help | -V | -m | -t)
return
;;
-d)
- COMPREPLY=( $(compgen -W '{0..2}' -- "$cur") )
+ COMPREPLY=($(compgen -W '{0..2}' -- "$cur"))
return
;;
-v)
- COMPREPLY=( $(compgen -W '{0..3}' -- "$cur") )
+ COMPREPLY=($(compgen -W '{0..3}' -- "$cur"))
return
;;
- -i|-H|-C)
+ -i | -H | -C)
_filedir
return
;;
- -o|-po)
+ -o | -po)
_xfunc ssh _ssh_options
return
;;
- -l|-L)
- COMPREPLY=( $(compgen -u -- "$cur") )
+ -l | -L)
+ COMPREPLY=($(compgen -u -- "$cur"))
return
;;
-s)
_shells
return
;;
- -p|-h)
+ -p | -h)
[[ $cur == *@* ]] && _user_at_host || _known_hosts_real -a -- "$cur"
return
;;
-c)
compopt -o filenames
- COMPREPLY+=( $(compgen -c -- "$cur") )
+ COMPREPLY+=($(compgen -c -- "$cur"))
return
;;
esac
- [[ $cur != -* ]] || \
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ [[ $cur != -* ]] ||
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
} &&
-complete -F _mussh mussh
+ complete -F _mussh mussh
# ex: filetype=sh
diff --git a/completions/mutt b/completions/mutt
index 43a8842e..1161487a 100644
--- a/completions/mutt
+++ b/completions/mutt
@@ -9,19 +9,18 @@ _muttaddr()
_muttaliases "$1"
_muttquery "$1"
- COMPREPLY+=( $(compgen -u -- "$1") )
+ COMPREPLY+=($(compgen -u -- "$1"))
}
-
# Find muttrc to use
# @output muttrc filename
_muttrc()
{
# Search COMP_WORDS for '-F muttrc' or '-Fmuttrc' argument
set -- "${words[@]}"
- while [[ $# -gt 0 ]]; do
+ while (($# > 0)); do
if [[ $1 == -F* ]]; then
- if [[ ${#1} -gt 2 ]]; then
+ if ((${#1} > 2)); then
muttrc="$(dequote "${1:2}")"
else
shift
@@ -32,17 +31,16 @@ _muttrc()
shift
done
- if [[ -z $muttrc ]]; then
+ if [[ ! -v muttrc ]]; then
if [[ -f ~/.${muttcmd}rc ]]; then
- muttrc="~/.${muttcmd}rc"
+ muttrc=\~/.${muttcmd}rc
elif [[ -f ~/.${muttcmd}/${muttcmd}rc ]]; then
- muttrc="~/.${muttcmd}/${muttcmd}rc"
+ muttrc=\~/.${muttcmd}/${muttcmd}rc
fi
fi
- printf "%s" "$muttrc"
+ printf "%s" "${muttrc-}"
}
-
# Recursively build list of sourced config files
# @param $1 List of config files found so far
# @param $2 Config file to process
@@ -54,11 +52,11 @@ _muttconffiles()
sofar=" $1 "
shift
- while [[ "$1" ]]; do
- newconffiles=( $(command sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' $(eval printf %s $1) ) )
- for file in "${newconffiles[@]}"; do
+ while [[ ${1-} ]]; do
+ newconffiles=($(command sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' "$(eval printf %s $1)"))
+ for file in ${newconffiles+"${newconffiles[@]}"}; do
__expand_tilde_by_ref file
- [[ ! -f "$file" || $sofar == *\ $file\ * ]] && continue
+ [[ ! -f $file || $sofar == *\ $file\ * ]] && continue
sofar+=" $file"
sofar=" $(eval _muttconffiles \"$sofar\" $file) "
done
@@ -67,7 +65,6 @@ _muttconffiles()
printf '%s\n' $sofar
}
-
# @param $1 (cur) Current word to complete
_muttaliases()
{
@@ -77,13 +74,13 @@ _muttaliases()
muttrc=$(_muttrc)
[[ -z $muttrc ]] && return
- conffiles=( $(eval _muttconffiles $muttrc $muttrc) )
- aliases=( $(command sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' \
- $(eval echo "${conffiles[@]}")) )
- COMPREPLY+=( $(compgen -W "${aliases[*]}" -- "$cur") )
+ conffiles=($(eval _muttconffiles $muttrc $muttrc))
+ # shellcheck disable=SC2046
+ aliases=("$(command sed -n 's|^alias[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' \
+ $(eval echo "${conffiles[@]}"))")
+ COMPREPLY+=($(compgen -W "${aliases[*]}" -- "$cur"))
}
-
# @param $1 (cur) Current word to complete
_muttquery()
{
@@ -91,18 +88,17 @@ _muttquery()
local -a queryresults
querycmd="$($muttcmd -Q query_command 2>/dev/null | command sed -e 's|^query_command=\"\(.*\)\"$|\1|' -e 's|%s|'$cur'|')"
- if [[ -z "$cur" || -z "$querycmd" ]]; then
+ if [[ -z $cur || -z $querycmd ]]; then
queryresults=()
else
__expand_tilde_by_ref querycmd
- queryresults=( $($querycmd | \
- command sed -n '2,$s|^\([^[:space:]]\{1,\}\).*|\1|p') )
+ queryresults=($($querycmd |
+ command sed -n '2,$s|^\([^[:space:]]\{1,\}\).*|\1|p'))
fi
- COMPREPLY+=( $(compgen -W "${queryresults[*]}" -- "$cur") )
+ COMPREPLY+=($(compgen -W "${queryresults[*]}" -- "$cur"))
}
-
# @param $1 (cur) Current word to complete
_muttfiledir()
{
@@ -116,50 +112,49 @@ _muttfiledir()
# Match any file in $folder beginning with $cur
# (minus the leading '=' sign).
compopt -o filenames
- COMPREPLY=( $(compgen -f -- "$folder/${cur:1}") )
- COMPREPLY=( ${COMPREPLY[@]#$folder/} )
+ COMPREPLY=($(compgen -f -- "$folder/${cur:1}"))
+ COMPREPLY=(${COMPREPLY[@]#$folder/})
return
elif [[ $cur == !* ]]; then
- spoolfile="$($muttcmd -F "$muttrc" -Q spoolfile 2>/dev/null | \
+ spoolfile="$($muttcmd -F "$muttrc" -Q spoolfile 2>/dev/null |
command sed -e 's|^spoolfile=\"\(.*\)\"$|\1|')"
- [[ ! -z $spoolfile ]] && eval cur="${cur/^!/$spoolfile}"
+ [[ -n $spoolfile ]] && eval cur="${cur/^!/$spoolfile}"
fi
_filedir
}
-
_mutt()
{
local cur prev words cword
_init_completion -n =+! || return
case $cur in
- -*)
- COMPREPLY=( $(compgen -W '-A -a -b -c -e -f -F -H -i -m -n -p -Q -R -s
- -v -x -y -z -Z -h' -- "$cur") )
- return
- ;;
- *)
- case $prev in
- -*[afFHi])
- _muttfiledir "$cur"
- return
- ;;
- -*A)
- _muttaliases "$cur"
- return
- ;;
- -*[emQshpRvyzZ])
+ -*)
+ COMPREPLY=($(compgen -W '-A -a -b -c -e -f -F -H -i -m -n -p -Q -R -s
+ -v -x -y -z -Z -h' -- "$cur"))
return
;;
*)
- _muttaddr "$cur"
- return
+ case $prev in
+ -*[afFHi])
+ _muttfiledir "$cur"
+ return
+ ;;
+ -*A)
+ _muttaliases "$cur"
+ return
+ ;;
+ -*[emQshpRvyzZ])
+ return
+ ;;
+ *)
+ _muttaddr "$cur"
+ return
+ ;;
+ esac
;;
- esac
- ;;
esac
} &&
-complete -F _mutt -o default mutt muttng
+ complete -F _mutt -o default mutt muttng
# ex: filetype=sh
diff --git a/completions/mypy b/completions/mypy
index 82da1f08..534d5755 100644
--- a/completions/mypy
+++ b/completions/mypy
@@ -5,12 +5,12 @@ _mypy()
local cur prev words cword split
_init_completion -s || return
- [[ $cword -gt 2 && ${words[cword-2]} == --shadow-file ]] && \
- prev=--shadow-file # hack; takes two args
+ [[ $cword -gt 2 && ${words[cword - 2]} == --shadow-file ]] &&
+ prev=--shadow-file # hack; takes two args
case $prev in
- --help|--version|--python-version|--platform|--always-true|\
- --always-false|--find-occurrences|--package|--command|-!(-*)[hVpc])
+ --help | --version | --python-version | --platform | --always-true | \
+ --always-false | --find-occurrences | --package | --command | -!(-*)[hVpc])
return
;;
--config-file)
@@ -18,18 +18,18 @@ _mypy()
return
;;
--follow-imports)
- COMPREPLY=( $(compgen -W 'normal silent skip error' -- "$cur") )
+ COMPREPLY=($(compgen -W 'normal silent skip error' -- "$cur"))
return
;;
--python-executable)
- COMPREPLY=( $(compgen -c -- "${cur:-py}") )
+ COMPREPLY=($(compgen -c -- "${cur:-py}"))
return
;;
- --*-dir|--*-report)
+ --*-dir | --*-report)
_filedir -d
return
;;
- --custom-typing|--module|-!(-*)m)
+ --custom-typing | --module | -!(-*)m)
_xfunc python _python_modules
return
;;
@@ -46,12 +46,12 @@ _mypy()
$split && return
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
return
fi
_filedir '@(py|pyi)'
} &&
-complete -F _mypy mypy
+ complete -F _mypy mypy
# ex: filetype=sh
diff --git a/completions/mysql b/completions/mysql
index ffb4bcd7..93631332 100644
--- a/completions/mysql
+++ b/completions/mysql
@@ -2,12 +2,13 @@
_mysql_character_sets()
{
- local IFS=$' \t\n' reset=$(shopt -p failglob); shopt -u failglob
- local -a charsets=( /usr/share/m{ariadb,ysql}/charsets/*.xml )
+ local IFS=$' \t\n' reset=$(shopt -p failglob)
+ shopt -u failglob
+ local -a charsets=(/usr/share/m{ariadb,ysql}/charsets/*.xml)
$reset
- charsets=( "${charsets[@]##*/}" )
- charsets=( "${charsets[@]%%?(Index|\*).xml}" utf8 )
- COMPREPLY+=( $(compgen -W '${charsets[@]}' -- "$cur") )
+ charsets=("${charsets[@]##*/}")
+ charsets=("${charsets[@]%%?(Index|\*).xml}" utf8)
+ COMPREPLY+=($(compgen -W '${charsets[@]}' -- "$cur"))
}
_mysql()
@@ -16,16 +17,16 @@ _mysql()
_init_completion -s || return
case $prev in
- --user|-!(-*)u)
- COMPREPLY=( $(compgen -u -- "$cur") )
+ --user | -!(-*)u)
+ COMPREPLY=($(compgen -u -- "$cur"))
return
;;
- --database|-!(-*)D)
- COMPREPLY=( $(compgen -W "$(mysqlshow 2>/dev/null | command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" -- "$cur") )
+ --database | -!(-*)D)
+ COMPREPLY=($(compgen -W "$(mysqlshow 2>/dev/null | command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" -- "$cur"))
return
;;
- --host|-!(-*)h)
+ --host | -!(-*)h)
_known_hosts_real -- "$cur"
return
;;
@@ -34,23 +35,23 @@ _mysql()
return
;;
- --character-sets-dir|--ssl-capath)
+ --character-sets-dir | --ssl-capath)
_filedir -d
return
;;
- --socket|-!(-*)S)
+ --socket | -!(-*)S)
_filedir sock
return
;;
--protocol)
- COMPREPLY=( $(compgen -W 'tcp socket pipe memory' -- "$cur") )
+ COMPREPLY=($(compgen -W 'tcp socket pipe memory' -- "$cur"))
return
;;
- --defaults-file|--defaults-extra-file|--tee)
+ --defaults-file | --defaults-extra-file | --tee)
_filedir
return
;;
- --ssl-ca|--ssl-cert)
+ --ssl-ca | --ssl-cert)
_filedir '@(pem|cer|c?(e)rt)'
return
;;
@@ -58,13 +59,13 @@ _mysql()
_filedir '@(pem|key)'
return
;;
- --port|--set-variable|--ssl-cipher|--connect_timeout|\
- --max_allowed_packet|--prompt|--net_buffer_length|--select_limit|\
- --max_join_size|--server-arg|--debug|--delimiter|--execute|--pager|\
- -!(-*)[Pe])
+ --port | --set-variable | --ssl-cipher | --connect_timeout | \
+ --max_allowed_packet | --prompt | --net_buffer_length | --select_limit | \
+ --max_join_size | --server-arg | --debug | --delimiter | --execute | --pager | \
+ -!(-*)[Pe])
return
;;
- --help|--version|-!(-*)[?IV])
+ --help | --version | -!(-*)[?IV])
return
;;
esac
@@ -76,23 +77,23 @@ _mysql()
local help=$(_parse_help "$1")
help+=" --skip-comments --skip-ssl"
- COMPREPLY=( $(compgen -W "$help" -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ COMPREPLY=($(compgen -W "$help" -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
;;
# only complete long options
-)
compopt -o nospace
- COMPREPLY=( -- )
+ COMPREPLY=(--)
return
;;
esac
- COMPREPLY=( $(compgen -W \
+ COMPREPLY=($(compgen -W \
"$(mysqlshow 2>/dev/null | command sed -ne '2d' -e 's/^|.\([^|]*\)|.*/\1/p')" \
- -- "$cur") )
+ -- "$cur"))
} &&
-complete -F _mysql mysql
+ complete -F _mysql mysql
# ex: filetype=sh
diff --git a/completions/mysqladmin b/completions/mysqladmin
index 1e34a34d..53295340 100644
--- a/completions/mysqladmin
+++ b/completions/mysqladmin
@@ -6,15 +6,15 @@ _mysqladmin()
_init_completion -s || return
case $prev in
- --user|-!(-*)u)
- COMPREPLY=( $(compgen -u -- "$cur") )
+ --user | -!(-*)u)
+ COMPREPLY=($(compgen -u -- "$cur"))
return
;;
- --host|-!(-*)h)
+ --host | -!(-*)h)
_known_hosts_real -- "$cur"
return
;;
- --character-sets-dir|--ssl-capath)
+ --character-sets-dir | --ssl-capath)
_filedir -d
return
;;
@@ -22,15 +22,15 @@ _mysqladmin()
_xfunc mysql _mysql_character_sets
return
;;
- --socket|-!(-*)S)
+ --socket | -!(-*)S)
_filedir sock
return
;;
- --defaults-file|--defaults-extra-file)
+ --defaults-file | --defaults-extra-file)
_filedir
return
;;
- --ssl-ca|--ssl-cert)
+ --ssl-ca | --ssl-cert)
_filedir '@(pem|cer|c?(e)rt)'
return
;;
@@ -38,26 +38,26 @@ _mysqladmin()
_filedir '@(pem|key)'
return
;;
- --count|--port|--set-variable|--sleep|--ssl-cipher|--wait|\
- --connect_timeout|--shutdown_timeout|-!(-*)[cPOiw])
+ --count | --port | --set-variable | --sleep | --ssl-cipher | --wait | \
+ --connect_timeout | --shutdown_timeout | -!(-*)[cPOiw])
return
;;
- --help|--version|-!(-*)[?V])
+ --help | --version | -!(-*)[?V])
return
;;
esac
$split && return
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
- COMPREPLY+=( $(compgen -W 'create debug drop extended-status flush-hosts
+ COMPREPLY+=($(compgen -W 'create debug drop extended-status flush-hosts
flush-logs flush-status flush-tables flush-threads flush-privileges
kill password old-password ping processlist reload refresh shutdown
- status start-slave stop-slave variables version' -- "$cur") )
+ status start-slave stop-slave variables version' -- "$cur"))
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
} &&
-complete -F _mysqladmin mysqladmin
+ complete -F _mysqladmin mysqladmin
# ex: filetype=sh
diff --git a/completions/nc b/completions/nc
index 0ba61808..6fb09943 100644
--- a/completions/nc
+++ b/completions/nc
@@ -10,7 +10,7 @@ _nc()
return
;;
-*s)
- if [[ "${words[*]}" == *-6* ]]; then
+ if [[ ${words[*]} == *-6* ]]; then
_ip_addresses -6
__ltrim_colon_completions "$cur"
else
@@ -19,13 +19,13 @@ _nc()
return
;;
-*T)
- COMPREPLY=( $(compgen -W 'critical inetcontrol lowcost lowdelay
+ COMPREPLY=($(compgen -W 'critical inetcontrol lowcost lowdelay
netcontrol throughput reliability ef af{11..43} cs{0..7}' \
- -- "$cur") )
+ -- "$cur"))
return
;;
-*X)
- COMPREPLY=( $(compgen -W '4 5 connect' -- "$cur") )
+ COMPREPLY=($(compgen -W '4 5 connect' -- "$cur"))
return
;;
-*x)
@@ -34,17 +34,18 @@ _nc()
;;
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
# Complete 1st non-option arg only
- local args; _count_args "" "-*[IiMmOPpqsTVWwXx]"
- [[ $args -eq 1 ]] || return
+ local args
+ _count_args "" "-*[IiMmOPpqsTVWwXx]"
+ ((args == 1)) || return
_known_hosts_real -- "$cur"
} &&
-complete -F _nc nc
+ complete -F _nc nc
# ex: filetype=sh
diff --git a/completions/ncftp b/completions/ncftp
index 35146f3c..c3f2cf15 100644
--- a/completions/ncftp
+++ b/completions/ncftp
@@ -6,22 +6,22 @@ _ncftp()
_init_completion || return
case $prev in
- -u|-p|-P|-j|-F)
+ -u | -p | -P | -j | -F)
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
if [[ $cword -eq 1 && -f ~/.ncftp/bookmarks ]]; then
- COMPREPLY=( $(compgen -W '$(command sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \
- ~/.ncftp/bookmarks)' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(command sed -ne "s/^\([^,]\{1,\}\),.*$/\1/p" \
+ ~/.ncftp/bookmarks)' -- "$cur"))
fi
} &&
-complete -F _ncftp -o default ncftp
+ complete -F _ncftp -o default ncftp
# ex: filetype=sh
diff --git a/completions/nethogs b/completions/nethogs
index 85fc1cb4..5cd3650e 100644
--- a/completions/nethogs
+++ b/completions/nethogs
@@ -8,19 +8,19 @@ _nethogs()
case "$prev" in
-d)
# expect integer value
- COMPREPLY+=( $(compgen -W '{0..9}') )
+ COMPREPLY+=($(compgen -W '{0..9}'))
compopt -o nospace
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
_available_interfaces -a
} &&
-complete -F _nethogs nethogs
+ complete -F _nethogs nethogs
# ex: filetype=sh
diff --git a/completions/newlist b/completions/newlist
index 793928c3..f1f6cf85 100644
--- a/completions/newlist
+++ b/completions/newlist
@@ -6,20 +6,20 @@ _newlist()
_init_completion -s || return
case $prev in
- -l|--language|-u|--urlhost|-e|--emailhost|--help)
+ -l | --language | -u | --urlhost | -e | --emailhost | --help)
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
_xfunc list_lists _mailman_lists
fi
} &&
-complete -F _newlist newlist
+ complete -F _newlist newlist
# ex: filetype=sh
diff --git a/completions/newusers b/completions/newusers
index b7792b54..890a5fcc 100644
--- a/completions/newusers
+++ b/completions/newusers
@@ -6,25 +6,25 @@ _newusers()
_init_completion -s || return
case $prev in
- -c|--crypt)
- COMPREPLY=( $(compgen -W 'DES MD5 NONE SHA256 SHA512' -- "$cur") )
+ -c | --crypt)
+ COMPREPLY=($(compgen -W 'DES MD5 NONE SHA256 SHA512' -- "$cur"))
return
;;
- -s|--sha-rounds)
+ -s | --sha-rounds)
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
_filedir
} &&
-complete -F _newusers newusers
+ complete -F _newusers newusers
# ex: filetype=sh
diff --git a/completions/ngrep b/completions/ngrep
index 65f4dc6d..7d16c8d6 100644
--- a/completions/ngrep
+++ b/completions/ngrep
@@ -6,20 +6,20 @@ _ngrep()
_init_completion || return
case $prev in
- -h|-V|-n|-A|-s|-S|-c|-P)
+ -h | -V | -n | -A | -s | -S | -c | -P)
return
;;
- -I|-O)
+ -I | -O)
_filedir 'pcap?(ng)'
return
;;
-d)
_available_interfaces -a
- COMPREPLY+=( $(compgen -W 'any' -- "$cur") )
+ COMPREPLY+=($(compgen -W 'any' -- "$cur"))
return
;;
-W)
- COMPREPLY=( $(compgen -W 'normal byline single none' -- "$cur") )
+ COMPREPLY=($(compgen -W 'normal byline single none' -- "$cur"))
return
;;
-F)
@@ -28,11 +28,11 @@ _ngrep()
;;
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
} &&
-complete -F _ngrep ngrep
+ complete -F _ngrep ngrep
# ex: filetype=sh
diff --git a/completions/nmap b/completions/nmap
index b4e76baf..482148e3 100644
--- a/completions/nmap
+++ b/completions/nmap
@@ -2,15 +2,15 @@
_nmap()
{
- local cur prev words cword
- _init_completion || return
+ local cur prev words cword split
+ _init_completion -s || return
case $prev in
- -iL|-oN|-oX|-oS|-oG|---excludefile|--resume|--stylesheet)
+ -iL | -oN | -oX | -oS | -oG | ---excludefile | --resume | --stylesheet)
_filedir
return
;;
- -oA|--datadir)
+ -oA | --datadir)
_filedir -d
return
;;
@@ -18,33 +18,39 @@ _nmap()
_available_interfaces -a
return
;;
- -b|--dns-servers)
+ -b | --dns-servers)
_known_hosts_real -- "$cur"
return
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '-iL -iR --exclude --excludefile -sL -sP -PN
- -PS -PA -PU -PY -PE -PP -PM -PO -n -R --dns-servers --system-dns
- --traceroute -sS -sT -sA -sW -sM -sU -sN -sF -sX --scanflags -sI
- -sY -sZ -sO -b -p -F -r --top-ports --port-ratio -sV
- --version-intensity --version-light --version-all --version-trace
- -sC --script= --script-args= --script-trace --script-updatedb -O
- --osscan-limit --osscan-guess -T0 -T1 -T2 -T3 -T4 -T5
- --min-hostgroup --max-hostgroup --min-parallelism --max-parallelism
- --min-rtt-timeout --max-rtt-timeout --initial-rtt-timeout
- --max-retries --host-timeout --scan-delay --max-scan-delay
- --min-rate --max-rate -f --mtu -D -S -e --source-port --data-length
- --ip-options --ttl --spoof-mac --badsum --adler32 -oN -oX -oS -oG
- -oA -v -d --reason --open --packet-trace --iflist --log-errors
- --append-output --resume --stylesheet --webxml --no-stylesheet -6
- -A --datadir --send-eth --send-ip --privilege--unprivileged -V
- -h' -- "$cur") )
+ $split && return
+
+ if [[ $cur == -* ]]; then
+ # strip everything following a :, inclusive
+ # strip everything following a =, exclusive
+ # expand -X; -Y to -X -Y
+ # expand -X/-Y/-Z to -X -Y -Z
+ # expand -X/Y/Z to -X -Y -Z
+ # expand --foo/bar to --foo --bar
+ # strip everything following a non-option name or = char
+ # TODO: should expand -T<0-5> to -T0 ... -T5
+ COMPREPLY=($(compgen -W "$(
+ "$1" --help 2>&1 | command sed \
+ -e "s/:.*$//" \
+ -e "s/=.*$/=/" \
+ -e "s/;[[:space:]]*-/ -/g" \
+ -e "s/\/-/ -/g" \
+ -e "/^[[:space:]]*-[^-]/s/\/\([^-]\)/ -\1/g" \
+ -e "/^[[:space:]]*--/s/\/\([^-]\)/ --\1/g" \
+ -e "s/[^[:space:]a-zA-Z0-9=-].*$//"
+ )" \
+ -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
_known_hosts_real -- "$cur"
fi
} &&
-complete -F _nmap nmap
+ complete -F _nmap nmap
# ex: filetype=sh
diff --git a/completions/nproc b/completions/nproc
index 84092679..50273f07 100644
--- a/completions/nproc
+++ b/completions/nproc
@@ -6,7 +6,7 @@ _nproc()
_init_completion -s || return
case $prev in
- --help|--version|--ignore)
+ --help | --version | --ignore)
return
;;
esac
@@ -14,10 +14,10 @@ _nproc()
$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 _nproc nproc
+ complete -F _nproc nproc
# ex: filetype=sh
diff --git a/completions/nslookup b/completions/nslookup
index 267d0c30..3341b1f6 100644
--- a/completions/nslookup
+++ b/completions/nslookup
@@ -2,15 +2,15 @@
_bind_queryclass()
{
- COMPREPLY+=( $(compgen -W 'IN CH HS ANY' -- "$cur") )
+ COMPREPLY+=($(compgen -W 'IN CH HS ANY' -- "$cur"))
}
_bind_querytype()
{
- # http://en.wikipedia.org/wiki/List_of_DNS_record_types
- COMPREPLY+=( $(compgen -W 'A AAAA AFSDB APL CERT CNAME DHCID DLV DNAME
+ # https://en.wikipedia.org/wiki/List_of_DNS_record_types
+ COMPREPLY+=($(compgen -W 'A AAAA AFSDB APL CERT CNAME DHCID DLV DNAME
DNSKEY DS HIP IPSECKEY KEY KX LOC MX NAPTR NS NSEC NSEC3 NSEC3PARAM PTR
- RRSIG RP SIG SOA SPF SRV SSHFP TXT' -- "$cur") )
+ RRSIG RP SIG SOA SPF SRV SSHFP TXT' -- "$cur"))
}
_nslookup()
@@ -19,12 +19,12 @@ _nslookup()
_init_completion -n = || return
case $cur in
- -class=*|-cl=*)
+ -class=* | -cl=*)
cur=${cur#*=}
_bind_queryclass
return
;;
- -querytype=*|-type=*|-q=*|-ty=*)
+ -querytype=* | -type=* | -q=* | -ty=*)
cur=${cur#*=}
_bind_querytype
return
@@ -35,21 +35,21 @@ _nslookup()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '-all -class= -debug -nodebug -d2 -nod2
+ COMPREPLY=($(compgen -W '-all -class= -debug -nodebug -d2 -nod2
-domain= -search -nosearch -port= -querytype= -recurse -norecurse
- -retry= -timeout= -vc -novc -fail -nofail' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ -retry= -timeout= -vc -novc -fail -nofail' -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
local args
_count_args =
- if [[ $args -le 2 ]]; then
+ if ((args <= 2)); then
_known_hosts_real -- "$cur"
- [[ $args -eq 1 && $cur == @(|-) ]] && COMPREPLY+=( - )
+ [[ $args -eq 1 && $cur == @(|-) ]] && COMPREPLY+=(-)
fi
} &&
-complete -F _nslookup nslookup
+ complete -F _nslookup nslookup
_host()
{
@@ -66,21 +66,21 @@ _host()
return
;;
-m)
- COMPREPLY=( $(compgen -W 'trace record usage' -- "$cur") )
+ COMPREPLY=($(compgen -W 'trace record usage' -- "$cur"))
return
;;
- -N|-R|-W)
+ -N | -R | -W)
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
return
fi
_known_hosts_real -- "$cur"
} &&
-complete -F _host host
+ complete -F _host host
# ex: filetype=sh
diff --git a/completions/nsupdate b/completions/nsupdate
index ff3b9a47..68df333e 100644
--- a/completions/nsupdate
+++ b/completions/nsupdate
@@ -20,21 +20,21 @@ _nsupdate()
;;
-*y)
if [[ $cur == h* ]]; then
- COMPREPLY=( $(compgen -W "hmac-{md5,sha{1,224,256,384,512}}" \
- -S : -- "$cur") )
- [[ $COMPREPLY == *: ]] && compopt -o nospace
+ COMPREPLY=($(compgen -W "hmac-{md5,sha{1,224,256,384,512}}" \
+ -S : -- "$cur"))
+ [[ ${COMPREPLY-} == *: ]] && compopt -o nospace
fi
return
;;
esac
- 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 _nsupdate nsupdate
+ complete -F _nsupdate nsupdate
# ex: filetype=sh
diff --git a/completions/ntpdate b/completions/ntpdate
index 5291336c..f6ee8f54 100644
--- a/completions/ntpdate
+++ b/completions/ntpdate
@@ -11,11 +11,11 @@ _ntpdate()
return
;;
-*U)
- COMPREPLY=( $(compgen -u -- "$cur") )
+ COMPREPLY=($(compgen -u -- "$cur"))
return
;;
-*p)
- COMPREPLY=( $(compgen -W '{1..8}' -- "$cur") )
+ COMPREPLY=($(compgen -W '{1..8}' -- "$cur"))
return
;;
@@ -24,12 +24,12 @@ _ntpdate()
;;
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 _ntpdate ntpdate
+ complete -F _ntpdate ntpdate
# ex: filetype=sh
diff --git a/completions/oggdec b/completions/oggdec
index 9bdf5019..97bde205 100644
--- a/completions/oggdec
+++ b/completions/oggdec
@@ -6,18 +6,18 @@ _oggdec()
_init_completion -s || return
case $prev in
- --help|--version|-!(-*)[hV]*)
+ --help | --version | -!(-*)[hV]*)
return
;;
- --bits|-!(-*)b)
- COMPREPLY=( $(compgen -W "8 16" -- "$cur") )
+ --bits | -!(-*)b)
+ COMPREPLY=($(compgen -W "8 16" -- "$cur"))
return
;;
- --endianness|--sign|-!(-*)[es])
- COMPREPLY=( $(compgen -W "0 1" -- "$cur") )
+ --endianness | --sign | -!(-*)[es])
+ COMPREPLY=($(compgen -W "0 1" -- "$cur"))
return
;;
- --output|-!(-*)o)
+ --output | -!(-*)o)
_filedir wav
return
;;
@@ -25,14 +25,14 @@ _oggdec()
$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 ogg
} &&
-complete -F _oggdec oggdec
+ complete -F _oggdec oggdec
# ex: filetype=sh
diff --git a/completions/op b/completions/op
index ddbe4c73..31d64758 100644
--- a/completions/op
+++ b/completions/op
@@ -3,7 +3,7 @@
_op_commands()
{
"$@" --help 2>/dev/null |
- awk "/^(Available |Sub)commands/{flag=1;next}/^ /&&flag{print \$1}"
+ awk '/^(Available |Sub)commands/{flag=1;next}/^ /&&flag{print $1}'
}
_op_command_options()
@@ -11,11 +11,11 @@ _op_command_options()
case $cur in
-*)
for i in "${!words[@]}"; do
- [[ ${words[i]} == -* || $i -eq 0 ]] && unset words[i]
+ [[ ${words[i]} == -* || $i -eq 0 ]] && unset "words[i]"
done
- COMPREPLY=( $(compgen -W \
- '$(_parse_usage "$1" "${words[*]} --help") --help' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ COMPREPLY=($(compgen -W \
+ '$(_parse_usage "$1" "${words[*]} --help") --help' -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return 0
;;
esac
@@ -28,29 +28,32 @@ _op()
_init_completion -s || return
local command i
- for (( i=1; i < cword; i++ )); do
+ for ((i = 1; i < cword; i++)); do
case ${words[i]} in
- --help|--version) return ;;
+ --help | --version) return ;;
-*) ;;
- *) command=${words[i]}; break ;;
+ *)
+ command=${words[i]}
+ break
+ ;;
esac
done
- if [[ -z $command && $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ if [[ ! -v command && $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- [[ $command ]] && _op_command_options "$1" && return
+ [[ -v command ]] && _op_command_options "$1" && return
- if [[ -z $command || $command == $prev ]]; then
- COMPREPLY=( $(compgen -W '$(_op_commands "$1" $command)' -- "$cur") )
- [[ $COMPREPLY ]] && return
+ if [[ ! -v command || $command == "$prev" ]]; then
+ COMPREPLY=($(compgen -W '$(_op_commands "$1" ${command-})' -- "$cur"))
+ [[ ${COMPREPLY-} ]] && return
fi
# TODO specific command and subcommand completions
} &&
-complete -F _op op
+ complete -F _op op
# ex: filetype=sh
diff --git a/completions/openssl b/completions/openssl
index 50300a43..dd770920 100644
--- a/completions/openssl
+++ b/completions/openssl
@@ -5,9 +5,9 @@ _openssl_sections()
local config f
# check if a specific configuration file is used
- for (( i=2; i < cword; i++ )); do
- if [[ "${words[i]}" == -config ]]; then
- config=${words[i+1]}
+ for ((i = 2; i < cword; i++)); do
+ if [[ ${words[i]} == -config ]]; then
+ config=${words[i + 1]}
break
fi
done
@@ -22,13 +22,17 @@ _openssl_sections()
[[ ! -f $config ]] && return
- COMPREPLY=( $(compgen -W "$(awk '/\[.*\]/ {print $2}' $config)" -- "$cur") )
+ COMPREPLY=($(compgen -W "$(awk '/\[.*\]/ {print $2}' $config)" -- "$cur"))
}
_openssl_digests()
{
- "$1" dgst -h 2>&1 | \
+ "$1" dgst -h 2>&1 |
awk '/^-.*[ \t]to use the .* message digest algorithm/ { print $1 }'
+ local -a digests=($("$1" help 2>&1 |
+ command sed -ne '/^Message Digest commands/,/^[[:space:]]*$/p' |
+ command sed -e 1d))
+ printf "%s\n" "${digests[@]/#/-}"
}
_openssl()
@@ -51,29 +55,29 @@ _openssl()
rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb rc4 rc4-40
sha224 sha256 sha384 sha512 genpkey pkey pkeyparam pkeyutl'
- if [[ $cword -eq 1 ]]; then
- COMPREPLY=( $(compgen -W "$commands" -- "$cur") )
+ if ((cword == 1)); then
+ COMPREPLY=($(compgen -W "$commands" -- "$cur"))
else
command=${words[1]}
case $prev in
- -CA|-CAfile|-CAkey|-CAserial|-cert|-certfile|-config|-content| \
- -dcert|-dkey|-dhparam|-extfile|-in|-inkey|-kfile|-key|-keyout| \
- -out|-oid|-paramfile|-peerkey|-prvrify|-rand|-recip|-revoke| \
- -sess_in|-sess_out|-spkac|-sigfile|-sign|-signkey|-signer| \
- -signature|-ss_cert|-untrusted|-verify)
+ -CA | -CAfile | -CAkey | -CAserial | -cert | -certfile | -config | -content | \
+ -dcert | -dkey | -dhparam | -extfile | -in | -inkey | -kfile | -key | -keyout | \
+ -out | -oid | -paramfile | -peerkey | -prvrify | -rand | -recip | -revoke | \
+ -sess_in | -sess_out | -spkac | -sigfile | -sign | -signkey | -signer | \
+ -signature | -ss_cert | -untrusted | -verify | -writerand)
_filedir
return
;;
- -outdir|-CApath)
+ -outdir | -CApath)
_filedir -d
return
;;
- -name|-crlexts|-extensions)
+ -name | -crlexts | -extensions)
_openssl_sections
return
;;
- -inform|-outform|-keyform|-certform|-CAform|-CAkeyform|-dkeyform|\
- -dcertform|-peerform)
+ -inform | -outform | -keyform | -certform | -CAform | -CAkeyform | -dkeyform | \
+ -dcertform | -peerform)
formats='DER PEM'
case $command in
x509)
@@ -86,7 +90,7 @@ _openssl()
formats+=" ENGINE"
;;
esac
- COMPREPLY=( $(compgen -W "$formats" -- "$cur") )
+ COMPREPLY=($(compgen -W "$formats" -- "$cur"))
return
;;
-connect)
@@ -94,177 +98,41 @@ _openssl()
return
;;
-starttls)
- COMPREPLY=( $(compgen -W 'smtp pop3 imap ftp' -- "$cur") )
+ COMPREPLY=($(compgen -W '
+ smtp pop3 imap ftp xmpp xmpp-server telnet irc mysql
+ postgres lmtp nntp sieve ldap
+ ' -- "$cur"))
return
;;
-cipher)
- COMPREPLY=( $(IFS=: compgen -W "$($1 ciphers)" -- "$cur") )
+ COMPREPLY=($(IFS=: compgen -W "$($1 ciphers)" -- "$cur"))
return
;;
-kdf)
- COMPREPLY=( $(compgen -W 'TLS1-PRF HKDF' -- "$cur") )
+ COMPREPLY=($(compgen -W 'TLS1-PRF HKDF' -- "$cur"))
return
;;
esac
- if [[ "$cur" == -* ]]; then
+ if [[ $cur == -* ]]; then
# possible options for the command
+ options=$(_parse_help "$1" "$command -help" 2>/dev/null)
case $command in
- asn1parse)
- options='-inform -in -out -noout -offset -length -i -oid
- -strparse'
- ;;
- ca)
- options='-verbose -config -name -gencrl -revoke -crl_reason
- -crl_hold -crl_compromise -crl_CA_compromise -crldays
- -crlhours -crlexts -startdate -enddate -days -md
- -policy -keyfile -key -passin -cert -selfsig -in -out
- -notext -outdir -infiles -spkac -ss_cert -preserveDN
- -noemailDN -batch -msie_hack -extensions -extfile
- -engine -subj -utf8 -multivalue-rdn'
- ;;
- ciphers)
- options='-v -ssl2 -ssl3 -tls1'
- ;;
- crl)
- options='-inform -outform -text -in -out -noout -hash
- -issuer -lastupdate -nextupdate -CAfile -CApath'
- ;;
- crl2pkcs7)
- options='-inform -outform -in -out -print_certs'
- ;;
- dgst)
- options="-c -d -hex -binary -out -sign -verify -prverify
- -signature $(_openssl_digests $1)"
- ;;
- dsa)
- options='-inform -outform -in -passin -out -passout -des
- -des3 -idea -text -noout -modulus -pubin -pubout'
- ;;
- dsaparam)
- options='-inform -outform -in -out -noout -text -C -rand
- -genkey'
- ;;
- enc)
- options='-ciphername -in -out -pass -e -d -a -A -k -kfile
- -S -K -iv -p -P -bufsize -debug'
- ;;
- dhparam)
- options='-inform -outform -in -out -dsaparam -noout -text
- -C -2 -5 -rand'
- ;;
- gendsa)
- options='-out -des -des3 -idea -rand'
- ;;
- genpkey)
- options='-out -outform -pass -cipher -engine -paramfile
- -algorithm -pkeyopt -genparam -text'
- ;;
- genrsa)
- options='-out -passout -des -des3 -idea -f4 -3 -rand'
- ;;
- pkcs7)
- options='-inform -outform -in -out -print_certs -text
- -noout'
- ;;
- pkey)
- options='-inform -outform -in -passin -out -passout
- -traditional -cipher -text -text_pub -noout -pubin
- -pubout -engine'
- ;;
- pkeyparam)
- options='-in -out -text -noout -engine'
- ;;
- pkeyutl)
- options='-in -out -sigfile -inkey -keyform -passin -peerkey
- -peerform -pubin -certin -rev -sign -verify
- -verifyrecover -encrypt -decrypt -derive -kdf -kdflen
- -pkeyopt -hexdump -asn1parse -engine -engine_impl'
- ;;
- rand)
- options='-out -rand -base64'
- ;;
- req)
- options="-inform -outform -in -passin -out -passout -text
- -noout -verify -modulus -new -rand -newkey -newkey
- -nodes -key -keyform -keyout $(_openssl_digests $1)
- -config -x509 -days -asn1-kludge -newhdr -extensions
- -reqexts section"
- ;;
- rsa)
- options='-inform -outform -in -passin -out -passout
- -sgckey -des -des3 -idea -text -noout -modulus -check
- -pubin -pubout -engine'
- ;;
- rsautl)
- options='-in -out -inkey -pubin -certin -sign -verify
- -encrypt -decrypt -pkcs -ssl -raw -hexdump -asn1parse'
- ;;
- s_client)
- options='-connect -verify -cert -certform -key -keyform
- -pass -CApath -CAfile -reconnect -pause -showcerts
- -debug -msg -nbio_test -state -nbio -crlf -ign_eof
- -quiet -ssl2 -ssl3 -tls1 -no_ssl2 -no_ssl3 -no_tls1
- -bugs -cipher -starttls -engine -tlsextdebug
- -no_ticket -sess_out -sess_in -rand'
- ;;
- s_server)
- options='-accept -context -verify -Verify -crl_check
- -crl_check_all -cert -certform -key -keyform -pass
- -dcert -dcertform -dkey -dkeyform -dpass -dhparam
- -nbio -nbio_test -crlf -debug -msg -state -CApath
- -CAfile -nocert -cipher -quiet -no_tmp_rsa -ssl2
- -ssl3 -tls1 -no_ssl2 -no_ssl3 -no_tls1 -no_dhe
- -bugs -hack -www -WWW -HTTP -engine -tlsextdebug
- -no_ticket -id_prefix -rand'
- ;;
- s_time)
- options='-connect -www -cert -key -CApath -CAfile -reuse
- -new -verify -nbio -time -ssl2 -ssl3 -bugs -cipher'
- ;;
- sess_id)
- options='-inform -outform -in -out -text -noout -context ID'
- ;;
- smime)
- options='-encrypt -decrypt -sign -verify -pk7out -des -des3
- -rc2-40 -rc2-64 -rc2-128 -aes128 -aes192 -aes256 -in
- -certfile -signer -recip -inform -passin -inkey -out
- -outform -content -to -from -subject -text -rand'
- ;;
- speed)
- options='-engine'
- ;;
- verify)
- options='-CApath -CAfile -purpose -untrusted -help
- -issuer_checks -verbose -certificates'
- ;;
- x509)
- options="-inform -outform -keyform -CAform -CAkeyform -in
- -out -serial -hash -subject_hash -issuer_hash -subject
- -issuer -nameopt -email -startdate -enddate -purpose
- -dates -modulus -fingerprint -alias -noout -trustout
- -clrtrust -clrreject -addtrust -addreject -setalias
- -days -set_serial -signkey -x509toreq -req -CA -CAkey
- -CAcreateserial -CAserial -text -C -clrext
- -extfile -extensions -engine $(_openssl_digests $1)"
- ;;
- md*|sha*|ripemd160)
- options='-c -d'
- ;;
+ dgst | req | x509) options+=" $(_openssl_digests $1)" ;;
esac
- COMPREPLY=( $(compgen -W "$options" -- "$cur") )
+ COMPREPLY=($(compgen -W "$options" -- "$cur"))
else
- if [[ "$command" == speed ]]; then
- COMPREPLY=( $(compgen -W 'md2 mdc2 md5 hmac sha1 rmd160
+ if [[ $command == speed ]]; then
+ COMPREPLY=($(compgen -W 'md2 mdc2 md5 hmac sha1 rmd160
idea-cbc rc2-cbc rc5-cbc bf-cbc des-cbc des-ede3 rc4
rsa512 rsa1024 rsa2048 rsa4096 dsa512 dsa1024 dsa2048 idea
- rc2 des rsa blowfish' -- "$cur") )
+ rc2 des rsa blowfish' -- "$cur"))
else
_filedir
fi
fi
fi
} &&
-complete -F _openssl -o default openssl
+ complete -F _openssl -o default openssl
# ex: filetype=sh
diff --git a/completions/opera b/completions/opera
index dc0859ea..f2bc8c30 100644
--- a/completions/opera
+++ b/completions/opera
@@ -6,8 +6,8 @@ _opera()
_init_completion || return
case "$prev" in
- ?(-)-widget|?(-)-urllist|?(-)-uiparserlog|?(-)-uiwidgetsparserlog|\
- ?(-)-profilinglog)
+ ?(-)-widget | ?(-)-urllist | ?(-)-uiparserlog | ?(-)-uiwidgetsparserlog | \
+ ?(-)-profilinglog)
_filedir
return
;;
@@ -16,32 +16,32 @@ _opera()
return
;;
?(-)-remote)
- COMPREPLY=( $(compgen -W 'openURL\\( openFile\\( openM2\\(
+ COMPREPLY=($(compgen -W 'openURL\\( openFile\\( openM2\\(
openComposer\\( addBookmark\\( raise\\(\\) lower\\(\\)' \
- -- "$cur") )
- [[ $COMPREPLY == *\( ]] && compopt -o nospace
+ -- "$cur"))
+ [[ ${COMPREPLY-} == *\( ]] && compopt -o nospace
return
;;
?(-)-windowname)
- COMPREPLY=( $(compgen -W 'first last opera{1..9}' -- "$cur") )
+ COMPREPLY=($(compgen -W 'first last opera{1..9}' -- "$cur"))
return
;;
- ?(-)-geometry|?(-)-window|?(-)-display|?(-)-urllistloadtimeout|\
- ?(-)-delaycustomizations|?(-)-dialogtest|?(-)-inidialogtest|\
- ?(-)-gputest)
+ ?(-)-geometry | ?(-)-window | ?(-)-display | ?(-)-urllistloadtimeout | \
+ ?(-)-delaycustomizations | ?(-)-dialogtest | ?(-)-inidialogtest | \
+ ?(-)-gputest)
# argument required but no completions available
return
;;
esac
- 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 '@(?([xX]|[sS])[hH][tT][mM]?([lL]))'
} &&
-complete -F _opera opera
+ complete -F _opera opera
# ex: filetype=sh
diff --git a/completions/optipng b/completions/optipng
index 22889bf4..0f6b40e1 100644
--- a/completions/optipng
+++ b/completions/optipng
@@ -6,14 +6,14 @@ _optipng()
_init_completion || return
case $prev in
- -'?'|-h|--help|-f)
+ -'?' | -h | --help | -f)
return
;;
-o)
- COMPREPLY=( $(compgen -W '{0..7}' -- "$cur") )
+ COMPREPLY=($(compgen -W '{0..7}' -- "$cur"))
return
;;
- -out|-log)
+ -out | -log)
_filedir
return
;;
@@ -22,31 +22,31 @@ _optipng()
return
;;
-i)
- COMPREPLY=( $(compgen -W '0 1' -- "$cur") )
+ COMPREPLY=($(compgen -W '0 1' -- "$cur"))
return
;;
- -zc|-zm)
- COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") )
+ -zc | -zm)
+ COMPREPLY=($(compgen -W '{1..9}' -- "$cur"))
return
;;
-zw)
- COMPREPLY=( $(compgen -W '256 512 1k 2k 4k 8k 16k 32k' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W '256 512 1k 2k 4k 8k 16k 32k' \
+ -- "$cur"))
return
;;
-strip)
- COMPREPLY=( $(compgen -W 'all' -- "$cur") )
+ COMPREPLY=($(compgen -W 'all' -- "$cur"))
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
return
fi
_filedir '@(png|bmp|gif|pnm|tif?(f))'
} &&
-complete -F _optipng optipng
+ complete -F _optipng optipng
# ex: filetype=sh
diff --git a/completions/p4 b/completions/p4
index e383c8cf..ed5f20c2 100644
--- a/completions/p4
+++ b/completions/p4
@@ -14,38 +14,38 @@ _p4()
uresource uxbinary xbinary xltext xtempobj xtext \
text binary resource"
- if [[ $cword -eq 1 ]]; then
- COMPREPLY=( $(compgen -W "$p4commands" -- "$cur") )
- elif [[ $cword -eq 2 ]]; then
+ if ((cword == 1)); then
+ COMPREPLY=($(compgen -W "$p4commands" -- "$cur"))
+ elif ((cword == 2)); then
case $prev in
help)
- COMPREPLY=( $(compgen -W "simple commands environment
+ COMPREPLY=($(compgen -W "simple commands environment
filetypes jobview revisions usage views $p4commands" \
- -- "$cur") )
+ -- "$cur"))
;;
admin)
- COMPREPLY=( $(compgen -W "checkpoint stop" -- "$cur") )
- ;;
- *)
+ COMPREPLY=($(compgen -W "checkpoint stop" -- "$cur"))
;;
+ *) ;;
+
esac
- elif [[ $cword -gt 2 ]]; then
+ elif ((cword > 2)); then
case $prev in
-t)
- case ${words[$cword-2]} in
- add|edit|reopen)
- COMPREPLY=( $(compgen -W "$p4filetypes" -- "$cur") )
- ;;
- *)
+ case ${words[cword - 2]} in
+ add | edit | reopen)
+ COMPREPLY=($(compgen -W "$p4filetypes" -- "$cur"))
;;
+ *) ;;
+
esac
;;
- *)
- ;;
+ *) ;;
+
esac
fi
} &&
-complete -F _p4 -o default p4 g4
+ complete -F _p4 -o default p4 g4
# ex: filetype=sh
diff --git a/completions/pack200 b/completions/pack200
index f35840b0..1a6ded7a 100644
--- a/completions/pack200
+++ b/completions/pack200
@@ -6,37 +6,37 @@ _pack200()
_init_completion -s || return
case $prev in
- -S|--segment-limit|-P|--pass-file|-C|--class-attribute|\
- -F|--field-attribute|-M|--method-attribute|-D|--code-attribute|\
- '-?'|-h|--help|-V|--version|-J)
+ -S | --segment-limit | -P | --pass-file | -C | --class-attribute | \
+ -F | --field-attribute | -M | --method-attribute | -D | --code-attribute | \
+ '-?' | -h | --help | -V | --version | -J)
return
;;
- -E|--effort)
- COMPREPLY=( $(compgen -W '{0..9}' -- "$cur") )
+ -E | --effort)
+ COMPREPLY=($(compgen -W '{0..9}' -- "$cur"))
return
;;
- -H|--deflate-hint)
- COMPREPLY=( $(compgen -W 'true false keep' -- "$cur") )
+ -H | --deflate-hint)
+ COMPREPLY=($(compgen -W 'true false keep' -- "$cur"))
return
;;
- -m|--modification-time)
- COMPREPLY=( $(compgen -W 'latest keep' -- "$cur") )
+ -m | --modification-time)
+ COMPREPLY=($(compgen -W 'latest keep' -- "$cur"))
return
;;
- -U|--unknown-attribute)
- COMPREPLY=( $(compgen -W 'error strip pass' -- "$cur") )
+ -U | --unknown-attribute)
+ COMPREPLY=($(compgen -W 'error strip pass' -- "$cur"))
return
;;
- -f|--config-file)
+ -f | --config-file)
_filedir properties
return
;;
- -l|--log-file)
- COMPREPLY=( $(compgen -W '-' -- "$cur") )
+ -l | --log-file)
+ COMPREPLY=($(compgen -W '-' -- "$cur"))
_filedir log
return
;;
- -r|--repack)
+ -r | --repack)
_filedir jar
return
;;
@@ -46,29 +46,29 @@ _pack200()
# Check if a pack or a jar was already given.
local i pack=false jar=false
- for (( i=0; i < ${#words[@]}-1; i++ )) ; do
+ for ((i = 1; i < ${#words[@]} - 1; i++)); do
case ${words[i]} in
- *.pack|*.pack.gz) pack=true ;;
+ *.pack | *.pack.gz) pack=true ;;
*.jar) jar=true ;;
esac
done
- if ! $pack ; then
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '--no-gzip --gzip --strip-debug
+ if ! $pack; then
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '--no-gzip --gzip --strip-debug
--no-keep-file-order --segment-limit= --effort= --deflate-hint=
--modification-time= --pass-file= --unknown-attribute=
--class-attribute= --field-attribute= --method-attribute=
--code-attribute= --config-file= --verbose --quiet --log-file=
- --help --version -J --repack' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ --help --version -J --repack' -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
_filedir 'pack?(.gz)'
fi
- elif ! $jar ; then
+ elif ! $jar; then
_filedir jar
fi
} &&
-complete -F _pack200 pack200
+ complete -F _pack200 pack200
# ex: filetype=sh
diff --git a/completions/passwd b/completions/passwd
index 5a1e5629..652a41e5 100644
--- a/completions/passwd
+++ b/completions/passwd
@@ -6,19 +6,19 @@ _passwd()
_init_completion || return
case $prev in
- --minimum|--maximum|--warning|--inactive|--help|--usage|-!(-*)[nxwi?])
+ --minimum | --maximum | --warning | --inactive | --help | --usage | -!(-*)[nxwi?])
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
_allowed_users
} &&
-complete -F _passwd passwd
+ complete -F _passwd passwd
# ex: filetype=sh
diff --git a/completions/patch b/completions/patch
index df85211d..e883d9ca 100644
--- a/completions/patch
+++ b/completions/patch
@@ -6,42 +6,42 @@ _patch()
_init_completion -s || return
case $prev in
- --strip|--ifdef|--prefix|--basename-prefix|--suffix|--get|\
- -!(-*)[pDBYzg])
+ --strip | --ifdef | --prefix | --basename-prefix | --suffix | --get | \
+ -!(-*)[pDBYzg])
return
;;
- --fuzz|-!(-*)F)
- COMPREPLY=( $(compgen -W '{0..3}' -- "$cur") )
+ --fuzz | -!(-*)F)
+ COMPREPLY=($(compgen -W '{0..3}' -- "$cur"))
return
;;
- --input|-!(-*)i)
+ --input | -!(-*)i)
_filedir '@(?(d)patch|dif?(f))'
return
;;
- --output|--reject-file|-!(-*)[or])
- [[ ! $cur || $cur == - ]] && COMPREPLY=( - )
+ --output | --reject-file | -!(-*)[or])
+ [[ ! $cur || $cur == - ]] && COMPREPLY=(-)
_filedir
return
;;
--quoting-style)
- COMPREPLY=( $(compgen -W 'literal shell shell-always c escape' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W 'literal shell shell-always c escape' \
+ -- "$cur"))
return
;;
- --version-control|-!(-*)V)
- COMPREPLY=( $(compgen -W 'simple numbered existing' -- "$cur") )
+ --version-control | -!(-*)V)
+ COMPREPLY=($(compgen -W 'simple numbered existing' -- "$cur"))
return
;;
- --directory|-!(-*)d)
+ --directory | -!(-*)d)
_filedir -d
return
;;
--reject-format)
- COMPREPLY=( $(compgen -W 'context unified' -- "$cur") )
+ COMPREPLY=($(compgen -W 'context unified' -- "$cur"))
return
;;
--read-only)
- COMPREPLY=( $(compgen -W 'ignore warn fail' -- "$cur") )
+ COMPREPLY=($(compgen -W 'ignore warn fail' -- "$cur"))
return
;;
esac
@@ -49,8 +49,8 @@ _patch()
$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
@@ -65,6 +65,6 @@ _patch()
;;
esac
} &&
-complete -F _patch patch
+ complete -F _patch patch
# ex: filetype=sh
diff --git a/completions/pdftotext b/completions/pdftotext
index 79c837e0..a3501baa 100644
--- a/completions/pdftotext
+++ b/completions/pdftotext
@@ -6,31 +6,34 @@ _pdftotext()
_init_completion || return
case $prev in
- -h|-help|--help|-'?'|-f|-l|-r|-x|-y|-W|-H|-fixed|-opw|-upw)
+ -h | -help | --help | -'?' | -f | -l | -r | -x | -y | -W | -H | -fixed | -opw | -upw)
return
;;
-enc)
- COMPREPLY=( $(compgen -W '$("$1" -listenc 2>/dev/null |
- command sed -e 1d)' -- "$cur") )
+ COMPREPLY=($(compgen -W '$("$1" -listenc 2>/dev/null |
+ command sed -e 1d)' -- "$cur"))
return
;;
-eol)
- COMPREPLY=( $(compgen -W "unix dos mac" -- "$cur") )
+ COMPREPLY=($(compgen -W "unix dos mac" -- "$cur"))
return
;;
esac
if [[ $cur == -* && ${prev,,} != *.pdf ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
return
fi
case ${prev,,} in
- -|*.txt) ;;
- *.pdf) COMPREPLY=( $(compgen -W '-' -- "$cur") ) ; _filedir txt ;;
+ - | *.txt) ;;
+ *.pdf)
+ COMPREPLY=($(compgen -W '-' -- "$cur"))
+ _filedir txt
+ ;;
*) _filedir pdf ;;
esac
} &&
-complete -F _pdftotext pdftotext
+ complete -F _pdftotext pdftotext
# ex: filetype=sh
diff --git a/completions/perl b/completions/perl
index bf117970..9823d730 100644
--- a/completions/perl
+++ b/completions/perl
@@ -2,9 +2,9 @@
_perl_helper()
{
- COMPREPLY=( $(compgen -P "$prefix" -W \
+ COMPREPLY=($(compgen -P "$prefix" -W \
"$(${2:-perl} ${BASH_SOURCE[0]%/*}/../helpers/perl $1 $cur)" \
- -- "$cur") )
+ -- "$cur"))
[[ $1 == functions ]] || __ltrim_colon_completions "$prefix$cur"
}
@@ -16,7 +16,7 @@ _perl()
local prefix="" temp optPrefix optSuffix
# If option not followed by whitespace, reassign prev and cur
- if [[ "$cur" == -?* ]]; then
+ if [[ $cur == -?* ]]; then
temp=$cur
prev=${temp:0:2}
cur=${temp:2}
@@ -35,7 +35,7 @@ _perl()
-*[Ix])
local IFS=$'\n'
compopt -o filenames
- COMPREPLY=( $(compgen -d $optPrefix $optSuffix -- "$cur") )
+ COMPREPLY=($(compgen -d $optPrefix $optSuffix -- "$cur"))
return
;;
-*[mM])
@@ -50,14 +50,14 @@ _perl()
temp="${cur##+(:)}"
prefix+="${cur%$temp}"
local IFS=$'\n'
- COMPREPLY=( $(compgen -P "$prefix" -W \
+ COMPREPLY=($(compgen -P "$prefix" -W \
'$($1 -MConfig -e "print join \"\\n\",
- keys %Config::Config" 2>/dev/null)' -- "$temp") )
+ keys %Config::Config" 2>/dev/null)' -- "$temp"))
__ltrim_colon_completions "$prefix$temp"
fi
return
;;
- -*d|-*dt)
+ -*d | -*dt)
if [[ $cur == :* ]]; then
temp="${cur#:}"
prefix="$prefix${cur%$temp}"
@@ -72,25 +72,25 @@ _perl()
# valid syntax. However, the argument is neither a filename nor a
# directory, but one line of perl program, thus do not suggest
# _filedir completion.
- elif [[ "$prev" == -e ]] || [[ "$prev" == -E ]]; then
+ elif [[ $prev == -e ]] || [[ $prev == -E ]]; then
return
# Likewise, `-I' also accepts a space between option and argument
# and it takes a directory as value.
- elif [[ "$prev" == -I ]]; then
+ elif [[ $prev == -I ]]; then
local IFS=$'\n'
compopt -o filenames
- COMPREPLY=( $(compgen -d $optPrefix $optSuffix -- "$cur") )
+ COMPREPLY=($(compgen -d ${optPrefix-} ${optSuffix-} -- "$cur"))
return
- elif [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p
- -n -a -F -l -0 -I -m -M -P -S -x -i -e' -- "$cur") )
+ elif [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p
+ -n -a -F -l -0 -I -m -M -P -S -x -i -e' -- "$cur"))
else
_filedir
fi
} &&
-complete -F _perl perl
+ complete -F _perl perl
_perldoc()
{
@@ -100,7 +100,7 @@ _perldoc()
local prefix="" temp
# completing an option (may or may not be separated by a space)
- if [[ "$cur" == -?* ]]; then
+ if [[ $cur == -?* ]]; then
temp=$cur
prev=${temp:0:2}
cur=${temp:2}
@@ -108,7 +108,7 @@ _perldoc()
fi
local perl="${1%doc}"
- [[ $perl == $1 ]] || ! type $perl &>/dev/null && perl=
+ [[ $perl == "$1" ]] || ! type $perl &>/dev/null && perl=
case $prev in
-*[hVnoMwL])
@@ -124,23 +124,23 @@ _perldoc()
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
else
# return available modules (unless it is clearly a file)
- if [[ "$cur" != @(*/|[.~])* ]]; then
+ if [[ $cur != @(*/|[.~])* ]]; then
_perl_helper perldocs $perl
if [[ $cur == p* ]]; then
- COMPREPLY+=( $(compgen -W \
+ COMPREPLY+=($(compgen -W \
'$(PERLDOC_PAGER=cat "$1" -u perl | \
command sed -ne "/perl.*Perl overview/,/perlwin32/p" | \
awk "\$NF=2 && \$1 ~ /^perl/ { print \$1 }")' \
- -- "$cur") )
+ -- "$cur"))
fi
fi
_filedir 'p@([lm]|od)'
fi
} &&
-complete -F _perldoc -o bashdefault perldoc
+ complete -F _perldoc -o bashdefault perldoc
# ex: filetype=sh
diff --git a/completions/perlcritic b/completions/perlcritic
index d9a4063d..78435495 100644
--- a/completions/perlcritic
+++ b/completions/perlcritic
@@ -6,46 +6,46 @@ _perlcritic()
_init_completion || return
case $prev in
- --help|--version|--top|--include|--exclude|--single-policy|\
- --colo?(u)r-severity-*|--program-extensions|-[?HVs])
+ --help | --version | --top | --include | --exclude | --single-policy | \
+ --colo?(u)r-severity-* | --program-extensions | -[?HVs])
return
;;
--severity)
- COMPREPLY=( $(compgen -W "{1..5} brutal cruel harsh stern gentle" \
- -- "$cur") )
+ COMPREPLY=($(compgen -W "{1..5} brutal cruel harsh stern gentle" \
+ -- "$cur"))
return
;;
- --profile|-p)
+ --profile | -p)
_filedir perlcriticrc
return
;;
--theme)
- COMPREPLY=( $(compgen -W '$("$1" --list-themes 2>/dev/null)' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W '$("$1" --list-themes 2>/dev/null)' \
+ -- "$cur"))
return
;;
--profile-strictness)
- COMPREPLY=( $(compgen -W 'warn fatal quiet' -- "$cur") )
+ COMPREPLY=($(compgen -W 'warn fatal quiet' -- "$cur"))
return
;;
--verbose)
- COMPREPLY=( $(compgen -W '{1..11}' -- "$cur") )
+ COMPREPLY=($(compgen -W '{1..11}' -- "$cur"))
return
;;
--pager)
compopt -o filenames
- COMPREPLY=( $(compgen -c -- "$cur") )
+ COMPREPLY=($(compgen -c -- "$cur"))
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
return
fi
_filedir 'p[lm]'
} &&
-complete -F _perlcritic perlcritic
+ complete -F _perlcritic perlcritic
# ex: filetype=sh
diff --git a/completions/perltidy b/completions/perltidy
index 91bd5094..4404cf80 100644
--- a/completions/perltidy
+++ b/completions/perltidy
@@ -6,7 +6,7 @@ _perltidy()
_init_completion -n = || return
case $prev in
- -h|--help)
+ -h | --help)
return
;;
-o)
@@ -22,20 +22,20 @@ _perltidy()
return
;;
-ole=*)
- COMPREPLY=( $(compgen -W 'dos win mac unix' -- "${cur#*=}") )
+ COMPREPLY=($(compgen -W 'dos win mac unix' -- "${cur#*=}"))
return
;;
- -bt=*|-pt=*|-sbt=*|-bvt=*|-pvt=*|-sbvt=*|-bvtc=*|-pvtc=*|-sbvtc=*|\
- -cti=*|-kbl=*|-vt=*)
- COMPREPLY=( $(compgen -W '0 1 2' -- "${cur#*=}") )
+ -bt=* | -pt=* | -sbt=* | -bvt=* | -pvt=* | -sbvt=* | -bvtc=* | -pvtc=* | -sbvtc=* | \
+ -cti=* | -kbl=* | -vt=*)
+ COMPREPLY=($(compgen -W '0 1 2' -- "${cur#*=}"))
return
;;
-vtc=*)
- COMPREPLY=( $(compgen -W '0 1' -- "${cur#*=}") )
+ COMPREPLY=($(compgen -W '0 1' -- "${cur#*=}"))
return
;;
-cab=*)
- COMPREPLY=( $(compgen -W '0 1 2 3' -- "${cur#*=}") )
+ COMPREPLY=($(compgen -W '0 1 2 3' -- "${cur#*=}"))
return
;;
-*=)
@@ -44,12 +44,12 @@ _perltidy()
esac
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 'p[lm]|t'
fi
} &&
-complete -F _perltidy perltidy
+ complete -F _perltidy perltidy
# ex: filetype=sh
diff --git a/completions/pgrep b/completions/pgrep
index 1c507a42..62dbb651 100644
--- a/completions/pgrep
+++ b/completions/pgrep
@@ -6,33 +6,43 @@ _pgrep()
_init_completion || return
case $prev in
- --delimiter|--pgroup|--session|--terminal|-!(-*)[cdgJMNstTz])
+ --delimiter | --pgroup | --session | --terminal | -!(-*)[cdgJMNstTz])
return
;;
--signal)
_signals
return
;;
- --pidfile|-!(-*)F)
+ --pidfile | -!(-*)F)
_filedir
return
;;
- --group|-!(-*)G)
+ --group | -!(-*)G)
_gids
return
;;
-j)
- COMPREPLY=( $(compgen -W 'any none' -- "$cur") )
+ COMPREPLY=($(compgen -W 'any none' -- "$cur"))
return
;;
- --parent|-!(-*)P)
+ --parent | --ns | -!(-*)P)
_pids
return
;;
- --euid|--uid|-!(-*)[uU])
+ --euid | --uid | -!(-*)[uU])
_uids
return
;;
+ --nslist)
+ local prefix=
+ [[ $cur == *,* ]] && prefix="${cur%,*},"
+ COMPREPLY=(
+ $(IFS="$IFS," compgen -W '$($1 --help 2>&1 |
+ command sed -ne "s/^[[:space:]]*Available namespaces://p")' \
+ -- "${cur##*,}"))
+ ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
+ return
+ ;;
esac
if [[ $cur == -* ]]; then
@@ -40,13 +50,13 @@ _pgrep()
[[ $help ]] || help='$("$1" --usage 2>&1 |
command sed -e "s/\[-signal\]//" -e "s/\[-SIGNAL\]//" |
_parse_usage -)'
- COMPREPLY=( $(compgen -W "$help" -- "$cur") )
+ COMPREPLY=($(compgen -W "$help" -- "$cur"))
[[ $cword -eq 1 && $1 == *pkill ]] && _signals -
return
fi
_pnames -s
} &&
-complete -F _pgrep pgrep pkill
+ complete -F _pgrep pgrep pkill
# ex: filetype=sh
diff --git a/completions/pidof b/completions/pidof
index 9e5c012b..a11b4323 100644
--- a/completions/pidof
+++ b/completions/pidof
@@ -6,22 +6,22 @@ _pidof()
_init_completion || return
case $prev in
- --help|-V|--version|-!(-*)[hV]*)
+ --help | -V | --version | -!(-*)[hV]*)
return
;;
- --omit-pid|-!(-*)o)
+ --omit-pid | -!(-*)o)
_pids
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
return
fi
_pnames
} &&
-complete -F _pidof pidof
+ complete -F _pidof pidof
# ex: filetype=sh
diff --git a/completions/pine b/completions/pine
index bf6056e0..319c8d5c 100644
--- a/completions/pine
+++ b/completions/pine
@@ -6,27 +6,27 @@ _pine()
_init_completion || return
case $prev in
- -help|-d|-f|-c|-I|-n|-url|-copy_pinerc|-copy_abook)
+ -help | -d | -f | -c | -I | -n | -url | -copy_pinerc | -copy_abook)
return
;;
- -attach|-attachlist|-attach_and_delete|-p|-P|-pinerc|-passfile|-x)
+ -attach | -attachlist | -attach_and_delete | -p | -P | -pinerc | -passfile | -x)
_filedir
return
;;
-sort)
- COMPREPLY=( $(compgen -W 'arrival subject threaded orderedsubject
- date from size score to cc' -- "$cur") )
+ COMPREPLY=($(compgen -W 'arrival subject threaded orderedsubject
+ date from size score to cc' -- "$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
- COMPREPLY=( $(compgen -W '$(awk "{print \$1}" ~/.addressbook \
- 2>/dev/null)' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(awk "{print \$1}" ~/.addressbook \
+ 2>/dev/null)' -- "$cur"))
fi
} &&
-complete -F _pine pine alpine
+ complete -F _pine pine alpine
# ex: filetype=sh
diff --git a/completions/ping b/completions/ping
index d611ae87..446f0267 100644
--- a/completions/ping
+++ b/completions/ping
@@ -19,22 +19,22 @@ _ping()
# Path MTU strategy in Linux, mask|time in FreeBSD
local opts="do want dont"
[[ $OSTYPE == *bsd* ]] && opts="mask time"
- COMPREPLY=( $(compgen -W '$opts' -- "$cur") )
+ COMPREPLY=($(compgen -W '$opts' -- "$cur"))
return
;;
-*N)
if [[ $cur != *= ]]; then
- COMPREPLY=( $(compgen -W 'name ipv6 ipv6-global ipv6-sitelocal
+ COMPREPLY=($(compgen -W 'name ipv6 ipv6-global ipv6-sitelocal
ipv6-linklocal ipv6-all ipv4 ipv4-all subject-ipv6=
- subject-ipv4= subject-name= subject-fqdn=' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ subject-ipv4= subject-name= subject-fqdn=' -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
return
;;
-*Q)
# TOS in Linux, "somewhat quiet" (no args) in FreeBSD
if [[ $OSTYPE != *bsd* ]]; then
- COMPREPLY=( $(compgen -W '{0..7}' -- "$cur") )
+ COMPREPLY=($(compgen -W '{0..7}' -- "$cur"))
return
fi
;;
@@ -45,8 +45,8 @@ _ping()
;;
-*T)
# Timestamp option in Linux, TTL in FreeBSD
- [[ $OSTYPE == *bsd* ]] || \
- COMPREPLY=( $(compgen -W 'tsonly tsandaddr' -- "$cur") )
+ [[ $OSTYPE == *bsd* ]] ||
+ COMPREPLY=($(compgen -W 'tsonly tsandaddr' -- "$cur"))
return
;;
-*4*)
@@ -59,13 +59,13 @@ _ping()
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
[[ $1 == *6 ]] && ipvx=-6
- _known_hosts_real $ipvx -- "$cur"
+ _known_hosts_real ${ipvx-} -- "$cur"
} &&
-complete -F _ping ping ping6
+ complete -F _ping ping ping6
# ex: filetype=sh
diff --git a/completions/pkg-config b/completions/pkg-config
index 57191370..b9db1673 100644
--- a/completions/pkg-config
+++ b/completions/pkg-config
@@ -6,24 +6,24 @@ _pkg_config()
_init_completion -s || return
case $prev in
- --define-variable|--atleast-version|--atleast-pkgconfig-version| \
- --exact-version|--max-version)
+ --define-variable | --atleast-version | --atleast-pkgconfig-version | \
+ --exact-version | --max-version)
# argument required but no completions available
return
;;
--variable)
- local i
- for (( i=1; i < ${#words[@]}; i++ )); do
- if [[ ${words[i]} != -* ]]; then
- COMPREPLY=( $(compgen -W \
- '$("$1" ${words[i]} --print-variables 2>/dev/null)' \
- -- "$cur") )
+ local word
+ for word in "${words[@]:1}"; do
+ if [[ $word != -* ]]; then
+ COMPREPLY=($(compgen -W \
+ '$("$1" $word --print-variables 2>/dev/null)' \
+ -- "$cur"))
break
fi
done
return
;;
- -\?|--help|--version|--usage)
+ -\? | --help | --version | --usage)
# all other arguments are noop with these
return
;;
@@ -31,15 +31,15 @@ _pkg_config()
$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
- COMPREPLY=( $(compgen -W "$($1 --list-all \
- 2>/dev/null | awk '{print $1}')" -- "$cur") )
+ COMPREPLY=($(compgen -W "$($1 --list-all \
+ 2>/dev/null | awk '{print $1}')" -- "$cur"))
_filedir pc
fi
} &&
-complete -F _pkg_config pkg-config
+ complete -F _pkg_config pkg-config
# ex: filetype=sh
diff --git a/completions/pkg-get b/completions/pkg-get
index 2f251338..72bd0a05 100644
--- a/completions/pkg-get
+++ b/completions/pkg-get
@@ -15,7 +15,7 @@ _pkg_get_get_catalog_file()
done
conffile="${conffile:-/opt/csw/etc/pkg-get.conf}"
- if [[ -z "$url" ]]; then
+ if [[ -z $url ]]; then
url=$(awk -F= ' $1=="url" { print $2 }' $conffile)
fi
@@ -25,48 +25,48 @@ _pkg_get_get_catalog_file()
echo "$catalog_file"
} &&
-_pkg_get()
-{
- local cur prev file catalog_file url command
- COMPREPLY=()
- cur="${COMP_WORDS[COMP_CWORD]}"
- prev="${COMP_WORDS[COMP_CWORD-1]}"
-
- if [[ "${prev}" == "-s" ]]; then
- return 1
- fi
+ _pkg_get()
+ {
+ local cur prev file catalog_file url command
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD - 1]}"
- local i=${#COMP_WORDS[*]}
- while [[ $i -gt 0 ]]; do
- if [[ "${COMP_WORDS[--i]}" == -s ]]; then
- url="${COMP_WORDS[$((i+1))]}"
+ if [[ ${prev} == "-s" ]]; then
+ return 1
fi
- if [[ "${COMP_WORDS[$i]}" == @(-[aDdiUu]|available|describe|download|install|list|updatecatalog|upgrade) ]]; then
- command="${COMP_WORDS[$i]}"
- fi
- done
- if [[ -n "$command" ]]; then
- if [[ "$command" == @(-[Ddi]|describe|download|install) ]]; then
- catalog_file=$(_pkg_get_get_catalog_file "$url")
- if [[ -f $catalog_file ]]; then
- local packages_list=$(awk ' $0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' $catalog_file)
- COMPREPLY=( $(compgen -W "${packages_list}" -- ${cur}) )
+ local i=${#COMP_WORDS[*]}
+ while ((i > 0)); do
+ if [[ ${COMP_WORDS[--i]} == -s ]]; then
+ url="${COMP_WORDS[i + 1]}"
+ fi
+ if [[ ${COMP_WORDS[i]} == @(-[aDdiUu]|available|describe|download|install|list|updatecatalog|upgrade) ]]; then
+ command="${COMP_WORDS[i]}"
+ fi
+ done
+
+ if [[ -v command ]]; then
+ if [[ $command == @(-[Ddi]|describe|download|install) ]]; then
+ catalog_file=$(_pkg_get_get_catalog_file "$url")
+ if [[ -f $catalog_file ]]; then
+ local packages_list=$(awk ' $0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' $catalog_file)
+ COMPREPLY=($(compgen -W "${packages_list}" -- ${cur}))
+ fi
fi
+ return
fi
- return
- fi
- if [[ ${cur} == -* ]]; then
- local opts="-c -d -D -f -i -l -s -S -u -U -v"
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return
- fi
+ if [[ ${cur} == -* ]]; then
+ local opts="-c -d -D -f -i -l -s -S -u -U -v"
+ COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+ return
+ fi
- local commands="available describe download install list \
+ local commands="available describe download install list \
updatecatalog upgrade"
- COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) )
-} &&
-complete -F _pkg_get pkg-get
+ COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
+ } &&
+ complete -F _pkg_get pkg-get
# ex: filetype=sh
diff --git a/completions/pkg_delete b/completions/pkg_delete
index 942647d0..2abb6714 100644
--- a/completions/pkg_delete
+++ b/completions/pkg_delete
@@ -7,12 +7,12 @@ _pkg_delete()
local pkgdir=${PKG_DBDIR:-/var/db/pkg}/
- [[ "$prev" == -o || "$prev" == -p || "$prev" == -W ]] && return
+ [[ $prev == -o || $prev == -p || $prev == -W ]] && return
- COMPREPLY=( $(compgen -d -- "$pkgdir$cur") )
- COMPREPLY=( ${COMPREPLY[@]#$pkgdir} )
+ COMPREPLY=($(compgen -d -- "$pkgdir$cur"))
+ ((${#COMPREPLY[@]} == 0)) || COMPREPLY=(${COMPREPLY[@]#$pkgdir})
} &&
-complete -F _pkg_delete -o dirnames pkg_delete pkg_info pkg_deinstall
+ complete -F _pkg_delete -o dirnames pkg_delete pkg_info pkg_deinstall
# ex: filetype=sh
diff --git a/completions/pkgadd b/completions/pkgadd
index 576b4114..3f5b6a11 100644
--- a/completions/pkgadd
+++ b/completions/pkgadd
@@ -2,7 +2,7 @@
#
# Copyright 2006 Yann Rouillard <yann@opencsw.org>
-_pkgadd ()
+_pkgadd()
{
local cur prev words cword
_init_completion -n : || return
@@ -12,10 +12,10 @@ _pkgadd ()
# available in this directory
local device=/var/spool/pkg
local i=$cword
- while [[ $((i--)) -gt 0 ]]; do
- case "${words[$i]}" in
+ while ((i-- > 0)); do
+ case "${words[i]}" in
-d)
- device="${words[$((i+1))]}"
+ device="${words[i + 1]}"
break
;;
esac
@@ -26,35 +26,37 @@ _pkgadd ()
_filedir pkg
_filedir -d
;;
- -a|-r|-V)
+ -a | -r | -V)
_filedir
;;
- -k|-s|-R)
+ -k | -s | -R)
_filedir -d
;;
- -P|-k|-x)
- ;;
+ -P | -x) ;;
+
*)
if [[ ${cur} == -* ]]; then
local opts="-a -A -d -k -n -M -P -r -R -s -v -V -x"
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
else
local pkginst_list
if [[ -d $device ]]; then
+ local -a tmplist
for filedir in $(/bin/ls -1 $device); do
if [[ -d "$device/$filedir" ]] && [[ -f "$device/$filedir/pkginfo" ]]; then
- pkginst_list+=( ${pkginst_list[@]:-} "$filedir" )
+ tmplist+=(${tmplist[@]:-} "$filedir")
fi
done
- pkginst_list="${pkginst_list[@]}"
+ pkginst_list="${tmplist[*]}"
else
- pkginst_list=$(strings $(dequote $device) | \
- command grep "^PKG=" | sort -u | cut -d= -f2)
+ pkginst_list="$(strings "$(dequote $device)" |
+ command grep ^PKG= | sort -u | cut -d= -f2)"
+ fi
+ COMPREPLY=($(compgen -W "$pkginst_list" -- ${cur}))
fi
- COMPREPLY=( $(compgen -W "$pkginst_list" -- ${cur}) )
- fi
+ ;;
esac
} &&
-complete -F _pkgadd pkgadd
+ complete -F _pkgadd pkgadd
# ex: filetype=sh
diff --git a/completions/pkgrm b/completions/pkgrm
index ef3b2a8d..2449d349 100644
--- a/completions/pkgrm
+++ b/completions/pkgrm
@@ -2,7 +2,7 @@
#
# Copyright 2006 Yann Rouillard <yann@opencsw.org>
-_pkgrm ()
+_pkgrm()
{
local cur prev words cword
_init_completion || return
@@ -12,13 +12,13 @@ _pkgrm ()
# available in this directory
local spool=/var/sadm/pkg
local i=$cword
- while [[ $((i--)) -gt 0 ]]; do
- (( i-- ))
- case "${words[$i]}" in
+ while ((i-- > 0)); do
+ ((i--))
+ case "${words[i]}" in
-s)
- spool="${words[$((i+1))]}"
+ spool="${words[i + 1]}"
break
- ;;
+ ;;
esac
done
@@ -29,8 +29,8 @@ _pkgrm ()
-s | -R)
_filedir -d
;;
- -Y)
- ;;
+ -Y) ;;
+
*)
if [[ ${cur} == -* ]]; then
local opts="-a -A -n -M -R -s -v -V -Y"
@@ -38,9 +38,9 @@ _pkgrm ()
else
COMPREPLY=($(compgen -W "$(/bin/ls -1 $spool)" -- ${cur}))
fi
- ;;
+ ;;
esac
} &&
-complete -F _pkgrm pkgrm
+ complete -F _pkgrm pkgrm
# ex: filetype=sh
diff --git a/completions/pkgtool b/completions/pkgtool
index 8bea9cdd..951bae40 100644
--- a/completions/pkgtool
+++ b/completions/pkgtool
@@ -6,7 +6,7 @@ _pkgtool()
_init_completion || return
case "$prev" in
- --source_dir|--target_dir)
+ --source_dir | --target_dir)
_filedir -d
return
;;
@@ -15,7 +15,7 @@ _pkgtool()
return
;;
--source_device)
- COMPREPLY=( $(compgen -f -d -- "${cur:-/dev/}") )
+ COMPREPLY=($(compgen -f -d -- "${cur:-/dev/}"))
return
;;
--tagfile)
@@ -24,12 +24,12 @@ _pkgtool()
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '--sets --ignore-tagfiles --tagfile
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '--sets --ignore-tagfiles --tagfile
--source-mounted --source_dir --target_dir --source_device' \
- -- "$cur") )
+ -- "$cur"))
fi
} &&
-complete -F _pkgtool pkgtool
+ complete -F _pkgtool pkgtool
# ex: filetype=sh
diff --git a/completions/pkgutil b/completions/pkgutil
index febc2135..91d87480 100644
--- a/completions/pkgutil
+++ b/completions/pkgutil
@@ -22,74 +22,74 @@ _pkgutil()
declare -a catalog_files=()
local i=$cword
- while [[ $((i--)) -gt 1 ]]; do
- if [[ "${words[$i]}" == -@(t|-temp) ]]; then
- local url="${words[$((i+1))]}"
+ while ((i-- > 1)); do
+ if [[ ${words[i]} == -@(t|-temp) ]]; then
+ local url="${words[i + 1]}"
local catalog=$(_pkgutil_url2catalog "$url")
catalog_files=("$catalog")
- elif [[ "${words[$i]}" == --config ]]; then
- configuration_files=( "$(dequote ${words[$((i+1))]})" )
- elif [[ "${words[$i]}" == -@([iurdacUS]|-install|-upgrade|-remove|-download|-available|-compare|-catalog|-stream) ]]; then
- command="${words[$i]}"
+ elif [[ ${words[i]} == --config ]]; then
+ configuration_files=("$(dequote ${words[i + 1]})")
+ elif [[ ${words[i]} == -@([iurdacUS]|-install|-upgrade|-remove|-download|-available|-compare|-catalog|-stream) ]]; then
+ command="${words[i]}"
fi
done
- if [[ "$prev" == -@([WPR]|-workdir|-pkgdir|-rootpath) ]]; then
+ if [[ $prev == -@([WPR]|-workdir|-pkgdir|-rootpath) ]]; then
_filedir -d
return
fi
- if [[ "$prev" == -@(o|-output|-config) ]]; then
+ if [[ $prev == -@(o|-output|-config) ]]; then
_filedir
return
fi
- if [[ "$prev" == -@(p|-param) ]]; then
+ if [[ $prev == -@(p|-param) ]]; then
compopt -o nospace
- COMPREPLY=( $(compgen -W "mirror: pkgaddopts: pkgrmopts: wgetopts: use_gpg: use_md5: pkgliststyle: maxpkglist: noncsw: stop_on_hook_soft_error: exclude_pattern: gpg_homedir: root_path: deptree_filter_common: show_current: catalog_not_cached: catalog_update:" -- $cur) )
+ COMPREPLY=($(compgen -W "mirror: pkgaddopts: pkgrmopts: wgetopts: use_gpg: use_md5: pkgliststyle: maxpkglist: noncsw: stop_on_hook_soft_error: exclude_pattern: gpg_homedir: root_path: deptree_filter_common: show_current: catalog_not_cached: catalog_update:" -- $cur))
return
fi
- if [[ "$prev" == @(-T|--target) ]]; then
+ if [[ $prev == @(-T|--target) ]]; then
# Work-around bash_completion issue where bash interprets a colon
# as a separator, borrowed from maven completion code which borrowed
# it from darcs completion code :)
local colonprefixes=${cur%"${cur##*:}"}
- COMPREPLY=( $(compgen -W "sparc:5.9 sparc:5.10 sparc:5.11 i386:5.9 i386:5.10 i386:5.11" -- $cur) )
+ COMPREPLY=($(compgen -W "sparc:5.9 sparc:5.10 sparc:5.11 i386:5.9 i386:5.10 i386:5.11" -- $cur))
local i=${#COMPREPLY[*]}
- while [ $((--i)) -ge 0 ]; do
- COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"}
+ while ((i-- > 0)); do
+ COMPREPLY[i]=${COMPREPLY[i]#"$colonprefixes"}
done
return
fi
- if [[ -n "$command" ]] && [[ ! "$cur" == -* ]]; then
+ if [[ -v command && $cur != -* ]]; then
local mirrors mirror_url
mirrors=$(awk -F= ' $1 ~ /^ *mirror *$/ { print $2 }' "${configuration_files[@]}")
mirrors=${mirrors:-http://mirror.opencsw.org/opencsw/testing}
for mirror_url in $mirrors; do
local catalog=$(_pkgutil_url2catalog "$mirror_url")
- catalog_files=( "${catalog_files[@]}" "$catalog" )
+ catalog_files=("${catalog_files[@]}" "$catalog")
done
- if [[ "$command" == -@([dius]|-download|-install|-upgrade|-stream) ]]; then
+ if [[ $command == -@([dius]|-download|-install|-upgrade|-stream) ]]; then
local packages_list=$(awk ' $0 ~ /BEGIN PGP SIGNATURE/ { exit } $1 ~ /^Hash:/ || $1 ~ /^ *(-|#|$)/ { next } { print $1 }' "${catalog_files[@]}")
- COMPREPLY=( $(compgen -W "${packages_list}" -- $cur) )
+ COMPREPLY=($(compgen -W "${packages_list}" -- $cur))
- elif [[ "$command" == @(-r|--remove) ]]; then
- local packages_list=$(pkginfo | awk ' $2 ~ /^CSW/ { printf ("%s|",$2) }')
+ elif [[ $command == @(-r|--remove) ]]; then
+ local packages_list=$(pkginfo | awk ' $2 ~ /^CSW/ { printf ("%s|",$2) }')
packages_list=${packages_list%|}
packages_list=$(nawk " \$3 ~ /^$packages_list\$/ { print \$1 }" "${catalog_files[@]}")
- COMPREPLY=( $(compgen -W "${packages_list}" -- $cur) )
+ COMPREPLY=($(compgen -W "${packages_list}" -- $cur))
fi
return
fi
local commands="-i --install -u --upgrade -r --remove -d --download -U --catalog -a --available --describe -c --compare -C --compare-diff -A --compare-avail -e --email -t --temp -x --exclude -W --workdir -P --pkgdir -R --rootpath --config -y --yes -f --force -n --nomod -N --nodeps -D --debug --trace -h --help -v --version -V --syscheck -l --list -L --listfile -F --findfile --deptree --extract -s --stream -o --output -T --target --single -p --param --parse --cleanup --catinfo"
- COMPREPLY=( $(compgen -W "${commands}" -- $cur) )
+ COMPREPLY=($(compgen -W "${commands}" -- $cur))
} &&
-complete -F _pkgutil pkgutil
+ complete -F _pkgutil pkgutil
# ex: filetype=sh
diff --git a/completions/plague-client b/completions/plague-client
index d8b2140e..4e982063 100644
--- a/completions/plague-client
+++ b/completions/plague-client
@@ -5,10 +5,10 @@ _plague_client()
local cur prev words cword
_init_completion || return
- [[ $cword -eq 1 ]] && \
- COMPREPLY=( $(compgen -W 'build detail finish help is_paused kill list
- list_builders pause requeue unpause update_builders' -- "$cur") )
+ ((cword == 1)) &&
+ COMPREPLY=($(compgen -W 'build detail finish help is_paused kill list
+ list_builders pause requeue unpause update_builders' -- "$cur"))
} &&
-complete -F _plague_client plague-client
+ complete -F _plague_client plague-client
# ex: filetype=sh
diff --git a/completions/pm-hibernate b/completions/pm-hibernate
index 1deadd11..ea3b0aa7 100644
--- a/completions/pm-hibernate
+++ b/completions/pm-hibernate
@@ -5,8 +5,8 @@ _pm_action()
local cur prev words cword
_init_completion || return
- COMPREPLY=( $(compgen -W "--help $(_parse_help "$1")" -- "$cur") )
+ COMPREPLY=($(compgen -W "--help $(_parse_help "$1")" -- "$cur"))
} &&
-complete -F _pm_action pm-hibernate pm-suspend pm-suspend-hybrid
+ complete -F _pm_action pm-hibernate pm-suspend pm-suspend-hybrid
# ex: filetype=sh
diff --git a/completions/pm-is-supported b/completions/pm-is-supported
index 6a112aeb..adc7fde7 100644
--- a/completions/pm-is-supported
+++ b/completions/pm-is-supported
@@ -5,9 +5,9 @@ _pm_is_supported()
local cur prev words cword
_init_completion || return
- COMPREPLY=( $(compgen -W '--help --suspend --hibernate --suspend-hybrid' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W '--help --suspend --hibernate --suspend-hybrid' \
+ -- "$cur"))
} &&
-complete -F _pm_is_supported pm-is-supported
+ complete -F _pm_is_supported pm-is-supported
# ex: filetype=sh
diff --git a/completions/pm-powersave b/completions/pm-powersave
index 06f93de0..affb195d 100644
--- a/completions/pm-powersave
+++ b/completions/pm-powersave
@@ -5,8 +5,8 @@ _pm_powersave()
local cur prev words cword
_init_completion || return
- COMPREPLY=( $(compgen -W "true false" -- "$cur") )
+ COMPREPLY=($(compgen -W "true false" -- "$cur"))
} &&
-complete -F _pm_powersave pm-powersave
+ complete -F _pm_powersave pm-powersave
# ex: filetype=sh
diff --git a/completions/pngfix b/completions/pngfix
index b4b58e83..64b5481d 100644
--- a/completions/pngfix
+++ b/completions/pngfix
@@ -6,7 +6,7 @@ _pngfix()
_init_completion -s || return
case $prev in
- --suffix|--prefix)
+ --suffix | --prefix)
return
;;
--output)
@@ -14,9 +14,9 @@ _pngfix()
return
;;
--strip)
- COMPREPLY=( $(IFS='|' compgen -W '$("$1" --help 2>&1 |
+ COMPREPLY=($(IFS='|' compgen -W '$("$1" --help 2>&1 |
command sed -ne "s/.*--strip=\[\([^]]*\)\].*/\1/p")' \
- -- "$cur") )
+ -- "$cur"))
return
;;
esac
@@ -24,13 +24,13 @@ _pngfix()
$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 png
} &&
-complete -F _pngfix pngfix
+ complete -F _pngfix pngfix
# ex: filetype=sh
diff --git a/completions/portinstall b/completions/portinstall
index 8a70b136..80337407 100644
--- a/completions/portinstall
+++ b/completions/portinstall
@@ -13,19 +13,19 @@ _portinstall()
# First try INDEX-5
indexfile=$portsdir/INDEX-5
# Then INDEX if INDEX-5 does not exist or system is not FreeBSD 5.x
- [[ "${OSTYPE%.*}" == freebsd5 && -f $indexfile ]] ||
+ [[ ${OSTYPE%.*} == freebsd5 && -f $indexfile ]] ||
indexfile=$portsdir/INDEX
- [[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return
+ [[ $prev == -l || $prev == -L || $prev == -o ]] && return
- COMPREPLY=( $(command grep -E "^$cur" 2>/dev/null <$indexfile | \
- cut -d'|' -f1) )
- COMPREPLY2=( $(command grep -E "^[^\|]+\|$portsdir$cur" 2>/dev/null \
- <$indexfile | cut -d'|' -f2) )
- COMPREPLY2=( ${COMPREPLY2[@]#$portsdir} )
- COMPREPLY+=( "${COMPREPLY2[@]}" )
+ COMPREPLY=($(command grep -E "^$cur" 2>/dev/null <$indexfile |
+ cut -d'|' -f1))
+ COMPREPLY2=($(command grep -E "^[^\|]+\|$portsdir$cur" 2>/dev/null \
+ <$indexfile | cut -d'|' -f2))
+ COMPREPLY2=(${COMPREPLY2[@]#$portsdir})
+ COMPREPLY+=("${COMPREPLY2[@]}")
} &&
-complete -F _portinstall -o dirnames portinstall
+ complete -F _portinstall -o dirnames portinstall
# ex: filetype=sh
diff --git a/completions/portsnap b/completions/portsnap
index f865183b..a2f0a936 100644
--- a/completions/portsnap
+++ b/completions/portsnap
@@ -8,18 +8,18 @@ _portsnap()
_init_completion || return
case $prev in
- -d|-p)
+ -d | -p)
_filedir -d
return
;;
- -l|-f)
+ -l | -f)
_filedir
return
;;
esac
- COMPREPLY=( $(compgen -W "fetch cron extract update" -- $cur) )
+ COMPREPLY=($(compgen -W "fetch cron extract update" -- $cur))
} &&
-complete -F _portsnap portsnap
+ complete -F _portsnap portsnap
# ex: filetype=sh
diff --git a/completions/portupgrade b/completions/portupgrade
index 42538077..ffe63056 100644
--- a/completions/portupgrade
+++ b/completions/portupgrade
@@ -5,15 +5,15 @@ _portupgrade()
local cur prev words cword
_init_completion || return
- [[ "$prev" == -l || "$prev" == -L || "$prev" == -o ]] && return
+ [[ $prev == -l || $prev == -L || $prev == -o ]] && return
local pkgdir=${PKG_DBDIR:-/var/db/pkg}/
- COMPREPLY=( $(compgen -d -- "$pkgdir$cur") )
- COMPREPLY=( ${COMPREPLY[@]#$pkgdir} )
- COMPREPLY=( ${COMPREPLY[@]%-*} )
+ COMPREPLY=($(compgen -d -- "$pkgdir$cur"))
+ COMPREPLY=(${COMPREPLY[@]#$pkgdir})
+ COMPREPLY=(${COMPREPLY[@]%-*})
} &&
-complete -F _portupgrade -o dirnames portupgrade
+ complete -F _portupgrade -o dirnames portupgrade
# ex: filetype=sh
diff --git a/completions/postcat b/completions/postcat
index 22006233..a58b0e57 100644
--- a/completions/postcat
+++ b/completions/postcat
@@ -13,20 +13,20 @@ _postcat()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
return
fi
local idx qfile=0
for idx in "${words[@]}"; do
- [[ "$idx" == -q ]] && qfile=1 && break
+ [[ $idx == -q ]] && qfile=1 && break
done
- if [[ $qfile -eq 1 ]]; then
+ if ((qfile == 1)); then
local len=${#cur} pval
- for pval in $(mailq 2>/dev/null | \
+ for pval in $(mailq 2>/dev/null |
command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//'); do
- if [[ "$cur" == "${pval:0:$len}" ]]; then
- COMPREPLY+=( $pval )
+ if [[ $cur == "${pval:0:len}" ]]; then
+ COMPREPLY+=($pval)
fi
done
return
@@ -34,6 +34,6 @@ _postcat()
_filedir
} &&
-complete -F _postcat postcat
+ complete -F _postcat postcat
# ex: filetype=sh
diff --git a/completions/postconf b/completions/postconf
index 45b376be..4cb324c1 100644
--- a/completions/postconf
+++ b/completions/postconf
@@ -8,7 +8,7 @@ _postconf()
local eqext
case $prev in
- -b|-t)
+ -b | -t)
_filedir
return
;;
@@ -23,17 +23,17 @@ _postconf()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
return
fi
local len=${#cur} pval
for pval in $(/usr/sbin/postconf 2>/dev/null | cut -d ' ' -f 1); do
- if [[ "$cur" == "${pval:0:$len}" ]]; then
- COMPREPLY+=( "$pval$eqext" )
+ if [[ $cur == "${pval:0:len}" ]]; then
+ COMPREPLY+=("$pval${eqext-}")
fi
done
} &&
-complete -F _postconf postconf
+ complete -F _postconf postconf
# ex: filetype=sh
diff --git a/completions/postfix b/completions/postfix
index eda9ad46..f9605502 100644
--- a/completions/postfix
+++ b/completions/postfix
@@ -11,21 +11,23 @@ _postfix()
return
;;
-D)
- COMPREPLY=( $(compgen -W 'start' -- "$cur") )
+ COMPREPLY=($(compgen -W 'start' -- "$cur"))
return
;;
esac
if [[ $cur == -* ]]; then
- # TODO: doesn't seem to work; the usage message doesn't get output
- # if we try to grep it, it's only output on the console?
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
+ COMPREPLY=($(
+ compgen -W \
+ '$(_bashcomp_try_faketty "$1" --help 2>&1 | _parse_usage -)' \
+ -- "$cur"
+ ))
return
fi
- COMPREPLY=( $(compgen -W 'check start stop abort flush reload status
- set-permissions upgrade-configuration' -- "$cur") )
+ COMPREPLY=($(compgen -W 'check start stop abort flush reload status
+ set-permissions upgrade-configuration' -- "$cur"))
} &&
-complete -F _postfix postfix
+ complete -F _postfix postfix
# ex: filetype=sh
diff --git a/completions/postmap b/completions/postmap
index 66756c1e..35c4ada1 100644
--- a/completions/postmap
+++ b/completions/postmap
@@ -16,26 +16,26 @@ _postmap()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
return
fi
- if [[ "$cur" == *:* ]]; then
+ if [[ $cur == *:* ]]; then
compopt -o filenames
- COMPREPLY=( $(compgen -f -- "${cur#*:}") )
+ COMPREPLY=($(compgen -f -- "${cur#*:}"))
else
local len=${#cur} pval
for pval in $(/usr/sbin/postconf -m 2>/dev/null); do
- if [[ "$cur" == "${pval:0:$len}" ]]; then
- COMPREPLY+=( "$pval:" )
+ if [[ $cur == "${pval:0:len}" ]]; then
+ COMPREPLY+=("$pval:")
fi
done
- if [[ ! $COMPREPLY ]]; then
+ if [[ ! ${COMPREPLY-} ]]; then
compopt -o filenames
- COMPREPLY=( $(compgen -f -- "$cur") )
+ COMPREPLY=($(compgen -f -- "$cur"))
fi
fi
} &&
-complete -F _postmap postmap postalias
+ complete -F _postmap postmap postalias
# ex: filetype=sh
diff --git a/completions/postsuper b/completions/postsuper
index 509d2484..559449aa 100644
--- a/completions/postsuper
+++ b/completions/postsuper
@@ -14,30 +14,30 @@ _postsuper()
;;
-[dr])
len=${#cur}
- for pval in ALL $(mailq 2>/dev/null | \
+ for pval in ALL $(mailq 2>/dev/null |
command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* !].*$//'); do
- if [[ "$cur" == "${pval:0:$len}" ]]; then
- COMPREPLY+=( $pval )
+ if [[ $cur == "${pval:0:len}" ]]; then
+ COMPREPLY+=($pval)
fi
done
return
;;
-h)
len=${#cur}
- for pval in ALL $(mailq 2>/dev/null | \
+ for pval in ALL $(mailq 2>/dev/null |
command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; s/[* ].*$//; /!$/d'); do
- if [[ "$cur" == "${pval:0:$len}" ]]; then
- COMPREPLY+=( $pval )
+ if [[ $cur == "${pval:0:len}" ]]; then
+ COMPREPLY+=($pval)
fi
done
return
;;
-H)
len=${#cur}
- for pval in ALL $(mailq 2>/dev/null | \
+ for pval in ALL $(mailq 2>/dev/null |
command sed -e '1d; $d; /^[^0-9A-Z]/d; /^$/d; /^[0-9A-Z]*[* ]/d; s/!.*$//'); do
- if [[ "$cur" == "${pval:0:$len}" ]]; then
- COMPREPLY+=( $pval )
+ if [[ $cur == "${pval:0:len}" ]]; then
+ COMPREPLY+=($pval)
fi
done
return
@@ -45,12 +45,12 @@ _postsuper()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
return
fi
- COMPREPLY=( $(compgen -W 'hold incoming active deferred' -- "$cur") )
+ COMPREPLY=($(compgen -W 'hold incoming active deferred' -- "$cur"))
} &&
-complete -F _postsuper postsuper
+ complete -F _postsuper postsuper
# ex: filetype=sh
diff --git a/completions/povray b/completions/povray
index c5af018a..56dfd94d 100644
--- a/completions/povray
+++ b/completions/povray
@@ -16,35 +16,41 @@ _povray()
cur="${povcur#[-+]I}" # to confuse _filedir
pfx="${povcur%"$cur"}"
_filedir pov
- COMPREPLY=( ${COMPREPLY[@]/#/$pfx} )
+ COMPREPLY=(${COMPREPLY[@]/#/$pfx})
return
;;
[-+]O*)
# guess what output file type user may want
- case $(IFS=$'\n'; command grep '^[-+]F' <<<"${words[*]}") in
+ case $(
+ IFS=$'\n'
+ command grep '^[-+]F' <<<"${words[*]}"
+ ) in
[-+]FN) oext=png ;;
[-+]FP) oext=ppm ;;
[-+]F[CT]) oext=tga ;;
*) oext=$defoext ;;
esac
# complete filename corresponding to previously specified +I
- COMPREPLY=( $(IFS=$'\n'; command grep '^[-+]I' <<<"${words[*]}") )
- COMPREPLY=( ${COMPREPLY[@]#[-+]I} )
- COMPREPLY=( ${COMPREPLY[@]/%.pov/.$oext} )
+ COMPREPLY=($(
+ IFS=$'\n'
+ command grep '^[-+]I' <<<"${words[*]}"
+ ))
+ COMPREPLY=(${COMPREPLY[@]#[-+]I})
+ COMPREPLY=(${COMPREPLY[@]/%.pov/.$oext})
cur="${povcur#[-+]O}" # to confuse _filedir
pfx="${povcur%"$cur"}"
_filedir $oext
- COMPREPLY=( ${COMPREPLY[@]/#/$pfx} )
+ COMPREPLY=(${COMPREPLY[@]/#/$pfx})
return
;;
- *.ini\[|*.ini\[*[^]]) # sections in .ini files
+ *.ini\[ | *.ini\[*[^]]) # sections in .ini files
cur="${povcur#*\[}"
pfx="${povcur%\["$cur"}" # prefix == filename
[[ -r $pfx ]] || return
- COMPREPLY=( $(command sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' \
- -e 't' -e 'd' -- "$pfx") )
+ COMPREPLY=($(command sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' \
+ -e 't' -e 'd' -- "$pfx"))
# to prevent [bar] expand to nothing. can be done more easily?
- COMPREPLY=( "${COMPREPLY[@]/#/${pfx}[}" )
+ COMPREPLY=("${COMPREPLY[@]/#/${pfx}[}")
return
;;
*)
@@ -53,6 +59,6 @@ _povray()
;;
esac
} &&
-complete -F _povray povray xpovray spovray
+ complete -F _povray povray xpovray spovray
# ex: filetype=sh
diff --git a/completions/prelink b/completions/prelink
index 62580a95..1c39611f 100644
--- a/completions/prelink
+++ b/completions/prelink
@@ -6,18 +6,18 @@ _prelink()
_init_completion -s || return
case $prev in
- -'?'|--help|--usage|-V|--version|-r|--reloc-only)
+ -'?' | --help | --usage | -V | --version | -r | --reloc-only)
return
;;
- -b|--black-list|--dynamic-linker|--undo-output)
+ -b | --black-list | --dynamic-linker | --undo-output)
_filedir
return
;;
- -c|--config-file)
+ -c | --config-file)
_filedir conf
return
;;
- -C|--cache)
+ -C | --cache)
_filedir cache
return
;;
@@ -30,13 +30,13 @@ _prelink()
$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
} &&
-complete -F _prelink prelink
+ complete -F _prelink prelink
# ex: filetype=sh
diff --git a/completions/printenv b/completions/printenv
new file mode 100644
index 00000000..3553e83d
--- /dev/null
+++ b/completions/printenv
@@ -0,0 +1,23 @@
+# printenv(1) completion -*- shell-script -*-
+
+_printenv()
+{
+ local cur prev words cword
+ _init_completion || return
+
+ case $prev in
+ --help | --version)
+ return
+ ;;
+ esac
+
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ return
+ fi
+
+ COMPREPLY=($(compgen -v -- "$cur"))
+} &&
+ complete -F _printenv printenv
+
+# ex: filetype=sh
diff --git a/completions/protoc b/completions/protoc
index d4381446..fdd77be6 100644
--- a/completions/protoc
+++ b/completions/protoc
@@ -6,11 +6,7 @@ _protoc()
_init_completion -s || return
case $prev in
- --proto_path|--cpp_out|--java_out|--python_out)
- _filedir -d
- return
- ;;
- --version|-h|--help|--encode|--decode)
+ --version | -h | --help | --encode | --decode)
return
;;
--descriptor_set_out)
@@ -18,16 +14,20 @@ _protoc()
return
;;
--error_format)
- COMPREPLY=( $(compgen -W 'gcc msvs' -- "$cur") )
+ COMPREPLY=($(compgen -W 'gcc msvs' -- "$cur"))
return
;;
--plugin)
if [[ $cur != *=* ]]; then
compopt -o filenames
- COMPREPLY=( $(compgen -c -- "$cur") )
+ COMPREPLY=($(compgen -c -- "$cur"))
fi
return
;;
+ --proto_path | --*_out)
+ _filedir -d
+ return
+ ;;
esac
$split && return
@@ -36,28 +36,28 @@ _protoc()
-o*)
cur=${cur:2}
_filedir
- COMPREPLY=( "${COMPREPLY[@]/#/-o}" )
+ COMPREPLY=("${COMPREPLY[@]/#/-o}")
return
;;
-I*)
cur=${cur:2}
_filedir -d
- COMPREPLY=( "${COMPREPLY[@]/#/-I}" )
+ COMPREPLY=("${COMPREPLY[@]/#/-I}")
return
;;
-*)
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
local i
for i in "${!COMPREPLY[@]}"; do
[[ ${COMPREPLY[i]} == -oFILE ]] && unset 'COMPREPLY[i]'
done
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
;;
esac
_filedir proto
} &&
-complete -F _protoc protoc
+ complete -F _protoc protoc
# ex: filetype=sh
diff --git a/completions/psql b/completions/psql
index ceedf07e..4bc6049f 100644
--- a/completions/psql
+++ b/completions/psql
@@ -4,16 +4,16 @@ _pg_databases()
{
# -w was introduced in 8.4, https://launchpad.net/bugs/164772
# "Access privileges" in output may contain linefeeds, hence the NF > 1
- COMPREPLY=( $(compgen -W "$(psql -XAtqwlF $'\t' 2>/dev/null | \
- awk 'NF > 1 { print $1 }')" -- "$cur") )
+ COMPREPLY=($(compgen -W "$(psql -XAtqwlF $'\t' 2>/dev/null |
+ awk 'NF > 1 { print $1 }')" -- "$cur"))
}
_pg_users()
{
# -w was introduced in 8.4, https://launchpad.net/bugs/164772
- COMPREPLY=( $(compgen -W "$(psql -XAtqwc 'select usename from pg_user' \
- template1 2>/dev/null)" -- "$cur") )
- [[ ${#COMPREPLY[@]} -eq 0 ]] && COMPREPLY=( $(compgen -u -- "$cur") )
+ COMPREPLY=($(compgen -W "$(psql -XAtqwc 'select usename from pg_user' \
+ template1 2>/dev/null)" -- "$cur"))
+ ((${#COMPREPLY[@]} == 0)) && COMPREPLY=($(compgen -u -- "$cur"))
}
# createdb(1) completion
@@ -24,29 +24,29 @@ _createdb()
_init_completion -s || return
case $prev in
- --host|-!(-*)h)
+ --host | -!(-*)h)
_known_hosts_real -- "$cur"
return
;;
- --username|--owner|-!(-*)[UO])
+ --username | --owner | -!(-*)[UO])
_pg_users
return
;;
- --help|--version|--port|--tablespace|--encoding|--template|-!(-*)[pDET])
+ --help | --version | --port | --tablespace | --encoding | --template | -!(-*)[pDET])
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
_pg_databases
fi
} &&
-complete -F _createdb createdb
+ complete -F _createdb createdb
# createuser(1) completion
#
@@ -56,14 +56,14 @@ _createuser()
_init_completion -s || return
case $prev in
- --help|--version|--port|--connection-limit|-!(-*)[pc])
+ --help | --version | --port | --connection-limit | -!(-*)[pc])
return
;;
- --host|-!(-*)h)
+ --host | -!(-*)h)
_known_hosts_real -- "$cur"
return
;;
- --username|-!(-*)U)
+ --username | -!(-*)U)
_pg_users
return
;;
@@ -71,12 +71,12 @@ _createuser()
$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 _createuser createuser
+ complete -F _createuser createuser
# dropdb(1) completion
#
@@ -86,29 +86,29 @@ _dropdb()
_init_completion -s || return
case $prev in
- --host|-!(-*)h)
+ --host | -!(-*)h)
_known_hosts_real -- "$cur"
return
;;
- --username|-!(-*)U)
+ --username | -!(-*)U)
_pg_users
return
;;
- --help|--version)
+ --help | --version)
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
_pg_databases
fi
} &&
-complete -F _dropdb dropdb
+ complete -F _dropdb dropdb
# dropuser(1) completion
#
@@ -118,14 +118,14 @@ _dropuser()
_init_completion -s || return
case $prev in
- --help|--version|--port|-!(-*)p)
+ --help | --version | --port | -!(-*)p)
return
;;
- --host|-!(-*)h)
+ --host | -!(-*)h)
_known_hosts_real -- "$cur"
return
;;
- --username|-!(-*)U)
+ --username | -!(-*)U)
_pg_users
return
;;
@@ -133,14 +133,14 @@ _dropuser()
$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
_pg_users
fi
} &&
-complete -F _dropuser dropuser
+ complete -F _dropuser dropuser
# psql(1) completion
#
@@ -150,39 +150,39 @@ _psql()
_init_completion -s || return
case $prev in
- --host|-!(-*)h)
+ --host | -!(-*)h)
_known_hosts_real -- "$cur"
return
;;
- --username|-!(-*)U)
+ --username | -!(-*)U)
_pg_users
return
;;
- --dbname|-!(-*)d)
+ --dbname | -!(-*)d)
_pg_databases
return
;;
- --output|--file|--log-file|-!(-*)[ofL])
+ --output | --file | --log-file | -!(-*)[ofL])
_filedir
return
;;
- --help|--version|--command|--field-separator|--port|--pset|\
- --record-separator|--table-attr|--set|--variable|-!(-*)[?VcFpPRTv])
+ --help | --version | --command | --field-separator | --port | --pset | \
+ --record-separator | --table-attr | --set | --variable | -!(-*)[?VcFpPRTv])
return
;;
esac
$split && return
- if [[ "$cur" == -* ]]; then
+ if [[ $cur == -* ]]; then
# return list of available options
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
# return list of available databases
_pg_databases
fi
} &&
-complete -F _psql psql
+ complete -F _psql psql
# ex: filetype=sh
diff --git a/completions/puppet b/completions/puppet
index b9e1bcd6..e8767de1 100644
--- a/completions/puppet
+++ b/completions/puppet
@@ -3,54 +3,54 @@
_puppet_logdest()
{
if [[ -z $cur ]]; then
- COMPREPLY=( $(compgen -W 'syslog console /' -- "$cur") )
+ COMPREPLY=($(compgen -W 'syslog console /' -- "$cur"))
else
- COMPREPLY=( $(compgen -W 'syslog console' -- "$cur") )
+ COMPREPLY=($(compgen -W 'syslog console' -- "$cur"))
_filedir
fi
}
_puppet_digest()
{
- COMPREPLY=( $(compgen -W 'MD5 MD2 SHA1 SHA256' -- "$cur") )
+ COMPREPLY=($(compgen -W 'MD5 MD2 SHA1 SHA256' -- "$cur"))
}
_puppet_certs()
{
local puppetca="puppet cert"
- PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type puppetca &>/dev/null \
- && puppetca=puppetca
+ PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type puppetca &>/dev/null &&
+ puppetca=puppetca
- if [[ "$1" == --all ]]; then
+ if [[ $1 == --all ]]; then
cert_list=$($puppetca --list --all | command sed -e 's/^[+-]\{0,1\}\s*\(\S\+\)\s\+.*$/\1/')
else
cert_list=$($puppetca --list)
fi
- COMPREPLY+=( $(compgen -W "$cert_list" -- "$cur") )
+ COMPREPLY+=($(compgen -W "$cert_list" -- "$cur"))
}
_puppet_types()
{
puppet_types=$(puppet describe --list | command sed -e 's/^\(\S\{1,\}\).*$/\1/')
- COMPREPLY+=( $(compgen -W "$puppet_types" -- "$cur") )
+ COMPREPLY+=($(compgen -W "$puppet_types" -- "$cur"))
}
_puppet_references()
{
local puppetdoc="puppet doc"
- PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type puppetdoc &>/dev/null \
- && puppetdoc=puppetdoc
+ PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type puppetdoc &>/dev/null &&
+ puppetdoc=puppetdoc
puppet_doc_list=$($puppetdoc --list | command sed -e 's/^\(\S\{1,\}\).*$/\1/')
- COMPREPLY+=( $(compgen -W "$puppet_doc_list" -- "$cur") )
+ COMPREPLY+=($(compgen -W "$puppet_doc_list" -- "$cur"))
}
_puppet_subcmd_opts()
{
# puppet cmd help is somewhat slow, avoid if possible
- [[ -z $cur || $cur == -* ]] && \
- COMPREPLY+=( $(compgen -W \
- '$(_parse_usage "$1" "help $2")' -- "$cur") )
+ [[ -z $cur || $cur == -* ]] &&
+ COMPREPLY+=($(compgen -W \
+ '$(_parse_usage "$1" "help $2")' -- "$cur"))
}
_puppet()
@@ -58,10 +58,10 @@ _puppet()
local cur prev words cword
_init_completion || return
- local xspec helpopts subcommand action
+ local subcommand action
case $prev in
- -h|--help|-V|--version)
+ -h | --help | -V | --version)
return
;;
esac
@@ -96,19 +96,20 @@ _puppet()
;;
puppet)
case ${words[1]} in
- agent|apply|cert|describe|doc|filebucket|kick|master|parser|queue|resource)
+ agent | apply | cert | describe | doc | filebucket | kick | master | parser | queue | resource)
subcommand=${words[1]}
;;
- *.pp|*.rb)
+ *.pp | *.rb)
subcommand=apply
;;
*)
- COMPREPLY=( $(compgen -W 'agent apply cert describe doc
+ COMPREPLY=($(compgen -W 'agent apply cert describe doc
filebucket kick master parser queue resource' \
- -- "$cur") )
+ -- "$cur"))
return
;;
esac
+ ;;
esac
case $subcommand in
@@ -126,46 +127,48 @@ _puppet()
_known_hosts_real -- "$cur"
return
;;
- -l|--logdest)
+ -l | --logdest)
_puppet_logdest
return
;;
--masterport)
- COMPREPLY=( $(compgen -W '8140' -- "$cur") )
+ COMPREPLY=($(compgen -W '8140' -- "$cur"))
return
;;
- -w|--waitforcert)
- COMPREPLY=( $(compgen -W '0 15 30 60 120' -- "$cur") )
+ -w | --waitforcert)
+ COMPREPLY=($(compgen -W '0 15 30 60 120' -- "$cur"))
return
;;
*)
_puppet_subcmd_opts "$1" $subcommand
# _parse_usage doesn't grok [-D|--daemonize|--no-daemonize]
- COMPREPLY+=( $(compgen -W '--no-daemonize' -- "$cur") )
+ COMPREPLY+=($(compgen -W '--no-daemonize' -- "$cur"))
return
+ ;;
esac
;;
apply)
case $prev in
--catalog)
- COMPREPLY=( $(compgen -W '-' -- "$cur") )
+ COMPREPLY=($(compgen -W '-' -- "$cur"))
_filedir json
return
;;
--execute)
return
;;
- -l|--logdest)
+ -l | --logdest)
_puppet_logdest
return
;;
*)
- if [[ "$cur" == -* ]]; then
+ if [[ $cur == -* ]]; then
_puppet_subcmd_opts "$1" $subcommand
else
_filedir
fi
return
+ ;;
esac
;;
cert)
@@ -176,117 +179,123 @@ _puppet()
;;
*)
action=$prev
- COMPREPLY=( $(compgen -W '--digest --debug --help --verbose --version' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W '--digest --debug --help --verbose --version' \
+ -- "$cur"))
case $action in
- fingerprint|list|verify|--fingerprint|--list|--verify)
- COMPREPLY+=( $(compgen -W '--all' -- "$cur") )
+ fingerprint | list | verify | --fingerprint | --list | --verify)
+ COMPREPLY+=($(compgen -W '--all' -- "$cur"))
_puppet_certs --all
return
;;
- generate|--generate)
+ generate | --generate)
_known_hosts_real -- "$cur"
return
;;
- clean|print|revoke|--clean|--print|--revoke)
+ clean | print | revoke | --clean | --print | --revoke)
_puppet_certs --all
return
;;
- sign|--sign)
- COMPREPLY+=( $(compgen -W '--all' -- "$cur") )
+ sign | --sign)
+ COMPREPLY+=($(compgen -W '--all' -- "$cur"))
_puppet_certs
return
;;
*)
- COMPREPLY+=( $(compgen -W 'clean fingerprint generate
- list print revoke sign verify reinventory' -- "$cur") )
+ COMPREPLY+=($(compgen -W 'clean fingerprint generate
+ list print revoke sign verify reinventory' -- "$cur"))
return
+ ;;
esac
+ ;;
esac
;;
describe)
_puppet_subcmd_opts "$1" $subcommand
- if [[ "$cur" != -* ]]; then
+ if [[ $cur != -* ]]; then
_puppet_types
fi
return
;;
doc)
case $prev in
- -o|--outputdir)
+ -o | --outputdir)
_filedir -d
return
;;
- -m|--mode)
- COMPREPLY=( $(compgen -W 'text trac pdf rdoc' -- "$cur") )
+ -m | --mode)
+ COMPREPLY=($(compgen -W 'text trac pdf rdoc' -- "$cur"))
return
;;
- -r|--reference)
+ -r | --reference)
_puppet_references
return
;;
*)
- if [[ "$cur" == -* ]]; then
+ if [[ $cur == -* ]]; then
_puppet_subcmd_opts "$1" $subcommand
else
_filedir
fi
return
+ ;;
esac
;;
filebucket)
case $prev in
- -s|--server)
+ -s | --server)
_known_hosts_real -- "$cur"
return
;;
- -b|--bucket)
+ -b | --bucket)
_filedir -d
return
;;
*)
- if [[ "$cur" == -* ]]; then
+ if [[ $cur == -* ]]; then
_puppet_subcmd_opts "$1" $subcommand
else
- COMPREPLY=( $(compgen -W 'backup get restore' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W 'backup get restore' \
+ -- "$cur"))
_filedir
fi
return
+ ;;
esac
;;
kick)
case $prev in
- -c|--class)
+ -c | --class)
return
;;
--host)
_known_hosts_real -- "$cur"
return
;;
- -t|--tag)
+ -t | --tag)
return
;;
*)
- if [[ "$cur" == -* ]]; then
+ if [[ $cur == -* ]]; then
_puppet_subcmd_opts "$1" $subcommand
else
_known_hosts_real -- "$cur"
fi
return
+ ;;
esac
;;
master)
case $prev in
- -l|--logdest)
+ -l | --logdest)
_puppet_logdest
return
;;
*)
_puppet_subcmd_opts "$1" $subcommand
# _parse_usage doesn't grok [-D|--daemonize|--no-daemonize]
- COMPREPLY+=( $(compgen -W '--no-daemonize' -- "$cur") )
+ COMPREPLY+=($(compgen -W '--no-daemonize' -- "$cur"))
return
+ ;;
esac
;;
parser)
@@ -297,31 +306,33 @@ _puppet()
return
;;
*)
- COMPREPLY=( $(compgen -W 'validate' -- "$cur") )
+ COMPREPLY=($(compgen -W 'validate' -- "$cur"))
return
+ ;;
esac
;;
queue)
case $prev in
- -l|--logdest)
+ -l | --logdest)
_puppet_logdest
return
;;
*)
- if [[ "$cur" == -* ]]; then
+ if [[ $cur == -* ]]; then
_puppet_subcmd_opts "$1" $subcommand
else
_filedir
fi
return
+ ;;
esac
;;
- resource|*)
+ resource | *)
_puppet_subcmd_opts "$1" $subcommand
return
;;
esac
} &&
-complete -F _puppet puppetmasterd puppetd puppetca ralsh puppetrun puppetqd filebucket puppetdoc puppet
+ complete -F _puppet puppetmasterd puppetd puppetca ralsh puppetrun puppetqd filebucket puppetdoc puppet
# ex: filetype=sh
diff --git a/completions/pv b/completions/pv
index 007bb36b..99933f29 100644
--- a/completions/pv
+++ b/completions/pv
@@ -6,26 +6,26 @@ _pv()
_init_completion || return
case $prev in
- --help|--version|--last-written|--format|--delay-start|--interval|\
- --width|--height|--name|--rate-limit|--buffer-size|-!(-*)[hVAFDiwHNLB])
+ --help | --version | --last-written | --format | --delay-start | --interval | \
+ --width | --height | --name | --rate-limit | --buffer-size | -!(-*)[hVAFDiwHNLB])
return
;;
- --remote|-!(-*)R)
+ --remote | -!(-*)R)
_pids
return
;;
- --pidfile|--watchfd|-!(-*)[Pd])
+ --pidfile | --watchfd | -!(-*)[Pd])
_filedir pid
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
else
_filedir
fi
} &&
-complete -F _pv pv
+ complete -F _pv pv
# ex: filetype=sh
diff --git a/completions/pwck b/completions/pwck
index cc5f2e42..fa07b0e1 100644
--- a/completions/pwck
+++ b/completions/pwck
@@ -5,14 +5,14 @@ _pwck()
local cur prev words cword
_init_completion || return
- 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 _pwck pwck
+ complete -F _pwck pwck
# ex: filetype=sh
diff --git a/completions/pwd b/completions/pwd
index 56100173..b9c4fbc0 100644
--- a/completions/pwd
+++ b/completions/pwd
@@ -6,15 +6,15 @@ _pwd()
_init_completion || return
case $prev in
- --help|--version)
+ --help | --version)
return
;;
esac
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
- [[ $COMPREPLY ]] || \
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ [[ ${COMPREPLY-} ]] ||
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
} &&
-complete -F _pwd pwd
+ complete -F _pwd pwd
# ex: filetype=sh
diff --git a/completions/pwdx b/completions/pwdx
index 675c41ff..25a1a1e1 100644
--- a/completions/pwdx
+++ b/completions/pwdx
@@ -6,7 +6,7 @@ _pwdx()
_init_completion || return
case $prev in
- -h|--help|-V|--version)
+ -h | --help | -V | --version)
return
;;
esac
@@ -14,11 +14,11 @@ _pwdx()
if [[ $cur == -* ]]; then
local help='$(_parse_help "$1")'
[[ $help ]] || help=-V
- COMPREPLY=( $(compgen -W "$help" -- "$cur") )
+ COMPREPLY=($(compgen -W "$help" -- "$cur"))
else
_pids
fi
} &&
-complete -F _pwdx pwdx
+ complete -F _pwdx pwdx
# ex: filetype=sh
diff --git a/completions/pwgen b/completions/pwgen
index 8781cb9a..50d31d5f 100644
--- a/completions/pwgen
+++ b/completions/pwgen
@@ -6,10 +6,10 @@ _pwgen()
_init_completion -s || return
case $prev in
- --num-passwords|--help|-!(-*)[Nh])
+ --num-passwords | --help | -!(-*)[Nh])
return
;;
- --sha1|-!(-*)H)
+ --sha1 | -!(-*)H)
_filedir
return
;;
@@ -18,11 +18,11 @@ _pwgen()
$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
} &&
-complete -F _pwgen pwgen
+ complete -F _pwgen pwgen
# ex: filetype=sh
diff --git a/completions/pycodestyle b/completions/pycodestyle
index 2eac748c..dec6f375 100644
--- a/completions/pycodestyle
+++ b/completions/pycodestyle
@@ -6,11 +6,11 @@ _pycodestyle()
_init_completion -s || return
case $prev in
- -h|--help|--version)
+ -h | --help | --version)
return
;;
--format)
- COMPREPLY=( $(compgen -W 'default pylint' -- "$cur") )
+ COMPREPLY=($(compgen -W 'default pylint' -- "$cur"))
return
;;
--config)
@@ -22,13 +22,13 @@ _pycodestyle()
$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 _pycodestyle pycodestyle
+ complete -F _pycodestyle pycodestyle
# ex: filetype=sh
diff --git a/completions/pydoc b/completions/pydoc
index 1e904885..e7b11788 100644
--- a/completions/pydoc
+++ b/completions/pydoc
@@ -6,7 +6,7 @@ _pydoc()
_init_completion || return
case $prev in
- -k|-p)
+ -k | -p)
return
;;
-w)
@@ -15,27 +15,28 @@ _pydoc()
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W \
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W \
'$("$1" | command sed -e "s/^pydoc3\{0,1\} //" | _parse_help -)' \
- -- "$cur") )
+ -- "$cur"))
return
fi
- COMPREPLY=( $(compgen -W 'keywords topics modules' -- "$cur") )
+ COMPREPLY=($(compgen -W 'keywords topics modules' -- "$cur"))
if [[ $cur != @(.|*/)* ]]; then
- local python=python; [[ ${1##*/} == *3* ]] && python=python3
+ local python=python
+ [[ ${1##*/} == *3* ]] && python=python3
_xfunc python _python_modules $python
fi
# Note that we don't do "pydoc modules" as it is known to hang on
# some systems; _python_modules tends to work better and faster.
- COMPREPLY+=( $(compgen -W \
- '$($1 keywords topics | command sed -e /^Here/d)' -- "$cur") )
+ COMPREPLY+=($(compgen -W \
+ '$($1 keywords topics | command sed -e /^Here/d)' -- "$cur"))
_filedir py
} &&
-complete -F _pydoc pydoc pydoc3
+ complete -F _pydoc pydoc pydoc3
# ex: filetype=sh
diff --git a/completions/pydocstyle b/completions/pydocstyle
index eb858901..acbf1ece 100644
--- a/completions/pydocstyle
+++ b/completions/pydocstyle
@@ -6,8 +6,8 @@ _pydocstyle()
_init_completion -s || return
case $prev in
- --help|--version|--match|--ignore-decorators|--select|--ignore|\
- --add-select|--add-ignore|-!(-*)h)
+ --help | --version | --match | --ignore-decorators | --select | --ignore | \
+ --add-select | --add-ignore | -!(-*)h)
return
;;
--config)
@@ -15,21 +15,21 @@ _pydocstyle()
return
;;
--convention)
- COMPREPLY=( $(compgen -W "pep257 numpy" -- "$cur") )
+ COMPREPLY=($(compgen -W "pep257 numpy" -- "$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
return
fi
_filedir py
} &&
-complete -F _pydocstyle pydocstyle
+ complete -F _pydocstyle pydocstyle
# ex: filetype=sh
diff --git a/completions/pyflakes b/completions/pyflakes
index 4a982784..0a4e9771 100644
--- a/completions/pyflakes
+++ b/completions/pyflakes
@@ -6,18 +6,18 @@ _pyflakes()
_init_completion || return
case $prev in
- -h|--help|--version)
+ -h | --help | --version)
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
return
fi
_filedir py
} &&
-complete -F _pyflakes pyflakes
+ complete -F _pyflakes pyflakes
# ex: filetype=sh
diff --git a/completions/pylint b/completions/pylint
index 35655964..8726f8bb 100644
--- a/completions/pylint
+++ b/completions/pylint
@@ -5,63 +5,66 @@ _pylint()
local cur prev words cword split
_init_completion -s || return
- local python=python; [[ ${1##*/} == *3* ]] && python=python3
+ local python=python
+ [[ ${1##*/} == *3* ]] && python=python3
case $prev in
- --version|--help|--long-help|--help-msg|--init-hook|--ignore|--enable|\
- --evaluation|--max-line-length|--max-module-lines|\
- --indent-string|--min-similarity-lines|--max-args|\
- --ignored-argument-names|--max-locals|--max-returns|--max-branchs|\
- --max-statements|--max-parents|--max-attributes|--min-public-methods|\
- --max-public-methods|--required-attributes|--bad-functions|\
- --module-rgx|--const-rgx|--class-rgx|--function-rgx|--method-rgx|\
- --attr-rgx|--argument-rgx|--variable-rgx|--inlinevar-rgx|--good-names|\
- --bad-names|--no-docstring-rgx|--dummy-variables-rgx|\
- --additional-builtins|--notes|--ignored-classes|--generated-members|\
- --overgeneral-exceptions|--ignore-iface-methods|\
- --defining-attr-methods|--valid-classmethod-first-arg|\
- --valid-metaclass-classmethod-first-arg|-!(-*)[he])
+ --version | --help | --long-help | --help-msg | --init-hook | --ignore | --enable | \
+ --evaluation | --max-line-length | --max-module-lines | \
+ --indent-string | --min-similarity-lines | --max-args | \
+ --ignored-argument-names | --max-locals | --max-returns | --max-branchs | \
+ --max-statements | --max-parents | --max-attributes | --min-public-methods | \
+ --max-public-methods | --required-attributes | --bad-functions | \
+ --module-rgx | --const-rgx | --class-rgx | --function-rgx | --method-rgx | \
+ --attr-rgx | --argument-rgx | --variable-rgx | --inlinevar-rgx | --good-names | \
+ --bad-names | --no-docstring-rgx | --dummy-variables-rgx | \
+ --additional-builtins | --notes | --ignored-classes | --generated-members | \
+ --overgeneral-exceptions | --ignore-iface-methods | \
+ --defining-attr-methods | --valid-classmethod-first-arg | \
+ --valid-metaclass-classmethod-first-arg | -!(-*)[he])
return
;;
- --disable|-!(-*)d)
- COMPREPLY=( $(compgen -W 'all' -- "$cur") )
+ --disable | -!(-*)d)
+ COMPREPLY=($(compgen -W 'all' -- "$cur"))
return
;;
--rcfile)
_filedir
return
;;
- --persistent|--include-ids|--symbols|--files-output|--reports|\
- --comment|--ignore-comments|--ignore-docstrings|--ignore-imports|\
- --init-import|--ignore-mixin-members|--zope|--suggestion-mode|\
- -!(-*)[isr])
- COMPREPLY=( $(compgen -W 'yes no' -- "$cur") )
+ --persistent | --include-ids | --symbols | --files-output | --reports | \
+ --comment | --ignore-comments | --ignore-docstrings | --ignore-imports | \
+ --init-import | --ignore-mixin-members | --zope | --suggestion-mode | \
+ -!(-*)[isr])
+ COMPREPLY=($(compgen -W 'yes no' -- "$cur"))
return
;;
- --load-plugins|--deprecated-modules)
- local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*},"
+ --load-plugins | --deprecated-modules)
+ local prefix=
+ [[ $cur == *,* ]] && prefix="${cur%,*},"
cur="${cur##*,}"
_xfunc python _python_modules $python
- [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} )
+ ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
return
;;
- --jobs|-!(-*)j)
- COMPREPLY=( $(compgen -W "{1..$(_ncpus)}" -- "$cur") )
+ --jobs | -!(-*)j)
+ COMPREPLY=($(compgen -W "{1..$(_ncpus)}" -- "$cur"))
return
;;
--confidence)
- local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*},"
- COMPREPLY=( $(compgen -W "HIGH INFERENCE INFERENCE_FAILURE
- UNDEFINED" -- "${cur##*,}") )
- [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} )
+ local prefix=
+ [[ $cur == *,* ]] && prefix="${cur%,*},"
+ COMPREPLY=($(compgen -W "HIGH INFERENCE INFERENCE_FAILURE
+ UNDEFINED" -- "${cur##*,}"))
+ ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
return
;;
- --format|-!(-*)f)
- COMPREPLY=( $(compgen -W 'text parseable colorized json msvs' \
- -- "$cur") )
+ --format | -!(-*)f)
+ COMPREPLY=($(compgen -W 'text parseable colorized json msvs' \
+ -- "$cur"))
return
;;
- --import-graph|--ext-import-graph|--int-import-graph)
+ --import-graph | --ext-import-graph | --int-import-graph)
_filedir dot
return
;;
@@ -70,15 +73,15 @@ _pylint()
$split && return
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W \
- '$(_parse_help "$1" --long-help)' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ COMPREPLY=($(compgen -W \
+ '$(_parse_help "$1" --long-help)' -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
[[ $cur == @(.|*/)* ]] || _xfunc python _python_modules $python
_filedir py
} &&
-complete -F _pylint pylint pylint-2 pylint-3
+ complete -F _pylint pylint pylint-2 pylint-3
# ex: filetype=sh
diff --git a/completions/pytest b/completions/pytest
index 9239766c..7457a840 100644
--- a/completions/pytest
+++ b/completions/pytest
@@ -3,38 +3,46 @@
_pytest()
{
local cur prev words cword split
- _init_completion -s || return
+ _init_completion -s -n : || return
case $prev in
- --help|--maxfail|--report|--junit-prefix|--doctest-glob|-!(-*)[hkmrp])
+ --help | --maxfail | --report | --junit-prefix | --doctest-glob | -!(-*)[hkmorp])
return
;;
--import-mode)
- COMPREPLY=( $(compgen -W "prepend append" -- "$cur") )
+ COMPREPLY=($(compgen -W "prepend append" -- "$cur"))
return
;;
--capture)
- COMPREPLY=( $(compgen -W "fd sys no" -- "$cur") )
+ COMPREPLY=($(compgen -W "fd sys no tee-sys" -- "$cur"))
+ return
+ ;;
+ --lfnf | --last-failed-no-failures)
+ COMPREPLY=($(compgen -W "all none" -- "$cur"))
return
;;
--tb)
- COMPREPLY=( $(compgen -W "auto long short line native no" \
- -- "$cur") )
+ COMPREPLY=($(compgen -W "auto long short line native no" \
+ -- "$cur"))
+ return
+ ;;
+ --show-capture)
+ COMPREPLY=($(compgen -W "no stdout stderr log all" -- "$cur"))
return
;;
--color)
- COMPREPLY=( $(compgen -W "yes no auto" -- "$cur") )
+ COMPREPLY=($(compgen -W "yes no auto" -- "$cur"))
return
;;
--pastebin)
- COMPREPLY=( $(compgen -W "failed all" -- "$cur") )
+ COMPREPLY=($(compgen -W "failed all" -- "$cur"))
return
;;
--junit-xml)
_filedir xml
return
;;
- --result-log)
+ --result-log | --log-file)
_filedir log
return
;;
@@ -42,45 +50,85 @@ _pytest()
_filedir
return
;;
- --confcutdir|--basetemp|--rsyncdir)
+ --confcutdir | --basetemp | --rsyncdir | --rootdir)
_filedir -d
return
;;
+ --doctest-report)
+ COMPREPLY=($(compgen -W "none cdiff ndiff udiff only_first_failure" -- "$cur"))
+ return
+ ;;
--assert)
- COMPREPLY=( $(compgen -W "plain reinterp rewrite" -- "$cur") )
+ COMPREPLY=($(compgen -W "plain reinterp rewrite" -- "$cur"))
return
;;
--genscript)
_filedir py
return
;;
- --pythonwarnings|-!(-*)W)
+ --pythonwarnings | -!(-*)W)
_xfunc python _python_warning_actions
return
;;
- --numprocesses|-!(-*)n)
- COMPREPLY=( $(compgen -W "{1..$(_ncpus)} auto" -- "$cur") )
+ --numprocesses | -!(-*)n)
+ COMPREPLY=($(compgen -W "{1..$(_ncpus)} auto" -- "$cur"))
return
;;
--dist)
- local modes=$("$1" --dist=nonexistent-distmode 2>&1 | \
+ local modes=$("$1" --dist=nonexistent-distmode 2>&1 |
command sed -e 's/[^[:space:][:alnum:]-]\{1,\}//g' \
- -ne 's/.*choose from //p')
- COMPREPLY=( $(compgen -W '$modes' -- "$cur") )
+ -ne 's/.*choose from //p')
+ COMPREPLY=($(compgen -W '$modes' -- "$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
+ return
+ fi
+
+ if [[ $cur == *.py::*:* ]]; then
+ local file=${cur/.py:*/.py}
+ local class=${cur#*.py::} in_class=false
+ local line
+ class=${class%%:*}
+ while IFS= read -r line; do
+ if [[ $line =~ ^class[[:space:]]+${class}[[:space:]:\(] ]]; then
+ in_class=true
+ elif [[ $line =~ ^class[[:space:]] ]]; then
+ in_class=false
+ fi
+ if $in_class && [[ $line =~ ^[[:space:]]+(async[[:space:]]+)?def[[:space:]]+(test_[A-Za-z0-9_]+) ]]; then
+ COMPREPLY+=(${BASH_REMATCH[2]})
+ fi
+ done 2>/dev/null <"$file"
+ ((!${#COMPREPLY[@]})) ||
+ COMPREPLY=($(compgen -P "$file::$class::" -W '${COMPREPLY[@]}' \
+ -- "${cur##*:?(:)}"))
+ __ltrim_colon_completions "$cur"
+ return
+ elif [[ $cur == *.py:* ]]; then
+ local file="${cur/.py:*/.py}" line
+ while IFS= read -r line; do
+ if [[ $line =~ ^class[[:space:]]+(Test[A-Za-z0-9_]+) ]]; then
+ COMPREPLY+=(${BASH_REMATCH[1]})
+ elif [[ $line =~ ^(async[[:space:]]+)?def[[:space:]]+(test_[A-Za-z0-9_]+) ]]; then
+ COMPREPLY+=(${BASH_REMATCH[2]})
+ fi
+ done 2>/dev/null <"$file"
+ ((!${#COMPREPLY[@]})) ||
+ COMPREPLY=($(compgen -P "$file::" -W '${COMPREPLY[@]}' \
+ -- "${cur##*.py:?(:)}"))
+ __ltrim_colon_completions "$cur"
return
fi
_filedir py
} &&
-complete -F _pytest pytest pytest-2 pytest-3 py.test py.test-2 py.test-3
+ complete -F _pytest pytest pytest-2 pytest-3 py.test py.test-2 py.test-3
# ex: filetype=sh
diff --git a/completions/python b/completions/python
index 5e69ff12..d50c18f0 100644
--- a/completions/python
+++ b/completions/python
@@ -2,15 +2,15 @@
_python_modules()
{
- COMPREPLY+=( $(compgen -W \
+ COMPREPLY+=($(compgen -W \
"$(${1:-python} ${BASH_SOURCE[0]%/*}/../helpers/python $cur \
- 2>/dev/null)" -- "$cur") )
+ 2>/dev/null)" -- "$cur"))
}
_python_warning_actions()
{
- COMPREPLY+=( $(compgen -W "ignore default all module once error" \
- ${prefix:+-P "$prefix"} -- "$cur") )
+ COMPREPLY+=($(compgen -W "ignore default all module once error" \
+ ${prefix:+-P "$prefix"} -- "$cur"))
}
_python()
@@ -23,11 +23,11 @@ _python()
prefix=${cur:0:2}
prev=$prefix
cur=${cur:2}
- ;;
+ ;;
esac
case $prev in
- --help|--version|-!(-*)[?hVcX])
+ --help | --version | -!(-*)[?hVcX])
return
;;
-!(-*)m)
@@ -35,8 +35,8 @@ _python()
return
;;
-!(-*)Q)
- COMPREPLY=( $(compgen -W "old new warn warnall" -P "$prefix" \
- -- "$cur") )
+ COMPREPLY=($(compgen -W "old new warn warnall" -P "$prefix" \
+ -- "$cur"))
return
;;
-!(-*)W)
@@ -45,24 +45,23 @@ _python()
;;
--jit)
# TODO: quite a few others, parse from "--jit help" output?
- COMPREPLY=( $(compgen -W "help off" -- "$cur") )
+ COMPREPLY=($(compgen -W "help off" -- "$cur"))
return
;;
!(?(*/)python*([0-9.])|?(*/)pypy*([0-9.])|-?))
- [[ $cword -lt 2 || ${words[cword-2]} != -[QWX] ]] && _filedir
+ [[ $cword -lt 2 || ${words[cword - 2]} != -[QWX] ]] && _filedir
;;
esac
-
# if -c or -m is already given, complete all kind of files.
- if [[ "${words[*]::$cword}" == *\ -[cm]\ * ]]; then
+ if [[ ${words[*]::cword} == *\ -[cm]\ * ]]; then
_filedir
- elif [[ "$cur" != -* ]]; then
+ elif [[ $cur != -* ]]; then
_filedir 'py?([cowz])'
else
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
fi
} &&
-complete -F _python python python2 python3 pypy pypy3 micropython
+ complete -F _python python python2 python2.7 python3 python3.{3..8} pypy pypy3 micropython
# ex: filetype=sh
diff --git a/completions/pyvenv b/completions/pyvenv
index d5135e87..527a3840 100644
--- a/completions/pyvenv
+++ b/completions/pyvenv
@@ -6,20 +6,20 @@ _pyvenv()
_init_completion -s || return
case $prev in
- -h|--help)
+ -h | --help)
return
;;
esac
$split && return
- if [[ "$cur" == -* ]]; then
+ if [[ $cur == -* ]]; then
_longopt "$1"
return
fi
_filedir -d
} &&
-complete -F _pyvenv pyvenv pyvenv-3.{4..8}
+ complete -F _pyvenv pyvenv pyvenv-3.{4..8}
# ex: filetype=sh
diff --git a/completions/qdbus b/completions/qdbus
index 9a22e800..5b5a5e37 100644
--- a/completions/qdbus
+++ b/completions/qdbus
@@ -5,10 +5,10 @@ _qdbus()
local cur prev words cword
_init_completion || return
- [[ -n $cur ]] && unset "words[$((${#words[@]}-1))]"
- COMPREPLY=( $(compgen -W '$(command ${words[@]} 2>/dev/null | \
- command sed "s/(.*)//")' -- "$cur") )
+ [[ -n $cur ]] && unset "words[$((${#words[@]} - 1))]"
+ COMPREPLY=($(compgen -W '$(command ${words[@]} 2>/dev/null | \
+ command sed "s/(.*)//")' -- "$cur"))
} &&
-complete -F _qdbus qdbus dcop
+ complete -F _qdbus qdbus dcop
# ex: filetype=sh
diff --git a/completions/qemu b/completions/qemu
index 8602cebd..83829812 100644
--- a/completions/qemu
+++ b/completions/qemu
@@ -6,88 +6,88 @@ _qemu()
_init_completion || return
case $prev in
- -fd[ab]|-hd[abcd]|-cdrom|-option-rom|-kernel|-initrd|-bootp|-pidfile| \
- -loadvm|-mtdblock|-sd|-pflash|-bios)
+ -fd[ab] | -hd[abcd] | -cdrom | -option-rom | -kernel | -initrd | -bootp | -pidfile | \
+ -loadvm | -mtdblock | -sd | -pflash | -bios)
_filedir
return
;;
- -tftp|-smb|-L|-chroot)
+ -tftp | -smb | -L | -chroot)
_filedir -d
return
;;
-boot)
- COMPREPLY=( $(compgen -W 'a c d n' -- "$cur") )
+ COMPREPLY=($(compgen -W 'a c d n' -- "$cur"))
return
;;
-k)
- COMPREPLY=( $(compgen -W 'ar de-ch es fo fr-ca hu ja mk no pt-br
+ COMPREPLY=($(compgen -W 'ar de-ch es fo fr-ca hu ja mk no pt-br
sv da en-gb et fr fr-ch is lt nl pl ru th de en-us fi fr-be hr
- it lv nl-be pt sl tr' -- "$cur") )
+ it lv nl-be pt sl tr' -- "$cur"))
return
;;
-soundhw)
- COMPREPLY=( $(compgen -W "$($1 -soundhw ? | awk \
- '/^[[:lower:]]/ {print $1}') all" -- "$cur") )
+ COMPREPLY=($(compgen -W "$($1 -soundhw help | awk \
+ '/^[[:lower:]]/ {print $1}') all" -- "$cur"))
return
;;
- -M)
- COMPREPLY=( $(compgen -W "$($1 -M ? | awk \
- '/^[[:lower:]]/ {print $1}')" -- "$cur") )
+ -machine | -M)
+ COMPREPLY=($(compgen -W "$($1 $prev help | awk \
+ '/^[[:lower:]]/ {print $1}')" -- "$cur"))
return
;;
-cpu)
- COMPREPLY=( $(compgen -W "$($1 -cpu ? | awk '{print $2}')" \
- -- "$cur") )
+ COMPREPLY=($(compgen -W "$($1 -cpu help | awk '{print $2}')" \
+ -- "$cur"))
return
;;
-usbdevice)
- COMPREPLY=( $(compgen -W 'mouse tablet disk: host: serial: braille
- net' -- "$cur") )
+ COMPREPLY=($(compgen -W 'mouse tablet disk: host: serial: braille
+ net' -- "$cur"))
return
;;
-net)
- COMPREPLY=( $(compgen -W 'nic user tap socket vde none dump' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W 'nic user tap socket vde none dump' \
+ -- "$cur"))
return
;;
- -serial|-parallel|-monitor)
- COMPREPLY=( $(compgen -W 'vc pty none null /dev/ file: stdio pipe:
- COM udp: tcp: telnet: unix: mon: braille' -- "$cur") )
+ -serial | -parallel | -monitor)
+ COMPREPLY=($(compgen -W 'vc pty none null /dev/ file: stdio pipe:
+ COM udp: tcp: telnet: unix: mon: braille' -- "$cur"))
return
;;
-redir)
- COMPREPLY=( $(compgen -S":" -W 'tcp udp' -- "$cur") )
+ COMPREPLY=($(compgen -S":" -W 'tcp udp' -- "$cur"))
return
;;
-bt)
- COMPREPLY=( $(compgen -W 'hci vhci device' -- "$cur") )
+ COMPREPLY=($(compgen -W 'hci vhci device' -- "$cur"))
return
;;
-vga)
- COMPREPLY=( $(compgen -W 'cirrus std vmware xenfb none' -- "$cur") )
+ COMPREPLY=($(compgen -W 'cirrus std vmware xenfb none' -- "$cur"))
return
;;
-drive)
- COMPREPLY=( $(compgen -S"=" -W 'file if bus unit index media cyls
- snapshot cache format serial addr' -- "$cur") )
+ COMPREPLY=($(compgen -S"=" -W 'file if bus unit index media cyls
+ snapshot cache format serial addr' -- "$cur"))
return
;;
-balloon)
- COMPREPLY=( $(compgen -W 'none virtio' -- "$cur") )
+ COMPREPLY=($(compgen -W 'none virtio' -- "$cur"))
return
;;
-smbios)
- COMPREPLY=( $(compgen -W 'file type' -- "$cur") )
+ COMPREPLY=($(compgen -W 'file type' -- "$cur"))
return
;;
-watchdog)
- COMPREPLY=( $(compgen -W "$($1 -watchdog ? 2>&1 | \
- awk '{print $1}')" -- "$cur") )
+ COMPREPLY=($(compgen -W "$($1 -watchdog help 2>&1 |
+ awk '{print $1}')" -- "$cur"))
return
;;
-watchdog-action)
- COMPREPLY=( $(compgen -W 'reset shutdown poweroff pause debug
- none' -- "$cur") )
+ COMPREPLY=($(compgen -W 'reset shutdown poweroff pause debug
+ none' -- "$cur"))
return
;;
-runas)
@@ -96,14 +96,13 @@ _qemu()
;;
esac
-
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help) -fd{a,b}
- -hd{a..d}' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" -help) -fd{a,b}
+ -hd{a..d}' -- "$cur"))
else
_filedir
fi
} &&
-complete -F _qemu qemu qemu-kvm qemu-system-i386 qemu-system-x86_64
+ complete -F _qemu qemu qemu-kvm qemu-system-i386 qemu-system-x86_64
# ex: filetype=sh
diff --git a/completions/qrunner b/completions/qrunner
index b0421a09..3919ea25 100644
--- a/completions/qrunner
+++ b/completions/qrunner
@@ -7,12 +7,12 @@ _qrunner()
$split && return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '--runner --once --list --verbose --subproc
- --help' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '--runner --once --list --verbose --subproc
+ --help' -- "$cur"))
fi
} &&
-complete -F _qrunner qrunner
+ complete -F _qrunner qrunner
# ex: filetype=sh
diff --git a/completions/querybts b/completions/querybts
index 69c5aa08..edeba967 100644
--- a/completions/querybts
+++ b/completions/querybts
@@ -6,18 +6,18 @@ _querybts()
_init_completion -s || return
case $prev in
- --bts|-!(-*)B)
- COMPREPLY=( $(compgen -W "debian guug kde mandrake help" \
- -- "$cur") )
+ --bts | -!(-*)B)
+ COMPREPLY=($(compgen -W "debian guug kde mandrake help" \
+ -- "$cur"))
return
;;
- --ui|--interface|-!(-*)u)
- COMPREPLY=( $(compgen -W "newt text gnome" -- "$cur") )
+ --ui | --interface | -!(-*)u)
+ COMPREPLY=($(compgen -W "newt text gnome" -- "$cur"))
return
;;
--mbox-reader-cmd)
compopt -o filenames
- COMPREPLY=( $(compgen -c -- "$cur") )
+ COMPREPLY=($(compgen -c -- "$cur"))
return
;;
esac
@@ -25,16 +25,16 @@ _querybts()
$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
- COMPREPLY=( $(compgen -W 'wnpp boot-floppies kernel bugs.debian.org
+ COMPREPLY=($(compgen -W 'wnpp boot-floppies kernel bugs.debian.org
cdimage.debian.org general installation-reports listarchives
lists.debian.org mirrors nm.debian.org press project qa.debian.org
release-notes security.debian.org tech-ctte upgrade-reports
- www.debian.org $(apt-cache pkgnames 2>/dev/null)' -- "$cur") )
+ www.debian.org $(_xfunc apt-cache _apt_cache_packages)' -- "$cur"))
fi
} &&
-complete -F _querybts querybts
+ complete -F _querybts querybts
# ex: filetype=sh
diff --git a/completions/quota b/completions/quota
index bf7319bc..f5f9cc82 100644
--- a/completions/quota
+++ b/completions/quota
@@ -5,35 +5,35 @@ _user_or_group()
local i
# complete on groups if -g was given
- for (( i=1; i < cword; i++ )); do
- if [[ "${words[i]}" == -@(g|-group) ]]; then
- COMPREPLY=( $(compgen -g -- "$cur") )
+ for ((i = 1; i < cword; i++)); do
+ if [[ ${words[i]} == -@(g|-group) ]]; then
+ COMPREPLY=($(compgen -g -- "$cur"))
return
fi
done
# otherwise complete on users
- COMPREPLY=( $(compgen -u -- "$cur") )
+ COMPREPLY=($(compgen -u -- "$cur"))
}
_quota_parse_help()
{
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
}
_quota_formats()
{
- COMPREPLY=( $(compgen -W 'vfsold vfsv0 rpc xfs' -- "$cur") )
+ COMPREPLY=($(compgen -W 'vfsold vfsv0 rpc xfs' -- "$cur"))
}
_filesystems()
{
# Only list filesystems starting with "/", otherwise we also get
#+ "binfmt_misc", "proc", "tmpfs", ...
- COMPREPLY=( $(compgen -W "$(awk '/^\// {print $1}' /etc/mtab)" \
- -- "$cur") )
+ COMPREPLY=($(compgen -W "$(awk '/^\// {print $1}' /etc/mtab)" \
+ -- "$cur"))
}
_quota()
@@ -42,24 +42,24 @@ _quota()
_init_completion -s || return
case $prev in
- -F|--format)
+ -F | --format)
_quota_formats
return
;;
- -h|--help|-V|--version)
+ -h | --help | -V | --version)
return
;;
esac
$split && return
- if [[ "$cur" == -* ]]; then
+ if [[ $cur == -* ]]; then
_quota_parse_help "$1"
else
_user_or_group
fi
} &&
-complete -F _quota -o default quota
+ complete -F _quota -o default quota
_setquota()
{
@@ -67,22 +67,22 @@ _setquota()
_init_completion -s || return
case $prev in
- -F|--format)
+ -F | --format)
_quota_formats
return
;;
- -p|--prototype)
+ -p | --prototype)
_user_or_group
return
;;
- -h|--help|-V|--version)
+ -h | --help | -V | --version)
return
;;
esac
$split && return
- if [[ "$cur" == -* ]]; then
+ if [[ $cur == -* ]]; then
_quota_parse_help "$1"
else
local args
@@ -99,7 +99,7 @@ _setquota()
fi
} &&
-complete -F _setquota -o default setquota
+ complete -F _setquota -o default setquota
_edquota()
{
@@ -107,32 +107,32 @@ _edquota()
_init_completion -s || return
case $prev in
- -F|--format)
+ -F | --format)
_quota_formats
return
;;
- -f|--filesystem)
+ -f | --filesystem)
_filesystems
return
;;
- -p|--prototype)
+ -p | --prototype)
_user_or_group
return
;;
- -h|--help|-V|--version)
+ -h | --help | -V | --version)
return
;;
esac
$split && return
- if [[ "$cur" == -* ]]; then
+ if [[ $cur == -* ]]; then
_quota_parse_help "$1"
else
_user_or_group
fi
} &&
-complete -F _edquota -o default edquota
+ complete -F _edquota -o default edquota
_quotacheck()
{
@@ -140,24 +140,24 @@ _quotacheck()
_init_completion -s || return
case $prev in
- -F|--format)
+ -F | --format)
_quota_formats
return
;;
- -h|--help|-V|--version)
+ -h | --help | -V | --version)
return
;;
esac
$split && return
- if [[ "$cur" == -* ]]; then
+ if [[ $cur == -* ]]; then
_quota_parse_help "$1"
else
_filesystems
fi
} &&
-complete -F _quotacheck -o default quotacheck repquota
+ complete -F _quotacheck -o default quotacheck repquota
_quotaon()
{
@@ -165,27 +165,27 @@ _quotaon()
_init_completion -s || return
case $prev in
- -F|--format)
+ -F | --format)
_quota_formats
return
;;
- -x|--xfs-command)
- COMPREPLY=( $(compgen -W 'delete enforce' -- "$cur") )
+ -x | --xfs-command)
+ COMPREPLY=($(compgen -W 'delete enforce' -- "$cur"))
return
;;
- -h|--help|-V|--version)
+ -h | --help | -V | --version)
return
;;
esac
$split && return
- if [[ "$cur" == -* ]]; then
+ if [[ $cur == -* ]]; then
_quota_parse_help "$1"
else
_filesystems
fi
} &&
-complete -F _quotaon -o default quotaon quotaoff
+ complete -F _quotaon -o default quotaon quotaoff
# ex: filetype=sh
diff --git a/completions/radvdump b/completions/radvdump
index 469c8f12..850628fd 100644
--- a/completions/radvdump
+++ b/completions/radvdump
@@ -6,17 +6,17 @@ _radvdump()
_init_completion || return
case $prev in
- -h|--help|-v|--version)
+ -h | --help | -v | --version)
return
;;
- -d|--debug)
- COMPREPLY=( $(compgen -W '{1..4}' -- "$cur") )
+ -d | --debug)
+ COMPREPLY=($(compgen -W '{1..4}' -- "$cur"))
return
;;
esac
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
} &&
-complete -F _radvdump radvdump
+ complete -F _radvdump radvdump
# ex: filetype=sh
diff --git a/completions/rcs b/completions/rcs
index cfad0211..c04d89d2 100644
--- a/completions/rcs
+++ b/completions/rcs
@@ -11,26 +11,26 @@ _rcs()
dir=${cur%/*}
# deal with relative directory
- [[ $file == $dir ]] && dir=.
+ [[ $file == "$dir" ]] && dir=.
- COMPREPLY=( $(compgen -f -- "$dir/RCS/$file") )
+ COMPREPLY=($(compgen -f -- "$dir/RCS/$file"))
- for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
- file=${COMPREPLY[$i]##*/}
- dir=${COMPREPLY[$i]%RCS/*}
- COMPREPLY[$i]=$dir$file
+ for i in ${!COMPREPLY[*]}; do
+ file=${COMPREPLY[i]##*/}
+ dir=${COMPREPLY[i]%RCS/*}
+ COMPREPLY[i]=$dir$file
done
- COMPREPLY+=( $(compgen -G "$dir/$file*,v") )
+ COMPREPLY+=($(compgen -G "$dir/$file*,v"))
- for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
- COMPREPLY[$i]=${COMPREPLY[$i]%,v}
+ for i in ${!COMPREPLY[*]}; do
+ COMPREPLY[i]=${COMPREPLY[i]%,v}
done
# default to files if nothing returned and we're checking in.
# otherwise, default to directories
[[ ${#COMPREPLY[@]} -eq 0 && $1 == *ci ]] && _filedir || _filedir -d
} &&
-complete -F _rcs ci co rlog rcs rcsdiff
+ complete -F _rcs ci co rlog rcs rcsdiff
# ex: filetype=sh
diff --git a/completions/rdesktop b/completions/rdesktop
index 5226a123..54c1ae66 100644
--- a/completions/rdesktop
+++ b/completions/rdesktop
@@ -7,34 +7,34 @@ _rdesktop()
case $prev in
-*k)
- COMPREPLY=( $(command ls \
- /usr/share/rdesktop/keymaps 2>/dev/null | \
- command grep -E -v '(common|modifiers)') )
- COMPREPLY+=( $(command ls $HOME/.rdesktop/keymaps 2>/dev/null) )
- COMPREPLY+=( $(command ls ./keymaps 2>/dev/null) )
- COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "$cur") )
+ COMPREPLY=($(command ls \
+ /usr/share/rdesktop/keymaps 2>/dev/null |
+ command grep -E -v '(common|modifiers)'))
+ COMPREPLY+=($(command ls $HOME/.rdesktop/keymaps 2>/dev/null))
+ COMPREPLY+=($(command ls ./keymaps 2>/dev/null))
+ COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur"))
return
;;
-*a)
- COMPREPLY=( $(compgen -W '8 15 16 24' -- "$cur") )
+ COMPREPLY=($(compgen -W '8 15 16 24' -- "$cur"))
return
;;
-*x)
- COMPREPLY=( $(compgen -W 'broadband modem lan' -- "$cur") )
+ COMPREPLY=($(compgen -W 'broadband modem lan' -- "$cur"))
return
;;
-*r)
case $cur in
sound:*)
- COMPREPLY=( $(compgen -W 'local off remote' \
- -- "${cur#sound:}") )
- ;;
- *:*)
+ COMPREPLY=($(compgen -W 'local off remote' \
+ -- "${cur#sound:}"))
;;
+ *:*) ;;
+
*)
- COMPREPLY=( $(compgen -W 'comport: disk: lptport:
- printer: sound: lspci scard' -- "$cur") )
- [[ $COMPREPLY == *: ]] && compopt -o nospace
+ COMPREPLY=($(compgen -W 'comport: disk: lptport:
+ printer: sound: lspci scard' -- "$cur"))
+ [[ ${COMPREPLY-} == *: ]] && compopt -o nospace
;;
esac
return
@@ -44,14 +44,14 @@ _rdesktop()
;;
esac
- if [[ "$cur" == -* ]]; then
- local opts=( $(_parse_help "$1") )
- COMPREPLY=( $(compgen -W '${opts[@]%:}' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ local opts=($(_parse_help "$1"))
+ COMPREPLY=($(compgen -W '${opts[@]%:}' -- "$cur"))
else
_known_hosts_real -- "$cur"
fi
} &&
-complete -F _rdesktop rdesktop
+ complete -F _rdesktop rdesktop
# ex: filetype=sh
diff --git a/completions/remove_members b/completions/remove_members
index c22286f1..db7ad0bc 100644
--- a/completions/remove_members
+++ b/completions/remove_members
@@ -6,7 +6,7 @@ _remove_members()
_init_completion -s || return
case $prev in
- -f|--file)
+ -f | --file)
_filedir
return
;;
@@ -14,14 +14,14 @@ _remove_members()
$split && return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '--file --all --fromall --nouserack
- --noadminack --help' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '--file --all --fromall --nouserack
+ --noadminack --help' -- "$cur"))
else
_xfunc list_lists _mailman_lists
fi
} &&
-complete -F _remove_members remove_members
+ complete -F _remove_members remove_members
# ex: filetype=sh
diff --git a/completions/removepkg b/completions/removepkg
index 77f414f6..a56beb07 100644
--- a/completions/removepkg
+++ b/completions/removepkg
@@ -4,20 +4,22 @@ _removepkg()
{
local cur prev words cword
_init_completion || return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '-copy -keep -preserve -warn' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '-copy -keep -preserve -warn' -- "$cur"))
return
fi
- if [[ "$cur" == */* ]]; then
+ if [[ $cur == */* ]]; then
_filedir
return
fi
local root=${ROOT:-/}
- COMPREPLY=( $(cd "$root/var/log/packages" 2>/dev/null || return 1; \
- compgen -f -- "$cur") )
+ COMPREPLY=($(
+ cd "$root/var/log/packages" 2>/dev/null || return 1
+ compgen -f -- "$cur"
+ ))
} &&
-complete -F _removepkg removepkg
+ complete -F _removepkg removepkg
# ex: filetype=sh
diff --git a/completions/reportbug b/completions/reportbug
index f5eaadf3..69b12e98 100644
--- a/completions/reportbug
+++ b/completions/reportbug
@@ -6,65 +6,64 @@ _reportbug()
_init_completion -s || return
case $prev in
- --class|--header|--pseudo-header|--mirror|--list-cc|--subject|\
- --http_proxy|--proxy|--email|--realname|--smtpuser|--smtppasswd|\
- --replyto|--reply-to|--justification|--package-version|--body|\
- --body-file|--timeout|--max-attachment-size|--envelope-from|\
- -!(-*)[CHPsjV])
+ --class | --header | --pseudo-header | --mirror | --list-cc | --subject | \
+ --http_proxy | --proxy | --email | --realname | --smtpuser | --smtppasswd | \
+ --replyto | --reply-to | --justification | --package-version | --body | \
+ --body-file | --timeout | --max-attachment-size | --envelope-from | \
+ -!(-*)[CHPsjV])
return
;;
- --filename|--include|--mta|--output|--attach|-[fioA])
+ --filename | --include | --mta | --output | --attach | -[fioA])
_filedir
return
;;
- --keyid|-!(-*)K)
- COMPREPLY=( $(compgen -W '$(IFS=: ; \
+ --keyid | -!(-*)K)
+ COMPREPLY=($(compgen -W '$(IFS=: ; \
gpg --list-keys --with-colons 2>/dev/null \
| while read -ra row ; do
[[ "${row[0]}" == [ps]ub && ${row[11]} == *s* ]] && \
printf "%s\n" "${row[4]}"
- done)' -- "$cur") )
+ done)' -- "$cur"))
return
;;
- --bts|-!(-*)B)
- COMPREPLY=( $(compgen -W "debian guug kde mandrake help" -- \
- "$cur") )
+ --bts | -!(-*)B)
+ COMPREPLY=($(compgen -W "debian guug kde mandrake help" -- \
+ "$cur"))
return
;;
- --editor|--mua|--mbox-reader-cmd|-!(-*)e)
- words=( words[0] "$cur" )
- cword=1
- _command
+ --editor | --mua | --mbox-reader-cmd | -!(-*)e)
+ compopt -o filenames
+ COMPREPLY=($(compgen -c -- "$cur"))
return
;;
--mode)
- COMPREPLY=( $(compgen -W "novice standard expert" -- "$cur") )
+ COMPREPLY=($(compgen -W "novice standard expert" -- "$cur"))
return
;;
- --severity|-!(-*)S)
- COMPREPLY=( $(compgen -W "grave serious important normal minor
- wishlist" -- "$cur") )
+ --severity | -!(-*)S)
+ COMPREPLY=($(compgen -W "grave serious important normal minor
+ wishlist" -- "$cur"))
return
;;
- --ui|--interface|-!(-*)u)
- COMPREPLY=( $(compgen -W "newt text gnome" -- "$cur") )
+ --ui | --interface | -!(-*)u)
+ COMPREPLY=($(compgen -W "newt text gnome" -- "$cur"))
return
;;
- --type|-!(-*)t)
- COMPREPLY=( $(compgen -W "gnats debbugs" -- "$cur") )
+ --type | -!(-*)t)
+ COMPREPLY=($(compgen -W "gnats debbugs" -- "$cur"))
return
;;
- --tag|-!(-*)T)
- COMPREPLY=( $(compgen -W "none woody potato sarge sarge-ignore
+ --tag | -!(-*)T)
+ COMPREPLY=($(compgen -W "none woody potato sarge sarge-ignore
etch etch-ignore lenny lenny-ignore sid experimental confirmed
d-i fixed fixed-in-experimental fixed-upstream help l10n
moreinfo patch pending security unreproducible upstream wontfix
- ipv6 lfs" -- "$cur") )
+ ipv6 lfs" -- "$cur"))
return
;;
--from-buildd)
- COMPREPLY=( $(compgen -S "_" -W '$(apt-cache dumpavail | \
- command grep "^Source: $cur" | sort -u | cut -f2 -d" ")') )
+ COMPREPLY=($(compgen -S "_" -W '$(apt-cache dumpavail | \
+ command grep "^Source: $cur" | sort -u | cut -f2 -d" ")'))
return
;;
--smtphost)
@@ -80,18 +79,18 @@ _reportbug()
$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 'wnpp boot-floppies kernel bugs.debian.org
+ COMPREPLY=($(compgen -W 'wnpp boot-floppies kernel bugs.debian.org
cdimage.debian.org general installation-reports listarchives
lists.debian.org mirrors nm.debian.org press project qa.debian.org
release-notes security.debian.org tech-ctte upgrade-reports
- www.debian.org $(apt-cache pkgnames 2>/dev/null)' -- "$cur") )
+ www.debian.org $(_xfunc apt-cache _apt_cache_packages)' -- "$cur"))
_filedir
} &&
-complete -F _reportbug reportbug
+ complete -F _reportbug reportbug
# ex: filetype=sh
diff --git a/completions/resolvconf b/completions/resolvconf
index b4659612..b407488c 100644
--- a/completions/resolvconf
+++ b/completions/resolvconf
@@ -6,16 +6,16 @@ _resolvconf()
_init_completion || return
case $prev in
- -a|-d)
+ -a | -d)
_available_interfaces
return
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '-a -d -u' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '-a -d -u' -- "$cur"))
fi
} &&
-complete -F _resolvconf resolvconf
+ complete -F _resolvconf resolvconf
# ex: filetype=sh
diff --git a/completions/ri b/completions/ri
index 7d1e7cf9..9c34b27f 100644
--- a/completions/ri
+++ b/completions/ri
@@ -14,21 +14,21 @@ _ri_get_methods()
regex=Class
fi
- COMPREPLY+=( \
+ COMPREPLY+=(
"$(ri "${classes[@]}" 2>/dev/null | ruby -ane \
- 'if /^'"$regex"' methods:/.../^------------------|^$/ and \
+ 'if /^'"$regex"' methods:/.../^------------------|^$/ and \
/^ / then print $_.split(/, |,$/).grep(/^[^\[]*$/).join("\n"); \
- end' 2>/dev/null | sort -u)" )
+ end' 2>/dev/null | sort -u)")
else
# older versions of ri didn't distinguish between class/module and
# instance methods
- COMPREPLY+=( \
+ COMPREPLY+=(
"$(ruby -W0 $ri_path "${classes[@]}" 2>/dev/null | ruby -ane \
- 'if /^-/.../^-/ and ! /^-/ and ! /^ +(class|module): / then \
+ 'if /^-/.../^-/ and ! /^-/ and ! /^ +(class|module): / then \
print $_.split(/, |,$| +/).grep(/^[^\[]*$/).join("\n"); \
- end' | sort -u)" )
+ end' | sort -u)")
fi
- COMPREPLY=( $(compgen $prefix -W '${COMPREPLY[@]}' -- $method) )
+ COMPREPLY=($(compgen $prefix -W '${COMPREPLY[@]}' -- $method))
}
# needs at least Ruby 1.8.0 in order to use -W0
@@ -38,14 +38,14 @@ _ri()
_init_completion -s -n : || return
case $prev in
- --help|--width|-!(-*)[hw])
+ --help | --width | -!(-*)[hw])
return
;;
- --format|-!(-*)f)
- COMPREPLY=( $(compgen -W 'ansi bs html rdoc' -- "$cur") )
+ --format | -!(-*)f)
+ COMPREPLY=($(compgen -W 'ansi bs html rdoc' -- "$cur"))
return
;;
- --doc-dir|-!(-*)d)
+ --doc-dir | -!(-*)d)
_filedir -d
return
;;
@@ -57,9 +57,9 @@ _ri()
$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
@@ -71,17 +71,17 @@ _ri()
# -W0 is required here to stop warnings from older versions of ri
# from being captured when used with Ruby 1.8.1 and later
ri_version="$(ruby -W0 $ri_path -v 2>&1)" || ri_version=integrated
- [[ $ri_version != ${ri_version%200*} ]] && ri_version=integrated
+ [[ $ri_version != "${ri_version%200*}" ]] && ri_version=integrated
[[ $ri_version =~ ri[[:space:]]v?([0-9]+) ]] && ri_major=${BASH_REMATCH[1]}
# need to also split on commas
IFS=$', \n\t'
- if [[ "$cur" == [A-Z]*[#.]* ]]; then
- [[ "$cur" == *#* ]] && separator=# || separator=.
+ if [[ $cur == [A-Z]*[#.]* ]]; then
+ [[ $cur == *#* ]] && separator=# || separator=.
# we're completing on class and method
class=${cur%$separator*}
method=${cur#*$separator}
- classes=( $class )
+ classes=($class)
prefix="-P $class$separator"
_ri_get_methods
return
@@ -89,24 +89,24 @@ _ri()
if [[ $ri_version == integrated ]]; then
# integrated ri from Ruby 1.9
- classes=( $(ri -c 2>/dev/null | ruby -ne 'if /^\s*$/..$stdin.eof then \
- if /^ +[A-Z]/ then print; end; end' 2>/dev/null) )
+ classes=($(ri -c 2>/dev/null | ruby -ne 'if /^\s*$/..$stdin.eof then \
+ if /^ +[A-Z]/ then print; end; end' 2>/dev/null))
elif [[ $ri_major && $ri_major -ge 3 ]]; then
- classes=( $(ri -l 2>/dev/null) )
+ classes=($(ri -l 2>/dev/null))
elif [[ $ri_version == "ri 1.8a" ]]; then
- classes=( $(ruby -W0 $ri_path | \
+ classes=($(ruby -W0 $ri_path |
ruby -ne 'if /^'"'"'ri'"'"' has/..$stdin.eof then \
- if /^ .*[A-Z]/ then print; end; end') )
+ if /^ .*[A-Z]/ then print; end; end'))
else
- classes=( $(ruby -W0 $ri_path | \
+ classes=($(ruby -W0 $ri_path |
ruby -ne 'if /^I have/..$stdin.eof then \
- if /^ .*[A-Z]/ then print; end; end') )
+ if /^ .*[A-Z]/ then print; end; end'))
fi
- COMPREPLY=( $(compgen -W '${classes[@]}' -- "$cur") )
+ COMPREPLY=($(compgen -W '${classes[@]}' -- "$cur"))
__ltrim_colon_completions "$cur"
- if [[ "$cur" == [A-Z]* ]]; then
+ if [[ $cur == [A-Z]* ]]; then
# we're completing on class or module alone
return
fi
@@ -115,6 +115,6 @@ _ri()
method=$cur
_ri_get_methods
} &&
-complete -F _ri ri
+ complete -F _ri ri
# ex: filetype=sh
diff --git a/completions/rmlist b/completions/rmlist
index d096352c..0cc473a9 100644
--- a/completions/rmlist
+++ b/completions/rmlist
@@ -5,13 +5,13 @@ _rmlist()
local cur prev words cword
_init_completion || return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '--archives --help' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '--archives --help' -- "$cur"))
else
_xfunc list_lists _mailman_lists
fi
} &&
-complete -F _rmlist rmlist
+ complete -F _rmlist rmlist
# ex: filetype=sh
diff --git a/completions/rmmod b/completions/rmmod
index 12f2334e..7ec29e6c 100644
--- a/completions/rmmod
+++ b/completions/rmmod
@@ -7,18 +7,18 @@ _rmmod()
_init_completion || return
case $prev in
- -h|--help|-V|--version)
+ -h | --help | -V | --version)
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
return
fi
_installed_modules "$cur"
} &&
-complete -F _rmmod rmmod
+ complete -F _rmmod rmmod
# ex: filetype=sh
diff --git a/completions/route b/completions/route
index a7c06d6d..f9b31964 100644
--- a/completions/route
+++ b/completions/route
@@ -17,14 +17,14 @@ _route()
for opt in add del -host -net netmask metric mss window irtt reject mod \
dyn reinstate dev default gw; do
found=false
- for (( i=1; i < ${#words[@]}-1; i++ )); do
- [[ ${words[i]} == $opt ]] && found=true && break
+ for ((i = 1; i < ${#words[@]} - 1; i++)); do
+ [[ ${words[i]} == "$opt" ]] && found=true && break
done
- $found || COMPREPLY[${#COMPREPLY[@]}]="$opt"
+ $found || COMPREPLY+=("$opt")
done
- COMPREPLY=( $(compgen -W '"${COMPREPLY[@]}"' -- "$cur") )
+ COMPREPLY=($(compgen -W '"${COMPREPLY[@]}"' -- "$cur"))
} &&
-complete -F _route route
+ complete -F _route route
# ex: filetype=sh
diff --git a/completions/rpcdebug b/completions/rpcdebug
index ce4f9372..6e2b88c5 100644
--- a/completions/rpcdebug
+++ b/completions/rpcdebug
@@ -2,18 +2,18 @@
_rpcdebug_flags()
{
-
local i module
- for (( i=0; i < ${#words[@]}; i++ )); do
+ for ((i = 1; i < ${#words[@]}; i++)); do
if [[ ${words[i]} == -m ]]; then
- module=${words[i+1]}
+ module=${words[i + 1]}
+ break
fi
done
if [[ -n $module ]]; then
- COMPREPLY=( $(compgen -W "$(rpcdebug -vh 2>&1 | \
- command sed -ne 's/^'$module'[[:space:]]\{1,\}//p')" -- "$cur") )
+ COMPREPLY=($(compgen -W "$(rpcdebug -vh 2>&1 |
+ command sed -ne 's/^'$module'[[:space:]]\{1,\}//p')" -- "$cur"))
fi
}
@@ -32,15 +32,15 @@ _rpcdebug()
return
;;
-*m)
- COMPREPLY=( $(compgen -W 'rpc nfs nfsd nlm' -- "$cur") )
+ COMPREPLY=($(compgen -W 'rpc nfs nfsd nlm' -- "$cur"))
return
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1" -h) -s -c' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1" -h) -s -c' -- "$cur"))
fi
} &&
-complete -F _rpcdebug rpcdebug
+ complete -F _rpcdebug rpcdebug
# ex: filetype=sh
diff --git a/completions/rpm b/completions/rpm
index b797e9fb..8299a37a 100644
--- a/completions/rpm
+++ b/completions/rpm
@@ -7,38 +7,38 @@ _rpm_installed_packages()
if [[ -r /var/log/rpmpkgs && \
/var/log/rpmpkgs -nt /var/lib/rpm/Packages ]]; then
# using RHL 7.2 or later - this is quicker than querying the DB
- COMPREPLY=( $(compgen -W "$(command sed -ne \
+ COMPREPLY=($(compgen -W "$(command sed -ne \
's|^\([^[:space:]]\{1,\}\)-[^[:space:]-]\{1,\}-[^[:space:]-]\{1,\}\.rpm$|\1|p' \
- /var/log/rpmpkgs)" -- "$cur") )
- elif type rpmqpack &>/dev/null ; then
+ /var/log/rpmpkgs)" -- "$cur"))
+ elif type rpmqpack &>/dev/null; then
# SUSE's rpmqpack is faster than rpm -qa
- COMPREPLY=( $(compgen -W '$(rpmqpack)' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(rpmqpack)' -- "$cur"))
else
- COMPREPLY=( $(${1:-rpm} -qa --nodigest --nosignature \
- --queryformat='%{NAME} ' "$cur*" 2>/dev/null) )
+ COMPREPLY=($(${1:-rpm} -qa --nodigest --nosignature \
+ --queryformat='%{NAME} ' "$cur*" 2>/dev/null))
fi
}
_rpm_groups()
{
local IFS=$'\n'
- COMPREPLY=( $(compgen -W "$(${1:-rpm} -qa --nodigest --nosignature \
- --queryformat='%{GROUP}\n' 2>/dev/null)" -- "$cur") )
+ COMPREPLY=($(compgen -W "$(${1:-rpm} -qa --nodigest --nosignature \
+ --queryformat='%{GROUP}\n' 2>/dev/null)" -- "$cur"))
}
_rpm_macros()
{
# get a list of macros
- COMPREPLY=( $(compgen -W "$(${1:-rpm} --showrc | command sed -ne \
+ COMPREPLY=($(compgen -W "$(${1:-rpm} --showrc | command sed -ne \
's/^-\{0,1\}[0-9]\{1,\}[:=][[:space:]]\{1,\}\([^[:space:](]\{3,\}\).*/%\1/p')" \
- -- "$cur") )
+ -- "$cur"))
}
_rpm_buildarchs()
{
- COMPREPLY=( $(compgen -W "$(${1:-rpm} --showrc | command sed -ne \
+ COMPREPLY=($(compgen -W "$(${1:-rpm} --showrc | command sed -ne \
's/^\s*compatible\s\s*build\s\s*archs\s*:\s*\(.*\)/\1/ p')" \
- -- "$cur") )
+ -- "$cur"))
}
# rpm(8) completion
@@ -48,35 +48,35 @@ _rpm()
local cur prev words cword split
_init_completion -s || return
- if [[ $cword -eq 1 ]]; then
+ if ((cword == 1)); then
# first parameter on line
case $cur in
--*)
- COMPREPLY=( $(compgen -W '--help --version --initdb
+ COMPREPLY=($(compgen -W '--help --version --initdb
--checksig --addsign --delsign --rebuilddb --showrc
--setperms --setugids --eval --install --upgrade --query
--freshen --erase --verify --querytags --import' \
- -- "$cur") )
+ -- "$cur"))
;;
*)
- COMPREPLY=( $(compgen -W '-e -E -F -i -q -t -U -V' -- "$cur") )
+ COMPREPLY=($(compgen -W '-e -E -F -i -q -t -U -V' -- "$cur"))
;;
esac
return
fi
case $prev in
- --dbpath|--excludepath|--prefix|--relocate|--root|-!(-*)r)
+ --dbpath | --excludepath | --prefix | --relocate | --root | -!(-*)r)
_filedir -d
return
;;
- --eval|-!(-*)E)
+ --eval | -!(-*)E)
_rpm_macros $1
return
;;
--pipe)
compopt -o filenames
- COMPREPLY=( $(compgen -c -- "$cur") )
+ COMPREPLY=($(compgen -c -- "$cur"))
return
;;
--rcfile)
@@ -88,28 +88,28 @@ _rpm()
_filedir spec
return
;;
- --whatenhances|--whatprovides|--whatrecommends|--whatrequires|\
- --whatsuggests|--whatsupplements)
- if [[ "$cur" == */* ]]; then
+ --whatenhances | --whatprovides | --whatrecommends | --whatrequires | \
+ --whatsuggests | --whatsupplements)
+ if [[ $cur == */* ]]; then
_filedir
else
# complete on capabilities
local IFS=$'\n' fmt
case $prev in
- *enhances) fmt=ENHANCENAME ;;
- *provides) fmt=PROVIDENAME ;;
- *recommends) fmt=RECOMMENDNAME ;;
- *requires) fmt=REQUIRENAME ;;
- *suggests) fmt=SUGGESTNAME ;;
- *supplements) fmt=SUPPLEMENTNAME ;;
+ *enhances) fmt="%{ENHANCENAME}" ;;
+ *provides) fmt="%{PROVIDENAME}" ;;
+ *recommends) fmt="%{RECOMMENDNAME}" ;;
+ *requires) fmt="%{REQUIRENAME}" ;;
+ *suggests) fmt="%{SUGGESTNAME}" ;;
+ *supplements) fmt="%{SUPPLEMENTNAME}" ;;
esac
- COMPREPLY=( $(compgen -W "$($1 -qa --nodigest --nosignature \
- --queryformat=\"%{$fmt}\\n\" 2>/dev/null |
- command grep -vF '(none)')" -- "$cur") )
+ COMPREPLY=($(compgen -W "$($1 -qa --nodigest --nosignature \
+ --queryformat=\"$fmt\\n\" 2>/dev/null |
+ command grep -vF '(none)')" -- "$cur"))
fi
return
;;
- --define|--fileid|--hdrid|--pkgid|-!(-*)D)
+ --define | --fileid | --hdrid | --pkgid | -!(-*)D)
# argument required but no completions available
return
;;
@@ -122,28 +122,28 @@ _rpm()
--quiet --pipe --verbose"
case ${words[1]} in
- -[iFU]*|--install|--freshen|--upgrade)
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W "$opts --percent --force --test
+ -[iFU]* | --install | --freshen | --upgrade)
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W "$opts --percent --force --test
--replacepkgs --replacefiles --root --excludedocs --includedocs
--noscripts --ignorearch --dbpath --prefix= --ignoreos --nodeps
--allfiles --ftpproxy --ftpport --justdb --httpproxy --httpport
--noorder --relocate= --badreloc --notriggers --excludepath=
--ignoresize --oldpackage --queryformat --repackage
- --nosuggests" -- "$cur") )
+ --nosuggests" -- "$cur"))
else
_filedir '[rs]pm'
fi
;;
- -e|--erase)
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W "$opts --allmatches --noscripts
- --notriggers --nodeps --test --repackage" -- "$cur") )
+ -e | --erase)
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W "$opts --allmatches --noscripts
+ --notriggers --nodeps --test --repackage" -- "$cur"))
else
_rpm_installed_packages $1
fi
;;
- -q*|--query)
+ -q* | --query)
# options common to all query types
opts+=" --changelog --configfiles --conflicts --docfiles --dump
--enhances --filesbypkg --filecaps --fileclass --filecolor
@@ -152,85 +152,85 @@ _rpm()
--scripts --suggests --triggers --xml --recommends
--supplements --filetriggers --licensefiles"
- if [[ "${words[*]}" == *\ -@(*([^ -])f|-file )* ]]; then
+ if [[ ${words[*]} == *\ -@(*([^ -])f|-file )* ]]; then
# -qf completion
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W "$opts --dbpath --fscontext
- --last --root --state" -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W "$opts --dbpath --fscontext
+ --last --root --state" -- "$cur"))
else
_filedir
fi
- elif [[ "${words[*]}" == *\ -@(*([^ -])g|-group )* ]]; then
+ elif [[ ${words[*]} == *\ -@(*([^ -])g|-group )* ]]; then
# -qg completion
_rpm_groups $1
- elif [[ "${words[*]}" == *\ -@(*([^ -])p|-package )* ]]; then
+ elif [[ ${words[*]} == *\ -@(*([^ -])p|-package )* ]]; then
# -qp; uninstalled package completion
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W "$opts --ftpport --ftpproxy
- --httpport --httpproxy --nomanifest" -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W "$opts --ftpport --ftpproxy
+ --httpport --httpproxy --nomanifest" -- "$cur"))
else
_filedir '[rs]pm'
fi
else
# -q; installed package completion
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W "$opts --all --file --fileid
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W "$opts --all --file --fileid
--dbpath --fscontext --ftswalk --group --hdrid --last
--package --pkgid --root= --specfile --state
--triggeredby --whatenhances --whatprovides
--whatrecommends --whatrequires --whatsuggests
--whatsupplements" \
- -- "$cur") )
- elif [[ "${words[*]}" != *\ -@(*([^ -])a|-all )* ]]; then
+ -- "$cur"))
+ elif [[ ${words[*]} != *\ -@(*([^ -])a|-all )* ]]; then
_rpm_installed_packages $1
fi
fi
;;
- -K*|--checksig)
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W "$opts --nopgp --nogpg --nomd5" \
- -- "$cur") )
+ -K* | --checksig)
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W "$opts --nopgp --nogpg --nomd5" \
+ -- "$cur"))
else
_filedir '[rs]pm'
fi
;;
- -[Vy]*|--verify)
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W "$opts --root= --dbpath --nodeps
+ -[Vy]* | --verify)
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W "$opts --root= --dbpath --nodeps
--nogroup --nolinkto --nomode --nomtime --nordev --nouser
--nofiles --noscripts --nomd5 --querytags --specfile
--whatenhances --whatprovides --whatrecommends
--whatrequires --whatsuggests --whatsupplements" \
- -- "$cur") )
+ -- "$cur"))
# check whether we're doing file completion
- elif [[ "${words[*]}" == *\ -@(*([^ -])f|-file )* ]]; then
+ elif [[ ${words[*]} == *\ -@(*([^ -])f|-file )* ]]; then
_filedir
- elif [[ "${words[*]}" == *\ -@(*([^ -])g|-group )* ]]; then
+ elif [[ ${words[*]} == *\ -@(*([^ -])g|-group )* ]]; then
_rpm_groups $1
- elif [[ "${words[*]}" == *\ -@(*([^ -])p|-package )* ]]; then
+ elif [[ ${words[*]} == *\ -@(*([^ -])p|-package )* ]]; then
_filedir '[rs]pm'
else
_rpm_installed_packages $1
fi
;;
- --resign|--addsign|--delsign)
+ --resign | --addsign | --delsign)
_filedir '[rs]pm'
;;
- --setperms|--setgids)
+ --setperms | --setgids)
_rpm_installed_packages $1
;;
- --import|--dbpath|--root)
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '--import --dbpath --root=' \
- -- "$cur") )
+ --import | --dbpath | --root)
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '--import --dbpath --root=' \
+ -- "$cur"))
else
_filedir
fi
;;
esac
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
} &&
-complete -F _rpm rpm
+ complete -F _rpm rpm
_rpmbuild()
{
@@ -238,33 +238,33 @@ _rpmbuild()
_init_completion -s || return
local rpm="${1%build*}"
- [[ $rpm == $1 ]] || ! type $rpm &>/dev/null && rpm=
+ [[ $rpm == "$1" ]] || ! type $rpm &>/dev/null && rpm=
case $prev in
- --buildroot|--root|--dbpath|-!(-*)r)
+ --buildroot | --root | --dbpath | -!(-*)r)
_filedir -d
return
;;
--target)
- _rpm_buildarchs
+ _rpm_buildarchs $rpm
return
;;
- --eval|-!(-*)E)
+ --eval | -!(-*)E)
_rpm_macros $rpm
return
;;
- --macros|--rcfile)
+ --macros | --rcfile)
_filedir
return
;;
--buildpolicy)
local cfgdir=$($rpm --eval '%{_rpmconfigdir}' 2>/dev/null)
if [[ $cfgdir ]]; then
- COMPREPLY=( $(compgen -W "$(command ls $cfgdir 2>/dev/null \
- | command sed -ne 's/^brp-//p')" -- "$cur") )
+ COMPREPLY=($(compgen -W "$(command ls $cfgdir 2>/dev/null |
+ command sed -ne 's/^brp-//p')" -- "$cur"))
fi
;;
- --define|--with|--without|-!(-*)D)
+ --define | --with | --without | -!(-*)D)
return
;;
esac
@@ -272,8 +272,8 @@ _rpmbuild()
$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
@@ -281,15 +281,15 @@ _rpmbuild()
local word ext
for word in "${words[@]}"; do
case $word in
- -b?|--clean|--nobuild)
+ -b? | --clean | --nobuild)
ext=spec
break
;;
- -t?|--tarbuild)
+ -t? | --tarbuild)
ext='@(t?(ar.)@([gx]z|bz?(2))|tar?(.@(lzma|Z)))'
break
;;
- --rebuild|--recompile)
+ --rebuild | --recompile)
ext='@(?(no)src.r|s)pm'
break
;;
@@ -297,6 +297,6 @@ _rpmbuild()
done
[[ -n $ext ]] && _filedir $ext
} &&
-complete -F _rpmbuild rpmbuild rpmbuild-md5
+ complete -F _rpmbuild rpmbuild rpmbuild-md5
# ex: filetype=sh
diff --git a/completions/rpm2tgz b/completions/rpm2tgz
index da4b7e5e..5ddcfd59 100644
--- a/completions/rpm2tgz
+++ b/completions/rpm2tgz
@@ -5,13 +5,13 @@ _rpm2tgz()
local cur prev words cword
_init_completion || return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '-s -S -n -r -d -c' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '-s -S -n -r -d -c' -- "$cur"))
return
fi
_filedir "rpm"
} &&
-complete -F _rpm2tgz rpm2tgz rpm2txz rpm2targz
+ complete -F _rpm2tgz rpm2tgz rpm2txz rpm2targz
# ex: filetype=sh
diff --git a/completions/rpmcheck b/completions/rpmcheck
index f8577c4e..cf4ed958 100644
--- a/completions/rpmcheck
+++ b/completions/rpmcheck
@@ -12,13 +12,13 @@ _rpmcheck()
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '-explain -failures -successes -dump
- -dump-all -base -help -compressed-input' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '-explain -failures -successes -dump
+ -dump-all -base -help -compressed-input' -- "$cur"))
else
_filedir
fi
} &&
-complete -F _rpmcheck rpmcheck
+ complete -F _rpmcheck rpmcheck
# ex: filetype=sh
diff --git a/completions/rrdtool b/completions/rrdtool
index c8214a49..dcb9ce67 100644
--- a/completions/rrdtool
+++ b/completions/rrdtool
@@ -1,17 +1,17 @@
# bash completion for rrdtool -*- shell-script -*-
-_rrdtool ()
+_rrdtool()
{
local cur prev words cword
_init_completion || return
- if [[ ${#words[@]} -eq 2 ]]; then
- COMPREPLY=( $(compgen -W 'create update updatev graph dump restore
- last lastupdate first info fetch tune resize xport' -- "$cur") )
+ if ((${#words[@]} == 2)); then
+ COMPREPLY=($(compgen -W 'create update updatev graph dump restore
+ last lastupdate first info fetch tune resize xport' -- "$cur"))
else
_filedir rrd
fi
} &&
-complete -F _rrdtool rrdtool
+ complete -F _rrdtool rrdtool
# ex: filetype=sh
diff --git a/completions/rsync b/completions/rsync
index 03495244..0bf53898 100644
--- a/completions/rsync
+++ b/completions/rsync
@@ -6,26 +6,26 @@ _rsync()
_init_completion -s -n : || return
case $prev in
- --config|--password-file|--include-from|--exclude-from|--files-from|\
- --log-file|--write-batch|--only-write-batch|--read-batch)
+ --config | --password-file | --include-from | --exclude-from | --files-from | \
+ --log-file | --write-batch | --only-write-batch | --read-batch)
compopt +o nospace
_filedir
return
;;
- --temp-dir|--compare-dest|--backup-dir|--partial-dir|--copy-dest|\
- --link-dest|-!(-*)T)
+ --temp-dir | --compare-dest | --backup-dir | --partial-dir | --copy-dest | \
+ --link-dest | -!(-*)T)
compopt +o nospace
_filedir -d
return
;;
- --rsh|-!(-*)e)
+ --rsh | -!(-*)e)
compopt +o nospace
- COMPREPLY=( $(compgen -W 'rsh ssh' -- "$cur") )
+ COMPREPLY=($(compgen -W 'rsh ssh' -- "$cur"))
return
;;
--compress-level)
compopt +o nospace
- COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") )
+ COMPREPLY=($(compgen -W '{1..9}' -- "$cur"))
return
;;
esac
@@ -36,7 +36,7 @@ _rsync()
case $cur in
-*)
- COMPREPLY=( $(compgen -W '--verbose --quiet --no-motd --checksum
+ COMPREPLY=($(compgen -W '--verbose --quiet --no-motd --checksum
--archive --recursive --relative --no-implied-dirs
--backup --backup-dir= --suffix= --update --inplace --append
--append-verify --dirs --old-dirs --links --copy-links
@@ -61,15 +61,15 @@ _rsync()
--out-format= --log-file= --log-file-format= --password-file=
--list-only --bwlimit= --write-batch= --only-write-batch=
--read-batch= --protocol= --iconv= --ipv4 --ipv6 --version
- --help --daemon --config= --no-detach' -- "$cur") )
- [[ $COMPREPLY == *= ]] || compopt +o nospace
+ --help --daemon --config= --no-detach' -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] || compopt +o nospace
;;
*:*)
# find which remote shell is used
local i shell=ssh
- for (( i=1; i < cword; i++ )); do
- if [[ "${words[i]}" == -@(e|-rsh) ]]; then
- shell=${words[i+1]}
+ for ((i = 1; i < cword; i++)); do
+ if [[ ${words[i]} == -@(e|-rsh) ]]; then
+ shell=${words[i + 1]}
break
fi
done
@@ -81,6 +81,6 @@ _rsync()
;;
esac
} &&
-complete -F _rsync -o nospace rsync
+ complete -F _rsync -o nospace rsync
# ex: filetype=sh
diff --git a/completions/sbcl b/completions/sbcl
index a8dd5345..22a93e4a 100644
--- a/completions/sbcl
+++ b/completions/sbcl
@@ -8,14 +8,14 @@ _sbcl()
_init_completion || return
# completing an option (may or may not be separated by a space)
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '--core --noinform --help --version
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '--core --noinform --help --version
--sysinit --userinit --eval --noprint --disable-debugger
- --end-runtime-options --end-toplevel-options ' -- "$cur") )
+ --end-runtime-options --end-toplevel-options ' -- "$cur"))
else
_filedir
fi
} &&
-complete -F _sbcl sbcl sbcl-mt
+ complete -F _sbcl sbcl sbcl-mt
# ex: filetype=sh
diff --git a/completions/sbopkg b/completions/sbopkg
index 1504a54e..16bd58f9 100644
--- a/completions/sbopkg
+++ b/completions/sbopkg
@@ -5,14 +5,14 @@ _sbopkg()
local cur prev words cword
_init_completion || return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") )
- [[ $COMPREPLY ]] && return
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
+ [[ ${COMPREPLY-} ]] && return
fi
case "$prev" in
-e)
- COMPREPLY=( $(compgen -W 'ask continue stop' -- "$cur") )
+ COMPREPLY=($(compgen -W 'ask continue stop' -- "$cur"))
return
;;
-f)
@@ -24,12 +24,12 @@ _sbopkg()
return
;;
-V)
- COMPREPLY=( $(compgen -W "?
- $(sbopkg -V ? 2>&1 | cut -s -f1)" -- "$cur") )
+ COMPREPLY=($(compgen -W "?
+ $(sbopkg -V '?' 2>&1 | cut -s -f1)" -- "$cur"))
return
;;
- -i|-b)
- ;;
+ -i | -b) ;;
+
*)
return
;;
@@ -37,34 +37,37 @@ _sbopkg()
local i config
config="/etc/sbopkg/sbopkg.conf"
- for (( i=${#words[@]}-1; i>0; i-- )); do
- if [[ "${words[i]}" == -f ]]; then
- config="${words[i+1]}"
+ for ((i = ${#words[@]} - 1; i > 0; i--)); do
+ if [[ ${words[i]} == -f ]]; then
+ config="${words[i + 1]}"
__expand_tilde_by_ref config
break
fi
done
- [[ -r "$config" ]] || return
+ [[ -r $config ]] || return
. $config
- for (( i=1; i<${#words[@]}; i++ )); do
+ for ((i = 1; i < ${#words[@]}; i++)); do
case "${words[i]}" in
-V)
- REPO_NAME="${words[i+1]%%/*}"
- REPO_BRANCH="${words[i+1]#*/}"
+ REPO_NAME="${words[i + 1]%%/*}"
+ REPO_BRANCH="${words[i + 1]#*/}"
;;
-d)
- REPO_ROOT="${words[i+1]}"
+ REPO_ROOT="${words[i + 1]}"
;;
esac
done
[[ -r $REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT ]] || return
- COMPREPLY=( $(command sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}"\
+ COMPREPLY=($(command sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}" \
$REPO_ROOT/$REPO_NAME/$REPO_BRANCH/SLACKBUILDS.TXT)
- $(cd $QUEUEDIR; compgen -f -X "!*.sqf" -- "$cur") )
+ $(
+ cd $QUEUEDIR
+ compgen -f -X "!*.sqf" -- "$cur"
+ ))
} &&
-complete -F _sbopkg sbopkg
+ complete -F _sbopkg sbopkg
# ex: filetype=sh
diff --git a/completions/screen b/completions/screen
index 17642863..651ca2c9 100644
--- a/completions/screen
+++ b/completions/screen
@@ -2,11 +2,11 @@
_screen_sessions()
{
- local sessions=( $(command screen -ls | command sed -ne \
- 's|^\t\{1,\}\([0-9]\{1,\}\.[^\t]\{1,\}\).*'"$1"'.*$|\1|p') )
+ local sessions=($(command screen -ls | command sed -ne \
+ 's|^\t\{1,\}\([0-9]\{1,\}\.[^\t]\{1,\}\).*'"$1"'.*$|\1|p'))
if [[ $cur == +([0-9])?(.*) ]]; then
# Complete sessions including pid prefixes
- COMPREPLY=( $(compgen -W '${sessions[@]}' -- "$cur") )
+ COMPREPLY=($(compgen -W '${sessions[@]}' -- "$cur"))
else
# Create unique completions, dropping pids where possible
local -A res
@@ -15,106 +15,109 @@ _screen_sessions()
res[${i/#+([0-9])./}]+=" $i"
done
for i in "${!res[@]}"; do
- [[ ${res[$i]} == \ *\ * ]] && tmp+=" ${res[$i]}" || tmp+=" $i"
+ [[ ${res[i]} == \ *\ * ]] && tmp+=" ${res[i]}" || tmp+=" $i"
done
- COMPREPLY=( $(compgen -W '$tmp' -- "$cur") )
+ COMPREPLY=($(compgen -W '$tmp' -- "$cur"))
fi
} &&
-_screen()
-{
- local cur prev words cword
- _init_completion || return
+ _screen()
+ {
+ local cur prev words cword
+ _init_completion || return
- if ((cword == 1)); then
- if [[ $cur == /dev* ]]; then
- COMPREPLY=( $(compgen -W "$(shopt -s nullglob; printf '%s\n' \
- /dev/serial/by-id/* /dev/ttyUSB* /dev/ttyACM* 2>/dev/null)" \
- -- "$cur") )
- return
+ if ((cword == 1)); then
+ if [[ $cur == /dev* ]]; then
+ COMPREPLY=($(compgen -W "$(
+ shopt -s nullglob
+ printf '%s\n' \
+ /dev/serial/by-id/* /dev/ttyUSB* /dev/ttyACM* 2>/dev/null
+ )" \
+ -- "$cur"))
+ return
+ fi
+ if [[ $cur == //* ]]; then
+ COMPREPLY=($(compgen -W '//telnet' -- "$cur"))
+ return
+ fi
fi
- if [[ $cur == //* ]]; then
- COMPREPLY=( $(compgen -W '//telnet' -- "$cur") )
- return
+
+ case ${words[1]} in
+ /dev*)
+ if ((cword == 2)); then
+ COMPREPLY=($(compgen -W '110 300 600 1200 2400 4800 9600 \
+ 14400 19200 38400 57600 115200 128000 256000' -- "$cur"))
+ # TODO more, comma separated options
+ fi
+ return
+ ;;
+ //telnet)
+ ((cword == 2)) && _known_hosts_real -- "$cur"
+ return
+ ;;
+ esac
+
+ if ((cword > 2)); then
+ case ${words[cword - 2]} in
+ -*[dD])
+ _screen_sessions
+ return
+ ;;
+ esac
fi
- fi
- case ${words[1]} in
- /dev*)
- if ((cword == 2)); then
- COMPREPLY=( $(compgen -W '110 300 600 1200 2400 4800 9600 \
- 14400 19200 38400 57600 115200 128000 256000' -- "$cur") )
- # TODO more, comma separated options
- fi
- return
- ;;
- //telnet)
- ((cword == 2)) && _known_hosts_real -- "$cur"
+ local i
+ for ((i = 1; i <= cword; i++)); do
+ case ${words[i]} in
+ -*[rRdDxscTehpSt])
+ ((i++))
+ continue
+ ;;
+ -*)
+ continue
+ ;;
+ esac
+
+ _command_offset $i
return
- ;;
- esac
+ done
- if ((cword > 2)); then
- case ${words[cword-2]} in
+ case $prev in
+ -*[rR])
+ # list detached
+ _screen_sessions 'Detached'
+ return
+ ;;
-*[dD])
+ # list attached
+ _screen_sessions 'Attached'
+ return
+ ;;
+ -*x)
+ # list both
_screen_sessions
return
;;
- esac
- fi
-
- local i
- for (( i=1; i <= cword; i++ )); do
- case ${words[i]} in
- -*[rRdDxscTehpSt])
- (( i++ ))
- continue
+ -*s)
+ _shells
+ return
;;
- -*)
- continue
+ -*c)
+ _filedir
+ return
+ ;;
+ -T)
+ _terms
+ return
+ ;;
+ -*[ehpSt])
+ return
;;
esac
- _command_offset $i
- return
- done
-
- case $prev in
- -*[rR])
- # list detached
- _screen_sessions 'Detached'
- return
- ;;
- -*[dD])
- # list attached
- _screen_sessions 'Attached'
- return
- ;;
- -*x)
- # list both
- _screen_sessions
- return
- ;;
- -*s)
- _shells
- return
- ;;
- -*c)
- _filedir
- return
- ;;
- -T)
- _terms
- return
- ;;
- -*[ehpSt])
- return
- ;;
- esac
-
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
- fi
-} &&
-complete -F _screen screen
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ fi
+ } &&
+ complete -F _screen screen
# ex: filetype=sh
diff --git a/completions/scrub b/completions/scrub
index 7fca6077..bbb37be4 100644
--- a/completions/scrub
+++ b/completions/scrub
@@ -6,16 +6,16 @@ _scrub()
_init_completion -s || return
case $prev in
- --version|--help|--blocksize|--device-size|--dirent|-!(-*)[vhbsD])
+ --version | --help | --blocksize | --device-size | --dirent | -!(-*)[vhbsD])
return
;;
- --pattern|-!(-*)p)
- COMPREPLY=( $(compgen -W '$("$1" --help 2>&1 |
+ --pattern | -!(-*)p)
+ COMPREPLY=($(compgen -W '$("$1" --help 2>&1 |
awk "/^Available/{flag=1;next}/^ /&&flag{print \$1}")' \
- -- "$cur") )
+ -- "$cur"))
return
;;
- --freespace|-!(-*)X)
+ --freespace | -!(-*)X)
_filedir -d
return
;;
@@ -24,13 +24,13 @@ _scrub()
$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
} &&
-complete -F _scrub scrub
+ complete -F _scrub scrub
# ex: filetype=sh
diff --git a/completions/secret-tool b/completions/secret-tool
new file mode 100644
index 00000000..5462fc06
--- /dev/null
+++ b/completions/secret-tool
@@ -0,0 +1,50 @@
+# bash completion for secret-tool(1) -*- shell-script -*-
+
+_secret_tool()
+{
+ local cur prev words cword split
+ _init_completion -s || return
+
+ $split && return
+
+ local -i i
+ local mode word
+ for i in ${!words[*]}; do
+ if [[ $i -gt 0 && ${words[i]} != -* ]]; then
+ ((i != cword)) && mode=${words[i]}
+ break
+ fi
+ done
+ if [[ ! -v mode ]]; then
+ local -a modes
+ modes=($("$1" nonexistent-mode 2>&1 |
+ while read -r first second third rest; do
+ if [[ $first == "${1##*/}" ]]; then
+ printf "%s\n" "$second"
+ elif [[ $first == usage: && $second == "${1##*/}" ]]; then
+ printf "%s\n" "$third"
+ fi
+ done))
+ COMPREPLY=($(compgen -W '${modes[@]}' -- "$cur"))
+ return
+ fi
+
+ case $mode in
+ store)
+ if [[ ${words[*]} != *\ --label[\ =]* ]]; then
+ COMPREPLY=($(compgen -W "--label=" -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
+ fi
+ ;;
+ search)
+ local -A opts=([--all]="" [--unlock]="")
+ for word in "${words[@]:2}"; do
+ [[ $word ]] && unset opts["$word"]
+ done
+ COMPREPLY=($(compgen -W '${opts[@]}' -- "$cur"))
+ ;;
+ esac
+} &&
+ complete -F _secret_tool secret-tool
+
+# ex: filetype=sh
diff --git a/completions/sh b/completions/sh
index 93f00952..5624ffa3 100644
--- a/completions/sh
+++ b/completions/sh
@@ -9,28 +9,28 @@ _sh()
-c)
return
;;
- -o|+o)
- COMPREPLY=( $(compgen -W 'allexport errexit ignoreeof monitor
+ -o | +o)
+ COMPREPLY=($(compgen -W 'allexport errexit ignoreeof monitor
noclobber noglob noexec nolog notify nounset verbose vi
- xtrace' -- "$cur") )
+ xtrace' -- "$cur"))
return
;;
esac
local opts="-a -b -C -e -f -h -i -m -n -o -u -v -x"
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W "$opts -c -s" -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W "$opts -c -s" -- "$cur"))
return
- elif [[ "$cur" == +* ]]; then
- COMPREPLY=( $(compgen -W "${opts//-/+}" -- "$cur") )
+ elif [[ $cur == +* ]]; then
+ COMPREPLY=($(compgen -W "${opts//-/+}" -- "$cur"))
return
fi
local args ext=
_count_args "" "@(-c|[-+]o)"
- [[ $args -eq 1 ]] && ext=sh
+ ((args == 1)) && ext="sh"
_filedir $ext
} &&
-complete -F _sh sh
+ complete -F _sh sh
# ex: filetype=sh
diff --git a/completions/shellcheck b/completions/shellcheck
index 4a40c8f9..6421d7b6 100644
--- a/completions/shellcheck
+++ b/completions/shellcheck
@@ -2,9 +2,9 @@
_shellcheck_optarg()
{
- local args=$("$1" --help 2>&1 | \
+ local args=$("$1" --help 2>&1 |
command sed -e 's/,/ /g' -ne 's/^.*'$2'\>.*(\([^)]*\)).*/\1/p')
- COMPREPLY+=( $(compgen -W '$args' -- "$cur") )
+ COMPREPLY+=($(compgen -W '$args' -- "$cur"))
}
_shellcheck()
@@ -13,51 +13,51 @@ _shellcheck()
_init_completion -s || return
case $prev in
- --version|-!(-*)V*)
+ --version | -!(-*)V*)
return
;;
- --exclude|--include|-!(-*)[ei])
+ --exclude | --include | -!(-*)[ei])
return
;;
- --format|-!(-*)f)
- local args=$("$1" --format=nonexistent-format /dev/null 2>&1 | \
- command sed -ne '/^Supported formats/,//p' | \
+ --format | -!(-*)f)
+ local args=$("$1" --format=nonexistent-format /dev/null 2>&1 |
+ command sed -ne '/^Supported formats/,//p' |
command sed -ne '/^[[:space:]]/p')
- COMPREPLY=( $(compgen -W '$args' -- "$cur") )
+ COMPREPLY=($(compgen -W '$args' -- "$cur"))
return
;;
- --color|-!(-*)C)
+ --color | -!(-*)C)
_shellcheck_optarg "$1" --color
return
;;
- --shell|-!(-*)s)
+ --shell | -!(-*)s)
_shellcheck_optarg "$1" --shell
return
;;
- --enable|-!(-*)o)
- COMPREPLY=( $(compgen -W 'all' -- "$cur") ) # TODO others?
+ --enable | -!(-*)o)
+ COMPREPLY=($(compgen -W 'all' -- "$cur")) # TODO others?
return
;;
- --source-path|-!(-*)P)
+ --source-path | -!(-*)P)
_filedir -d
- COMPREPLY+=( $(compgen -W 'SCRIPTDIR' -- "$cur") )
+ COMPREPLY+=($(compgen -W 'SCRIPTDIR' -- "$cur"))
return
;;
- --wiki-link-count|-!(-*)W)
+ --wiki-link-count | -!(-*)W)
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
_filedir
} &&
-complete -F _shellcheck shellcheck
+ complete -F _shellcheck shellcheck
# ex: filetype=sh
diff --git a/completions/sitecopy b/completions/sitecopy
index dae0548d..85156875 100644
--- a/completions/sitecopy
+++ b/completions/sitecopy
@@ -9,17 +9,17 @@ _sitecopy()
_init_completion -s || return
case $prev in
- --debug|-!(-*)d)
- COMPREPLY=( $(compgen -W "socket files rcfile ftp http httpbody
- rsh sftp xml xmlparse cleartext" -- "$cur") )
+ --debug | -!(-*)d)
+ COMPREPLY=($(compgen -W "socket files rcfile ftp http httpbody
+ rsh sftp xml xmlparse cleartext" -- "$cur"))
compopt -o nospace
return
;;
- --logfile|--rcfile|-!(-*)[gr])
+ --logfile | --rcfile | -!(-*)[gr])
_filedir
return
;;
- --storepath|-!(-*)p)
+ --storepath | -!(-*)p)
_filedir -d
return
;;
@@ -27,24 +27,24 @@ _sitecopy()
case $cur in
--*)
- COMPREPLY=( $(compgen -W "$(_parse_help $1)" -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ COMPREPLY=($(compgen -W "$(_parse_help $1)" -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
;;
# only complete long options
-)
compopt -o nospace
- COMPREPLY=( -- )
+ COMPREPLY=(--)
return
;;
esac
if [[ -r ~/.sitecopyrc ]]; then
- COMPREPLY=( $(compgen -W "$($1 -v | \
- command sed -n '/^Site:/s/Site: //p')" -- "$cur") )
+ COMPREPLY=($(compgen -W "$($1 -v |
+ command sed -n '/^Site:/s/Site: //p')" -- "$cur"))
fi
} &&
-complete -F _sitecopy -o default sitecopy
+ complete -F _sitecopy -o default sitecopy
# ex: filetype=sh
diff --git a/completions/slackpkg b/completions/slackpkg
index a1d500dc..1d879280 100644
--- a/completions/slackpkg
+++ b/completions/slackpkg
@@ -7,23 +7,23 @@ _slackpkg()
_init_completion -n = || return
local split=false
- if [[ "$cur" == -?*=* ]]; then
+ if [[ $cur == -?*=* ]]; then
prev="${cur%%?(\\)=*}"
cur="${cur#*=}"
split=true
fi
case "$prev" in
- -delall|-checkmd5|-checkgpg|-checksize|-postinst|-onoff|-download_all|\
- -dialog|-batch|-only_new_dotnew|-use_includes|-spinning)
- COMPREPLY=( $(compgen -W 'on off' -- "$cur") )
+ -delall | -checkmd5 | -checkgpg | -checksize | -postinst | -onoff | -download_all | \
+ -dialog | -batch | -only_new_dotnew | -use_includes | -spinning)
+ COMPREPLY=($(compgen -W 'on off' -- "$cur"))
return
;;
-default_answer)
- COMPREPLY=( $(compgen -W 'yes no' -- "$cur") )
+ COMPREPLY=($(compgen -W 'yes no' -- "$cur"))
return
;;
- -dialog_maxargs|-mirror)
+ -dialog_maxargs | -mirror)
# argument required but no completions available
return
;;
@@ -31,77 +31,82 @@ _slackpkg()
$split && return
- if [[ "$cur" == -* ]]; then
+ if [[ $cur == -* ]]; then
compopt -o nospace
- COMPREPLY=( $(compgen -W '-delall= -checkmd5= -checkgpg=
+ COMPREPLY=($(compgen -W '-delall= -checkmd5= -checkgpg=
-checksize= -postinst= -onoff= -download_all= -dialog=
-dialog_maxargs= -batch= -only_new_dotnew= -use_includes=
- -spinning= -default_answer= -mirror=' -- "$cur") )
+ -spinning= -default_answer= -mirror=' -- "$cur"))
return
fi
local confdir="/etc/slackpkg"
local config="$confdir/slackpkg.conf"
- [[ -r "$config" ]] || return
+ [[ -r $config ]] || return
. "$config"
local i action
- for (( i=1; i<${#words[@]}; i++ )); do
- if [[ "${words[i]}" != -* ]]; then
+ for ((i = 1; i < ${#words[@]}; i++)); do
+ if [[ ${words[i]} != -* ]]; then
action="${words[i]}"
break
fi
done
case "$action" in
- generate-template|search|file-search)
+ generate-template | search | file-search)
# argument required but no completions available
return
;;
- install-template|remove-template)
+ install-template | remove-template)
if [[ -e $confdir/templates ]]; then
- COMPREPLY=( $(cd "$confdir/templates"; \
- compgen -f -X "!*.template" -- "$cur") )
- COMPREPLY=( ${COMPREPLY[@]%.template} )
+ COMPREPLY=($(
+ cd "$confdir/templates"
+ compgen -f -X "!*.template" -- "$cur"
+ ))
+ COMPREPLY=(${COMPREPLY[@]%.template})
fi
return
;;
remove)
_filedir
- COMPREPLY+=( $(compgen -W 'a ap d e f k kde kdei l n t tcl x
- xap xfce y' -- "$cur") )
- COMPREPLY+=( $(cd /var/log/packages; compgen -f -- "$cur") )
+ COMPREPLY+=($(compgen -W 'a ap d e f k kde kdei l n t tcl x
+ xap xfce y' -- "$cur"))
+ COMPREPLY+=($(
+ cd /var/log/packages
+ compgen -f -- "$cur"
+ ))
return
;;
- install|reinstall|upgrade|blacklist|download)
+ install | reinstall | upgrade | blacklist | download)
_filedir
- COMPREPLY+=( $(compgen -W 'a ap d e f k kde kdei l n t tcl x
- xap xfce y' -- "$cur") )
- COMPREPLY+=( $(cut -f 6 -d\ "${WORKDIR}/pkglist" 2>/dev/null | \
- command grep "^$cur") )
+ COMPREPLY+=($(compgen -W 'a ap d e f k kde kdei l n t tcl x
+ xap xfce y' -- "$cur"))
+ COMPREPLY+=($(cut -f 6 -d\ "${WORKDIR}/pkglist" 2>/dev/null |
+ command grep "^$cur"))
return
;;
info)
- COMPREPLY=( $(cut -f 6 -d\ "${WORKDIR}/pkglist" 2>/dev/null | \
- command grep "^$cur") )
+ COMPREPLY=($(cut -f 6 -d\ "${WORKDIR}/pkglist" 2>/dev/null |
+ command grep "^$cur"))
return
;;
update)
# we should complete the same as the next `list` + "gpg"
- COMPREPLY=( $(compgen -W 'gpg' -- "$cur") )
+ COMPREPLY=($(compgen -W 'gpg' -- "$cur"))
;&
*)
- COMPREPLY+=( $(compgen -W 'install reinstall upgrade remove
+ COMPREPLY+=($(compgen -W 'install reinstall upgrade remove
blacklist download update install-new upgrade-all
clean-system new-config check-updates help generate-template
install-template remove-template search file-search info' -- \
- "$cur") )
+ "$cur"))
return
;;
esac
} &&
-complete -F _slackpkg slackpkg
+ complete -F _slackpkg slackpkg
# ex: filetype=sh
diff --git a/completions/slapt-get b/completions/slapt-get
index 9b249f19..14c2dbea 100644
--- a/completions/slapt-get
+++ b/completions/slapt-get
@@ -6,25 +6,27 @@ _slapt_get()
_init_completion || return
case "$prev" in
- --config|-c)
+ --config | -c)
_filedir
return
;;
- --retry|--search)
+ --retry | --search)
# argument required but no completions available
return
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
- [[ $COMPREPLY ]] && return
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur"))
+ if [[ ${COMPREPLY-} ]]; then
+ [[ $COMPREPLY == *= ]] && compopt -o nospace
+ return
+ fi
fi
local i t
# search for last action (--install|--install-set|--remove|--show|--filelist)
- for (( i=${#words[@]}-1; i>0; i-- )); do
+ for ((i = ${#words[@]} - 1; i > 0; i--)); do
if [[ ${words[i]} == --show ]]; then
t="all"
break
@@ -42,40 +44,43 @@ _slapt_get()
local config="/etc/slapt-get/slapt-getrc" # default config location
# search for config
- for (( i=${#words[@]}-1; i>0; i-- )); do
+ for ((i = ${#words[@]} - 1; i > 0; i--)); do
if [[ ${words[i]} == -@(c|-config) ]]; then
- config="${words[i+1]}"
+ config="${words[i + 1]}"
__expand_tilde_by_ref config
break
fi
done
- [[ -r "$config" ]] || return
+ [[ -r $config ]] || return
case $t in
all) # --show
# slapt-get will fail to search for "^name-version"
# it can search for names only
local name=${cur%%-*}
- COMPREPLY=( $(LC_ALL=C "$1" -c "$config" --search "^$name" \
- 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}") )
+ COMPREPLY=($(LC_ALL=C "$1" -c "$config" --search "^$name" \
+ 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}"))
return
;;
avl) # --install|-i|
- COMPREPLY=( $(LC_ALL=C "$1" -c "$config" --available \
- 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}") )
+ COMPREPLY=($(LC_ALL=C "$1" -c "$config" --available \
+ 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}"))
return
;;
ins) # --remove|--filelist
- COMPREPLY=( $(cd /var/log/packages; compgen -f -- "$cur") )
+ COMPREPLY=($(
+ cd /var/log/packages
+ compgen -f -- "$cur"
+ ))
return
;;
set) # --install-set
- COMPREPLY=( $(compgen -W 'a ap d e f k kde kdei l n t tcl x
- xap xfce y' -- "$cur") )
+ COMPREPLY=($(compgen -W 'a ap d e f k kde kdei l n t tcl x
+ xap xfce y' -- "$cur"))
return
;;
esac
} &&
-complete -F _slapt_get slapt-get
+ complete -F _slapt_get slapt-get
# ex: filetype=sh
diff --git a/completions/slapt-src b/completions/slapt-src
index 64458bab..1e3828c0 100644
--- a/completions/slapt-src
+++ b/completions/slapt-src
@@ -6,11 +6,11 @@ _slapt_src()
_init_completion -s -n : || return
case "$prev" in
- --config|-c)
+ --config | -c)
_filedir
return
;;
- --search|-s|--postprocess|-p)
+ --search | -s | --postprocess | -p)
# argument required but no completions available
return
;;
@@ -18,15 +18,17 @@ _slapt_src()
$split && return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" --help)' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
- [[ $COMPREPLY ]] && return
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" --help)' -- "$cur"))
+ if [[ ${COMPREPLY-} ]]; then
+ [[ $COMPREPLY == *= ]] && compopt -o nospace
+ return
+ fi
fi
local i t
# search for last action (-i|-w|-b|-f)
- for (( i=${#words[@]}-1; i>0; i-- )); do
+ for ((i = ${#words[@]} - 1; i > 0; i--)); do
if [[ ${words[i]} == -@([iwfb]|-install|-show|-build|-fetch) ]]; then
t="all"
break
@@ -38,9 +40,9 @@ _slapt_src()
local config="/etc/slapt-get/slapt-srcrc" # default config location
# search for config
- for (( i=${#words[@]}-1; i>0; i-- )); do
+ for ((i = ${#words[@]} - 1; i > 0; i--)); do
if [[ ${words[i]} == -@(c|-config) ]]; then
- config="${words[i+1]}"
+ config="${words[i + 1]}"
__expand_tilde_by_ref config
break
fi
@@ -49,19 +51,18 @@ _slapt_src()
break
fi
done
- [[ -r "$config" ]] || return
+ [[ -r $config ]] || return
- if [[ "$cur" == *:* ]]; then
+ if [[ $cur == *:* ]]; then
local name=${cur%:*}
- local version=${cur##*:}
- COMPREPLY=( $(LC_ALL=C "$1" --config "$config" --search "^$name" \
+ COMPREPLY=($(LC_ALL=C "$1" --config "$config" --search "^$name" \
2>/dev/null | LC_ALL=C command sed -ne \
- "/^$cur/{s/^$name:\([^ ]*\) .*$/\1/;p}") )
+ "/^$cur/{s/^$name:\([^ ]*\) .*$/\1/;p}"))
else
- COMPREPLY=( $(LC_ALL=C "$1" --config "$config" --search "^$cur" \
- 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}") )
+ COMPREPLY=($(LC_ALL=C "$1" --config "$config" --search "^$cur" \
+ 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p}"))
fi
} &&
-complete -F _slapt_src slapt-src
+ complete -F _slapt_src slapt-src
# ex: filetype=sh
diff --git a/completions/smartctl b/completions/smartctl
index ecef0b99..ee45a7c3 100644
--- a/completions/smartctl
+++ b/completions/smartctl
@@ -2,25 +2,27 @@
_smartctl_quietmode()
{
- COMPREPLY=( $(compgen -W 'errorsonly silent noserial' -- "$cur") )
+ COMPREPLY=($(compgen -W 'errorsonly silent noserial' -- "$cur"))
}
_smartctl_device()
{
case $cur in
- areca*|3ware*|megaraid*|cciss*)
- COMPREPLY+=( ${cur%%,*},{0..31} )
- COMPREPLY=( $(compgen -W '"${COMPREPLY[@]}"' -- "$cur") )
+ areca* | 3ware* | megaraid* | cciss*)
+ # shellcheck disable=SC2054
+ COMPREPLY+=(${cur%%,*},{0..31})
+ COMPREPLY=($(compgen -W '"${COMPREPLY[@]}"' -- "$cur"))
;;
hpt*)
- COMPREPLY+=( hpt,{1..4}/{1..8} hpt,{1..4}/{1..8}/{1..5} )
- COMPREPLY=( $(compgen -W '"${COMPREPLY[@]}"' -- "$cur") )
+ # shellcheck disable=SC2054
+ COMPREPLY+=(hpt,{1..4}/{1..8} hpt,{1..4}/{1..8}/{1..5})
+ COMPREPLY=($(compgen -W '"${COMPREPLY[@]}"' -- "$cur"))
;;
*)
- COMPREPLY=( $(compgen -W "ata scsi sat usbcypress usbjmicron
+ COMPREPLY=($(compgen -W "ata scsi sat usbcypress usbjmicron
usbsunplus marvell areca 3ware hpt megaraid cciss auto test" \
- -- "$cur") )
+ -- "$cur"))
case "${COMPREPLY[@]}" in
- areca|3ware|hpt|megaraid|cciss)
+ areca | 3ware | hpt | megaraid | cciss)
compopt -o nospace
;;
esac
@@ -29,54 +31,54 @@ _smartctl_device()
}
_smartctl_tolerance()
{
- COMPREPLY=( $(compgen -W 'normal conservative permissive verypermissive' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W 'normal conservative permissive verypermissive' \
+ -- "$cur"))
}
_smartctl_badsum()
{
- COMPREPLY=( $(compgen -W 'warn exit ignore' -- "$cur") )
+ COMPREPLY=($(compgen -W 'warn exit ignore' -- "$cur"))
}
_smartctl_report()
{
- COMPREPLY=( $(compgen -W 'ioctl ataioctl scsiioctl' -- "$cur") )
+ COMPREPLY=($(compgen -W 'ioctl ataioctl scsiioctl' -- "$cur"))
}
_smartctl_powermode()
{
- COMPREPLY=( $(compgen -W 'never sleep standby idle' -- "$cur") )
+ COMPREPLY=($(compgen -W 'never sleep standby idle' -- "$cur"))
}
_smartctl_feature()
{
- COMPREPLY=( $(compgen -W 'on off' -- "$cur") )
+ COMPREPLY=($(compgen -W 'on off' -- "$cur"))
}
_smartctl_log()
{
- COMPREPLY=( $(compgen -W 'error selftest selective directory background
+ COMPREPLY=($(compgen -W 'error selftest selective directory background
sasphy sasphy,reset sataphy sataphy,reset scttemp scttempsts
- scttemphist scterc gplog smartlog xerror xselftest' -- "$cur") )
+ scttemphist scterc gplog smartlog xerror xselftest' -- "$cur"))
}
_smartctl_vendorattribute()
{
- COMPREPLY=( $(compgen -W 'help 9,minutes 9,seconds 9,halfminutes 9,temp
+ COMPREPLY=($(compgen -W 'help 9,minutes 9,seconds 9,halfminutes 9,temp
192,emergencyretractcyclect 193,loadunload 194,10xCelsius 194,unknown
198,offlinescanuncsectorct 200,writeerrorcount 201,detectedtacount
- 220,temp' -- "$cur") )
+ 220,temp' -- "$cur"))
}
_smartctl_firmwarebug()
{
- COMPREPLY=( $(compgen -W 'none samsung samsung2 samsung3 swapid' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W 'none samsung samsung2 samsung3 swapid' \
+ -- "$cur"))
}
_smartctl_presets()
{
- COMPREPLY=( $(compgen -W 'use ignore show showall' -- "$cur") )
+ COMPREPLY=($(compgen -W 'use ignore show showall' -- "$cur"))
}
_smartctl_test()
{
[[ $cur == @(pending|scttempint|vendor), ]] && return
- COMPREPLY=( $(compgen -W 'offline short long conveyance select,
+ COMPREPLY=($(compgen -W 'offline short long conveyance select,
select,redo select,next afterselect,on afterselect,off pending,
- scttempint, vendor,' -- "$cur") )
- [[ $COMPREPLY == *, ]] && compopt -o nospace
+ scttempint, vendor,' -- "$cur"))
+ [[ ${COMPREPLY-} == *, ]] && compopt -o nospace
}
_smartctl_drivedb()
{
@@ -86,7 +88,7 @@ _smartctl_drivedb()
cur="${cur#+}"
fi
_filedir h
- [[ -n $prefix ]] && COMPREPLY=( "${COMPREPLY[@]/#/$prefix}" )
+ [[ -n $prefix ]] && COMPREPLY=("${COMPREPLY[@]/#/$prefix}")
}
_smartctl()
@@ -95,54 +97,54 @@ _smartctl()
_init_completion -s || return
case $prev in
- --quietmode|-!(-*)q)
+ --quietmode | -!(-*)q)
_smartctl_quietmode
;;
- --device|-!(-*)d)
+ --device | -!(-*)d)
_smartctl_device
return
;;
- --tolerance|-!(-*)T)
+ --tolerance | -!(-*)T)
_smartctl_tolerance
return
;;
- --badsum|-!(-*)b)
+ --badsum | -!(-*)b)
_smartctl_badsum
return
;;
- --report|-!(-*)r)
+ --report | -!(-*)r)
_smartctl_report
return
;;
- --nocheck|-!(-*)n)
+ --nocheck | -!(-*)n)
_smartctl_powermode
return
;;
- --smart|--offlineauto|--saveauto|-!(-*)[soS])
+ --smart | --offlineauto | --saveauto | -!(-*)[soS])
_smartctl_feature
return
;;
- --log|-!(-*)l)
+ --log | -!(-*)l)
_smartctl_log
return
;;
- --vendorattribute|-!(-*)v)
+ --vendorattribute | -!(-*)v)
_smartctl_vendorattribute
return
;;
- --firmwarebug|-!(-*)F)
+ --firmwarebug | -!(-*)F)
_smartctl_firmwarebug
return
;;
- --presets|-!(-*)P)
+ --presets | -!(-*)P)
_smartctl_presets
return
;;
- --drivedb|-!(-*)B)
+ --drivedb | -!(-*)B)
_smartctl_drivedb
return
;;
- --test|-!(-*)t)
+ --test | -!(-*)t)
_smartctl_test
return
;;
@@ -150,14 +152,14 @@ _smartctl()
$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
cur=${cur:=/dev/}
_filedir
fi
} &&
-complete -F _smartctl smartctl
+ complete -F _smartctl smartctl
# ex: filetype=sh
diff --git a/completions/smbclient b/completions/smbclient
index c896ce42..cea21076 100644
--- a/completions/smbclient
+++ b/completions/smbclient
@@ -2,40 +2,41 @@
_samba_resolve_order()
{
- COMPREPLY=( $(compgen -W 'lmhosts host wins bcast' -- "$cur") )
+ COMPREPLY=($(compgen -W 'lmhosts host wins bcast' -- "$cur"))
}
_samba_domains()
{
if [[ -n ${COMP_SAMBA_SCAN:-} ]]; then
- COMPREPLY=( $(compgen -W '$(smbtree -N -D)' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(smbtree -N -D)' -- "$cur"))
fi
}
_samba_hosts()
{
if [[ -n ${COMP_SAMBA_SCAN:-} ]]; then
- COMPREPLY=( $(compgen -W "$(smbtree -N -S | \
- command sed -ne 's/^[[:space:]]*\\\\*\([^[:space:]]*\).*/\1/p' \
- )" -- "$cur") )
+ COMPREPLY=($(compgen -W "$(
+ smbtree -N -S |
+ command sed -ne 's/^[[:space:]]*\\\\*\([^[:space:]]*\).*/\1/p'
+ )" -- "$cur"))
fi
}
_samba_debuglevel()
{
- COMPREPLY=( $(compgen -W '{0..10}' -- "$cur") )
+ COMPREPLY=($(compgen -W '{0..10}' -- "$cur"))
}
_samba_sockopts()
{
- COMPREPLY=( $(compgen -W 'SO_KEEPALIVE SO_REUSEADDR SO_BROADCAST
+ COMPREPLY=($(compgen -W 'SO_KEEPALIVE SO_REUSEADDR SO_BROADCAST
TCP_NODELAY IPTOS_LOWDELAY IPTOS_THROUGHPUT SO_SNDBUF SO_RCVBUF
- SO_SNDLOWAT SO_RCVLOWAT' -- "$cur") )
+ SO_SNDLOWAT SO_RCVLOWAT' -- "$cur"))
}
_samba_signing()
{
- COMPREPLY=( $(compgen -W 'on off required' -- "$cur") )
+ COMPREPLY=($(compgen -W 'on off required' -- "$cur"))
}
_smbclient()
@@ -44,64 +45,64 @@ _smbclient()
_init_completion -s || return
case $prev in
- --name-resolve|-!(-*)R)
+ --name-resolve | -!(-*)R)
_samba_resolve_order
return
;;
-!(-*)t)
- COMPREPLY=( $(compgen -W 'SJIS EUC JIS7 JIS8 JUNET HEX CAP' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W 'SJIS EUC JIS7 JIS8 JUNET HEX CAP' \
+ -- "$cur"))
return
;;
- --configfile|--authentication-file|-!(-*)[sA])
+ --configfile | --authentication-file | -!(-*)[sA])
_filedir
return
;;
- --log-basename|--directory|-!(-*)[lD])
+ --log-basename | --directory | -!(-*)[lD])
_filedir -d
return
;;
- --socket-options|-!(-*)O)
+ --socket-options | -!(-*)O)
_samba_sockopts
return
;;
-!(-*)T)
- COMPREPLY=( $(compgen -W 'c x I X F b g q r N a' -- "$cur") )
+ COMPREPLY=($(compgen -W 'c x I X F b g q r N a' -- "$cur"))
return
;;
- --workgroup|-!(-*)W)
+ --workgroup | -!(-*)W)
_samba_domains
return
;;
- --debuglevel|-!(-*)d)
+ --debuglevel | -!(-*)d)
_samba_debuglevel
return
;;
- --list|-!(-*)L)
+ --list | -!(-*)L)
_samba_hosts
return
;;
- --signing|-!(-*)S)
+ --signing | -!(-*)S)
_samba_signing
return
;;
- --port|--message|--ip-address|--send-buffer|--user|--netbiosname|\
- --scope|--tar|--command|--max-protocol|-!(-*)[pMIbUniTcm])
+ --port | --message | --ip-address | --send-buffer | --user | --netbiosname | \
+ --scope | --tar | --command | --max-protocol | -!(-*)[pMIbUniTcm])
return
;;
- --help|--version|-!(-*)[?V])
+ --help | --version | -!(-*)[?V])
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 _smbclient smbclient
+ complete -F _smbclient smbclient
_smbget()
{
@@ -109,31 +110,31 @@ _smbget()
_init_completion -s || return
case $prev in
- --outputfile|--rcfile|-!(-*)[of])
+ --outputfile | --rcfile | -!(-*)[of])
_filedir
return
;;
- --debuglevel|-!(-*)d)
+ --debuglevel | -!(-*)d)
_samba_debuglevel
return
;;
- --workgroup|-!(-*)w)
+ --workgroup | -!(-*)w)
_samba_domains
return
;;
- --username|--password|--blocksize|-!(-*)[upb])
+ --username | --password | --blocksize | -!(-*)[upb])
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 _smbget smbget
+ complete -F _smbget smbget
_smbcacls()
{
@@ -141,15 +142,15 @@ _smbcacls()
_init_completion -s || return
case $prev in
- --configfile|--authentication-file|-!(-*)[As])
+ --configfile | --authentication-file | -!(-*)[As])
_filedir
return
;;
- --log-basename|-!(-*)l)
+ --log-basename | -!(-*)l)
_filedir -d
return
;;
- --debuglevel|-!(-*)d)
+ --debuglevel | -!(-*)d)
_samba_debuglevel
return
;;
@@ -157,28 +158,28 @@ _smbcacls()
_samba_signing
return
;;
- --socket-options|-!(-*)O)
+ --socket-options | -!(-*)O)
_samba_sockopts
return
;;
- --workgroup|-!(-*)W)
+ --workgroup | -!(-*)W)
_samba_domains
return
;;
- --help|--usage|--delete|--modify|--add|--set|--chown|--chgrp|\
- --netbiosname|--scope|--user|-!(-*)[?DMaSCGniU])
+ --help | --usage | --delete | --modify | --add | --set | --chown | --chgrp | \
+ --netbiosname | --scope | --user | -!(-*)[?DMaSCGniU])
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 _smbcacls smbcacls
+ complete -F _smbcacls smbcacls
_smbcquotas()
{
@@ -186,15 +187,15 @@ _smbcquotas()
_init_completion -s || return
case $prev in
- --configfile|--authentication-file|-!(-*)[sA])
+ --configfile | --authentication-file | -!(-*)[sA])
_filedir
return
;;
- --log-basename|-!(-*)l)
+ --log-basename | -!(-*)l)
_filedir -d
return
;;
- --debuglevel|-!(-*)d)
+ --debuglevel | -!(-*)d)
_samba_debuglevel
return
;;
@@ -202,19 +203,19 @@ _smbcquotas()
_samba_signing
return
;;
- --help|--usage|--user|--set|-!(-*)[?UuS])
+ --help | --usage | --user | --set | -!(-*)[?UuS])
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 _smbcquotas smbcquotas
+ complete -F _smbcquotas smbcquotas
_smbpasswd()
{
@@ -243,11 +244,11 @@ _smbpasswd()
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
fi
} &&
-complete -F _smbpasswd smbpasswd
+ complete -F _smbpasswd smbpasswd
_smbtar()
{
@@ -276,11 +277,11 @@ _smbtar()
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
fi
} &&
-complete -F _smbtar smbtar
+ complete -F _smbtar smbtar
_smbtree()
{
@@ -288,34 +289,34 @@ _smbtree()
_init_completion -s || return
case $prev in
- --configfile|--authentication-file|-!(-*)[sA])
+ --configfile | --authentication-file | -!(-*)[sA])
_filedir
return
;;
- --log-basename|-!(-*)l)
+ --log-basename | -!(-*)l)
_filedir -d
return
;;
- --debuglevel|-!(-*)d)
+ --debuglevel | -!(-*)d)
_samba_debuglevel
return
;;
- --signing|-!(-*)S)
+ --signing | -!(-*)S)
_samba_signing
return
;;
- --help|--usage|--user|-!(-*)[?U])
+ --help | --usage | --user | -!(-*)[?U])
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 _smbtree smbtree
+ complete -F _smbtree smbtree
# ex: filetype=sh
diff --git a/completions/snownews b/completions/snownews
index 3938454f..5b585d92 100644
--- a/completions/snownews
+++ b/completions/snownews
@@ -5,11 +5,11 @@ _snownews()
local cur prev words cword
_init_completion || return
- if [[ "$cur" == -* ]]; then
+ if [[ $cur == -* ]]; then
# return list of available options
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
fi
} &&
-complete -F _snownews snownews
+ complete -F _snownews snownews
# ex: filetype=sh
diff --git a/completions/sqlite3 b/completions/sqlite3
index a7005489..26d38a1f 100644
--- a/completions/sqlite3
+++ b/completions/sqlite3
@@ -8,8 +8,8 @@ _sqlite3()
local dbexts='@(sqlite?(3)|?(s?(3))db)'
case $prev in
- -help|-version|-lookaside|-mmap|-newline|-nullvalue|-pagecache|\
- -scratch|-separator|*.$dbexts)
+ -help | -version | -lookaside | -mmap | -newline | -nullvalue | -pagecache | \
+ -scratch | -separator | *.$dbexts)
return
;;
-init)
@@ -18,21 +18,21 @@ _sqlite3()
;;
-cmd)
compopt -o filenames
- COMPREPLY=( $(compgen -c -- "$cur") )
+ COMPREPLY=($(compgen -c -- "$cur"))
return
;;
esac
- [[ $cword -gt 2 && ${words[cword-2]} == -@(lookaside|pagecache|scratch) ]] \
- && return
+ [[ $cword -gt 2 && ${words[cword - 2]} == -@(lookaside|pagecache|scratch) ]] &&
+ return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
return
fi
_filedir "$dbexts"
} &&
-complete -F _sqlite3 sqlite3
+ complete -F _sqlite3 sqlite3
# ex: filetype=sh
diff --git a/completions/ss b/completions/ss
index 05e4e4b2..4a27d514 100644
--- a/completions/ss
+++ b/completions/ss
@@ -6,23 +6,24 @@ _ss()
_init_completion -s || return
case $prev in
- --help|--version|-!(-*)[hV])
+ --help | --version | -!(-*)[hV])
return
;;
- --family|-!(-*)f)
- COMPREPLY=( $(compgen -W 'unix inet inet6 link netlink' \
- -- "$cur") )
+ --family | -!(-*)f)
+ COMPREPLY=($(compgen -W 'unix inet inet6 link netlink' \
+ -- "$cur"))
return
;;
- --query|-!(-*)A)
- local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*},"
- COMPREPLY=( $(compgen -W '$("$1" --help | \
+ --query | -!(-*)A)
+ local prefix=
+ [[ $cur == *,* ]] && prefix="${cur%,*},"
+ COMPREPLY=($(compgen -W '$("$1" --help | \
command sed -e "s/|/ /g" -ne "s/.*QUERY := {\([^}]*\)}.*/\1/p")' \
- -- "${cur##*,}") )
- [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} )
+ -- "${cur##*,}"))
+ ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
return
;;
- --diag|--filter|-!(-*)[DF])
+ --diag | --filter | -!(-*)[DF])
_filedir
return
;;
@@ -31,10 +32,10 @@ _ss()
$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 _ss ss
+ complete -F _ss ss
# ex: filetype=sh
diff --git a/completions/ssh b/completions/ssh
index ecbd5896..907c0390 100644
--- a/completions/ssh
+++ b/completions/ssh
@@ -2,9 +2,12 @@
_ssh_queries()
{
- COMPREPLY+=( $(compgen -W \
- "cipher cipher-auth mac kex key key-cert key-plain protocol-version sig" \
- -- "$cur") )
+ COMPREPLY+=($(compgen -W \
+ "cipher cipher-auth help mac kex key key-cert key-plain key-sig
+ protocol-version compression sig
+ ciphers macs kexalgorithms pubkeyacceptedkeytypes
+ hostkeyalgorithms hostbasedkeytypes hostbasedacceptedkeytypes" \
+ -- "${cur,,}"))
}
_ssh_query()
@@ -18,7 +21,7 @@ _ssh_ciphers()
[[ $ciphers ]] || ciphers="3des-cbc aes128-cbc aes192-cbc aes256-cbc
aes128-ctr aes192-ctr aes256-ctr arcfour128 arcfour256 arcfour
blowfish-cbc cast128-cbc"
- COMPREPLY+=( $(compgen -W "$ciphers" -- "$cur") )
+ COMPREPLY+=($(compgen -W "$ciphers" -- "$cur"))
}
_ssh_macs()
@@ -26,7 +29,7 @@ _ssh_macs()
local macs='$(_ssh_query "$1" mac)'
[[ $macs ]] || macs="hmac-md5 hmac-sha1 umac-64@openssh.com hmac-ripemd160
hmac-sha1-96 hmac-md5-96"
- COMPREPLY+=( $(compgen -W "$macs" -- "$cur") )
+ COMPREPLY+=($(compgen -W "$macs" -- "$cur"))
}
_ssh_options()
@@ -55,19 +58,20 @@ _ssh_options()
ServerAliveInterval SmartcardDevice StreamLocalBindMask
StreamLocalBindUnlink StrictHostKeyChecking SyslogFacility TCPKeepAlive
Tunnel TunnelDevice UpdateHostKeys UsePrivilegedPort User
- UserKnownHostsFile VerifyHostKeyDNS VisualHostKey XAuthLocation )
+ UserKnownHostsFile VerifyHostKeyDNS VisualHostKey XAuthLocation)
local protocols=$(_ssh_query "$1" protocol-version)
if [[ -z $protocols || $protocols == *1* ]]; then
- opts+=( Cipher CompressionLevel Protocol RhostsRSAAuthentication
- RSAAuthentication )
+ opts+=(Cipher CompressionLevel Protocol RhostsRSAAuthentication
+ RSAAuthentication)
fi
compopt -o nospace
- local IFS=$' \t\n' reset=$(shopt -p nocasematch); shopt -s nocasematch
+ local IFS=$' \t\n' reset=$(shopt -p nocasematch)
+ shopt -s nocasematch
local option
- COMPREPLY=( $(for option in "${opts[@]}"; do
- [[ $option == "$cur"* ]] && printf '%s=\n' "$option"
- done) )
+ COMPREPLY=($(for option in "${opts[@]}"; do
+ [[ $option == "$cur"* ]] && printf '%s=\n' "$option"
+ done))
$reset
}
@@ -82,68 +86,68 @@ _ssh_suboption()
local prev=${1%%=*} cur=${1#*=}
case ${prev,,} in
- batchmode|canonicaldomains|canonicalizefallbacklocal|\
- challengeresponseauthentication|checkhostip|\
- clearallforwardings|controlpersist|compression|enablesshkeysign|\
- exitonforwardfailure|forwardagent|forwardx11|forwardx11trusted|\
- gatewayports|gssapiauthentication|gssapikeyexchange|\
- gssapidelegatecredentials|gssapirenewalforcesrekey|gssapitrustdns|\
- hashknownhosts|hostbasedauthentication|identitiesonly|\
- kbdinteractiveauthentication|kbdinteractivedevices|\
- nohostauthenticationforlocalhost|passwordauthentication|permitlocalcommand|\
- proxyusefdpass|pubkeyauthentication|rhostsrsaauthentication|\
- rsaauthentication|streamlocalbindunlink|\
- tcpkeepalive|useprivilegedport|visualhostkey)
- COMPREPLY=( $(compgen -W 'yes no' -- "$cur") )
+ batchmode | canonicaldomains | canonicalizefallbacklocal | \
+ challengeresponseauthentication | checkhostip | \
+ clearallforwardings | controlpersist | compression | enablesshkeysign | \
+ exitonforwardfailure | forwardagent | forwardx11 | forwardx11trusted | \
+ gatewayports | gssapiauthentication | gssapikeyexchange | \
+ gssapidelegatecredentials | gssapirenewalforcesrekey | gssapitrustdns | \
+ hashknownhosts | hostbasedauthentication | identitiesonly | \
+ kbdinteractiveauthentication | kbdinteractivedevices | \
+ nohostauthenticationforlocalhost | passwordauthentication | permitlocalcommand | \
+ proxyusefdpass | pubkeyauthentication | rhostsrsaauthentication | \
+ rsaauthentication | streamlocalbindunlink | \
+ tcpkeepalive | useprivilegedport | visualhostkey)
+ COMPREPLY=($(compgen -W 'yes no' -- "$cur"))
;;
addkeystoagent)
- COMPREPLY=( $(compgen -W 'yes ask confirm no' -- "$cur") )
+ COMPREPLY=($(compgen -W 'yes ask confirm no' -- "$cur"))
;;
addressfamily)
- COMPREPLY=( $(compgen -W 'any inet inet6' -- "$cur") )
+ COMPREPLY=($(compgen -W 'any inet inet6' -- "$cur"))
;;
bindaddress)
_ip_addresses
;;
canonicalizehostname)
- COMPREPLY=( $(compgen -W 'yes no always' -- "$cur") )
+ COMPREPLY=($(compgen -W 'yes no always' -- "$cur"))
;;
identityfile)
_ssh_identityfile
;;
- *file|identityagent|include|controlpath|revokedhostkeys|xauthlocation)
+ *file | identityagent | include | controlpath | revokedhostkeys | xauthlocation)
_filedir
;;
casignaturealgorithms)
- COMPREPLY=( $(compgen -W '$(_ssh_query "$2" sig)' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_ssh_query "$2" sig)' -- "$cur"))
;;
cipher)
- COMPREPLY=( $(compgen -W 'blowfish des 3des' -- "$cur") )
+ COMPREPLY=($(compgen -W 'blowfish des 3des' -- "$cur"))
;;
ciphers)
_ssh_ciphers "$2"
;;
controlmaster)
- COMPREPLY=( $(compgen -W 'yes ask auto autoask no' -- "$cur") )
+ COMPREPLY=($(compgen -W 'yes ask auto autoask no' -- "$cur"))
;;
compressionlevel)
- COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") )
+ COMPREPLY=($(compgen -W '{1..9}' -- "$cur"))
;;
fingerprinthash)
- COMPREPLY=( $(compgen -W 'md5 sha256' -- "$cur") )
+ COMPREPLY=($(compgen -W 'md5 sha256' -- "$cur"))
;;
ipqos)
- COMPREPLY=( $(compgen -W 'af1{1..4} af2{2..3} af3{1..3} af4{1..3}
- cs{0..7} ef lowdelay throughput reliability' -- "$cur") )
+ COMPREPLY=($(compgen -W 'af1{1..4} af2{2..3} af3{1..3} af4{1..3}
+ cs{0..7} ef lowdelay throughput reliability' -- "$cur"))
;;
- hostbasedkeytypes|hostkeyalgorithms)
- COMPREPLY=( $(compgen -W '$(_ssh_query "$2" key)' -- "$cur") )
+ hostbasedkeytypes | hostkeyalgorithms)
+ COMPREPLY=($(compgen -W '$(_ssh_query "$2" key)' -- "$cur"))
;;
kexalgorithms)
- COMPREPLY=( $(compgen -W '$(_ssh_query "$2" kex)' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_ssh_query "$2" kex)' -- "$cur"))
;;
loglevel)
- COMPREPLY=( $(compgen -W 'QUIET FATAL ERROR INFO VERBOSE DEBUG{,1,2,3}' -- "$cur") )
+ COMPREPLY=($(compgen -W 'QUIET FATAL ERROR INFO VERBOSE DEBUG{,1,2,3}' -- "$cur"))
;;
macs)
_ssh_macs "$2"
@@ -152,40 +156,40 @@ _ssh_suboption()
_filedir so
;;
preferredauthentications)
- COMPREPLY=( $(compgen -W 'gssapi-with-mic host-based publickey
- keyboard-interactive password' -- "$cur") )
+ COMPREPLY=($(compgen -W 'gssapi-with-mic host-based publickey
+ keyboard-interactive password' -- "$cur"))
;;
protocol)
- local protocols=( $(_ssh_query "$2" protocol-version) )
+ local protocols=($(_ssh_query "$2" protocol-version))
[[ $protocols ]] || protocols=(1 2)
- if [[ ${#protocols[@]} -gt 1 ]]; then
- COMPREPLY=( $(compgen -W '${protocols[@]}' -- "$cur") )
+ if ((${#protocols[@]} > 1)); then
+ COMPREPLY=($(compgen -W '${protocols[@]}' -- "$cur"))
fi
;;
proxyjump)
- _known_hosts_real -a -F "$configfile" -- "$cur"
+ _known_hosts_real -a ${configfile:+-F "$configfile"} -- "$cur"
;;
- proxycommand|remotecommand|localcommand)
- COMPREPLY=( $(compgen -c -- "$cur") )
+ proxycommand | remotecommand | localcommand)
+ COMPREPLY=($(compgen -c -- "$cur"))
;;
pubkeyacceptedkeytypes)
- COMPREPLY=( $(compgen -W '$(_ssh_query "$2" key)' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_ssh_query "$2" key)' -- "$cur"))
;;
requesttty)
- COMPREPLY=( $(compgen -W 'no yes force auto' -- "$cur") )
+ COMPREPLY=($(compgen -W 'no yes force auto' -- "$cur"))
;;
stricthostkeychecking)
- COMPREPLY=( $(compgen -W 'accept-new ask no off' -- "$cur") )
+ COMPREPLY=($(compgen -W 'accept-new ask no off' -- "$cur"))
;;
syslogfacility)
- COMPREPLY=( $(compgen -W 'DAEMON USER AUTH LOCAL{0..7}' -- "$cur") )
+ COMPREPLY=($(compgen -W 'DAEMON USER AUTH LOCAL{0..7}' -- "$cur"))
;;
tunnel)
- COMPREPLY=( $(compgen -W 'yes no point-to-point ethernet' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W 'yes no point-to-point ethernet' \
+ -- "$cur"))
;;
- updatehostkeys|verifyhostkeydns)
- COMPREPLY=( $(compgen -W 'yes no ask' -- "$cur") )
+ updatehostkeys | verifyhostkeydns)
+ COMPREPLY=($(compgen -W 'yes no ask' -- "$cur"))
;;
esac
return 0
@@ -197,7 +201,7 @@ _ssh_suboption()
_ssh_suboption_check()
{
# Get prev and cur words without splitting on =
- local cureq=`_get_cword :=` preveq=`_get_pword :=`
+ local cureq=$(_get_cword :=) preveq=$(_get_pword :=)
if [[ $cureq == *=* && $preveq == -*o ]]; then
_ssh_suboption $cureq "$1"
return $?
@@ -209,13 +213,13 @@ _ssh_suboption_check()
_ssh_configfile()
{
set -- "${words[@]}"
- while [[ $# -gt 0 ]]; do
+ while (($# > 0)); do
if [[ $1 == -F* ]]; then
- if [[ ${#1} -gt 2 ]]; then
+ if ((${#1} > 2)); then
configfile="$(dequote "${1:2}")"
else
shift
- [[ $1 ]] && configfile="$(dequote "$1")"
+ [[ ${1-} ]] && configfile="$(dequote "$1")"
fi
break
fi
@@ -224,13 +228,14 @@ _ssh_configfile()
}
# With $1 set, look for public key files, else private
+# shellcheck disable=SC2120
_ssh_identityfile()
{
[[ -z $cur && -d ~/.ssh ]] && cur=~/.ssh/id
_filedir
- if (( ${#COMPREPLY[@]} > 0 )); then
- COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' \
- -X "${1:+!}*.pub" -- "$cur") )
+ if ((${#COMPREPLY[@]} > 0)); then
+ COMPREPLY=($(compgen -W '${COMPREPLY[@]}' \
+ -X "${1:+!}*.pub" -- "$cur"))
fi
}
@@ -239,8 +244,6 @@ _ssh()
local cur prev words cword
_init_completion -n : || return
- local -a config
-
local configfile
_ssh_configfile
@@ -249,12 +252,6 @@ _ssh()
local ipvx
case $prev in
- -*4*)
- ipvx=-4
- ;;
- -*6*)
- ipvx=-6
- ;;
-*b)
_ip_addresses
return
@@ -279,11 +276,11 @@ _ssh()
return
;;
-*J)
- _known_hosts_real -a -F "$configfile" -- "$cur"
+ _known_hosts_real -a ${configfile:+-F "$configfile"} -- "$cur"
return
;;
-*l)
- COMPREPLY=( $(compgen -u -- "$cur") )
+ COMPREPLY=($(compgen -u -- "$cur"))
return
;;
-*m)
@@ -291,7 +288,7 @@ _ssh()
return
;;
-*O)
- COMPREPLY=( $(compgen -W 'check forward cancel exit stop' -- "$cur") )
+ COMPREPLY=($(compgen -W 'check forward cancel exit stop' -- "$cur"))
return
;;
-*o)
@@ -306,28 +303,34 @@ _ssh()
_available_interfaces
return
;;
+ -*4*)
+ ipvx=-4
+ ;;
+ -*6*)
+ ipvx=-6
+ ;;
esac
- if [[ "$cur" == -F* ]]; then
+ if [[ $cur == -F* ]]; then
cur=${cur#-F}
_filedir
# Prefix completions with '-F'
- COMPREPLY=( "${COMPREPLY[@]/#/-F}" )
- cur=-F$cur # Restore cur
- elif [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
+ COMPREPLY=("${COMPREPLY[@]/#/-F}")
+ cur=-F$cur # Restore cur
+ elif [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
else
- _known_hosts_real $ipvx -a -F "$configfile" -- "$cur"
+ _known_hosts_real ${ipvx-} -a ${configfile:+-F "$configfile"} -- "$cur"
local args
_count_args
- if [[ $args -gt 1 ]]; then
+ if ((args > 1)); then
compopt -o filenames
- COMPREPLY+=( $(compgen -c -- "$cur") )
+ COMPREPLY+=($(compgen -c -- "$cur"))
fi
fi
} &&
-shopt -u hostcomplete && complete -F _ssh ssh slogin autossh sidedoor
+ shopt -u hostcomplete && complete -F _ssh ssh slogin autossh sidedoor
# sftp(1) completion
#
@@ -344,12 +347,6 @@ _sftp()
local ipvx
case $prev in
- -*4*)
- ipvx=-4
- ;;
- -*6*)
- ipvx=-6
- ;;
-*[BDlPRs])
return
;;
@@ -366,7 +363,7 @@ _sftp()
return
;;
-*J)
- _known_hosts_real -a -F "$configfile" -- "$cur"
+ _known_hosts_real -a ${configfile:+-F "$configfile"} -- "$cur"
return
;;
-*o)
@@ -374,30 +371,39 @@ _sftp()
return
;;
-*S)
- _command
+ compopt -o filenames
+ COMPREPLY=($(compgen -c -- "$cur"))
return
;;
+ -*4*)
+ ipvx=-4
+ ;;
+ -*6*)
+ ipvx=-6
+ ;;
esac
- if [[ "$cur" == -F* ]]; then
+ if [[ $cur == -F* ]]; then
cur=${cur#-F}
_filedir
# Prefix completions with '-F'
- COMPREPLY=( "${COMPREPLY[@]/#/-F}" )
- cur=-F$cur # Restore cur
- elif [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
+ COMPREPLY=("${COMPREPLY[@]/#/-F}")
+ cur=-F$cur # Restore cur
+ elif [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
else
- _known_hosts_real $ipvx -a -F "$configfile" -- "$cur"
+ _known_hosts_real ${ipvx-} -a ${configfile:+-F "$configfile"} -- "$cur"
fi
} &&
-shopt -u hostcomplete && complete -F _sftp sftp
+ shopt -u hostcomplete && complete -F _sftp sftp
# things we want to backslash escape in scp paths
-_scp_path_esc='[][(){}<>",:;^&!$=?`|\\'"'"'[:space:]]'
+# shellcheck disable=SC2089
+_scp_path_esc='[][(){}<>"'"'"',:;^&!$=?`\\|[:space:]]'
# Complete remote files with ssh. If the first arg is -d, complete on dirs
# only. Returns paths escaped with three backslashes.
+# shellcheck disable=SC2120
_scp_remote_files()
{
local IFS=$'\n'
@@ -409,6 +415,7 @@ _scp_remote_files()
local path=${cur#*:}
# unescape (3 backslashes to 1 for chars we escaped)
+ # shellcheck disable=SC2090
path=$(command sed -e 's/\\\\\\\('$_scp_path_esc'\)/\\\1/g' <<<"$path")
# default to home dir of specified user on remote host
@@ -419,18 +426,20 @@ _scp_remote_files()
local files
if [[ $1 == -d ]]; then
# escape problematic characters; remove non-dirs
+ # shellcheck disable=SC2090
files=$(ssh -o 'Batchmode yes' $userhost \
- command ls -aF1dL "$path*" 2>/dev/null | \
+ command ls -aF1dL "$path*" 2>/dev/null |
command sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e '/[^\/]$/d')
else
# escape problematic characters; remove executables, aliases, pipes
# and sockets; add space at end of file names
+ # shellcheck disable=SC2090
files=$(ssh -o 'Batchmode yes' $userhost \
- command ls -aF1dL "$path*" 2>/dev/null | \
+ command ls -aF1dL "$path*" 2>/dev/null |
command sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e 's/[*@|=]$//g' \
- -e 's/[^\/]$/& /g')
+ -e 's/[^\/]$/& /g')
fi
- COMPREPLY+=( $files )
+ COMPREPLY+=($files)
}
# This approach is used instead of _filedir to get a space appended
@@ -442,18 +451,18 @@ _scp_local_files()
local IFS=$'\n'
local dirsonly=false
- if [[ $1 == -d ]]; then
+ if [[ ${1-} == -d ]]; then
dirsonly=true
shift
fi
- if $dirsonly ; then
- COMPREPLY+=( $(command ls -aF1dL $cur* 2>/dev/null | \
- command sed -e "s/$_scp_path_esc/\\\\&/g" -e '/[^\/]$/d' -e "s/^/$1/") )
+ if $dirsonly; then
+ COMPREPLY+=($(command ls -aF1dL $cur* 2>/dev/null |
+ command sed -e "s/$_scp_path_esc/\\\\&/g" -e '/[^\/]$/d' -e "s/^/${1-}/"))
else
- COMPREPLY+=( $(command ls -aF1dL $cur* 2>/dev/null | \
+ COMPREPLY+=($(command ls -aF1dL $cur* 2>/dev/null |
command sed -e "s/$_scp_path_esc/\\\\&/g" -e 's/[*@|=]$//g' \
- -e 's/[^\/]$/& /g' -e "s/^/$1/") )
+ -e 's/[^\/]$/& /g' -e "s/^/${1-}/"))
fi
}
@@ -468,22 +477,16 @@ _scp()
_ssh_configfile
_ssh_suboption_check && {
- COMPREPLY=( "${COMPREPLY[@]/%/ }" )
+ COMPREPLY=("${COMPREPLY[@]/%/ }")
return
}
local ipvx
case $prev in
- -*4*)
- ipvx=-4
- ;;
- -*6*)
- ipvx=-6
- ;;
-*c)
_ssh_ciphers
- COMPREPLY=( "${COMPREPLY[@]/%/ }" )
+ COMPREPLY=("${COMPREPLY[@]/%/ }")
return
;;
-*F)
@@ -497,7 +500,7 @@ _scp()
return
;;
-*J)
- _known_hosts_real -a -F "$configfile" -- "$cur"
+ _known_hosts_real -a ${configfile:+-F "$configfile"} -- "$cur"
return
;;
-*[lP])
@@ -508,43 +511,53 @@ _scp()
return
;;
-*S)
- _command
- compopt +o nospace
+ compopt +o nospace -o filenames
+ COMPREPLY=($(compgen -c -- "$cur"))
return
;;
+ -*4*)
+ ipvx=-4
+ ;;
+ -*6*)
+ ipvx=-6
+ ;;
esac
_expand || return
case $cur in
- !(*:*)/*|[.~]*) ;; # looks like a path
- *:*) _scp_remote_files ; return ;;
+ !(*:*)/* | [.~]*) ;; # looks like a path
+ *:*)
+ _scp_remote_files
+ return
+ ;;
esac
local prefix
- if [[ "$cur" == -F* ]]; then
+ if [[ $cur == -F* ]]; then
cur=${cur#-F}
prefix=-F
else
case $cur in
-*)
- COMPREPLY=( $(compgen -W '$(_parse_usage "${words[0]}")' \
- -- "$cur") )
- COMPREPLY=( "${COMPREPLY[@]/%/ }" )
+ COMPREPLY=($(compgen -W '$(_parse_usage "${words[0]}")' \
+ -- "$cur"))
+ COMPREPLY=("${COMPREPLY[@]/%/ }")
return
;;
- */*|[.~]*)
+ */* | [.~]*)
# not a known host, pass through
;;
*)
- _known_hosts_real $ipvx -c -a -F "$configfile" -- "$cur"
+ _known_hosts_real ${ipvx-} -c -a \
+ ${configfile:+-F "$configfile"} -- "$cur"
;;
esac
fi
- _scp_local_files "$prefix"
+ _scp_local_files "${prefix-}"
} &&
-complete -F _scp -o nospace scp
+ complete -F _scp -o nospace scp
# ex: filetype=sh
diff --git a/completions/ssh-add b/completions/ssh-add
index f35c7d00..d8f74926 100644
--- a/completions/ssh-add
+++ b/completions/ssh-add
@@ -7,7 +7,7 @@ _ssh_add()
case $prev in
-*E)
- COMPREPLY=( $(compgen -W 'md5 sha256' -- "$cur") )
+ COMPREPLY=($(compgen -W 'md5 sha256' -- "$cur"))
return
;;
-*t)
@@ -24,12 +24,12 @@ _ssh_add()
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" "-\?")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" "-\?")' -- "$cur"))
return
fi
_filedir
} &&
-complete -F _ssh_add ssh-add
+ complete -F _ssh_add ssh-add
# ex: filetype=sh
diff --git a/completions/ssh-copy-id b/completions/ssh-copy-id
index ebfc46e6..f6281947 100644
--- a/completions/ssh-copy-id
+++ b/completions/ssh-copy-id
@@ -21,12 +21,12 @@ _ssh_copy_id()
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1" --help)' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1" --help)' -- "$cur"))
else
_known_hosts_real -a -- "$cur"
fi
} &&
-complete -F _ssh_copy_id ssh-copy-id
+ complete -F _ssh_copy_id ssh-copy-id
# ex: filetype=sh
diff --git a/completions/ssh-keygen b/completions/ssh-keygen
index 36fa2cad..0e629a56 100644
--- a/completions/ssh-keygen
+++ b/completions/ssh-keygen
@@ -3,14 +3,30 @@
_ssh_keygen()
{
local cur prev words cword
- _init_completion -n = || return
+ _init_completion -n := || return
case $prev in
- -*[abCIJjMNnrPSVWz])
+ -*[aCIJjMNPSVWz])
+ return
+ ;;
+ -*b)
+ local -a sizes
+ case "${words[*]}" in
+ *" -t dsa"?( *))
+ sizes=(1024)
+ ;;
+ *" -t ecdsa"?( *))
+ sizes=(256 384 521)
+ ;;
+ *" -t rsa"?( *))
+ sizes=(1024 2048 3072 4096)
+ ;;
+ esac
+ COMPREPLY=($(compgen -W '${sizes[@]}' -- "$cur"))
return
;;
-*E)
- COMPREPLY=( $(compgen -W 'md5 sha256' -- "$cur") )
+ COMPREPLY=($(compgen -W 'md5 sha256' -- "$cur"))
return
;;
-*[FR])
@@ -18,7 +34,7 @@ _ssh_keygen()
_known_hosts_real -- "$cur"
return
;;
- -*D)
+ -*[Dw])
_filedir so
return
;;
@@ -27,37 +43,81 @@ _ssh_keygen()
return
;;
-*m)
- COMPREPLY=( $(compgen -W 'PEM PKCS8 RFC4716' -- "$cur") )
+ COMPREPLY=($(compgen -W 'PEM PKCS8 RFC4716' -- "$cur"))
+ return
+ ;;
+ -*n)
+ [[ ${words[*]} != *\ -*Y\ * ]] || return
+ local prefix=
+ [[ $cur == *,* ]] && prefix="${cur%,*},"
+ if [[ ${words[*]} == *\ -*h\ * ]]; then
+ _known_hosts_real -- "${cur##*,}"
+ else
+ COMPREPLY=($(compgen -u -- "${cur##*,}"))
+ fi
+ ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
return
;;
-*O)
if [[ $cur != *=* ]]; then
- COMPREPLY=( $(compgen -W 'clear force-command=
+ COMPREPLY=($(compgen -W '
+ clear critical: extension: force-command=
no-agent-forwarding no-port-forwarding no-pty no-user-rc
no-x11-forwarding permit-agent-forwarding
permit-port-forwarding permit-pty permit-user-rc
- permit-x11-forwarding source-address=' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ permit-X11-forwarding no-touch-required source-address=
+
+ lines= start-line= checkpoint= memory= start= generator=
+
+ application challenge= device resident user
+ write-attestation-path
+ ' -- "$cur"))
+ [[ ${COMPREPLY-} == *[:=] ]] && compopt -o nospace
+ __ltrim_colon_completions "$cur"
+ else
+ case $cur in
+ force-command=*)
+ compopt -o filenames
+ COMPREPLY=($(compgen -c -- "${cur#*=}"))
+ ;;
+ checkpoint=* | challenge=*)
+ cur=${cur#*=}
+ _filedir
+ ;;
+ esac
fi
return
;;
+ -*r)
+ [[ ${words[*]} != *\ -*Y\ * ]] || _filedir
+ return
+ ;;
-*t)
local protocols=$(_xfunc ssh _ssh_query "$1" protocol-version)
- local types='dsa ecdsa ed25519 rsa'
+ local types='dsa ecdsa ecdsa-sk ed25519 ed25519-sk rsa'
if [[ $protocols == *1* ]]; then
types+=' rsa1'
fi
- COMPREPLY=( $(compgen -W "$types" -- "$cur") )
+ COMPREPLY=($(compgen -W "$types" -- "$cur"))
+ return
+ ;;
+ -*Y)
+ COMPREPLY=($(compgen -W 'find-principals check-novalidate sign
+ verify' -- "$cur"))
return
;;
esac
if [[ $cur == -* ]]; then
local opts=$(_parse_usage "$1" "-?")
- [[ -z "$opts" ]] && opts=$(_parse_help "$1" "-?") # OpenSSH < 7
- COMPREPLY=( $(compgen -W "$opts" -- "$cur") )
+ [[ -z $opts ]] && opts=$(_parse_help "$1" "-?") # OpenSSH < 7
+ COMPREPLY=($(compgen -W "$opts" -- "$cur"))
+ fi
+
+ if [[ ${words[*]} == *\ -*s\ * ]]; then
+ _filedir pub
fi
} &&
-complete -F _ssh_keygen ssh-keygen
+ complete -F _ssh_keygen ssh-keygen
# ex: filetype=sh
diff --git a/completions/sshfs b/completions/sshfs
index 4afcc994..223d029b 100644
--- a/completions/sshfs
+++ b/completions/sshfs
@@ -5,21 +5,19 @@ _sshfs()
local cur prev words cword
_init_completion -n : || return
- local userhost path
-
_expand || return
- if [[ "$cur" == *:* ]]; then
+ if [[ $cur == *:* ]]; then
_xfunc ssh _scp_remote_files -d
# unlike scp and rsync, sshfs works with 1 backslash instead of 3
- COMPREPLY=( "${COMPREPLY[@]//\\\\\\/\\}" )
+ COMPREPLY=("${COMPREPLY[@]//\\\\\\/\\}")
return
fi
- [[ "$cur" == @(*/|[.~])* ]] || _known_hosts_real -c -a -- "$cur"
+ [[ $cur == @(*/|[.~])* ]] || _known_hosts_real -c -a -- "$cur"
_xfunc ssh _scp_local_files -d
} &&
-complete -F _sshfs -o nospace sshfs
+ complete -F _sshfs -o nospace sshfs
# ex: filetype=sh
diff --git a/completions/sshmitm b/completions/sshmitm
index 8b320fa8..ee893e59 100644
--- a/completions/sshmitm
+++ b/completions/sshmitm
@@ -5,13 +5,13 @@ _sshmitm()
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"))
else
_known_hosts_real -- "$cur"
fi
} &&
-complete -F _sshmitm sshmitm
+ complete -F _sshmitm sshmitm
# ex: filetype=sh
diff --git a/completions/sshow b/completions/sshow
index e9ea9c2d..917444ea 100644
--- a/completions/sshow
+++ b/completions/sshow
@@ -16,11 +16,11 @@ _sshow()
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
fi
} &&
-complete -F _sshow sshow
+ complete -F _sshow sshow
# ex: filetype=sh
diff --git a/completions/strace b/completions/strace
index 339780b6..2b46ce8e 100644
--- a/completions/strace
+++ b/completions/strace
@@ -7,10 +7,10 @@ _strace()
# check if we're still completing strace
local offset=0 i
- for (( i=1; i <= cword; i++ )); do
- case ${words[$i]} in
- -o|-e|-p)
- (( i++ ))
+ for ((i = 1; i <= cword; i++)); do
+ case ${words[i]} in
+ -o | -e | -p)
+ ((i++))
continue
;;
-*)
@@ -21,13 +21,13 @@ _strace()
break
done
- if [[ $offset -gt 0 ]]; then
+ if ((offset > 0)); then
_command_offset $offset
else
case $prev in
-*e)
- if [[ "$cur" == *=* ]]; then
+ if [[ $cur == *=* ]]; then
prev=${cur/=*/}
cur=${cur/*=/}
@@ -39,33 +39,33 @@ _strace()
local -A syscalls
while read -r define syscall rest; do
[[ $define == "#define" && \
- $syscall =~ ^__NR_(.+) ]] && \
+ $syscall =~ ^__NR_(.+) ]] &&
syscalls[${BASH_REMATCH[1]}]=1
done 2>/dev/null </usr/include/asm/unistd.h
if [[ ! $syscalls ]]; then
local unistd arch=$(command uname -m)
- if [[ "$arch" == *86 ]]; then
+ if [[ $arch == *86 ]]; then
unistd=/usr/include/asm/unistd_32.h
else
unistd=/usr/include/asm/unistd_64.h
fi
while read -r define syscall rest; do
[[ $define == "#define" && \
- $syscall =~ ^__NR_(.+) ]] && \
+ $syscall =~ ^__NR_(.+) ]] &&
syscalls[${BASH_REMATCH[1]}]=1
done 2>/dev/null <$unistd
fi
- COMPREPLY=( $(compgen -W '${!syscalls[@]} file
+ COMPREPLY=($(compgen -W '${!syscalls[@]} file
process network signal ipc desc all none' \
- -- "$cur") )
+ -- "$cur"))
return
;;
esac
else
compopt -o nospace
- COMPREPLY=( $(compgen -S"=" -W 'trace abbrev verbose raw
- signal read write' -- "$cur") )
+ COMPREPLY=($(compgen -S"=" -W 'trace abbrev verbose raw
+ signal read write' -- "$cur"))
fi
return
;;
@@ -78,7 +78,7 @@ _strace()
return
;;
-*S)
- COMPREPLY=( $(compgen -W 'time calls name nothing' -- "$cur") )
+ COMPREPLY=($(compgen -W 'time calls name nothing' -- "$cur"))
return
;;
-*u)
@@ -87,13 +87,13 @@ _strace()
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
else
- COMPREPLY=( $(compgen -c -- "$cur") )
+ COMPREPLY=($(compgen -c -- "$cur"))
fi
fi
} &&
-complete -F _strace -o default strace
+ complete -F _strace -o default strace
# ex: filetype=sh
diff --git a/completions/strings b/completions/strings
index b4e13ab6..059f5571 100644
--- a/completions/strings
+++ b/completions/strings
@@ -6,21 +6,21 @@ _strings()
_init_completion -s || return
case $prev in
- --help|--version|--bytes|-!(-*)[hvVn])
+ --help | --version | --bytes | -!(-*)[hvVn])
return
;;
- --radix|-!(-*)t)
- COMPREPLY=( $(compgen -W 'o d x' -- "$cur") )
+ --radix | -!(-*)t)
+ COMPREPLY=($(compgen -W 'o d x' -- "$cur"))
return
;;
- --target|-!(-*)T)
- COMPREPLY=( $(compgen -W '$(LC_ALL=C "$1" --help 2>/dev/null | \
+ --target | -!(-*)T)
+ COMPREPLY=($(compgen -W '$(LC_ALL=C "$1" --help 2>/dev/null | \
command sed -ne "s/: supported targets: \(.*\)/\1/p")' \
- -- "$cur") )
+ -- "$cur"))
return
;;
- --encoding|-!(-*)e)
- COMPREPLY=( $(compgen -W 's S b l B L' -- "$cur") )
+ --encoding | -!(-*)e)
+ COMPREPLY=($(compgen -W 's S b l B L' -- "$cur"))
return
;;
esac
@@ -28,18 +28,18 @@ _strings()
$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
elif [[ $cur == @* ]]; then
cur=${cur:1}
_filedir
- COMPREPLY=( "${COMPREPLY[@]/#/@}" )
+ COMPREPLY=("${COMPREPLY[@]/#/@}")
return
fi
_filedir
} &&
-complete -F _strings strings
+ complete -F _strings strings
# ex: filetype=sh
diff --git a/completions/sudo b/completions/sudo
index 1b8e508f..c9a806ba 100644
--- a/completions/sudo
+++ b/completions/sudo
@@ -9,48 +9,48 @@ _sudo()
[[ $1 == *sudoedit ]] && mode=edit
[[ $mode == normal ]] &&
- for (( i=1; i <= cword; i++ )); do
- if [[ ${words[i]} != -* ]]; then
- local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
- local root_command=${words[i]}
- _command_offset $i
- return
- fi
- if [[ ${words[i]} == -@(!(-*)e*|-edit) ]]; then
- mode=edit
- break
- fi
- [[ ${words[i]} == \
- -@(user|other-user|group|close-from|prompt|!(-*)[uUgCp]) ]] \
- && ((i++))
- done
+ for ((i = 1; i <= cword; i++)); do
+ if [[ ${words[i]} != -* ]]; then
+ local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
+ local root_command=${words[i]}
+ _command_offset $i
+ return
+ fi
+ if [[ ${words[i]} == -@(!(-*)e*|-edit) ]]; then
+ mode=edit
+ break
+ fi
+ [[ ${words[i]} == \
+ -@(user|other-user|group|close-from|prompt|!(-*)[uUgCp]) ]] &&
+ ((i++))
+ done
case "$prev" in
- --user|--other-user|-!(-*)[uU])
- COMPREPLY=( $(compgen -u -- "$cur") )
+ --user | --other-user | -!(-*)[uU])
+ COMPREPLY=($(compgen -u -- "$cur"))
return
;;
- --group|-!(-*)g)
- COMPREPLY=( $(compgen -g -- "$cur") )
+ --group | -!(-*)g)
+ COMPREPLY=($(compgen -g -- "$cur"))
return
;;
- --close-from|--prompt|-!(-*)[Cp])
+ --close-from | --prompt | -!(-*)[Cp])
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
if [[ $mode == edit ]]; then
_filedir
fi
} &&
-complete -F _sudo sudo sudoedit
+ complete -F _sudo sudo sudoedit
# ex: filetype=sh
diff --git a/completions/svcadm b/completions/svcadm
index f23af1ff..5269c7be 100644
--- a/completions/svcadm
+++ b/completions/svcadm
@@ -20,14 +20,14 @@
# began to type svc:. In that case we will propose only the complete FMRI beginning with the
# pattern
#
-_smf_complete_fmri ()
+_smf_complete_fmri()
{
local cur="$1" prefix="$2"
local cur_prefix fmri fmri_list=""
local exact_mode pattern
- if [[ "$cur" == $prefix* ]]; then
- [[ "$cur" == $prefix ]] && cur+="/"
+ if [[ $cur == $prefix* ]]; then
+ [[ $cur == "$prefix" ]] && cur+="/"
pattern="$cur*"
exact_mode=1
else
@@ -38,18 +38,21 @@ _smf_complete_fmri ()
for fmri in $(svcs -H -o FMRI "$pattern" 2>/dev/null); do
local fmri_part_list fmri_part
- if [[ -z "$exact_mode" ]]; then
+ if [[ -z $exact_mode ]]; then
fmri=${fmri#$prefix/}
# we generate all possibles abbrevations for the FMRI
# no need to have a generic loop as we will have a finite
# number of components
- local OIFS="$IFS"; IFS="/"; set -- $fmri; IFS="$OIFS"
+ local ifs="$IFS"
+ IFS="/"
+ set -- $fmri
+ IFS=$ifs
case $# in
- 1) fmri_part_list=" $1";;
- 2) fmri_part_list=" $2 $1/$2";;
- 3) fmri_part_list=" $3 $2/$3 $1/$2/$3";;
- 4) fmri_part_list=" $4 $3/$4 $2/$3/$4 $1/$2/$3/$4";;
+ 1) fmri_part_list=" $1" ;;
+ 2) fmri_part_list=" $2 $1/$2" ;;
+ 3) fmri_part_list=" $3 $2/$3 $1/$2/$3" ;;
+ 4) fmri_part_list=" $4 $3/$4 $2/$3/$4 $1/$2/$3/$4" ;;
esac
else
fmri_part_list="$fmri"
@@ -58,28 +61,28 @@ _smf_complete_fmri ()
# Here we make sure the completions begins with the pattern and
# we cut them at the first slash
for fmri_part in $fmri_part_list; do
- [[ "$fmri_part" == $cur* ]] || continue
+ [[ $fmri_part == $cur* ]] || continue
local first_part=${fmri_part#$cur_prefix}
first_part=$cur_prefix${first_part%%/*}
- [[ "$first_part" != "$fmri_part" ]] && first_part+="/"
+ [[ $first_part != "$fmri_part" ]] && first_part+="/"
fmri_list+=" $first_part"
done
done
- COMPREPLY=( $fmri_list )
+ COMPREPLY=($fmri_list)
# here we want to detect if there only one completion proposed and that
# it ends with a slash. That means the users will still have to complete
# after, so we gain him one tab keystroke by immediately proposing the
# next completion alternatives
local i=${#COMPREPLY[*]}
- if [[ $i -gt 0 ]] && [[ "${COMPREPLY[$((--i))]}" == */ ]]; then
+ if [[ $i -gt 0 && ${COMPREPLY[--i]} == */ ]]; then
# we have to iterate through the list as we may have duplicate
- while [[ $i -ne 0 ]]; do
- [[ "${COMPREPLY[$i]}" != "${COMPREPLY[$((i - 1))]}" ]] && break
+ while ((i != 0)); do
+ [[ ${COMPREPLY[i]} != "${COMPREPLY[i - 1]}" ]] && break
((i--))
done
- if [[ $i -eq 0 ]]; then
+ if ((i == 0)); then
_smf_complete_fmri "${COMPREPLY[0]}" "$prefix"
return
fi
@@ -90,12 +93,12 @@ _smf_complete_fmri ()
# it from darcs completion code :)
local colonprefixes=${cur%"${cur##*:}"}
local i=${#COMPREPLY[*]}
- while [ $((--i)) -ge 0 ]; do
- COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"}
+ while ((i-- > 0)); do
+ COMPREPLY[i]=${COMPREPLY[i]#"$colonprefixes"}
done
}
-_svcadm ()
+_svcadm()
{
local cur prev words cword
_init_completion -n : || return
@@ -103,34 +106,38 @@ _svcadm ()
local command_list="enable disable restart refresh clear mark milestone"
local command i
- for (( i=1; i < $cword; i++ )); do
+ for ((i = 1; i < cword; i++)); do
if [[ ${words[i]} == @(enable|disable|restart|refresh|clear|mark|milestone) ]]; then
command=${words[i]}
fi
done
- if [[ -z "$command" ]]; then
- if [[ ${cur} == -* ]] ; then
- COMPREPLY=( $(compgen -W "-v" -- ${cur}) )
+ if [[ ! -v command ]]; then
+ if [[ ${cur} == -* ]]; then
+ COMPREPLY=($(compgen -W "-v" -- ${cur}))
else
- COMPREPLY=( $(compgen -W "$command_list" -- ${cur}) )
+ COMPREPLY=($(compgen -W "$command_list" -- ${cur}))
fi
else
if [[ ${cur} == -* ]]; then
case "$command" in
enable)
- COMPREPLY=( $(compgen -W "-r -s -t" -- ${cur}) );;
+ COMPREPLY=($(compgen -W "-r -s -t" -- ${cur}))
+ ;;
disable)
- COMPREPLY=( $(compgen -W "-s -t" -- ${cur}) );;
+ COMPREPLY=($(compgen -W "-s -t" -- ${cur}))
+ ;;
mark)
- COMPREPLY=( $(compgen -W "-I -t" -- ${cur}) );;
+ COMPREPLY=($(compgen -W "-I -t" -- ${cur}))
+ ;;
milestone)
- COMPREPLY=( $(compgen -W "-d" -- ${cur}) );;
+ COMPREPLY=($(compgen -W "-d" -- ${cur}))
+ ;;
esac
else
- if [[ "$command" == "mark" ]] && [[ "$prev" != @(degraded|maintenance) ]]; then
- COMPREPLY=( $(compgen -W "degraded maintenance" -- ${cur}) )
- elif [[ "$command" == "milestone" ]]; then
+ if [[ $command == "mark" ]] && [[ $prev != @(degraded|maintenance) ]]; then
+ COMPREPLY=($(compgen -W "degraded maintenance" -- ${cur}))
+ elif [[ $command == "milestone" ]]; then
_smf_complete_fmri "${cur}" "svc:/milestone"
else
_smf_complete_fmri "${cur}" "svc:"
@@ -138,6 +145,6 @@ _svcadm ()
fi
fi
} &&
-complete -F _svcadm svcadm
+ complete -F _svcadm svcadm
# ex: filetype=sh
diff --git a/completions/svk b/completions/svk
index f94356e1..9079df1c 100644
--- a/completions/svk
+++ b/completions/svk
@@ -14,15 +14,15 @@ _svk()
propget pg pget proplist pl plist propset ps pset pull push resolved
revert smerge sm status st stat switch sw sync sy update up 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
- -F|--file|--targets)
+ -F | --file | --targets)
_filedir
return
;;
@@ -34,50 +34,50 @@ _svk()
command=${words[1]}
- if [[ "$cur" == -* ]]; then
+ if [[ $cur == -* ]]; then
# possible options for the command
case $command in
add)
options=' --non-recursive -N -q --quiet'
;;
- blame|annotate|ann|praise)
+ blame | annotate | ann | praise)
options='-r --revisions -x --cross'
;;
cat)
options='-r --revision'
;;
- checkout|co)
+ checkout | co)
options='-r --revision -q --quiet -N --non-recursive -l
--list -d --detach --export --relocate --purge'
;;
cleanup)
options='-a --all'
;;
- cmerge|cm)
+ cmerge | cm)
options='-c --change -l --log -r --revision -a --auto
--verbatim --no-ticket -m --message -F --file
--template --encoding -P --patch -S --sign -C
--check-only --direct'
;;
- commit|ci)
+ commit | ci)
options='--import -m --message -F --file --encoding
--template -P --patch -S --sign -C --check-only -N
--non-recursive --direct'
;;
- copy|cp)
+ copy | cp)
options='-r --revision -p --parent -q --quiet -m --message
-F --file --template --encoding -P --patch -S --sign -C
--check-only --direct'
;;
- delete|del|remove|rm)
+ delete | del | remove | rm)
options='-k --keep-local -m --message -F --file --encoding
--template -P --patch -S --sign -C --check-only
--direct'
;;
- depotmap|depot)
+ depotmap | depot)
options='-i --init -l --list -d --detach --relocate'
;;
- diff|di)
+ diff | di)
options='-r --revision -s --summarize -b --verbose -N
--non-recursive'
;;
@@ -86,7 +86,7 @@ _svk()
-F --file --template --encoding -P --patch -S --sign -C
--check-only -N --non-recursive --direct'
;;
- list|ls)
+ list | ls)
options='-r --revision -v --verbose -R --recursive -d
--depth -f --full-path'
;;
@@ -101,7 +101,7 @@ _svk()
--template --encoding -P --patch -S --sign -C
--check-only --direct'
;;
- mirror|mi)
+ mirror | mi)
options='-l --list -d --detach --relocate --recover
--unlock --upgrade'
;;
@@ -110,7 +110,7 @@ _svk()
--encoding -P --patch -S --sign -C --check-only
--direct'
;;
- move|mv|rename|ren)
+ move | mv | rename | ren)
options='-r --revision -p --parent -q --quiet -m --message
-F --file --encoding --template -P --patch -S --sign -C
--check-only --direct'
@@ -118,20 +118,20 @@ _svk()
patch)
options='--depot'
;;
- propdel|propset|pdel|pset|pd|ps)
+ propdel | propset | pdel | pset | pd | ps)
options='-R --recursive -r --revision --revprop -m
--message -F --file --template --encoding -P --patch -S
--sign -C --check-only -q --quiet --direct'
;;
- propedit|pedit|pe)
+ propedit | pedit | pe)
options='-R --recursive -r --revision --revprop -m
--message -F --file --template --encoding -P --patch
-S --sign -C --check-only --direct'
;;
- propget|pget|pg)
+ propget | pget | pg)
options='-R --recursive -r --revision --revprop --strict'
;;
- proplist|plist|pl)
+ proplist | plist | pl)
options='-R --recursive -v --verbose -r --revision
--revprop'
;;
@@ -148,59 +148,59 @@ _svk()
revert)
options='-R --recursive -q --quiet'
;;
- smerge|sm)
+ smerge | sm)
options='-I --incremental -l --log -B --baseless -b --base
-s --sync -t --to -f --from --verbatim --no-ticket
--track-rename --host --remoterev -m --message -F
--file --template --encoding -P --patch -S --sign -C
--check-only --direct'
;;
- status|stat|st)
+ status | stat | st)
options='-q --quiet --no-ignore -N --non-recursive -v
--verbose'
;;
- switch|sw)
+ switch | sw)
options='-r --revision -d --detach -q --quiet'
;;
- sync|sy)
+ sync | sy)
options='-a --all -s --skipto -t --torev'
;;
- update|up)
+ update | up)
options='-r --revision -N --non-recursive -C --check-only
-s --sync -m --merge -q --quiet'
;;
esac
options+=" --help -h"
- COMPREPLY=( $(compgen -W "$options" -- "$cur") )
+ COMPREPLY=($(compgen -W "$options" -- "$cur"))
else
case $command in
- help|h|\?)
- COMPREPLY=( $(compgen -W "$commands environment commands
- intro" -- "$cur") )
+ help | h | \?)
+ COMPREPLY=($(compgen -W "$commands environment commands
+ intro" -- "$cur"))
;;
admin)
- COMPREPLY=( $(compgen -W 'help deltify dump hotcopy
+ COMPREPLY=($(compgen -W 'help deltify dump hotcopy
list-dblogs list-unused-dblogs load lstxns recover
- rmtxns setlog verify rmcache' -- "$cur") )
+ rmtxns setlog verify rmcache' -- "$cur"))
;;
patch)
- COMPREPLY=( $(compgen -W '--ls --list --cat --view
+ COMPREPLY=($(compgen -W '--ls --list --cat --view
--regen --regenerate --up --update --apply --rm
- --delete' -- "$cur") )
+ --delete' -- "$cur"))
;;
sync)
- COMPREPLY=( $(compgen -W "$($1 mirror --list \
- 2>/dev/null | awk '/^\//{print $1}')" -- "$cur") )
+ COMPREPLY=($(compgen -W "$($1 mirror --list \
+ 2>/dev/null | awk '/^\//{print $1}')" -- "$cur"))
;;
- co|checkout|push|pull)
- if [[ "$cur" == //*/* ]]; then
+ co | checkout | push | pull)
+ if [[ $cur == //*/* ]]; then
path=${cur%/*}/
else
path=//
fi
- COMPREPLY=( $(compgen -W "$($1 list $path 2>/dev/null | \
- command sed -e 's|\(.*\)|'$path'\1|')" -- "$cur") )
+ COMPREPLY=($(compgen -W "$($1 list $path 2>/dev/null |
+ command sed -e 's|\(.*\)|'$path'\1|')" -- "$cur"))
;;
*)
_filedir
@@ -209,6 +209,6 @@ _svk()
fi
fi
} &&
-complete -F _svk svk
+ complete -F _svk svk
# ex: filetype=sh
diff --git a/completions/sync_members b/completions/sync_members
index 653c0ea9..397f8b08 100644
--- a/completions/sync_members
+++ b/completions/sync_members
@@ -6,11 +6,11 @@ _sync_members()
_init_completion -s || return
case $prev in
- -w|-g|-d|--welcome-msg|--goodbye-msg|--digest)
- COMPREPLY=( $(compgen -W 'y n' -- "$cur") )
+ -w | -g | -d | --welcome-msg | --goodbye-msg | --digest)
+ COMPREPLY=($(compgen -W 'y n' -- "$cur"))
return
;;
- -d|--file)
+ --file)
_filedir
return
;;
@@ -18,14 +18,14 @@ _sync_members()
$split && return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '--no-change --welcome-msg --goodbye-msg
- --digest --notifyadmin --file --help' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '--no-change --welcome-msg --goodbye-msg
+ --digest --notifyadmin --file --help' -- "$cur"))
else
_xfunc list_lists _mailman_lists
fi
} &&
-complete -F _sync_members sync_members
+ complete -F _sync_members sync_members
# ex: filetype=sh
diff --git a/completions/synclient b/completions/synclient
index e7371cb7..c4a0d42f 100644
--- a/completions/synclient
+++ b/completions/synclient
@@ -6,19 +6,19 @@ _synclient()
_init_completion -n = || return
case $prev in
- -\?|-h|-V)
+ -\? | -h | -V)
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
elif [[ $cur != *=?* ]]; then
- COMPREPLY=( $(compgen -S = -W '$($1 -l 2>/dev/null | \
- awk "/^[ \t]/ { print \$1 }")' -- "$cur") )
+ COMPREPLY=($(compgen -S = -W '$($1 -l 2>/dev/null | \
+ awk "/^[ \t]/ { print \$1 }")' -- "$cur"))
compopt -o nospace
fi
} &&
-complete -F _synclient synclient
+ complete -F _synclient synclient
# ex: filetype=sh
diff --git a/completions/sysbench b/completions/sysbench
index fc942048..0af7cc33 100644
--- a/completions/sysbench
+++ b/completions/sysbench
@@ -6,84 +6,84 @@ _sysbench()
_init_completion -s || return
case $prev in
- --num-threads|--max-requests|--max-time|--thread-stack-size| \
- --help|--version|help|version)
+ --num-threads | --max-requests | --max-time | --thread-stack-size | \
+ --help | --version | help | version)
return
;;
- --init-rng|--debug|--validate)
- COMPREPLY=( $(compgen -W 'on off' -- "$cur") )
+ --init-rng | --debug | --validate)
+ COMPREPLY=($(compgen -W 'on off' -- "$cur"))
return
;;
--test)
- COMPREPLY=( $(compgen -W 'fileio cpu memory threads mutex oltp' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W 'fileio cpu memory threads mutex oltp' \
+ -- "$cur"))
return
;;
--cpu-max-prime)
return
;;
--file-test-mode)
- COMPREPLY=( $(compgen -W 'seqwr seqrewr seqrd rndrd rndwr rndrw' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W 'seqwr seqrewr seqrd rndrd rndwr rndrw' \
+ -- "$cur"))
return
;;
--file-io-mode)
- COMPREPLY=( $(compgen -W 'sync async fastmmap slowmmap' -- "$cur") )
+ COMPREPLY=($(compgen -W 'sync async fastmmap slowmmap' -- "$cur"))
return
;;
--file-extra-flags)
- COMPREPLY=( $(compgen -W 'sync dsync direct' -- "$cur") )
+ COMPREPLY=($(compgen -W 'sync dsync direct' -- "$cur"))
return
;;
- --file-fsync-all|--file-fsync-end)
- COMPREPLY=( $(compgen -W 'on off' -- "$cur") )
+ --file-fsync-all | --file-fsync-end)
+ COMPREPLY=($(compgen -W 'on off' -- "$cur"))
return
;;
--file-fsync-mode)
- COMPREPLY=( $(compgen -W 'fsync fdatasync' -- "$cur") )
+ COMPREPLY=($(compgen -W 'fsync fdatasync' -- "$cur"))
return
;;
--memory-scope)
- COMPREPLY=( $(compgen -W 'global local' -- "$cur") )
+ COMPREPLY=($(compgen -W 'global local' -- "$cur"))
return
;;
--memory-hugetlb)
- COMPREPLY=( $(compgen -W 'on off' -- "$cur") )
+ COMPREPLY=($(compgen -W 'on off' -- "$cur"))
return
;;
--memory-oper)
- COMPREPLY=( $(compgen -W 'read write none' -- "$cur") )
+ COMPREPLY=($(compgen -W 'read write none' -- "$cur"))
return
;;
--memory-access-mode)
- COMPREPLY=( $(compgen -W 'seq rnd' -- "$cur") )
+ COMPREPLY=($(compgen -W 'seq rnd' -- "$cur"))
return
;;
--oltp-test-mode)
- COMPREPLY=( $(compgen -W 'simple complex nontrx sp' -- "$cur") )
+ COMPREPLY=($(compgen -W 'simple complex nontrx sp' -- "$cur"))
return
;;
- --oltp-read-only|--oltp-skip-trx|--oltp-quto-inc|--mysql-ssl)
- COMPREPLY=( $(compgen -W 'on off' -- "$cur") )
+ --oltp-read-only | --oltp-skip-trx | --oltp-quto-inc | --mysql-ssl)
+ COMPREPLY=($(compgen -W 'on off' -- "$cur"))
return
;;
--oltp-nontrx-mode)
- COMPREPLY=( $(compgen -W 'select update_key update_nokey insert
- delete' -- "$cur") )
+ COMPREPLY=($(compgen -W 'select update_key update_nokey insert
+ delete' -- "$cur"))
return
;;
--oltp-dist-type)
- COMPREPLY=( $(compgen -W 'uniform gaussian special' -- "$cur") )
+ COMPREPLY=($(compgen -W 'uniform gaussian special' -- "$cur"))
return
;;
--db-driver)
- COMPREPLY=( $(compgen -W "$($1 --test=oltp help 2>/dev/null |
+ COMPREPLY=($(compgen -W "$($1 --test=oltp help 2>/dev/null |
command sed -e '/^.*database drivers:/,/^$/!d' \
- -ne 's/^ *\([^ ]*\) .*/\1/p')" -- "$cur") )
+ -ne 's/^ *\([^ ]*\) .*/\1/p')" -- "$cur"))
return
;;
--db-ps-mode)
- COMPREPLY=( $(compgen -W 'auto disable' -- "$cur") )
+ COMPREPLY=($(compgen -W 'auto disable' -- "$cur"))
return
;;
--mysql-socket)
@@ -91,12 +91,12 @@ _sysbench()
return
;;
--mysql-table-engine)
- COMPREPLY=( $(compgen -W 'myisam innodb bdb heap ndbcluster
- federated' -- "$cur") )
+ COMPREPLY=($(compgen -W 'myisam innodb bdb heap ndbcluster
+ federated' -- "$cur"))
return
;;
--mysql-engine-trx)
- COMPREPLY=( $(compgen -W 'yes no auto' -- "$cur") )
+ COMPREPLY=($(compgen -W 'yes no auto' -- "$cur"))
return
;;
--*)
@@ -106,7 +106,8 @@ _sysbench()
# find out which test we're running
local i test
- for (( i=1 ; $i < ${#words[@]}-1 ; i++ )); do
+ for ((i = 1; i < ${#words[@]} - 1; i++)); do
+ # TODO --test= is deprecated, bare test name preferred
if [[ ${words[i]} == --test* ]]; then
test=${words[i]#*=}
break
@@ -114,18 +115,18 @@ _sysbench()
done
local opts=$(_parse_help "$1")
- if [[ $test ]]; then
- local help=( $(_parse_help "$1" "--test=$test help") )
- opts="${opts[@]/--test=/} ${help[@]} prepare run cleanup help version"
+ if [[ -v test ]]; then
+ local help=($(_parse_help "$1" "--test=$test help"))
+ opts="${opts/--test=/} ${help[*]} prepare run cleanup help version"
fi
- if [[ "$cur" == -* || ! $test ]]; then
- COMPREPLY=( $(compgen -W "$opts" -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ if [[ $cur == -* || ! -v test ]]; then
+ COMPREPLY=($(compgen -W "$opts" -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
- COMPREPLY=( $(compgen -W "prepare run cleanup help version" -- "$cur") )
+ COMPREPLY=($(compgen -W "prepare run cleanup help version" -- "$cur"))
fi
} &&
-complete -F _sysbench sysbench
+ complete -F _sysbench sysbench
# ex: filetype=sh
diff --git a/completions/sysctl b/completions/sysctl
index 6eb3f391..005452da 100644
--- a/completions/sysctl
+++ b/completions/sysctl
@@ -6,10 +6,10 @@ _sysctl()
_init_completion || return
case $prev in
- --help|--version|--pattern|-!(-*)[hVr])
+ --help | --version | --pattern | -!(-*)[hVr])
return
;;
- --load|-!(-*)[pf])
+ --load | -!(-*)[pf])
_filedir conf
return
;;
@@ -17,15 +17,15 @@ _sysctl()
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
local suffix=
[[ $prev == -w ]] && suffix="="
- COMPREPLY=( $(compgen -S "$suffix" -W \
- "$(PATH="$PATH:/sbin" $1 -N -a 2>/dev/null)" -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ COMPREPLY=($(compgen -S "$suffix" -W \
+ "$(PATH="$PATH:/sbin" $1 -N -a 2>/dev/null)" -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
-complete -F _sysctl sysctl
+ complete -F _sysctl sysctl
# ex: filetype=sh
diff --git a/completions/tar b/completions/tar
index fda739c4..04b7fc07 100644
--- a/completions/tar
+++ b/completions/tar
@@ -47,10 +47,11 @@ __gtar_parse_help_opt()
separator=" "
case "$opt" in
- --*)
- ;;
+ --*) ;;
+
-\?)
- return ;;
+ return
+ ;;
-*)
opttype=short
opt=${opt##-}
@@ -76,7 +77,6 @@ __gtar_parse_help_opt()
eval "$optvar=\"\$$optvar$separator\"\"$opt\""
}
-
__gtar_parse_help_line()
{
local i
@@ -84,18 +84,18 @@ __gtar_parse_help_line()
for i in $1; do
case "$i" in
# regular options
- --*|-*)
+ --* | -*)
__gtar_parse_help_opt "$i" "$2"
;;
# end once there is single non-option word
*)
break
+ ;;
esac
done
}
-
__gnu_tar_parse_help()
{
local str line arg
@@ -104,7 +104,7 @@ __gnu_tar_parse_help()
# options on lines beginning with spaces. After that, there is one
# or more options separated by ', ' separator string. We are matching
# like this then: ^<spaces>(<separator>?<option>)+<whatever>$
- if [[ "$line" =~ \
+ if [[ $line =~ \
^[[:blank:]]{1,10}(((,[[:blank:]])?(--?([\]\[a-zA-Z0-9?=-]+))(,[[:space:]])?)+).*$ ]]; then
line=${BASH_REMATCH[1]}
@@ -115,8 +115,8 @@ __gnu_tar_parse_help()
# description in GNU help output mentions arguments. So the $line
# variable may contain e.g. '-X, --XXX[=NAME], -XXX2[=NAME]'.
arg=none
- if [[ "$line" =~ --[A-Za-z0-9-]+(\[?)= ]]; then
- [[ -n "${BASH_REMATCH[1]}" ]] && arg=opt || arg=req
+ if [[ $line =~ --[A-Za-z0-9-]+(\[?)= ]]; then
+ [[ -n ${BASH_REMATCH[1]} ]] && arg=opt || arg=req
fi
__gtar_parse_help_line "$str" "$arg"
@@ -124,14 +124,11 @@ __gnu_tar_parse_help()
done <<<"$(tar --help)"
long_opts="\
- $long_arg_none\
- $long_arg_opt\
- $long_arg_req"
+ $long_arg_none $long_arg_opt $long_arg_req"
short_opts="$short_arg_none$short_arg_opt$short_arg_req"
}
-
# Hack: parse --warning keywords from tar's error output
__gtar_parse_warnings()
{
@@ -143,32 +140,30 @@ __gtar_parse_warnings()
done
}
-
# Helper to obtain last character of string.
__tar_last_char()
{
- echo "${1: $(( ${#1} - 1))}"
+ echo "${1:$((${#1} - 1))}"
}
-
__tar_parse_old_opt()
{
local first_word char
# current word is the first word
- [[ "$cword" -eq 1 && -n "$cur" && "${cur:0:1}" != '-' ]] \
- && old_opt_progress=1
+ [[ $cword -eq 1 && -n $cur && ${cur:0:1} != '-' ]] &&
+ old_opt_progress=1
# check that first argument does not begin with "-"
first_word=${words[1]}
- [[ -n "$first_word" && "${first_word:0:1}" != "-" ]] \
- && old_opt_used=1
+ [[ -n $first_word && ${first_word:0:1} != "-" ]] &&
+ old_opt_used=1
# parse the old option (if present) contents to allow later code expect
# corresponding arguments
- if [[ $old_opt_used -eq 1 ]]; then
+ if ((old_opt_used == 1)); then
char=${first_word:0:1}
- while [[ -n "$char" ]]; do
+ while [[ -n $char ]]; do
if __tar_is_argreq "$char"; then
old_opt_parsed+=("$char")
fi
@@ -178,11 +173,10 @@ __tar_parse_old_opt()
fi
}
-
# Make the analysis of whole command line.
__tar_preparse_cmdline()
{
- local first_arg my_args tmparg i modes="ctxurdA"
+ local first_arg i modes="ctxurdA"
shift # progname
@@ -191,7 +185,7 @@ __tar_preparse_cmdline()
first_arg=1
for i in "$@"; do
case "$i" in
- --delete|--test-label)
+ --delete | --test-label)
tar_mode=${i:2:100}
tar_mode_arg=$i
break
@@ -207,7 +201,7 @@ __tar_preparse_cmdline()
;;
*[$modes]*)
# Only the first arg may be "MODE" without leading dash
- if [[ $first_arg -eq 1 ]]; then
+ if ((first_arg == 1)); then
tar_mode=${i//[^$modes]/}
tar_mode=${tar_mode:0:1}
tar_mode_arg=$i
@@ -218,7 +212,6 @@ __tar_preparse_cmdline()
done
}
-
# Generate completions for -f/--file.
__tar_file_option()
{
@@ -235,7 +228,6 @@ __tar_file_option()
esac
}
-
# Returns truth if option requires argument. No equal sign must be pasted.
# Accepts option in format: 'c', '-c', '--create'
__tar_is_argreq()
@@ -244,29 +236,28 @@ __tar_is_argreq()
opt=$1
case "$opt" in
-[A-Za-z0-9?])
- [[ "$short_arg_req" =~ ${opt##-} ]] && return 0
+ [[ $short_arg_req =~ ${opt##-} ]] && return 0
;;
[A-Za-z0-9?])
- [[ "$short_arg_req" =~ ${opt} ]] && return 0
+ [[ $short_arg_req =~ ${opt} ]] && return 0
;;
--*)
- [[ "$long_arg_req" =~ [[:blank:]]$opt=[[:blank:]] ]] && return 0
+ [[ $long_arg_req =~ [[:blank:]]$opt=[[:blank:]] ]] && return 0
;;
esac
return 1
}
-
# Called only for short parameter
__tar_complete_mode()
{
- local short_modes has_mode rawopt generated \
- allshort_raw_unused allshort_raw \
- filler i
+ local short_modes rawopt generated \
+ allshort_raw_unused allshort_raw \
+ filler i
short_modes="ctx"
- [[ -z "$basic_tar" ]] && short_modes="ctxurdA"
+ [[ ! -v basic_tar ]] && short_modes="ctxurdA"
# Remove prefix when needed
rawopt=${cur#-}
@@ -275,95 +266,92 @@ __tar_complete_mode()
allshort_raw=${short_opts//[- ]/}
# init the 'mode' option if no option is in ${cur}
- if [[ "$tar_mode" == none ]]; then
+ if [[ $tar_mode == none ]]; then
# when user passed something like 'tar cf' do not put the '-' before
filler=
- if [[ -z "$cur" && -z "$basic_tar" ]]; then
+ if [[ -z $cur && ! -v basic_tar ]]; then
filler=-
fi
generated=""
- for (( i=0 ; 1; i++ )); do
- local c="${short_modes:$i:1}"
- [[ -z "$c" ]] && break
+ for ((i = 0; 1; i++)); do
+ local c="${short_modes:i:1}"
+ [[ -z $c ]] && break
generated+=" $filler$cur$c"
done
- COMPREPLY=( $(compgen -W "$generated" ) )
+ COMPREPLY=($(compgen -W "$generated"))
return 0
fi
# The last short option requires argument, like '-cf<TAB>'. Cut the
# completion here to enforce argument processing.
- if [[ "$old_opt_progress" -eq 0 ]] \
- && __tar_is_argreq "$(__tar_last_char "$cur")"; then
- COMPREPLY=( "$cur" ) && return 0
+ if ((old_opt_progress == 0)) &&
+ __tar_is_argreq "$(__tar_last_char "$cur")"; then
+ COMPREPLY=("$cur") && return 0
fi
allshort_raw_unused=${allshort_raw//[$rawopt]/}
- if [[ "$tar_mode" != none ]]; then
- allshort_raw_unused=${allshort_raw_unused//[$short_modes]}
+ if [[ $tar_mode != none ]]; then
+ allshort_raw_unused=${allshort_raw_unused//[$short_modes]/}
fi
generated=
- for (( i=0 ; 1; i++ )); do
- local c="${allshort_raw_unused:$i:1}"
- [[ -z "$c" ]] && break
+ for ((i = 0; 1; i++)); do
+ local c="${allshort_raw_unused:i:1}"
+ [[ -z $c ]] && break
generated+=" $cur$c"
done
- COMPREPLY=( $(compgen -W "$generated") )
+ COMPREPLY=($(compgen -W "$generated"))
return 0
}
-
__gtar_complete_lopts()
{
local rv
- COMPREPLY=( $(compgen -W "$long_opts" -- "$cur") )
+ COMPREPLY=($(compgen -W "$long_opts" -- "$cur"))
rv=$?
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return $rv
}
-
__gtar_complete_sopts()
{
local generated short_mode_opts i c
short_mode_opts="ctxurdA"
generated=${short_opts//[$short_mode_opts]/}
- for (( i=0 ; 1; i++ )); do
- c="${allshort_raw_unused:$i:1}"
- [[ -z "$c" ]] && break
+ for ((i = 0; 1; i++)); do
+ c="${allshort_raw_unused:i:1}"
+ [[ -z $c ]] && break
generated+=" $cur$c"
done
- COMPREPLY=( $(compgen -W "$generated" -- "$cur") )
+ COMPREPLY=($(compgen -W "$generated" -- "$cur"))
}
-
__tar_try_mode()
{
case "$cur" in
--*)
# posix tar does not support long opts
- [[ -n "$basic_tar" ]] && return 0
+ [[ -v basic_tar ]] && return 0
__gtar_complete_lopts
return $?
;;
-*)
# posix tar does not support short optios
- [[ -n "$basic_tar" ]] && return 0
+ [[ -v basic_tar ]] && return 0
__tar_complete_mode && return 0
;;
*)
- if [[ "$cword" -eq 1 || "$tar_mode" == none ]]; then
+ if [[ $cword -eq 1 || $tar_mode == none ]]; then
__tar_complete_mode && return 0
fi
;;
@@ -371,31 +359,27 @@ __tar_try_mode()
return 1
}
-
__tar_adjust_PREV_from_old_option()
{
# deal with old style arguments here
# $ tar cfTC # expects this sequence of arguments:
# $ tar cfTC ARCHIVE_FILE PATTERNS_FILE CHANGE_DIR
- if [[ "$old_opt_used" -eq 1 && "$cword" -gt 1 \
- && "$cword" -lt $(( ${#old_opt_parsed[@]} + 2 )) ]];
- then
+ if ((old_opt_used == 1 && cword > 1 && \
+ cword < ${#old_opt_parsed[@]} + 2)); then
# make e.g. 'C' option from 'cffCT'
- prev="-${old_opt_parsed[ $cword - 2 ]}"
+ prev="-${old_opt_parsed[cword - 2]}"
fi
}
-
__tar_extract_like_mode()
{
local i
for i in x d t delete; do
- [[ "$tar_mode" == "$i" ]] && return 0
+ [[ $tar_mode == "$i" ]] && return 0
done
return 1
}
-
__tar_try_list_archive()
{
local tarball tarbin untar i
@@ -416,13 +400,13 @@ __tar_try_list_archive()
break
fi
done
- if [[ -n "$tarball" ]]; then
+ if [[ -n $tarball ]]; then
local IFS=$'\n'
COMPREPLY=($(compgen -o filenames -W "$(
$tarbin $untar "$tarball" 2>/dev/null |
- while read line; do
- printf "%q\n" "$(printf %q"\n" "$line")"
- done
+ while read line; do
+ printf "%q\n" "$(printf %q"\n" "$line")"
+ done
)" -- "$(printf "%q\n" "$cur")"))
return 0
fi
@@ -430,7 +414,7 @@ __tar_try_list_archive()
__tar_cleanup_prev()
{
- if [[ "$prev" =~ ^-[a-zA-Z0-9?]*$ ]]; then
+ if [[ $prev =~ ^-[a-zA-Z0-9?]*$ ]]; then
# transform '-caf' ~> '-f'
prev="-$(__tar_last_char "$prev")"
fi
@@ -448,11 +432,11 @@ __tar_detect_ext()
?(-)*[cr]*f)
ext='@(tar|gem|spkg)'
case ${words[1]} in
- *a*) ext="$tars" ;;
- *z*) ext='t?(ar.)gz' ;;
- *Z*) ext='ta@(r.Z|z)' ;;
+ *a*) ext="$tars" ;;
+ *z*) ext='t?(ar.)gz' ;;
+ *Z*) ext='ta@(r.Z|z)' ;;
*[jy]*) ext='t@(?(ar.)bz?(2)|b2)' ;;
- *J*) ext='t?(ar.)xz' ;;
+ *J*) ext='t?(ar.)xz' ;;
esac
;;
+([^ZzJjy])f)
@@ -470,14 +454,13 @@ __tar_detect_ext()
esac
}
-
_gtar()
{
- local long_opts short_opts \
- long_arg_none long_arg_opt long_arg_req \
- short_arg_none short_arg_opt short_arg_req \
- tar_mode tar_mode_arg old_opt_progress=0 \
- old_opt_used=0 old_opt_parsed=()
+ local long_opts short_opts \
+ long_arg_none="" long_arg_opt="" long_arg_req="" \
+ short_arg_none="" short_arg_opt="" short_arg_req="" \
+ tar_mode tar_mode_arg old_opt_progress=0 \
+ old_opt_used=0 old_opt_parsed=()
# Main mode, e.g. -x or -c (extract/creation)
local tar_mode=none
@@ -486,9 +469,9 @@ _gtar()
# FIXME: handle long options
local tar_mode_arg=
- if [[ "$_TAR_OPT_DEBUG" == 1 ]]; then
+ if [[ -v BASHCOMP_TAR_OPT_DEBUG ]]; then
set -x
- PS4="\$BASH_SOURCE:\$LINENO: "
+ PS4='$BASH_SOURCE:$LINENO: '
fi
local cur prev words cword split
@@ -500,7 +483,7 @@ _gtar()
__tar_preparse_cmdline "${words[@]}"
- local ext tar untar
+ local ext
__tar_detect_ext
@@ -513,53 +496,53 @@ _gtar()
# user (TODO: is there any sane way to deal with this?). This case
# statement successes only if there already is PREV.
case $prev in
- --directory|-!(-*)C)
+ --directory | -!(-*)C)
_filedir -d
break
;;
--atime-preserve)
- COMPREPLY=( $(compgen -W 'replace system' -- "$cur") )
+ COMPREPLY=($(compgen -W 'replace system' -- "$cur"))
break
;;
--group)
- COMPREPLY=( $(compgen -g -- "$cur") )
+ COMPREPLY=($(compgen -g -- "$cur"))
break
;;
--owner)
- COMPREPLY=( $(compgen -u -- "$cur") )
+ COMPREPLY=($(compgen -u -- "$cur"))
break
;;
- --info-script|--new-volume-script|--rmt-command|--rsh-command|\
- --use-compress-program|-!(-*)[FI])
+ --info-script | --new-volume-script | --rmt-command | --rsh-command | \
+ --use-compress-program | -!(-*)[FI])
compopt -o filenames
- COMPREPLY=( $(compgen -c -- "$cur") )
+ COMPREPLY=($(compgen -c -- "$cur"))
break
;;
- --volno-file|--add-file|--files-from|--exclude-from|\
- --index-file|--listed-incremental|-!(-*)[TXg])
+ --volno-file | --add-file | --files-from | --exclude-from | \
+ --index-file | --listed-incremental | -!(-*)[TXg])
_filedir
break
;;
- --format|-!(-*)H)
- COMPREPLY=( $(compgen -W 'gnu oldgnu pax posix ustar v7' \
- -- "$cur") )
+ --format | -!(-*)H)
+ COMPREPLY=($(compgen -W 'gnu oldgnu pax posix ustar v7' \
+ -- "$cur"))
break
;;
--quoting-style)
- COMPREPLY=( $(compgen -W 'literal shell shell-always c c-maybe
- escape locale clocale' -- "$cur") )
+ COMPREPLY=($(compgen -W 'literal shell shell-always c c-maybe
+ escape locale clocale' -- "$cur"))
break
;;
--totals)
- COMPREPLY=( $(compgen -W 'SIGHUP SIGQUIT SIGINT SIGUSR1 SIGUSR2' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W 'SIGHUP SIGQUIT SIGINT SIGUSR1 SIGUSR2' \
+ -- "$cur"))
break
;;
--warning)
- COMPREPLY=( $(compgen -W "$(__gtar_parse_warnings)" -- "$cur") )
+ COMPREPLY=($(compgen -W "$(__gtar_parse_warnings)" -- "$cur"))
break
;;
- --file|-!(-*)f)
+ --file | -!(-*)f)
__tar_file_option "$ext"
break
;;
@@ -581,7 +564,7 @@ _gtar()
;;
-!(-*)[a-zA-Z0-9?])
# argument required but no completion yet
- [[ "$short_arg_req" =~ ${prev##-} ]] && break
+ [[ $short_arg_req =~ ${prev##-} ]] && break
;;
esac
@@ -612,7 +595,7 @@ _gtar()
# the first argument must be "mode" argument or --param, if any of those
# was truth - the 'break' statement would have been already called
- [[ "$cword" -eq 1 ]] && break
+ ((cword == 1)) && break
__tar_try_list_archive && break
@@ -624,13 +607,12 @@ _gtar()
break
done # just-for-easy-break while
- if [[ "$_TAR_OPT_DEBUG" == 1 ]]; then
+ if [[ -v BASHCOMP_TAR_OPT_DEBUG ]]; then
set +x
unset PS4
fi
}
-
__tar_posix_prev_handle()
{
case "$prev" in
@@ -640,19 +622,19 @@ __tar_posix_prev_handle()
;;
-b)
return 0
+ ;;
esac
return 1
}
-
_posix_tar()
{
- local long_opts short_opts basic_tar \
- long_arg_none long_arg_opt long_arg_req \
- short_arg_none short_arg_opt short_arg_req \
- tar_mode tar_mode_arg old_opt_progress=0 \
- old_opt_used=1 old_opt_parsed=()
+ local long_opts short_opts basic_tar \
+ long_arg_none="" long_arg_opt long_arg_req="" \
+ short_arg_none short_arg_opt short_arg_req \
+ tar_mode tar_mode_arg old_opt_progress=0 \
+ old_opt_used=1 old_opt_parsed=()
# Main mode, e.g. -x or -c (extract/creation)
local tar_mode=none
@@ -675,7 +657,7 @@ _posix_tar()
__tar_preparse_cmdline "${words[@]}"
- local ext tar untar
+ local ext
__tar_detect_ext
@@ -691,23 +673,22 @@ _posix_tar()
_filedir
}
-
_tar()
{
local cmd=${COMP_WORDS[0]} func line
line="$($cmd --version 2>/dev/null)"
case "$line" in
- *GNU*)
- func=_gtar
- ;;
- *)
- func=_posix_tar
- ;;
+ *GNU*)
+ func=_gtar
+ ;;
+ *)
+ func=_posix_tar
+ ;;
esac
$func "$@"
# Install real completion for subsequent completions
- if [ -n "${COMP_TAR_INTERNAL_PATHS:-}" ]; then
+ if [[ ${COMP_TAR_INTERNAL_PATHS-} ]]; then
complete -F $func -o dirnames tar
else
complete -F $func tar
@@ -715,17 +696,16 @@ _tar()
unset -f _tar
}
-
-if [ -n "${COMP_TAR_INTERNAL_PATHS:-}" ]; then
- complete -F _tar -o dirnames tar
- complete -F _gtar -o dirnames gtar
- complete -F _posix_tar -o dirnames bsdtar
- complete -F _posix_tar -o dirnames star
+if [[ ${COMP_TAR_INTERNAL_PATHS-} ]]; then
+ complete -F _tar -o dirnames tar
+ complete -F _gtar -o dirnames gtar
+ complete -F _posix_tar -o dirnames bsdtar
+ complete -F _posix_tar -o dirnames star
else
- complete -F _tar tar
- complete -F _gtar gtar
- complete -F _posix_tar bsdtar
- complete -F _posix_tar star
+ complete -F _tar tar
+ complete -F _gtar gtar
+ complete -F _posix_tar bsdtar
+ complete -F _posix_tar star
fi
# ex: filetype=sh
diff --git a/completions/tcpdump b/completions/tcpdump
index d93c8795..9a7c2e9c 100644
--- a/completions/tcpdump
+++ b/completions/tcpdump
@@ -10,7 +10,7 @@ _tcpdump()
_filedir
return
;;
- --interface|-!(-*)i)
+ --interface | -!(-*)i)
_available_interfaces -a
return
;;
@@ -19,46 +19,46 @@ _tcpdump()
return
;;
-!(-*)T)
- COMPREPLY=( $(compgen -W 'aodv carp cnfp lmp pgm pgm_zmtp1 radius
+ COMPREPLY=($(compgen -W 'aodv carp cnfp lmp pgm pgm_zmtp1 radius
resp rpc rtcp rtp rtcp snmp tftp vat vxlan wb zmtp1' \
- -- "$cur") )
+ -- "$cur"))
return
;;
-!(-*)z)
compopt -o filenames
- COMPREPLY=( $(compgen -c -- "$cur") )
+ COMPREPLY=($(compgen -c -- "$cur"))
return
;;
- --relinquish-privileges|-!(-*)Z)
+ --relinquish-privileges | -!(-*)Z)
_allowed_users
return
;;
-!(-*)[BcCDEGMsWy])
return
;;
- --time-stamp-type|-!(-*)j)
- COMPREPLY=( $(compgen -W 'host host_lowprec host_hiprec adapter
- adapter_unsynced' -- "$cur") )
+ --time-stamp-type | -!(-*)j)
+ COMPREPLY=($(compgen -W 'host host_lowprec host_hiprec adapter
+ adapter_unsynced' -- "$cur"))
return
;;
- --direction|-!(-*)Q)
- COMPREPLY=( $(compgen -W 'in out inout' -- "$cur") )
+ --direction | -!(-*)Q)
+ COMPREPLY=($(compgen -W 'in out inout' -- "$cur"))
return
;;
--time-stamp-precision)
- COMPREPLY=( $(compgen -W 'micro nano' -- "$cur") )
+ COMPREPLY=($(compgen -W 'micro nano' -- "$cur"))
return
;;
esac
$split && return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
} &&
-complete -F _tcpdump tcpdump
+ complete -F _tcpdump tcpdump
# ex: filetype=sh
diff --git a/completions/tcpkill b/completions/tcpkill
index 200cfc38..189d928e 100644
--- a/completions/tcpkill
+++ b/completions/tcpkill
@@ -12,11 +12,11 @@ _tcpkill()
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '-i -1 -2 -3 -4 -5 -6 -7 -8 -9' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '-i -1 -2 -3 -4 -5 -6 -7 -8 -9' -- "$cur"))
fi
} &&
-complete -F _tcpkill tcpkill
+ complete -F _tcpkill tcpkill
# ex: filetype=sh
diff --git a/completions/tcpnice b/completions/tcpnice
index 0302d46d..c6a94d6b 100644
--- a/completions/tcpnice
+++ b/completions/tcpnice
@@ -12,11 +12,11 @@ _tcpnice()
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
fi
} &&
-complete -F _tcpnice tcpnice
+ complete -F _tcpnice tcpnice
# ex: filetype=sh
diff --git a/completions/timeout b/completions/timeout
index bcc9a865..32ff2e36 100644
--- a/completions/timeout
+++ b/completions/timeout
@@ -5,8 +5,8 @@ _timeout()
local cur prev words cword split i found=false
_init_completion -s || return
- for (( i=1; i <= COMP_CWORD; i++ )); do
- if [[ ${COMP_WORDS[i]} != -* && ${COMP_WORDS[i-1]} != = ]]; then
+ for ((i = 1; i <= COMP_CWORD; i++)); do
+ if [[ ${COMP_WORDS[i]} != -* && ${COMP_WORDS[i - 1]} != = ]]; then
if $found; then
_command_offset $i
return
@@ -17,10 +17,10 @@ _timeout()
done
case $prev in
- --help|--version|--kill-after|-!(-*)k)
+ --help | --version | --kill-after | -!(-*)k)
return
;;
- --signal|-!(-*)s)
+ --signal | -!(-*)s)
_signals
return
;;
@@ -30,10 +30,10 @@ _timeout()
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
fi
} &&
-complete -F _timeout timeout
+ complete -F _timeout timeout
# ex: filetype=sh
diff --git a/completions/tipc b/completions/tipc
index 830040d9..44ade360 100644
--- a/completions/tipc
+++ b/completions/tipc
@@ -1,20 +1,22 @@
# tipc(8) completion -*- shell-script -*-
-_tipc_media() {
+_tipc_media()
+{
local optind=$1
- if [[ $cword -eq $optind ]]; then
- COMPREPLY=( $(compgen -W 'media' -- $cur) )
+ if ((cword == optind)); then
+ COMPREPLY=($(compgen -W 'media' -- $cur))
return 0
- elif [[ $cword -eq $optind+1 ]]; then
- COMPREPLY=( $(compgen -W 'udp eth ib' -- $cur) )
+ elif ((cword == optind + 1)); then
+ COMPREPLY=($(compgen -W 'udp eth ib' -- $cur))
return 0
fi
return 1
}
-_tipc_bearer() {
+_tipc_bearer()
+{
local optind=$1
local media i
@@ -22,52 +24,54 @@ _tipc_bearer() {
return
fi
- for ((i = 0; i < $cword; i++)); do
- if [[ ${words[$i]} == 'media' ]]; then
- media=${words[$(($i + 1))]}
+ for ((i = 0; i < cword; i++)); do
+ if [[ ${words[i]} == 'media' ]]; then
+ media=${words[i + 1]}
fi
done
- if [[ $cword -eq $optind+2 ]]; then
+ if ((cword == optind + 2)); then
case "$media" in
- "udp")
- COMPREPLY=( $(compgen -W 'name' -- $cur) )
- ;;
- "eth" | "ib")
- COMPREPLY=( $(compgen -W 'device' -- $cur) )
- ;;
+ "udp")
+ COMPREPLY=($(compgen -W 'name' -- $cur))
+ ;;
+ "eth" | "ib")
+ COMPREPLY=($(compgen -W 'device' -- $cur))
+ ;;
esac
- elif [[ $cword -eq $optind+3 ]]; then
+ elif ((cword == optind + 3)); then
case "$media" in
- "udp")
- local names=$(tipc bearer list 2>/dev/null | awk -F: '/^udp:/ {print $2}')
- COMPREPLY=( $(compgen -W '$names' -- $cur) )
- ;;
- "eth")
- local interfaces=$(command ls /sys/class/net/)
- COMPREPLY=( $(compgen -W '$interfaces' -- $cur) )
- ;;
+ "udp")
+ local names=$(tipc bearer list 2>/dev/null | awk -F: '/^udp:/ {print $2}')
+ COMPREPLY=($(compgen -W '$names' -- $cur))
+ ;;
+ "eth")
+ local interfaces=$(command ls /sys/class/net/)
+ COMPREPLY=($(compgen -W '$interfaces' -- $cur))
+ ;;
esac
fi
}
-_tipc_link_opts() {
- COMPREPLY=( $(compgen -W 'priority tolerance window' -- $cur) )
+_tipc_link_opts()
+{
+ COMPREPLY=($(compgen -W 'priority tolerance window' -- $cur))
}
-_tipc_link() {
+_tipc_link()
+{
local optind=$1
local filter=$2
- if [[ $cword -eq $optind ]]; then
- COMPREPLY=( $(compgen -W 'link' -- $cur) )
- elif [[ $cword -eq $optind+1 ]]; then
+ if ((cword == optind)); then
+ COMPREPLY=($(compgen -W 'link' -- $cur))
+ elif ((cword == optind + 1)); then
# awk drops link state and last trailing :
- local links=$(tipc link list 2>/dev/null | \
+ local links=$(tipc link list 2>/dev/null |
awk '{print substr($1, 0, length($1))}')
local -a exclude
- [[ $filter == peers ]] && exclude=( -X broadcast-link )
- COMPREPLY=( $(compgen "${exclude[@]}" -W '$links' -- $cur) )
+ [[ $filter == peers ]] && exclude=(-X broadcast-link)
+ COMPREPLY=($(compgen "${exclude[@]}" -W '$links' -- $cur))
fi
}
@@ -82,203 +86,204 @@ _tipc()
# Flags can be placed anywhere in the commandline
case "$cur" in
-*)
- COMPREPLY=( $(compgen -W '-h --help' -- $cur) )
+ COMPREPLY=($(compgen -W '-h --help' -- $cur))
return
;;
esac
- if [[ $cword -eq 1 ]]; then
- COMPREPLY=( $(compgen -W 'bearer link media nametable node socket' -- $cur) )
+ if ((cword == 1)); then
+ COMPREPLY=($(compgen -W 'bearer link media nametable node socket' -- $cur))
return
fi
- case "${words[$optind]}" in
- bearer)
- (( optind++ ))
+ case "${words[optind]}" in
+ bearer)
+ ((optind++))
- if [[ $cword -eq $optind ]]; then
- COMPREPLY=( $(compgen -W 'enable disable set get list' -- $cur) )
- return
- fi
-
- case "${words[$optind]}" in
- enable)
- local media params
- (( optind++ ))
-
- if [[ $cword -lt $optind+4 ]]; then
- _tipc_bearer $optind
+ if ((cword == optind)); then
+ COMPREPLY=($(compgen -W 'enable disable set get list' -- $cur))
return
fi
- for ((i = 0; i < $cword; i++)); do
- if [[ ${words[$i]} == 'media' ]]; then
- media=${words[$(($i + 1))]}
- fi
- done
- case "$media" in
- "udp")
- declare -a params=("localip" "localport" "remoteip"
- "remoteport" "domain" "priority")
- ;;
- "eth" | "ib")
- declare -a params=("domain" "priority")
+ case "${words[optind]}" in
+ enable)
+ local media params
+ ((optind++))
+
+ if ((cword < optind + 4)); then
+ _tipc_bearer $optind
+ return
+ fi
+
+ for ((i = 0; i < cword; i++)); do
+ if [[ ${words[i]} == 'media' ]]; then
+ media=${words[i + 1]}
+ fi
+ done
+ case "$media" in
+ "udp")
+ declare -a params=("localip" "localport" "remoteip"
+ "remoteport" "domain" "priority")
+ ;;
+ "eth" | "ib")
+ declare -a params=("domain" "priority")
+ ;;
+ *)
+ return
+ ;;
+ esac
+
+ # If the previous word was a known parameter, we assume a value for
+ # that key. Note that this would break if the user attempts to use
+ # a known key as value.
+ for i in "${params[@]}"; do
+ if [[ $prev == "$i" ]]; then
+ return
+ fi
+ done
+
+ # In order not to print already used options, we remove them
+ for p in "${words[@]}"; do
+ for i in "${params[@]}"; do
+ if [[ $p == "$i" ]]; then
+ params=("${params[@]/$i/}")
+ fi
+ done
+ done
+
+ COMPREPLY=($(compgen -W '${params[@]}' -- $cur))
;;
- *)
- return
+ disable)
+ ((optind++))
+
+ _tipc_bearer $optind
;;
- esac
+ get)
+ ((optind++))
- # If the previous word was a known paramater we assume a value for
- # that key Note that this would break if the user attempts to use a
- # kown key as value
- for i in "${params[@]}"; do
- if [[ $prev == $i ]]; then
- return
- fi
- done
-
- # In order not to print already used options we remove them
- for p in "${words[@]}"; do
- for i in "${params[@]}"; do
- if [[ $p == $i ]]; then
- params=( "${params[@]/$i}" )
+ if ((cword == optind)); then
+ _tipc_link_opts
+ elif ((cword >= optind + 1)); then
+ _tipc_bearer $((optind + 1))
fi
- done
- done
-
- COMPREPLY=( $(compgen -W '${params[@]}' -- $cur) )
- ;;
- disable)
- (( optind++ ))
+ ;;
+ set)
+ ((optind++))
- _tipc_bearer $optind
+ if ((cword == optind)); then
+ _tipc_link_opts
+ elif ((cword >= optind + 2)); then
+ _tipc_bearer $((optind + 2))
+ fi
+ ;;
+ esac
;;
- get)
- (( optind++ ))
+ link)
+ ((optind++))
- if [[ $cword -eq $optind ]]; then
- _tipc_link_opts
- elif [[ $cword -ge $optind+1 ]]; then
- _tipc_bearer $(($optind + 1))
+ if ((cword == optind)); then
+ COMPREPLY=($(compgen -W 'get set list statistics' -- $cur))
+ return
fi
- ;;
- set)
- (( optind++ ))
- if [[ $cword -eq $optind ]]; then
- _tipc_link_opts
- elif [[ $cword -ge $optind+2 ]]; then
- _tipc_bearer $(($optind + 2))
- fi
- ;;
- esac
- ;;
- link)
- (( optind++ ))
+ case "${words[optind]}" in
+ get)
+ ((optind++))
- if [[ $cword -eq $optind ]]; then
- COMPREPLY=( $(compgen -W 'get set list statistics' -- $cur) )
- return
- fi
+ if ((cword == optind)); then
+ _tipc_link_opts
+ elif ((cword >= optind + 1)); then
+ _tipc_link $((optind + 1)) "peers"
+ fi
+ ;;
+ set)
+ ((optind++))
- case "${words[$optind]}" in
- get)
- (( optind++ ))
+ if ((cword == optind)); then
+ _tipc_link_opts
+ elif ((cword >= optind + 2)); then
+ _tipc_link $((optind + 2)) "peers"
+ fi
+ ;;
+ statistics)
+ ((optind++))
- if [[ $cword -eq $optind ]]; then
- _tipc_link_opts
- elif [[ $cword -ge $optind+1 ]]; then
- _tipc_link $(($optind + 1)) "peers"
- fi
- ;;
- set)
- (( optind++ ))
+ if ((cword == optind)); then
+ COMPREPLY=($(compgen -W 'show reset' -- $cur))
+ return
+ fi
- if [[ $cword -eq $optind ]]; then
- _tipc_link_opts
- elif [[ $cword -ge $optind+2 ]]; then
- _tipc_link $(($optind + 2)) "peers"
- fi
+ case "${words[optind]}" in
+ show | reset)
+ _tipc_link $((optind + 1))
+ ;;
+ esac
+ ;;
+ esac
;;
- statistics)
- (( optind++ ))
+ media)
+ ((optind++))
- if [[ $cword -eq $optind ]]; then
- COMPREPLY=( $(compgen -W 'show reset' -- $cur) )
+ if ((cword == optind)); then
+ COMPREPLY=($(compgen -W 'get set list' -- $cur))
return
fi
- case "${words[$optind]}" in
- show|reset)
- _tipc_link $(($optind + 1))
- ;;
- esac
- ;;
- esac
- ;;
- media)
- (( optind++ ))
+ case "${words[optind]}" in
+ get)
+ ((optind++))
- if [[ $cword -eq $optind ]]; then
- COMPREPLY=( $(compgen -W 'get set list' -- $cur) )
- return
- fi
-
- case "${words[$optind]}" in
- get)
- (( optind++ ))
+ if ((cword == optind)); then
+ _tipc_link_opts
+ elif ((cword >= optind + 1)); then
+ _tipc_media $((optind + 1))
+ fi
+ ;;
+ set)
+ ((optind++))
- if [[ $cword -eq $optind ]]; then
- _tipc_link_opts
- elif [[ $cword -ge $optind+1 ]]; then
- _tipc_media $(($optind + 1))
- fi
+ if ((cword == optind)); then
+ _tipc_link_opts
+ elif ((cword >= optind + 2)); then
+ _tipc_media $((optind + 2))
+ fi
+ ;;
+ esac
;;
- set)
- (( optind++ ))
+ nametable)
+ ((optind++))
- if [[ $cword -eq $optind ]]; then
- _tipc_link_opts
- elif [[ $cword -ge $optind+2 ]]; then
- _tipc_media $(($optind + 2))
+ if ((cword == optind)); then
+ COMPREPLY=($(compgen -W 'show' -- $cur))
fi
;;
- esac
- ;;
- nametable)
- (( optind++ ))
+ node)
+ ((optind++))
- if [[ $cword -eq $optind ]]; then
- COMPREPLY=( $(compgen -W 'show' -- $cur) )
- fi
- ;;
- node)
- (( optind++ ))
+ if ((cword == optind)); then
+ COMPREPLY=($(compgen -W 'list get set' -- $cur))
+ return
+ fi
- if [[ $cword -eq $optind ]]; then
- COMPREPLY=( $(compgen -W 'list get set' -- $cur) )
- return
- fi
+ case "${words[optind]}" in
+ get | set)
+ ((optind++))
- case "${words[$optind]}" in
- get|set)
- (( optind++ ))
+ if ((cword == optind)); then
+ COMPREPLY=($(compgen -W 'address netid' -- $cur))
+ fi
+ ;;
+ esac
+ ;;
+ socket)
+ ((optind++))
- if [[ $cword -eq $optind ]]; then
- COMPREPLY=( $(compgen -W 'address netid' -- $cur) )
+ if ((cword == optind)); then
+ COMPREPLY=($(compgen -W 'list' -- $cur))
fi
- esac
- ;;
- socket)
- (( optind++ ))
-
- if [[ $cword -eq $optind ]]; then
- COMPREPLY=( $(compgen -W 'list' -- $cur) )
- fi
- ;;
+ ;;
esac
} &&
-complete -F _tipc tipc
+ complete -F _tipc tipc
# ex: filetype=sh
diff --git a/completions/tox b/completions/tox
index 7dcddc54..0ea656e9 100644
--- a/completions/tox
+++ b/completions/tox
@@ -12,35 +12,40 @@ _tox()
fi
case $prev in
- --help|--version|--num|--index-url|--hashseed|--force-dep|-!(-*)[hni])
+ --help | --version | --num | --index-url | --hashseed | --force-dep | -!(-*)[hni])
return
;;
-!(-*)c)
_filedir ini
return
;;
- --installpkg|--result-json|--workdir)
+ --installpkg | --result-json | --workdir)
_filedir
return
;;
-!(-*)e)
local envs=$(
- { "$1" --listenvs-all || "$1" --listenvs; } 2>/dev/null )
+ {
+ "$1" --listenvs-all || "$1" --listenvs
+ } 2>/dev/null
+ )
[[ $envs ]] || envs=$(
- command sed -e 's/,/ /g' -ne 's/^envlist[[:space:]]*=//p' \
- tox.ini 2>/dev/null)
- local prefix=""; [[ $cur == *,* ]] && prefix="${cur%,*},"
- COMPREPLY=( $(compgen -X '*[{}]*' -W "$envs ALL" -- "${cur##*,}") )
- [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} )
+ command sed -e 's/,/ /g' -ne 's/^envlist[[:space:]]*=//p' \
+ tox.ini 2>/dev/null
+ )
+ local prefix=""
+ [[ $cur == *,* ]] && prefix="${cur%,*},"
+ COMPREPLY=($(compgen -X '*[{}]*' -W "$envs ALL" -- "${cur##*,}"))
+ ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1") --' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1") --' -- "$cur"))
return
fi
} &&
-complete -F _tox tox
+ complete -F _tox tox
# ex: filetype=sh
diff --git a/completions/tracepath b/completions/tracepath
index 29dec3e8..176534f1 100644
--- a/completions/tracepath
+++ b/completions/tracepath
@@ -13,14 +13,14 @@ _tracepath()
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 ipvx
[[ $1 == *6 ]] && ipvx=-6
- _known_hosts_real $ipvx -- "$cur"
+ _known_hosts_real ${ipvx-} -- "$cur"
} &&
-complete -F _tracepath tracepath tracepath6
+ complete -F _tracepath tracepath tracepath6
# ex: filetype=sh
diff --git a/completions/tshark b/completions/tshark
index 2f18d0a3..396fbcbd 100644
--- a/completions/tshark
+++ b/completions/tshark
@@ -23,13 +23,13 @@ _tshark()
cur=${cur#*:}
_filedir
else
- [ -n "$_tshark_prefs" ] ||
- _tshark_prefs="$("$1" -G defaultprefs 2>/dev/null | command\
- sed -ne 's/^#\{0,1\}\([a-z0-9_.-]\{1,\}:\).*/\1/p' |
+ [[ -v _tshark_prefs ]] ||
+ _tshark_prefs="$("$1" -G defaultprefs 2>/dev/null | command sed -ne 's/^#\{0,1\}\([a-z0-9_.-]\{1,\}:\).*/\1/p' |
tr '\n' ' ')"
- COMPREPLY=( $(compgen -P "$prefix" -W "$_tshark_prefs" \
- -- "${cur:${#prefix}}") )
- [[ $COMPREPLY == *: ]] && compopt -o nospace
+ : ${prefix:=}
+ COMPREPLY=($(compgen -P "$prefix" -W "$_tshark_prefs" \
+ -- "${cur:${#prefix}}"))
+ [[ ${COMPREPLY-} == *: ]] && compopt -o nospace
fi
return
;;
@@ -37,73 +37,71 @@ _tshark()
return
;;
-*i)
- COMPREPLY=( $(compgen -W \
- "$("$1" -D 2>/dev/null | awk '{print $2}')" -- "$cur") )
+ COMPREPLY=($(compgen -W \
+ "$("$1" -D 2>/dev/null | awk '{print $2}')" -- "$cur"))
return
;;
-*y)
local opts i
- for (( i=${#words[@]}-1; i > 0; i-- )); do
+ for ((i = ${#words[@]} - 1; i > 0; i--)); do
if [[ ${words[i]} == -i ]]; then
- opts+="-i ${words[i+1]}"
+ opts+="-i ${words[i + 1]}"
break
fi
done
- COMPREPLY=( $(compgen -W "$("$1" $opts -L 2>/dev/null | \
- awk '/^ / { print $1 }')" -- "$cur") )
+ COMPREPLY=($(compgen -W "$("$1" $opts -L 2>/dev/null |
+ awk '/^ / { print $1 }')" -- "$cur"))
return
;;
-*[ab])
- COMPREPLY=( $(compgen -W 'duration: filesize: files:' -- "$cur") )
- [[ $COMPREPLY == *: ]] && compopt -o nospace
+ COMPREPLY=($(compgen -W 'duration: filesize: files:' -- "$cur"))
+ [[ ${COMPREPLY-} == *: ]] && compopt -o nospace
return
;;
- -*r)
- _filedir '@(pcap?(ng)|cap)?(.gz)'
- return
- ;;
- -*H)
+ -*[rH])
+ # -r accepts a lot of different file types
_filedir
return
;;
-*w)
_filedir
- [[ $cur == @(|-) ]] && COMPREPLY+=( - )
+ [[ $cur == @(|-) ]] && COMPREPLY+=(-)
return
;;
-*F)
- COMPREPLY=( $(compgen -W "$("$1" -F 2>&1 | \
- awk '/^ / { print $1 }')" -- "$cur") )
+ COMPREPLY=($(compgen -W "$("$1" -F 2>&1 |
+ awk '/^ / { print $1 }')" -- "$cur"))
return
;;
-*O)
- local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*},"
- [ -n "$_tshark_protocols" ] ||
+ local prefix=
+ [[ $cur == *,* ]] && prefix="${cur%,*},"
+ [[ -v _tshark_protocols ]] ||
_tshark_protocols="$("$1" -G protocols 2>/dev/null |
cut -f 3 | tr '\n' ' ')"
- COMPREPLY=( $(compgen -W "$_tshark_protocols" -- "${cur##*,}") )
- [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} )
+ COMPREPLY=($(compgen -W "$_tshark_protocols" -- "${cur##*,}"))
+ ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
return
;;
-*T)
# Parse from: tshark -T . 2>&1 | awk -F \" '/^\t*"/ { print $2 }'
- COMPREPLY=( $(compgen -W \
- 'pdml ps psml json jsonraw ek tabs text fields' -- "$cur") )
+ COMPREPLY=($(compgen -W \
+ 'pdml ps psml json jsonraw ek tabs text fields' -- "$cur"))
return
;;
-*t)
# Parse from: tshark -t . 2>&1 | awk -F \" '/^\t*"/ { print $2 }'
- COMPREPLY=( $(compgen -W \
- 'a ad adoy d dd e r u ud udoy' -- "$cur") )
+ COMPREPLY=($(compgen -W \
+ 'a ad adoy d dd e r u ud udoy' -- "$cur"))
return
;;
-*u)
# TODO: could be parsed from "-u ." output
- COMPREPLY=( $(compgen -W 's hms' -- "$cur") )
+ COMPREPLY=($(compgen -W 's hms' -- "$cur"))
return
;;
-*W)
- COMPREPLY=( $(compgen -W 'n' -- "$cur") )
+ COMPREPLY=($(compgen -W 'n' -- "$cur"))
return
;;
-*X)
@@ -111,28 +109,28 @@ _tshark()
cur=${cur#*:}
_filedir lua
else
- COMPREPLY=( $(compgen -P "$prefix" -W 'lua_script:' -- \
- "${cur:${#prefix}}") )
- [[ $COMPREPLY == *: ]] && compopt -o nospace
+ COMPREPLY=($(compgen -P "$prefix" -W 'lua_script:' -- \
+ "${cur:${#prefix}}"))
+ [[ ${COMPREPLY-} == *: ]] && compopt -o nospace
fi
return
;;
-*G)
- COMPREPLY=( $(compgen -W "$("$1" -G \? 2>/dev/null | \
+ COMPREPLY=($(compgen -W "$("$1" -G \? 2>/dev/null |
awk '/^[ \t]*-G / \
{ sub("^[[]","",$2); sub("[]]$","",$2); print $2 }')" \
- -- "$cur") )
+ -- "$cur"))
return
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h 2>/dev/null)' \
- -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" -h 2>/dev/null)' \
+ -- "$cur"))
return
fi
} &&
-complete -F _tshark tshark
+ complete -F _tshark tshark
# ex: filetype=sh
diff --git a/completions/tsig-keygen b/completions/tsig-keygen
new file mode 100644
index 00000000..017e9d81
--- /dev/null
+++ b/completions/tsig-keygen
@@ -0,0 +1,28 @@
+# tsig-keygen(8) completion -*- shell-script -*-
+
+_tsig_keygen()
+{
+ local cur prev words cword
+ _init_completion || return
+
+ case $prev in
+ -h)
+ return
+ ;;
+ -a)
+ COMPREPLY=($(compgen -W 'hmac-{md5,sha{1,224,256,384,512}}' -- "$cur"))
+ return
+ ;;
+ -r)
+ COMPREPLY=($(compgen -W keyboard -- "$cur"))
+ _filedir
+ return
+ ;;
+ esac
+
+ [[ $cur != -* ]] ||
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+} &&
+ complete -F _tsig_keygen tsig-keygen
+
+# ex: filetype=sh
diff --git a/completions/tune2fs b/completions/tune2fs
index ab79cd51..66d629c4 100644
--- a/completions/tune2fs
+++ b/completions/tune2fs
@@ -10,12 +10,12 @@ _tune2fs()
return
;;
-*e)
- COMPREPLY=( $(compgen -W 'continue remount-ro panic' -- "$cur") )
+ COMPREPLY=($(compgen -W 'continue remount-ro panic' -- "$cur"))
return
;;
-*g)
_gids
- COMPREPLY=( $(compgen -g -W '${COMPREPLY[@]}' -- "$cur") )
+ COMPREPLY=($(compgen -g -W '${COMPREPLY[@]}' -- "$cur"))
return
;;
-*M)
@@ -26,7 +26,7 @@ _tune2fs()
local -a opts=(^debug ^bsdgroups ^user_xattr ^acl ^uid16
^journal_data ^journal_data_ordered ^journal_data_writeback
^nobarrier ^block_validity ^discard ^nodelalloc)
- COMPREPLY=( $(compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur") )
+ COMPREPLY=($(compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur"))
return
;;
-*O)
@@ -34,28 +34,28 @@ _tune2fs()
^filetype ^flex_bg ^has_journal ^huge_file ^large_file
^metadata_csum ^mmp ^project ^quota ^read-only ^resize_inode
^sparse_super ^uninit_bg)
- COMPREPLY=( $(compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur") )
+ COMPREPLY=($(compgen -W '${opts[@]} ${opts[@]#^}' -- "$cur"))
return
;;
-*u)
_uids
- COMPREPLY=( $(compgen -u -W '${COMPREPLY[@]}' -- "$cur") )
+ COMPREPLY=($(compgen -u -W '${COMPREPLY[@]}' -- "$cur"))
return
;;
-*U)
- COMPREPLY=( $(compgen -W 'clear random time' -- "$cur") )
+ COMPREPLY=($(compgen -W 'clear random time' -- "$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
cur=${cur:=/dev/}
_filedir
} &&
-complete -F _tune2fs tune2fs
+ complete -F _tune2fs tune2fs
# ex: filetype=sh
diff --git a/completions/ulimit b/completions/ulimit
index 3887cdf5..e596bf72 100644
--- a/completions/ulimit
+++ b/completions/ulimit
@@ -10,33 +10,33 @@ _ulimit()
local mode
case $prev in
-a)
- COMPREPLY=( $(compgen -W "-S -H" -- "$cur") )
+ COMPREPLY=($(compgen -W "-S -H" -- "$cur"))
return
;;
- -[SH])
- ;;
+ -[SH]) ;;
+
-*)
mode=$prev
;;
esac
- if [[ -z "$mode" ]]; then
+ if [[ ! -v mode ]]; then
local word
for word in "${words[@]}"; do
[[ $word == -*a* ]] && return
done
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
return
fi
fi
local args
_count_args
- [[ $args -eq 1 ]] && \
- COMPREPLY=( $(compgen -W "soft hard unlimited" -- "$cur") )
+ ((args == 1)) &&
+ COMPREPLY=($(compgen -W "soft hard unlimited" -- "$cur"))
} &&
-complete -F _ulimit ulimit
+ complete -F _ulimit ulimit
# ex: filetype=sh
diff --git a/completions/unace b/completions/unace
index a58bd6f0..7d6bd424 100644
--- a/completions/unace
+++ b/completions/unace
@@ -6,15 +6,15 @@ _unace()
_init_completion || return
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '-c -c- -f -f- -o -o- -p -y -y-' -- "$cur") )
+ COMPREPLY=($(compgen -W '-c -c- -f -f- -o -o- -p -y -y-' -- "$cur"))
else
- if [[ $cword -eq 1 ]]; then
- COMPREPLY=( $(compgen -W 'e l t v x' -- "$cur") )
+ if ((cword == 1)); then
+ COMPREPLY=($(compgen -W 'e l t v x' -- "$cur"))
else
_filedir ace
fi
fi
} &&
-complete -F _unace unace
+ complete -F _unace unace
# ex: filetype=sh
diff --git a/completions/unpack200 b/completions/unpack200
index 393df04d..8814259b 100644
--- a/completions/unpack200
+++ b/completions/unpack200
@@ -6,15 +6,15 @@ _unpack200()
_init_completion -s || return
case $prev in
- --help|--version|-!(-*)[?hVJ])
+ --help | --version | -!(-*)[?hVJ])
return
;;
- --deflate-hint|-!(-*)H)
- COMPREPLY=( $(compgen -W 'true false keep' -- "$cur") )
+ --deflate-hint | -!(-*)H)
+ COMPREPLY=($(compgen -W 'true false keep' -- "$cur"))
return
;;
- --log-file|-!(-*)l)
- COMPREPLY=( $(compgen -W '-' -- "$cur") )
+ --log-file | -!(-*)l)
+ COMPREPLY=($(compgen -W '-' -- "$cur"))
_filedir log
return
;;
@@ -23,26 +23,26 @@ _unpack200()
$split && return
# Check if a pack or a jar was already given.
- local i pack=false jar=false
- for (( i=0; i < ${#words[@]}-1; i++ )) ; do
- case ${words[i]} in
- *.pack|*.pack.gz) pack=true ;;
+ local word pack=false jar=false
+ for word in "${words[@]:1}"; do
+ case $word in
+ *.pack | *.pack.gz) pack=true ;;
*.jar) jar=true ;;
esac
done
- if ! $pack ; then
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '--deflate-hint= --remove-pack-file
- --verbose --quiet --log-file= --help --version' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ if ! $pack; then
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '--deflate-hint= --remove-pack-file
+ --verbose --quiet --log-file= --help --version' -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
else
_filedir 'pack?(.gz)'
fi
- elif ! $jar ; then
+ elif ! $jar; then
_filedir jar
fi
} &&
-complete -F _unpack200 unpack200
+ complete -F _unpack200 unpack200
# ex: filetype=sh
diff --git a/completions/unrar b/completions/unrar
index 959a5c9c..4cbac8fe 100644
--- a/completions/unrar
+++ b/completions/unrar
@@ -6,18 +6,18 @@ _unrar()
_init_completion || return
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '-ad -ap -av- -c- -cfg- -cl -cu -dh -ep -f
+ COMPREPLY=($(compgen -W '-ad -ap -av- -c- -cfg- -cl -cu -dh -ep -f
-idp -ierr -inul -kb -o+ -o- -ow -p -p- -r -ta -tb -tn -to -u -v
- -ver -vp -x -x@ -y' -- "$cur") )
+ -ver -vp -x -x@ -y' -- "$cur"))
else
- if [[ $cword -eq 1 ]]; then
- COMPREPLY=( $(compgen -W 'e l lb lt p t v vb vt x' -- "$cur") )
+ if ((cword == 1)); then
+ COMPREPLY=($(compgen -W 'e l lb lt p t v vb vt x' -- "$cur"))
else
_filedir '@(rar|exe)'
fi
fi
} &&
-complete -F _unrar unrar
+ complete -F _unrar unrar
# ex: filetype=sh
diff --git a/completions/unshunt b/completions/unshunt
index 214fa423..95a16015 100644
--- a/completions/unshunt
+++ b/completions/unshunt
@@ -5,13 +5,13 @@ _unshunt()
local cur prev words cword
_init_completion || return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
else
_filedir -d
fi
} &&
-complete -F _unshunt unshunt
+ complete -F _unshunt unshunt
# ex: filetype=sh
diff --git a/completions/update-alternatives b/completions/update-alternatives
index 17b687a7..25d2ce6b 100644
--- a/completions/update-alternatives
+++ b/completions/update-alternatives
@@ -7,13 +7,13 @@ _installed_alternatives()
for i in alternatives dpkg/alternatives rpm/alternatives; do
[[ -d /var/lib/$i ]] && admindir=/var/lib/$i && break
done
- for (( i=1; i < cword; i++ )); do
- if [[ "${words[i]}" == --admindir ]]; then
- admindir=${words[i+1]}
+ for ((i = 1; i < cword; i++)); do
+ if [[ ${words[i]} == --admindir ]]; then
+ admindir=${words[i + 1]}
break
fi
done
- COMPREPLY=( $(compgen -W '$(command ls $admindir)' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(command ls $admindir)' -- "$cur"))
}
_update_alternatives()
@@ -22,11 +22,11 @@ _update_alternatives()
_init_completion || return
case $prev in
- --altdir|--admindir)
+ --altdir | --admindir)
_filedir -d
return
;;
- --help|--usage|--version)
+ --help | --usage | --version)
return
;;
esac
@@ -34,18 +34,18 @@ _update_alternatives()
local mode args i
# find which mode to use and how many real args used so far
- for (( i=1; i < cword; i++ )); do
- if [[ "${words[i]}" == --@(install|remove|auto|display|config|remove-all|set) ]]; then
+ for ((i = 1; i < cword; i++)); do
+ if [[ ${words[i]} == --@(install|remove|auto|display|config|remove-all|set) ]]; then
mode=${words[i]}
- args=$(($cword - i))
+ args=$((cword - i))
break
fi
done
- case $mode in
+ case ${mode-} in
--install)
case $args in
- 1|3)
+ 1 | 3)
_filedir
;;
2)
@@ -56,19 +56,20 @@ _update_alternatives()
;;
*)
case $((args % 4)) in
- 0|2)
+ 0 | 2)
_filedir
;;
1)
- COMPREPLY=( $(compgen -W '--slave' -- "$cur") )
+ COMPREPLY=($(compgen -W '--slave' -- "$cur"))
;;
3)
_installed_alternatives
;;
esac
+ ;;
esac
;;
- --remove|--set)
+ --remove | --set)
case $args in
1)
_installed_alternatives
@@ -78,13 +79,14 @@ _update_alternatives()
;;
esac
;;
- --auto|--remove-all|--display|--config)
+ --auto | --remove-all | --display | --config)
_installed_alternatives
;;
*)
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ ;;
esac
} &&
-complete -F _update_alternatives update-alternatives alternatives
+ complete -F _update_alternatives update-alternatives alternatives
# ex: filetype=sh
diff --git a/completions/update-rc.d b/completions/update-rc.d
index 31cd820b..9b281d5f 100644
--- a/completions/update-rc.d
+++ b/completions/update-rc.d
@@ -9,50 +9,50 @@ _update_rc_d()
local sysvdir services 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=( -f -n )
+ services=($(printf '%s ' $sysvdir/!(README*|*.sh|$_backup_glob)))
+ services=(${services[@]#$sysvdir/})
+ options=(-f -n)
- if [[ $cword -eq 1 || "$prev" == -* ]]; then
- COMPREPLY=( $(compgen -W '${options[@]} ${services[@]}' \
- -X '$(tr " " "|" <<<${words[@]})' -- "$cur") )
- elif [[ "$prev" == ?($(tr " " "|" <<<"${services[*]}")) ]]; then
- COMPREPLY=( $(compgen -W 'remove defaults start stop' -- "$cur") )
- elif [[ "$prev" == defaults && "$cur" == [0-9] ]]; then
- COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
- elif [[ "$prev" == defaults && "$cur" == [sk]?([0-9]) ]]; then
- COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
- elif [[ "$prev" == defaults && -z "$cur" ]]; then
- COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 s k )
- elif [[ "$prev" == ?(start|stop) ]]; then
- if [[ "$cur" == [0-9] || -z "$cur" ]]; then
- COMPREPLY=( 0 1 2 3 4 5 6 7 8 9 )
- elif [[ "$cur" == [0-9][0-9] ]]; then
- COMPREPLY=( $cur )
+ if [[ $cword -eq 1 || $prev == -* ]]; then
+ COMPREPLY=($(compgen -W '${options[@]} ${services[@]}' \
+ -X '$(tr " " "|" <<<${words[@]})' -- "$cur"))
+ elif [[ $prev == ?($(tr " " "|" <<<"${services[*]}")) ]]; then
+ COMPREPLY=($(compgen -W 'remove defaults start stop' -- "$cur"))
+ elif [[ $prev == defaults && $cur == [0-9] ]]; then
+ COMPREPLY=(0 1 2 3 4 5 6 7 8 9)
+ elif [[ $prev == defaults && $cur == [sk]?([0-9]) ]]; then
+ COMPREPLY=(0 1 2 3 4 5 6 7 8 9)
+ elif [[ $prev == defaults && -z $cur ]]; then
+ COMPREPLY=(0 1 2 3 4 5 6 7 8 9 s k)
+ elif [[ $prev == ?(start|stop) ]]; then
+ if [[ $cur == [0-9] || -z $cur ]]; then
+ COMPREPLY=(0 1 2 3 4 5 6 7 8 9)
+ elif [[ $cur == [0-9][0-9] ]]; then
+ COMPREPLY=($cur)
else
COMPREPLY=()
fi
- elif [[ "$prev" == ?([0-9][0-9]|[0-6S]) ]]; then
- if [[ -z "$cur" ]]; then
+ elif [[ $prev == ?([0-9][0-9]|[0-6S]) ]]; then
+ if [[ -z $cur ]]; then
if [[ $prev == [0-9][0-9] ]]; then
- COMPREPLY=( 0 1 2 3 4 5 6 S )
+ COMPREPLY=(0 1 2 3 4 5 6 S)
else
- COMPREPLY=( 0 1 2 3 4 5 6 S . )
+ COMPREPLY=(0 1 2 3 4 5 6 S .)
fi
- elif [[ "$cur" == [0-6S.] ]]; then
- COMPREPLY=( $cur )
+ elif [[ $cur == [0-6S.] ]]; then
+ COMPREPLY=($cur)
else
COMPREPLY=()
fi
- elif [[ "$prev" == "." ]]; then
- COMPREPLY=( $(compgen -W "start stop" -- "$cur") )
+ elif [[ $prev == "." ]]; then
+ COMPREPLY=($(compgen -W "start stop" -- "$cur"))
else
COMPREPLY=()
fi
} &&
-complete -F _update_rc_d update-rc.d
+ complete -F _update_rc_d update-rc.d
# ex: filetype=sh
diff --git a/completions/upgradepkg b/completions/upgradepkg
index 7b775769..d3ce6084 100644
--- a/completions/upgradepkg
+++ b/completions/upgradepkg
@@ -5,26 +5,26 @@ _upgradepkg()
local cur prev words cword
_init_completion || return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '--dry-run --install-new --reinstall
- --verbose' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '--dry-run --install-new --reinstall
+ --verbose' -- "$cur"))
return
fi
- if [[ "$cur" == ?*%* ]]; then
+ if [[ $cur == ?*%* ]]; then
prev="${cur%%?(\\)%*}"
cur="${cur#*%}"
local nofiles IFS=$'\n'
compopt -o filenames
- COMPREPLY=( $(compgen -P "$prev%" -f -X "!*.@(t[bgxl]z)" -- "$cur") )
- [[ $COMPREPLY ]] || nofiles=1
- COMPREPLY+=( $(compgen -P "$prev%" -S '/' -d -- "$cur") )
- [[ $nofiles ]] && compopt -o nospace
+ COMPREPLY=($(compgen -P "$prev%" -f -X "!*.@(t[bgxl]z)" -- "$cur"))
+ [[ ${COMPREPLY-} ]] || nofiles=1
+ COMPREPLY+=($(compgen -P "$prev%" -S '/' -d -- "$cur"))
+ [[ -v nofiles ]] && compopt -o nospace
return
fi
_filedir 't[bglx]z'
} &&
-complete -F _upgradepkg upgradepkg
+ complete -F _upgradepkg upgradepkg
# ex: filetype=sh
diff --git a/completions/urlsnarf b/completions/urlsnarf
index d3581c5f..e3270762 100644
--- a/completions/urlsnarf
+++ b/completions/urlsnarf
@@ -16,11 +16,11 @@ _urlsnarf()
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
fi
} &&
-complete -F _urlsnarf urlsnarf
+ complete -F _urlsnarf urlsnarf
# ex: filetype=sh
diff --git a/completions/uscan b/completions/uscan
index de0e7174..441bae3f 100644
--- a/completions/uscan
+++ b/completions/uscan
@@ -7,7 +7,7 @@ _uscan()
case $prev in
--package)
- COMPREPLY=( $(_xfunc apt-cache _apt_cache_src_packages))
+ COMPREPLY=($(_xfunc apt-cache _apt_cache_src_packages))
return
;;
--watchfile)
@@ -18,16 +18,16 @@ _uscan()
_filedir -d
return
;;
- --timeout|--upstream-version|--download-version|--check-dirname-level|--check-dirname-regex)
- COMPREPLY=( )
+ --timeout | --upstream-version | --download-version | --check-dirname-level | --check-dirname-regex)
+ COMPREPLY=()
return
;;
esac
$split && return
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
} &&
-complete -F _uscan uscan
+ complete -F _uscan uscan
# ex: filetype=sh
diff --git a/completions/useradd b/completions/useradd
index 8e095441..ceeca914 100644
--- a/completions/useradd
+++ b/completions/useradd
@@ -9,27 +9,28 @@ _useradd()
# with -u/--uid
case $prev in
- --comment|--help|--expiredate|--inactive|--key|--password|--uid|\
- --selinux-user|-!(-*)[chefKpuZ])
+ --comment | --help | --expiredate | --inactive | --key | --password | --uid | \
+ --selinux-user | -!(-*)[chefKpuZ])
return
;;
- --base-dir|--home-dir|--skel|--root|-!(-*)[bdkR])
+ --base-dir | --home-dir | --skel | --root | -!(-*)[bdkR])
_filedir -d
return
;;
- --gid|-!(-*)g)
+ --gid | -!(-*)g)
_gids
- COMPREPLY=( $(compgen -W '${COMPREPLY[@]} $(compgen -g)' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W '${COMPREPLY[@]} $(compgen -g)' \
+ -- "$cur"))
return
;;
- --groups|-!(-*)G)
- local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*},"
- COMPREPLY=( $(compgen -g -- "${cur##*,}") )
- [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} )
+ --groups | -!(-*)G)
+ local prefix=
+ [[ $cur == *,* ]] && prefix="${cur%,*},"
+ COMPREPLY=($(compgen -g -- "${cur##*,}"))
+ ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
return
;;
- --shell|-!(-*)s)
+ --shell | -!(-*)s)
_shells
return
;;
@@ -37,9 +38,9 @@ _useradd()
$split && return
- [[ "$cur" == -* ]] && \
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ [[ $cur == -* ]] &&
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
} &&
-complete -F _useradd useradd
+ complete -F _useradd useradd
# ex: filetype=sh
diff --git a/completions/userdel b/completions/userdel
index 7d637d2e..ed98447b 100644
--- a/completions/userdel
+++ b/completions/userdel
@@ -6,22 +6,22 @@ _userdel()
_init_completion || return
case $prev in
- --help|-!(-*)h)
+ --help | -!(-*)h)
return
;;
- --root|-!(-*)R)
+ --root | -!(-*)R)
_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 -u -- "$cur") )
+ COMPREPLY=($(compgen -u -- "$cur"))
} &&
-complete -F _userdel userdel
+ complete -F _userdel userdel
# ex: filetype=sh
diff --git a/completions/usermod b/completions/usermod
index 3d0efdbd..77ab33c8 100644
--- a/completions/usermod
+++ b/completions/usermod
@@ -9,27 +9,28 @@ _usermod()
# with -u/--uid
case $prev in
- --comment|--home|--expiredate|--inactive|--help|--login|--password|\
- --uid|--selinux-user|-!(-*)[cdefhlpuZ])
+ --comment | --home | --expiredate | --inactive | --help | --login | --password | \
+ --uid | --selinux-user | -!(-*)[cdefhlpuZ])
return
;;
- --gid|-!(-*)g)
+ --gid | -!(-*)g)
_gids
- COMPREPLY=( $(compgen -W '${COMPREPLY[@]} $(compgen -g)' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W '${COMPREPLY[@]} $(compgen -g)' \
+ -- "$cur"))
return
;;
- --groups|-!(-*)G)
- local prefix=; [[ $cur == *,* ]] && prefix="${cur%,*},"
- COMPREPLY=( $(compgen -g -- "${cur##*,}") )
- [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=( ${COMPREPLY/#/$prefix} )
+ --groups | -!(-*)G)
+ local prefix=
+ [[ $cur == *,* ]] && prefix="${cur%,*},"
+ COMPREPLY=($(compgen -g -- "${cur##*,}"))
+ ((${#COMPREPLY[@]} == 1)) && COMPREPLY=(${COMPREPLY/#/$prefix})
return
;;
- --root|-!(-*)R)
+ --root | -!(-*)R)
_filedir -d
return
;;
- --shell|-!(-*)s)
+ --shell | -!(-*)s)
_shells
return
;;
@@ -37,14 +38,14 @@ _usermod()
$split && return
- if [[ "$cur" == -* ]]; then
+ if [[ $cur == -* ]]; then
# TODO: -U/--unlock, -p/--password, -L/--lock mutually exclusive
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
return
fi
- COMPREPLY=( $(compgen -u -- "$cur") )
+ COMPREPLY=($(compgen -u -- "$cur"))
} &&
-complete -F _usermod usermod
+ complete -F _usermod usermod
# ex: filetype=sh
diff --git a/completions/valgrind b/completions/valgrind
index 01ca62c5..f5411615 100644
--- a/completions/valgrind
+++ b/completions/valgrind
@@ -9,47 +9,47 @@ _valgrind()
# Note: intentionally using COMP_WORDS and COMP_CWORD instead of
# words and cword here due to splitting on = causing index differences
# (_command_offset assumes the former).
- for (( i=1; i <= COMP_CWORD; i++ )); do
- if [[ ${COMP_WORDS[i]} != @([-=])* && ${COMP_WORDS[i-1]} != = ]]; then
+ for ((i = 1; i <= COMP_CWORD; i++)); do
+ if [[ ${COMP_WORDS[i]} != @([-=])* && ${COMP_WORDS[i - 1]} != = ]]; then
_command_offset $i
return
fi
done
- local tool
- for (( i=1; i < ${#words[@]}; i++ )); do
- if [[ ${words[i]} == --tool=?* ]]; then
- tool=${words[i]}
+ local word tool
+ for word in "${words[@]:1}"; do
+ if [[ $word == --tool=?* ]]; then
+ tool=$word
break
fi
done
case $prev in
- -h|--help|--help-debug|--version)
+ -h | --help | --help-debug | --version)
return
;;
--tool)
# Tools seem to be named e.g. like memcheck-amd64-linux from which
# we want to grab memcheck.
- COMPREPLY=( $(compgen -W '$(
+ COMPREPLY=($(compgen -W '$(
for f in /usr{,/local}/lib{,64,exec}{/*-linux-gnu,}/valgrind/*
do
[[ $f != *.so && -x $f && $f =~ ^.*/(.*)-[^-]+-[^-]+ ]] &&
printf "%s\n" "${BASH_REMATCH[1]}"
- done)' -- "$cur") )
+ done)' -- "$cur"))
return
;;
--sim-hints)
- COMPREPLY=( $(compgen -W 'lax-ioctls enable-outer' -- "$cur") )
+ COMPREPLY=($(compgen -W 'lax-ioctls enable-outer' -- "$cur"))
return
;;
--soname-synonyms)
- COMPREPLY=( $(compgen -W 'somalloc' -S = -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ COMPREPLY=($(compgen -W 'somalloc' -S = -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
;;
--kernel-variant)
- COMPREPLY=( $(compgen -W 'bproc' -- "$cur") )
+ COMPREPLY=($(compgen -W 'bproc' -- "$cur"))
return
;;
# callgrind:
@@ -59,18 +59,18 @@ _valgrind()
;;
# exp-dhat:
--sort-by)
- COMPREPLY=( $(compgen -W 'max-bytes-live tot-bytes-allocd
- max-blocks-live' -- "$cur") )
+ COMPREPLY=($(compgen -W 'max-bytes-live tot-bytes-allocd
+ max-blocks-live' -- "$cur"))
return
;;
# massif:
--time-unit)
- COMPREPLY=( $(compgen -W 'i ms B' -- "$cur") )
+ COMPREPLY=($(compgen -W 'i ms B' -- "$cur"))
return
;;
- # generic cases parsed from --help output
+ # generic cases parsed from --help output
--+([-A-Za-z0-9_]))
- local value=$($1 --help-debug $tool 2>/dev/null | \
+ local value=$($1 --help-debug ${tool-} 2>/dev/null |
command sed -ne "s|^[[:blank:]]*$prev=\([^[:blank:]]\{1,\}\).*|\1|p")
case $value in
\<file*\>)
@@ -79,18 +79,18 @@ _valgrind()
;;
\<command\>)
compopt -o filenames
- COMPREPLY=( $(compgen -c -- "$cur") )
+ COMPREPLY=($(compgen -c -- "$cur"))
return
;;
\<+([0-9])..+([0-9])\>)
- COMPREPLY=( $(compgen -W "{${value:1:((${#value}-2))}}" \
- -- "$cur") )
+ COMPREPLY=($(compgen -W "{${value:1:${#value}-2}}" \
+ -- "$cur"))
return
;;
# "yes", "yes|no", etc (but not "string", "STR",
# "hint1,hint2,...")
- yes|+([-a-z0-9])\|+([-a-z0-9\|]))
- COMPREPLY=( $(IFS='|' compgen -W '$value' -- "$cur") )
+ yes | +([-a-z0-9])\|+([-a-z0-9\|]))
+ COMPREPLY=($(IFS='|' compgen -W '$value' -- "$cur"))
return
;;
esac
@@ -100,12 +100,12 @@ _valgrind()
$split && return
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" "--help $tool")' \
- -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" "--help ${tool-}")' \
+ -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
} &&
-complete -F _valgrind valgrind
+ complete -F _valgrind valgrind
# ex: filetype=sh
diff --git a/completions/vipw b/completions/vipw
index 46771a0a..b3a74156 100644
--- a/completions/vipw
+++ b/completions/vipw
@@ -6,17 +6,17 @@ _vipw()
_init_completion || return
case $prev in
- --help|-!(-*)h)
+ --help | -!(-*)h)
return
;;
- --root|-!(-*)R)
+ --root | -!(-*)R)
_filedir -d
return
;;
esac
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
} &&
-complete -F _vipw vipw vigr
+ complete -F _vipw vipw vigr
# ex: filetype=sh
diff --git a/completions/vmstat b/completions/vmstat
index f15d4089..e36934a5 100644
--- a/completions/vmstat
+++ b/completions/vmstat
@@ -6,22 +6,22 @@ _vmstat()
_init_completion || return
case $prev in
- --help|--version|--partition|-!(-*)[hVcMNnwp])
+ --help | --version | --partition | -!(-*)[hVcMNnwp])
return
;;
- --unit|-!(-*)S)
- [[ $OSTYPE == *linux* ]] && \
- COMPREPLY=( $(compgen -W 'k K m M' -- "$cur") )
+ --unit | -!(-*)S)
+ [[ $OSTYPE == *linux* ]] &&
+ COMPREPLY=($(compgen -W 'k K m M' -- "$cur"))
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
- [[ $COMPREPLY ]] || \
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ [[ ${COMPREPLY-} ]] ||
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
fi
} &&
-complete -F _vmstat vmstat
+ complete -F _vmstat vmstat
# ex: filetype=sh
diff --git a/completions/vncviewer b/completions/vncviewer
index 000ba1a8..ba552268 100644
--- a/completions/vncviewer
+++ b/completions/vncviewer
@@ -4,17 +4,17 @@ _vncviewer_bootstrap()
{
local fname
case $(_realcommand vncviewer) in
- *xvnc4viewer) fname=_xvnc4viewer ;;
- *tightvncviewer) fname=_tightvncviewer ;;
- *) fname=_known_hosts ;;
+ *xvnc4viewer) fname=_xvnc4viewer ;;
+ *tightvncviewer) fname=_tightvncviewer ;;
+ *) fname=_known_hosts ;;
esac
# Install real completion for subsequent completions
complete -F $fname vncviewer
- $fname # Generate completions once for now
+ $fname # Generate completions once for now
unset -f _vncviewer_bootstrap
} &&
-complete -F _vncviewer_bootstrap vncviewer
+ complete -F _vncviewer_bootstrap vncviewer
_tightvncviewer()
{
@@ -27,8 +27,8 @@ _tightvncviewer()
return
;;
-encodings)
- COMPREPLY=( $(compgen -W 'copyrect tight hextile zlib corre rre
- raw' -- "$cur") )
+ COMPREPLY=($(compgen -W 'copyrect tight hextile zlib corre rre
+ raw' -- "$cur"))
return
;;
-via)
@@ -37,18 +37,16 @@ _tightvncviewer()
;;
esac
-
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '-help -listen -via -shared -noshared
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '-help -listen -via -shared -noshared
-viewonly -fullscreen -noraiseonbeep -passwd -encodings -bgr233
-owncmap -truecolour -truecolor -depth -compresslevel -quality
- -nojpeg -nocursorshape -x11cursor' -- "$cur") )
+ -nojpeg -nocursorshape -x11cursor' -- "$cur"))
else
_known_hosts_real -- "$cur"
fi
} &&
-complete -F _tightvncviewer tightvncviewer
-
+ complete -F _tightvncviewer tightvncviewer
# NOTE: - VNC Viewer options are case insensitive.
# Preferred case is taken from -help.
@@ -61,12 +59,12 @@ _xvnc4viewer()
local opt=${prev/#--/-}
case ${opt,,} in
# -passwd, -PasswordFile
- -passwd|-passwordfile)
+ -passwd | -passwordfile)
_filedir
return
;;
-preferredencoding)
- COMPREPLY=( $(compgen -W 'zrle hextile raw' -- "$cur") )
+ COMPREPLY=($(compgen -W 'zrle hextile raw' -- "$cur"))
return
;;
-via)
@@ -75,26 +73,27 @@ _xvnc4viewer()
;;
esac
- if [[ "$cur" == -* || "$cur" == --* ]]; then
+ if [[ $cur == -* || $cur == --* ]]; then
# Default to vncviewer camelcase options, see `vncviewer -help'
- local dash options=( AcceptClipboard AutoSelect DebugDelay display
+ local dash options=(AcceptClipboard AutoSelect DebugDelay display
DotWhenNoCursor FullColor FullColour FullScreen geometry help
listen Log LowColourLevel MenuKey name Parent passwd PasswordFile
PointerEventInterval PreferredEncoding SendClipboard SendPrimary
Shared UseLocalCursor via ViewOnly WMDecorationHeight
- WMDecorationWidth ZlibLevel )
- [[ "$cur" == --* ]] && dash=-- || dash=-
+ WMDecorationWidth ZlibLevel)
+ [[ $cur == --* ]] && dash=-- || dash=-
- local IFS=$' \t\n' reset=$(shopt -p nocasematch); shopt -s nocasematch
+ local IFS=$' \t\n' reset=$(shopt -p nocasematch)
+ shopt -s nocasematch
local option
- COMPREPLY=( $(for option in "${options[@]}"; do
- [[ $dash$option == "$cur"* ]] && printf '%s\n' $dash$option
- done) )
+ COMPREPLY=($(for option in "${options[@]}"; do
+ [[ $dash$option == "$cur"* ]] && printf '%s\n' $dash$option
+ done))
$reset
else
_known_hosts_real -- "$cur"
fi
} &&
-complete -F _xvnc4viewer xvnc4viewer
+ complete -F _xvnc4viewer xvnc4viewer
# ex: filetype=sh
diff --git a/completions/vpnc b/completions/vpnc
index 5eb5be71..bbdb8ee7 100644
--- a/completions/vpnc
+++ b/completions/vpnc
@@ -6,9 +6,9 @@ _vpnc()
_init_completion || return
case $prev in
- --help|--long-help|--version|--id|--username|--domain|--ifname|\
- --application-version|--local-addr|--local-port|--udp-port|--dpd-idle|\
- --target-network|--ifmtu)
+ --help | --long-help | --version | --id | --username | --domain | --ifname | \
+ --application-version | --local-addr | --local-port | --udp-port | --dpd-idle | \
+ --target-network | --ifmtu)
return
;;
--gateway)
@@ -16,36 +16,36 @@ _vpnc()
return
;;
--vendor)
- COMPREPLY=( $(compgen -W 'cisco netscreen' -- "$cur") )
+ COMPREPLY=($(compgen -W 'cisco netscreen' -- "$cur"))
return
;;
--natt-mode)
- COMPREPLY=( $(compgen -W 'natt none force-natt cisco-udp' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W 'natt none force-natt cisco-udp' \
+ -- "$cur"))
return
;;
- --script|--pid-file|--ca-file)
+ --script | --pid-file | --ca-file)
_filedir
return
;;
--dh)
- COMPREPLY=( $(compgen -W 'dh1 dh2 dh5' -- "$cur") )
+ COMPREPLY=($(compgen -W 'dh1 dh2 dh5' -- "$cur"))
return
;;
--pfs)
- COMPREPLY=( $(compgen -W 'nopfs dh1 dh2 dh5 server' -- "$cur") )
+ COMPREPLY=($(compgen -W 'nopfs dh1 dh2 dh5 server' -- "$cur"))
return
;;
--ifmode)
- COMPREPLY=( $(compgen -W 'tun tap' -- "$cur") )
+ COMPREPLY=($(compgen -W 'tun tap' -- "$cur"))
return
;;
--debug)
- COMPREPLY=( $(compgen -W '0 1 2 3 99' -- "$cur") )
+ COMPREPLY=($(compgen -W '0 1 2 3 99' -- "$cur"))
return
;;
--auth-mode)
- COMPREPLY=( $(compgen -W 'psk cert hybrid' -- "$cur") )
+ COMPREPLY=($(compgen -W 'psk cert hybrid' -- "$cur"))
return
;;
--ca-dir)
@@ -54,28 +54,29 @@ _vpnc()
;;
--password-helper)
compopt -o filenames
- COMPREPLY=( $(compgen -c -- "$cur") )
+ COMPREPLY=($(compgen -c -- "$cur"))
return
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" --long-help)' -- "$cur") )
- elif [[ "$cur" == */* ]]; then
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" --long-help)' -- "$cur"))
+ elif [[ $cur == */* ]]; then
# explicit filename
_filedir conf
else
# config name, /etc/vpnc/<name>.conf
- local IFS=$' \t\n' reset=$(shopt -p nullglob); shopt -s nullglob
- local -a configs=( /etc/vpnc/*.conf )
- configs=( "${configs[@]##*/}" )
- configs=( "${configs[@]%.conf}" )
+ local IFS=$' \t\n' reset=$(shopt -p nullglob)
+ shopt -s nullglob
+ local -a configs=(/etc/vpnc/*.conf)
+ configs=("${configs[@]##*/}")
+ configs=("${configs[@]%.conf}")
$reset
IFS=$'\n'
compopt -o filenames
- COMPREPLY=( $(compgen -W '${configs[@]}' -- "$cur") )
+ COMPREPLY=($(compgen -W '${configs[@]}' -- "$cur"))
fi
} &&
-complete -F _vpnc vpnc
+ complete -F _vpnc vpnc
# ex: filetype=sh
diff --git a/completions/watch b/completions/watch
index eb04df89..efc0a98f 100644
--- a/completions/watch
+++ b/completions/watch
@@ -8,13 +8,13 @@ _watch()
_init_completion -s || return
local offset=0 i
- for (( i=1; i <= cword; i++ )); do
+ for ((i = 1; i <= cword; i++)); do
case ${words[i]} in
- --help|--version|-!(-*)h)
+ --help | --version | -!(-*)h)
return
;;
- --interval|-!(-*)n)
- (( i++ ))
+ --interval | -!(-*)n)
+ ((i++))
continue
;;
-*)
@@ -25,18 +25,18 @@ _watch()
break
done
- if [[ $offset -gt 0 ]]; then
+ if ((offset > 0)); then
_command_offset $offset
return
fi
case $prev in
- --differences|-!(-*)d)
- [[ $cur != -* ]] && \
- COMPREPLY=( $(compgen -W 'cumulative' -- "$cur") )
+ --differences | -!(-*)d)
+ [[ $cur != -* ]] &&
+ COMPREPLY=($(compgen -W 'cumulative' -- "$cur"))
return
;;
- --interval|-!(-*)n)
+ --interval | -!(-*)n)
return
;;
esac
@@ -44,11 +44,11 @@ _watch()
$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
} &&
-complete -F _watch watch
+ complete -F _watch watch
# ex: filetype=sh
diff --git a/completions/webmitm b/completions/webmitm
index d50bc3e3..549c5ef5 100644
--- a/completions/webmitm
+++ b/completions/webmitm
@@ -5,13 +5,13 @@ _webmitm()
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"))
else
_known_hosts_real -- "$cur"
fi
} &&
-complete -F _webmitm webmitm
+ complete -F _webmitm webmitm
# ex: filetype=sh
diff --git a/completions/wget b/completions/wget
index b27d860d..d6a2fe93 100644
--- a/completions/wget
+++ b/completions/wget
@@ -6,84 +6,87 @@ _wget()
_init_completion -s || return
case $prev in
- --version|--help|-!(-*)[hV])
+ --version | --help | -!(-*)[hV])
return
;;
--progress)
- COMPREPLY=( $(compgen -W 'bar dot' -- "$cur") )
+ COMPREPLY=($(compgen -W 'bar dot' -- "$cur"))
return
;;
--bind-address)
_ip_addresses
return
;;
- --domains|--exclude-domains|-!(-*)D)
+ --domains | --exclude-domains | -!(-*)D)
_known_hosts_real -- "$cur"
return
;;
--restrict-file-names)
local excludes=()
case $cur in
- *unix*|*windows*)
- excludes=( windows unix )
+ *unix* | *windows*)
+ excludes=(windows unix)
;;&
- *lowercase*|*uppercase*)
- excludes+=( lowercase uppercase )
+ *lowercase* | *uppercase*)
+ excludes+=(lowercase uppercase)
;;&
*nocontrol*)
- excludes+=( nocontrol )
+ excludes+=(nocontrol)
;;&
*ascii*)
- excludes+=( ascii )
+ excludes+=(ascii)
;;
esac
- local excludes_str=$(export IFS='|'; echo "${excludes[*]}";)
+ local excludes_str=$(
+ export IFS='|'
+ echo "${excludes[*]}"
+ )
# prevopt is the previous options string used as a prefix
# to avoid COMPREPLY replacing them with the $lastopt completion
- local lastopt=${cur/*,} prevopt=
+ local lastopt=${cur/*,/} prevopt=
[[ $cur == *,* ]] && prevopt=${cur%,*},
- COMPREPLY=( $(compgen -P "$prevopt" -X "@($excludes_str)" \
+ COMPREPLY=($(compgen -P "$prevopt" -X "@($excludes_str)" \
-W 'unix windows nocontrol ascii lowercase uppercase' \
- -- "$lastopt") )
+ -- "$lastopt"))
# +o nospace when no more valid option is possible (= append a space)
- local opt_as_arr=( $(echo ${COMPREPLY[0]//,/ }) )
- [[ ${#opt_as_arr[@]} -lt 4 ]] && compopt -o nospace
+ local opt_as_arr=(${COMPREPLY[0]//,/ })
+ ((${#opt_as_arr[@]} < 4)) && compopt -o nospace
return
;;
--prefer-family)
- COMPREPLY=( $(compgen -W 'IPv4 IPv6 none' -- "$cur") )
+ COMPREPLY=($(compgen -W 'IPv4 IPv6 none' -- "$cur"))
return
;;
- --directory-prefix|--ca-directory|--warc-tempdir|-!(-*)P)
+ --directory-prefix | --ca-directory | --warc-tempdir | -!(-*)P)
_filedir -d
return
;;
- --output-file|--append-output|--config|--load-cookies|--save-cookies|\
- --post-file|--certificate|--ca-certificate|--private-key|\
- --random-file|--egd-file|--warc-file|--warc-dedup|-!(-*)[oa])
+ --output-file | --append-output | --config | --load-cookies | --save-cookies | \
+ --post-file | --certificate | --ca-certificate | --private-key | \
+ --random-file | --egd-file | --warc-file | --warc-dedup | -!(-*)[oa])
_filedir
return
;;
- --output-document|--input-file|-!(-*)[Oi])
- _filedir && [[ $cur == - || -z $cur ]] && COMPREPLY+=( - )
+ --output-document | --input-file | -!(-*)[Oi])
+ _filedir && [[ $cur == - || -z $cur ]] && COMPREPLY+=(-)
return
;;
--secure-protocol)
- COMPREPLY=( $(compgen -W 'auto SSLv2 SSLv3 TLSv1' -- "$cur") )
+ COMPREPLY=($(compgen -W 'auto SSLv2 SSLv3 TLSv1' -- "$cur"))
return
;;
- --certificate-type|--private-key-type)
- COMPREPLY=( $(compgen -W 'PEM DER' -- "$cur") )
+ --certificate-type | --private-key-type)
+ COMPREPLY=($(compgen -W 'PEM DER' -- "$cur"))
return
;;
- --follow-tags|--ignore-tags)
- local lastopt=${cur/*,} prevopt=
+ --follow-tags | --ignore-tags)
+ local lastopt=${cur/*,/} prevopt=
[[ $cur == *,* ]] && prevopt=${cur%,*},
- COMPREPLY=( $(compgen -P "$prevopt" -W 'a abbr acronym address
+ COMPREPLY=($(compgen -P "$prevopt" -W 'a abbr acronym address
applet area b base basefont bdo big blockquote body br button
caption center cite code col colgroup dd del dir div dfn dl dt
em fieldset font form frame frameset h6 head hr html i iframe
@@ -91,37 +94,37 @@ _wget()
noframes noscript object ol optgroup option p param pre q s
samp script select small span strike strong style sub sup table
tbody td textarea tfoot th thead title tr tt u ul var xmp' \
- -- "$lastopt") )
+ -- "$lastopt"))
return
;;
- --tries|--timeout|--dns-timeout|--connect-timeout|--read-timeout|\
- --wait|--waitretry|--cut-dirs|--max-redirect|--level|-!(-*)[tTwl])
+ --tries | --timeout | --dns-timeout | --connect-timeout | --read-timeout | \
+ --wait | --waitretry | --cut-dirs | --max-redirect | --level | -!(-*)[tTwl])
# expect integer number
- COMPREPLY+=( $(compgen -P "$cur" -W "{0..9}") )
+ COMPREPLY+=($(compgen -P "$cur" -W "{0..9}"))
compopt -o nospace
return
;;
- --quota|--limit-rate|--warc-max-size|-!(-*)Q)
+ --quota | --limit-rate | --warc-max-size | -!(-*)Q)
# expect size
if [[ $cur == *[km] ]]; then
- COMPREPLY=( $(compgen -W "$cur") )
+ COMPREPLY=($(compgen -W "$cur"))
elif [[ $cur ]]; then
- COMPREPLY=( $(compgen -P "$cur" -W "{0..9} k m") )
+ COMPREPLY=($(compgen -P "$cur" -W "{0..9} k m"))
compopt -o nospace
else
- COMPREPLY=( $(compgen -W "{0..9}") )
+ COMPREPLY=($(compgen -W "{0..9}"))
compopt -o nospace
fi
return
;;
- --user|--http-user|--proxy-user|--ftp-user)
- COMPREPLY=( $(compgen -W "$(command sed -n \
+ --user | --http-user | --proxy-user | --ftp-user)
+ COMPREPLY=($(compgen -W "$(command sed -n \
'/^login/s/^[[:blank:]]*login[[:blank:]]//p' ~/.netrc \
- 2>/dev/null)" -- "$cur") )
+ 2>/dev/null)" -- "$cur"))
return
;;
--header)
- COMPREPLY=( $(compgen -W 'Accept Accept-Charset Accept-Encoding
+ COMPREPLY=($(compgen -W 'Accept Accept-Charset Accept-Encoding
Accept-Language Accept-Ranges Age Allow Authorization
Cache-Control Connection Content-Encoding Content-Language
Content-Length Content-Location Content-MD5 Content-Range
@@ -130,29 +133,29 @@ _wget()
Last-Modified Location Max-Forwards Pragma Proxy-Authenticate
Proxy-Authorization Range Referer Retry-After Server TE Trailer
Transfer-Encoding Upgrade User-Agent Vary Via Warning
- WWW-Authenticate' -- "$cur") )
+ WWW-Authenticate' -- "$cur"))
compopt -o nospace
return
;;
- --local-encoding|--remote-encoding)
+ --local-encoding | --remote-encoding)
type -P xauth &>/dev/null && _xfunc iconv _iconv_charsets
return
;;
- --execute|-!(-*)e)
+ --execute | -!(-*)e)
return # TODO base=STR
;;
--report-speed)
- COMPREPLY=( $(compgen -W 'bits' -- "$cur") )
+ COMPREPLY=($(compgen -W 'bits' -- "$cur"))
return
;;
--regex-type)
- COMPREPLY=( $(compgen -W 'posix' -- "$cur") )
+ COMPREPLY=($(compgen -W 'posix' -- "$cur"))
return
;;
- --base|--password|--ftp-password|--http-password|--proxy-password|\
- --default-page|--referer|--user-agent|--post-data|--warc-header|\
- --accept|--reject|--accept-regex|--reject-regex|--include-directories|\
- --exclude-directories|-!(-*)[BUARIX])
+ --base | --password | --ftp-password | --http-password | --proxy-password | \
+ --default-page | --referer | --user-agent | --post-data | --warc-header | \
+ --accept | --reject | --accept-regex | --reject-regex | --include-directories | \
+ --exclude-directories | -!(-*)[BUARIX])
# argument required but no completions available
return
;;
@@ -161,11 +164,11 @@ _wget()
$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 _wget wget
+ complete -F _wget wget
# ex: filetype=sh
diff --git a/completions/wine b/completions/wine
index dab45ae4..429fede4 100644
--- a/completions/wine
+++ b/completions/wine
@@ -5,16 +5,16 @@ _wine()
local cur prev words cword
_init_completion || return
- if [[ $cword -eq 1 ]]; then
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '--help --version' -- "$cur") )
- [[ $COMPREPLY ]] && return
+ if ((cword == 1)); then
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '--help --version' -- "$cur"))
+ [[ ${COMPREPLY-} ]] && return
fi
_filedir '@([eE][xX][eE]?(.[sS][oO])|[cC][oO][mM]|[sS][cC][rR]|[mM][sS][iI])'
else
_filedir
fi
} &&
-complete -F _wine wine wine-development wine-stable
+ complete -F _wine wine wine-development wine-stable
# ex: filetype=sh
diff --git a/completions/withlist b/completions/withlist
index cd030a27..4142471e 100644
--- a/completions/withlist
+++ b/completions/withlist
@@ -5,14 +5,14 @@ _withlist()
local cur prev words cword
_init_completion || return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '--lock --interactive --run --all --quiet
- --help' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '--lock --interactive --run --all --quiet
+ --help' -- "$cur"))
else
_xfunc list_lists _mailman_lists
fi
} &&
-complete -F _withlist withlist
+ complete -F _withlist withlist
# ex: filetype=sh
diff --git a/completions/wodim b/completions/wodim
index ac1dc5a9..b308291d 100644
--- a/completions/wodim
+++ b/completions/wodim
@@ -5,19 +5,19 @@ _cdrecord()
local cur prev words cword
_init_completion -n = || return
- local i generic_options track_options track_mode
+ local generic_options track_options track_mode
# foo=bar style option
- if [[ "$cur" == *=* ]]; then
+ if [[ $cur == *=* ]]; then
prev=${cur%%=*}
cur=${cur#*=}
case $prev in
- textfile|cuefile|msifile)
+ textfile | cuefile | msifile)
_filedir
;;
blank)
- COMPREPLY=( $(compgen -W 'help all fast track unreserve trtail
- unclose session' -- "$cur") )
+ COMPREPLY=($(compgen -W 'help all fast track unreserve trtail
+ unclose session' -- "$cur"))
;;
driveropts)
if [[ $cur == *=* ]]; then
@@ -25,53 +25,55 @@ _cdrecord()
cur=${cur#*=}
case $prev in
varirec)
- COMPREPLY=( $(compgen -W "-2 -1 0 1 2" -- "$cur") )
+ COMPREPLY=($(compgen -W "-2 -1 0 1 2" -- "$cur"))
;;
gigarec)
- COMPREPLY=( $(compgen -W "0.6 0.7 0.8 1.0 1.2 1.3
- 1.4" -- "$cur") )
+ COMPREPLY=($(compgen -W "0.6 0.7 0.8 1.0 1.2 1.3
+ 1.4" -- "$cur"))
;;
tattoofile)
_filedir
;;
esac
else
- COMPREPLY=( $(compgen -W 'burnfree noburnfree varirec=
+ COMPREPLY=($(compgen -W 'burnfree noburnfree varirec=
gigarec= audiomaster forcespeed noforcespeed speedread
nospeedread singlesession nosinglesession hidecdr
- nohidecdr tattooinfo tattoofile=' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ nohidecdr tattooinfo tattoofile=' -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
fi
;;
driver)
- COMPREPLY=( $(compgen -W "$($1 driver=help 2>&1 | \
- awk 'NR > 1 { print $1 }') help" -- "$cur") )
+ COMPREPLY=($(compgen -W "$($1 driver=help 2>&1 |
+ awk 'NR > 1 { print $1 }') help" -- "$cur"))
;;
minbuf)
- COMPREPLY=( $(compgen -W '{25..95}' -- "$cur") )
+ COMPREPLY=($(compgen -W '{25..95}' -- "$cur"))
;;
esac
return
fi
- generic_options=( -version -v -V -d -silent -force -immed -dummy -clone \
- -dao -sao -tao -raw -raw96r -raw96p -raw16 -multi -msinfo -toc -atip \
- -fix -nofix -waiti -load -lock -eject -format -setdropts -checkdrive \
- -prcap -inq -scanbus --devices -reset -abort -overburn -ignsize \
- -useinfo -packet -noclose -text debug= kdebug= minbuf= msifile= \
- speed= blank= fs= ts= dev= gracetime= timeout= driver= driveropts= \
- defpregap= pktsize= mcn= textfile= cuefile= )
- track_options=( -audio -swab -data -mode2 -xa -xa1 -xa2 -xamix -cdi \
- -isosize -pad -nopad -shorttrack -noshorttrack -preemp -nopreemp \
- -copy -nocopy -scms isrc= index= padsize= pregap= tsize= )
+ generic_options=(-version -v -V -d -silent -force -immed -dummy -clone
+ -dao -sao -tao -raw -raw96r -raw96p -raw16 -multi -msinfo -toc -atip
+ -fix -nofix -waiti -load -lock -eject -format -setdropts -checkdrive
+ -prcap -inq -scanbus --devices -reset -abort -overburn -ignsize
+ -useinfo -packet -noclose -text "debug=" "kdebug=" "minbuf="
+ "msifile=" "speed=" "blank=" "fs=" "ts=" "dev=" "gracetime="
+ "timeout=" "driver=" "driveropts=" "defpregap=" "pktsize=" "mcn="
+ "textfile=" "cuefile=")
+ track_options=(-audio -swab -data -mode2 -xa -xa1 -xa2 -xamix -cdi
+ -isosize -pad -nopad -shorttrack -noshorttrack -preemp -nopreemp
+ -copy -nocopy -scms "isrc=" "index=" "padsize=" "pregap=" "tsize=")
# look if previous was either a file or a track option
track_mode=0
- if [[ $cword -gt 1 ]]; then
+ if ((cword > 1)); then
if [[ -f $prev ]]; then
track_mode=1
else
- for (( i=0; i < ${#track_options[@]}; i++ )); do
- if [[ "${track_options[i]}" == "$prev" ]]; then
+ local opt
+ for opt in "${track_options[@]}"; do
+ if [[ $opt == "$prev" ]]; then
track_mode=1
break
fi
@@ -82,13 +84,13 @@ _cdrecord()
# files are always eligible completion
_filedir
# track options are always available
- COMPREPLY+=( $(compgen -W '${track_options[@]}' -- "$cur") )
+ COMPREPLY+=($(compgen -W '${track_options[@]}' -- "$cur"))
# general options are no more available after file or track option
- if [[ $track_mode -eq 0 ]]; then
- COMPREPLY+=( $(compgen -W '${generic_options[@]}' -- "$cur") )
+ if ((track_mode == 0)); then
+ COMPREPLY+=($(compgen -W '${generic_options[@]}' -- "$cur"))
fi
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
} &&
-complete -F _cdrecord cdrecord wodim
+ complete -F _cdrecord cdrecord wodim
# ex: filetype=sh
diff --git a/completions/wol b/completions/wol
index 0222b24d..eada070b 100644
--- a/completions/wol
+++ b/completions/wol
@@ -6,20 +6,22 @@ _wol()
_init_completion -s -n : || return
case $prev in
- --version|--help|--port|--passwd|--wait|-!(-*)[Vpw])
+ --version | --help | --port | --passwd | --wait | -!(-*)[Vpw])
return
;;
- --host|--ipaddr|-!(-*)[hi])
+ --host | --ipaddr | -!(-*)[hi])
# Broadcast addresses
local PATH=$PATH:/sbin
- COMPREPLY=( $({ ip addr show || ifconfig -a; } 2>/dev/null | \
+ COMPREPLY=($({
+ ip addr show || ifconfig -a
+ } 2>/dev/null |
command sed -ne 's/.*[[:space:]]Bcast:\([^[:space:]]*\).*/\1/p' -ne \
- 's/.*inet.*[[:space:]]brd[[:space:]]\([^[:space:]]*\).*/\1/p' -ne \
- 's/.*[[:space:]]broadcast[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p') )
+ 's/.*inet.*[[:space:]]brd[[:space:]]\([^[:space:]]*\).*/\1/p' -ne \
+ 's/.*[[:space:]]broadcast[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p'))
_known_hosts_real -- "$cur"
return
;;
- --file|-!(-*)f)
+ --file | -!(-*)f)
_filedir
return
;;
@@ -27,14 +29,14 @@ _wol()
$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
_mac_addresses
} &&
-complete -F _wol wol
+ complete -F _wol wol
# ex: filetype=sh
diff --git a/completions/wsimport b/completions/wsimport
index 406a47d7..d5bec9fe 100644
--- a/completions/wsimport
+++ b/completions/wsimport
@@ -6,7 +6,7 @@ _wsimport()
_init_completion -n : || return
case $prev in
- -help|-version|-B|-p|-wsdllocation)
+ -help | -version | -B | -p | -wsdllocation)
return
;;
-b)
@@ -17,12 +17,12 @@ _wsimport()
_filedir '@(xml|soc|catalog)'
return
;;
- -d|–s)
+ -d | –s)
_filedir -d
return
;;
-target)
- COMPREPLY=( $(compgen -W '2.0 2.1 2.2' -- "$cur") )
+ COMPREPLY=($(compgen -W '2.0 2.1 2.2' -- "$cur"))
return
;;
-clientjar)
@@ -35,14 +35,14 @@ _wsimport()
_known_hosts_real -- "${cur#-httpproxy:}"
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
__ltrim_colon_completions "$cur"
return
fi
_filedir wsdl
} &&
-complete -F _wsimport wsimport
+ complete -F _wsimport wsimport
# ex: filetype=sh
diff --git a/completions/wtf b/completions/wtf
index 6a596a3b..27fc10a7 100644
--- a/completions/wtf
+++ b/completions/wtf
@@ -7,34 +7,36 @@ _wtf()
_init_completion || return
[[ $prev == -f ]] && _filedir && return
- [[ "${words[*]}" == *\ -f* ]] && addf= || addf=-f
+ [[ ${words[*]} == *\ -f* ]] && addf= || addf=-f
if [[ $cur == -* ]]; then
- COMPREPLY=( $addf )
+ COMPREPLY=($addf)
return
fi
local db
set -- "${words[@]}"
- while [[ $# -gt 0 ]]; do
+ while (($# > 0)); do
if [[ $1 == -f ]]; then
- shift ; db=$1 ; break
+ shift
+ db=$1
+ break
fi
shift
done
- if [[ -z "$db" ]]; then
+ if [[ ! -v db ]]; then
local f
- for f in "$ACRONYMDB" /usr/share/misc/acronyms \
+ for f in "${ACRONYMDB-}" /usr/share/misc/acronyms \
/usr/share/games/bsdgames/acronyms; do
- [[ -f "$f" ]] && db="$f" && break
+ [[ -f $f ]] && db="$f" && break
done
- [[ -z "$db" ]] && return
+ [[ -v db ]] || return
fi
- COMPREPLY=( $(compgen -W "$(cut -f 1 -s $db* 2>/dev/null) $addf" \
- -- "${cur^^}") )
+ COMPREPLY=($(compgen -W "$(cut -f 1 -s $db* 2>/dev/null) $addf" \
+ -- "${cur^^}"))
} &&
-complete -F _wtf wtf
+ complete -F _wtf wtf
# ex: filetype=sh
diff --git a/completions/wvdial b/completions/wvdial
index e0316617..86674002 100644
--- a/completions/wvdial
+++ b/completions/wvdial
@@ -18,29 +18,29 @@ _wvdial()
case $cur in
-*)
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
;;
*)
# start with global and personal config files
config="/etc/wvdial.conf"$'\n'"$HOME/.wvdialrc"
# replace with command line config file if present
- for (( i=1; i < cword; i++ )); do
- if [[ "${words[i]}" == "--config" ]]; then
- config=${words[i+1]}
+ for ((i = 1; i < cword; i++)); do
+ if [[ ${words[i]} == "--config" ]]; then
+ config=${words[i + 1]}
break
fi
done
# parse config files for sections and
# remove default section
- COMPREPLY=( $(command sed -ne "s|^\[Dialer \($cur.*\)\]$|\1|p" $config \
+ COMPREPLY=($(command sed -ne "s|^\[Dialer \($cur.*\)\]$|\1|p" $config \
2>/dev/null | command grep -v '^Defaults$'))
# escape spaces
- COMPREPLY=${COMPREPLY// /\\ }
+ COMPREPLY=(${COMPREPLY[@]// /\\ })
;;
esac
} &&
-complete -F _wvdial wvdial
+ complete -F _wvdial wvdial
# ex: filetype=sh
diff --git a/completions/xdg-mime b/completions/xdg-mime
index 72e92c66..74c26c43 100644
--- a/completions/xdg-mime
+++ b/completions/xdg-mime
@@ -2,9 +2,9 @@
_xdg_mime_mimetype()
{
- COMPREPLY+=( $(compgen -S / -W 'application audio font image message model
- multipart text video' -- "$cur") )
- [[ $COMPREPLY == */ ]] && compopt -o nospace
+ COMPREPLY+=($(compgen -S / -W 'application audio font image message model
+ multipart text video' -- "$cur"))
+ [[ ${COMPREPLY-} == */ ]] && compopt -o nospace
}
_xdg_mime()
@@ -15,59 +15,60 @@ _xdg_mime()
local args
_count_args
- if [[ $args -eq 1 ]]; then
+ if ((args == 1)); then
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '--help --manual --version' -- "$cur") )
+ COMPREPLY=($(compgen -W '--help --manual --version' -- "$cur"))
return
fi
- COMPREPLY=( $(compgen -W \
- 'query default install uninstall' -- "$cur") )
+ COMPREPLY=($(compgen -W \
+ 'query default install uninstall' -- "$cur"))
return
fi
case ${words[1]} in
query)
- if [[ $args -eq 2 ]]; then
- COMPREPLY=( $(compgen -W 'filetype default' -- "$cur") )
+ if ((args == 2)); then
+ COMPREPLY=($(compgen -W 'filetype default' -- "$cur"))
return
fi
- case ${words[2]} in # TODO and $args -eq 3 (takes only one arg!)
+ case ${words[2]} in # TODO and args == 3 (takes only one arg!)
filetype) _filedir ;;
default) _xdg_mime_mimetype ;;
esac
;;
default)
- if [[ $args -eq 2 ]]; then
- local IFS=$' \t\n' reset=$(shopt -p nullglob); shopt -s nullglob
- local -a desktops=( /usr/share/applications/*.desktop )
- desktops=( "${desktops[@]##*/}" )
+ if ((args == 2)); then
+ local IFS=$' \t\n' reset=$(shopt -p nullglob)
+ shopt -s nullglob
+ local -a desktops=(/usr/share/applications/*.desktop)
+ desktops=("${desktops[@]##*/}")
$reset
IFS=$'\n'
- COMPREPLY=( $(compgen -W '${desktops[@]}' -- "$cur") )
+ COMPREPLY=($(compgen -W '${desktops[@]}' -- "$cur"))
else
_xdg_mime_mimetype
fi
;;
install)
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '--mode --novendor' -- "$cur") )
+ COMPREPLY=($(compgen -W '--mode --novendor' -- "$cur"))
elif [[ $prev == --mode ]]; then
- COMPREPLY=( $(compgen -W 'user system' -- "$cur") )
+ COMPREPLY=($(compgen -W 'user system' -- "$cur"))
else
_filedir xml
fi
;;
uninstall)
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '--mode' -- "$cur") )
+ COMPREPLY=($(compgen -W '--mode' -- "$cur"))
elif [[ $prev == --mode ]]; then
- COMPREPLY=( $(compgen -W 'user system' -- "$cur") )
+ COMPREPLY=($(compgen -W 'user system' -- "$cur"))
else
_filedir xml
fi
;;
esac
} &&
-complete -F _xdg_mime xdg-mime
+ complete -F _xdg_mime xdg-mime
# ex: filetype=sh
diff --git a/completions/xdg-settings b/completions/xdg-settings
index c14d37ba..abd92464 100644
--- a/completions/xdg-settings
+++ b/completions/xdg-settings
@@ -6,26 +6,26 @@ _xdg_settings()
_init_completion || return
case $prev in
- --help|--list|--manual|--version)
+ --help | --list | --manual | --version)
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$("$1" --help |
- tr "{|" "\n" | _parse_help -)' -- "$cur") )
+ COMPREPLY=($(compgen -W '$("$1" --help |
+ tr "{|" "\n" | _parse_help -)' -- "$cur"))
return
fi
local args
_count_args
- if [[ $args -eq 1 ]]; then
- COMPREPLY=( $(compgen -W "get check set" -- "$cur") )
- elif [[ $args -eq 2 ]]; then
- COMPREPLY=( $(compgen -W \
- '$("$1" --list | awk "!/^Known/ { print \$1 }")' -- "$cur") )
+ if ((args == 1)); then
+ COMPREPLY=($(compgen -W "get check set" -- "$cur"))
+ elif ((args == 2)); then
+ COMPREPLY=($(compgen -W \
+ '$("$1" --list | awk "!/^Known/ { print \$1 }")' -- "$cur"))
fi
} &&
-complete -F _xdg_settings xdg-settings
+ complete -F _xdg_settings xdg-settings
# ex: filetype=sh
diff --git a/completions/xfreerdp b/completions/xfreerdp
index f025cfce..f17414f2 100644
--- a/completions/xfreerdp
+++ b/completions/xfreerdp
@@ -5,63 +5,63 @@ _xfreerdp()
local cur prev words cword
_init_completion -n : || return
- case $prev in # old/dash syntax
+ case $prev in # old/dash syntax
-k)
- COMPREPLY=( $(compgen -W '$("$1" --kbd-list |
- awk "/^0x/ { print \$1 }")' -- "$cur") )
+ COMPREPLY=($(compgen -W '$("$1" --kbd-list |
+ awk "/^0x/ { print \$1 }")' -- "$cur"))
return
;;
-a)
- COMPREPLY=( $(compgen -W '8 15 16 24 32' -- "$cur") )
+ COMPREPLY=($(compgen -W '8 15 16 24 32' -- "$cur"))
return
;;
-x)
- COMPREPLY=( $(compgen -W 'broadband modem lan' -- "$cur") )
+ COMPREPLY=($(compgen -W 'broadband modem lan' -- "$cur"))
return
;;
--plugin)
- COMPREPLY=( $(compgen -W 'cliprdr rdpsnd rdpdr' -- "$cur") )
+ COMPREPLY=($(compgen -W 'cliprdr rdpsnd rdpdr' -- "$cur"))
return
;;
esac
- case $cur in # new/slash syntax
+ case $cur in # new/slash syntax
/kbd:*)
- COMPREPLY=( $(compgen -W '$("$1" /kbd-list |
- awk "/^0x/ { print \$1 }")' -- "${cur#/kbd:}") )
+ COMPREPLY=($(compgen -W '$("$1" /kbd-list |
+ awk "/^0x/ { print \$1 }")' -- "${cur#/kbd:}"))
return
;;
/bpp:*)
- COMPREPLY=( $(compgen -W '8 15 16 24 32' -- "${cur#/bpp:}") )
+ COMPREPLY=($(compgen -W '8 15 16 24 32' -- "${cur#/bpp:}"))
return
;;
- /*:*|/help|/version|-h|--help|--version)
+ /*:* | /help | /version | -h | --help | --version)
return
;;
esac
- if [[ "$cur" == /* ]]; then
- COMPREPLY=( $(compgen -W '$("$1" --help |
+ if [[ $cur == /* ]]; then
+ COMPREPLY=($(compgen -W '$("$1" --help |
awk "\$1 ~ /^\\// && \$1 !~ /^.(flag\$|option:)/ { sub(\":.*\",\":\",\$1); print \$1 }")' \
- -- "$cur") )
- [[ $COMPREPLY == *: ]] && compopt -o nospace
- elif [[ "$cur" == [+-]* ]]; then
+ -- "$cur"))
+ [[ ${COMPREPLY-} == *: ]] && compopt -o nospace
+ elif [[ $cur == [+-]* ]]; then
local char=${cur:0:1}
local help="$($1 --help)"
- if [[ "$help" == */help* ]]; then # new/slash syntax
- COMPREPLY=( $(compgen -W '$(awk "
+ if [[ $help == */help* ]]; then # new/slash syntax
+ COMPREPLY=($(compgen -W '$(awk "
\$1 ~ /^[+-]/ && \$1 !~ /^.toggle\$/ { sub(\"^.\",\"$char\",\$1); print \$1 }
- " <<<"$help")' -- "$cur") )
- else # old/dash syntax
- COMPREPLY=( $(_parse_help - <<<"$help") )
- COMPREPLY=( $(compgen -W '${COMPREPLY[@]%:}' -- "$cur") )
+ " <<<"$help")' -- "$cur"))
+ else # old/dash syntax
+ COMPREPLY=($(_parse_help - <<<"$help"))
+ COMPREPLY=($(compgen -W '${COMPREPLY[@]%:}' -- "$cur"))
fi
else
- COMPREPLY=( $(compgen -W "$(awk '{print $1}' ~/.freerdp/known_hosts \
- 2>/dev/null)" -- "$cur") )
+ COMPREPLY=($(compgen -W "$(awk '{print $1}' ~/.freerdp/known_hosts \
+ 2>/dev/null)" -- "$cur"))
fi
} &&
-complete -F _xfreerdp xfreerdp
+ complete -F _xfreerdp xfreerdp
# ex: filetype=sh
diff --git a/completions/xgamma b/completions/xgamma
index 005928d2..8d77ba3b 100644
--- a/completions/xgamma
+++ b/completions/xgamma
@@ -9,37 +9,37 @@ _xgamma()
-screen)
local screens=$(xrandr --query 2>/dev/null | command sed -n \
'/^Screen /s|^Screen \{1,\}\(.*\):.*$|\1|p' 2>/dev/null)
- COMPREPLY=( $(compgen -W "$screens" -- "$cur") )
+ COMPREPLY=($(compgen -W "$screens" -- "$cur"))
return
;;
- -gamma|-rgamma|-ggamma|-bgamma)
+ -gamma | -rgamma | -ggamma | -bgamma)
# expect f.f
- if [[ $cur && "$cur" != *.* ]]; then
- COMPREPLY=( . )
+ if [[ $cur && $cur != *.* ]]; then
+ COMPREPLY=(.)
fi
- COMPREPLY+=( $(compgen -W "{0..9}") )
+ COMPREPLY+=($(compgen -W "{0..9}"))
compopt -o nospace
return
;;
-display)
# expect hostname:displaynumber.screennumber
- if [[ "$cur" == :* && "$cur" != :*.* ]]; then
+ if [[ $cur == :* && $cur != :*.* ]]; then
# FIXME: where to get local display numbers?
local display=${cur#:}
- COMPREPLY=( $(compgen -W "${display:-0}.") )
+ COMPREPLY=($(compgen -W "${display:-0}."))
compopt -o nospace
- elif [[ "$cur" == :*.* ]]; then
+ elif [[ $cur == :*.* ]]; then
# local screen numbers
local t screens=$(xrandr --query 2>/dev/null | command sed -ne \
'/^Screen /s|^Screen \{1,\}\(.*\):.*$|\1|p' 2>/dev/null)
t="${cur#:}"
- COMPREPLY=( $(compgen -P "${t%.*}." -W "$screens" -- \
- "${cur##*.}") )
- elif [[ "$cur" != *:* ]]; then
+ COMPREPLY=($(compgen -P "${t%.*}." -W "$screens" -- \
+ "${cur##*.}"))
+ elif [[ $cur != *:* ]]; then
# complete hostnames
_known_hosts_real -c -- "$cur"
if [[ ! $cur ]]; then
- COMPREPLY+=( : )
+ COMPREPLY+=(:)
fi
compopt -o nospace
fi
@@ -48,12 +48,14 @@ _xgamma()
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
- [[ $COMPREPLY ]] && return
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
+ if [[ ${COMPREPLY-} ]]; then
+ [[ $COMPREPLY == *= ]] && compopt -o nospace
+ return
+ fi
fi
} &&
-complete -F _xgamma xgamma
+ complete -F _xgamma xgamma
# ex: filetype=sh
diff --git a/completions/xhost b/completions/xhost
index 53b3695b..648ae4f1 100644
--- a/completions/xhost
+++ b/completions/xhost
@@ -1,6 +1,6 @@
# xhost(1) completion -*- shell-script -*-
-_xhost ()
+_xhost()
{
local cur prev words cword
_init_completion || return
@@ -8,9 +8,9 @@ _xhost ()
case $cur in
+*) _known_hosts_real -p+ -- "${cur:1}" ;;
-*) _known_hosts_real -p- -- "${cur:1}" ;;
- *) _known_hosts_real -- "$cur" ;;
+ *) _known_hosts_real -- "$cur" ;;
esac
} &&
-complete -F _xhost xhost
+ complete -F _xhost xhost
# ex: filetype=sh
diff --git a/completions/xmllint b/completions/xmllint
index f5865b39..a6ef38f4 100644
--- a/completions/xmllint
+++ b/completions/xmllint
@@ -6,11 +6,11 @@ _xmllint()
_init_completion || return
case $prev in
- -o|--output)
+ -o | --output)
_filedir
return
;;
- --path|--dtdvalidfpi|--maxmem|--pattern|--xpath)
+ --path | --dtdvalidfpi | --maxmem | --pattern | --xpath)
# argument required but no completions available
return
;;
@@ -35,19 +35,19 @@ _xmllint()
return
;;
--pretty)
- COMPREPLY=( $(compgen -W '{0..2}' -- "$cur") )
+ COMPREPLY=($(compgen -W '{0..2}' -- "$cur"))
return
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
- COMPREPLY=( "${COMPREPLY[@]%:}" )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ COMPREPLY=("${COMPREPLY[@]%:}")
return
fi
_filedir '@(*ml|htm|svg?(z)|xs[dl]|rng|wsdl|jnlp|tld|dbk|docbook|page)?(.gz)'
} &&
-complete -F _xmllint xmllint
+ complete -F _xmllint xmllint
# ex: filetype=sh
diff --git a/completions/xmlwf b/completions/xmlwf
index 9cd0e195..b397af94 100644
--- a/completions/xmlwf
+++ b/completions/xmlwf
@@ -11,8 +11,8 @@ _xmlwf()
return
;;
-*e)
- COMPREPLY=( $(compgen -W 'US-ASCII UTF-8 UTF-16 ISO-8859-1' \
- -- "$cur") )
+ COMPREPLY=($(compgen -W 'US-ASCII UTF-8 UTF-16 ISO-8859-1' \
+ -- "$cur"))
return
;;
-*v)
@@ -20,13 +20,13 @@ _xmlwf()
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur"))
return
fi
_filedir '@(*ml|htm|svg|xs[dl]|rng|wsdl|jnlp|tld|dbk|docbook|page)'
} &&
-complete -F _xmlwf xmlwf
+ complete -F _xmlwf xmlwf
# ex: filetype=sh
diff --git a/completions/xmms b/completions/xmms
index 9f084c38..af4aefe9 100644
--- a/completions/xmms
+++ b/completions/xmms
@@ -6,24 +6,24 @@ _xmms()
_init_completion -s || return
case $prev in
- --help|--version|-!(-*)[hv])
+ --help | --version | -!(-*)[hv])
return
;;
- --toggle-shuffle|--toggle-repeat|--toggle-advance|-!(-*)[SRA])
- COMPREPLY=( $(compgen -W 'on off' -- "$cur") )
+ --toggle-shuffle | --toggle-repeat | --toggle-advance | -!(-*)[SRA])
+ COMPREPLY=($(compgen -W 'on off' -- "$cur"))
return
;;
esac
$split && return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
else
_filedir '@(mp[23]|ogg|wav|pls|m3u|xm|mod|s[3t]m|it|mtm|ult|flac)'
fi
} &&
-complete -F _xmms xmms
+ complete -F _xmms xmms
# ex: filetype=sh
diff --git a/completions/xmodmap b/completions/xmodmap
index 38bc6391..7cfa230b 100644
--- a/completions/xmodmap
+++ b/completions/xmodmap
@@ -6,18 +6,18 @@ _xmodmap()
_init_completion || return
case $prev in
- -display|-e)
+ -display | -e)
return
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" -help)' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" -help)' -- "$cur"))
return
fi
_filedir
} &&
-complete -F _xmodmap xmodmap
+ complete -F _xmodmap xmodmap
# ex: filetype=sh
diff --git a/completions/xrandr b/completions/xrandr
index 9b5b6a59..16704e31 100644
--- a/completions/xrandr
+++ b/completions/xrandr
@@ -6,58 +6,58 @@ _xrandr()
_init_completion || return
case "$prev" in
- -display|-d|-help|-s|--size|-r|--rate|--refresh|--screen|--fb|--fbmm|\
- --dpi|--pos|--set|--scale|--transform|--crtc|--panning|--gamma|\
- --newmode|--rmmode|--addmode|--delmode)
+ -display | -d | -help | -s | --size | -r | --rate | --refresh | --screen | --fb | --fbmm | \
+ --dpi | --pos | --set | --scale | --transform | --crtc | --panning | --gamma | \
+ --newmode | --rmmode | --addmode | --delmode)
return
;;
- --output|--left-of|--right-of|--above|--below|--same-as)
+ --output | --left-of | --right-of | --above | --below | --same-as)
local outputs=$("$1" | awk '/connected/ {print $1}')
- COMPREPLY=( $(compgen -W "$outputs" -- "$cur") )
+ COMPREPLY=($(compgen -W "$outputs" -- "$cur"))
return
;;
--mode)
local i output
- for (( i=1; i < cword; i++ )); do
- if [[ "${words[i]}" == --output ]]; then
- output=${words[i+1]}
+ for ((i = 1; i < cword; i++)); do
+ if [[ ${words[i]} == --output ]]; then
+ output=${words[i + 1]}
break
fi
done
- if [[ $output ]]; then
+ if [[ -v output ]]; then
local modes=$("$1" | command sed -e "1,/^$output / d" \
-e "/connected/,$ d" \
-e "s/\([^[:space:]]\)[[:space:]].*/\1/")
- COMPREPLY=( $(compgen -W "$modes" -- "$cur") )
+ COMPREPLY=($(compgen -W "$modes" -- "$cur"))
fi
return
;;
- -o|--orientation)
- COMPREPLY=( $(compgen -W 'normal inverted left right 0 1 2 3' -- \
- "$cur") )
+ -o | --orientation)
+ COMPREPLY=($(compgen -W 'normal inverted left right 0 1 2 3' -- \
+ "$cur"))
return
;;
--reflect)
- COMPREPLY=( $(compgen -W 'normal x y xy' -- "$cur") )
+ COMPREPLY=($(compgen -W 'normal x y xy' -- "$cur"))
return
;;
--rotate)
- COMPREPLY=( $(compgen -W 'normal inverted left right' -- "$cur") )
+ COMPREPLY=($(compgen -W 'normal inverted left right' -- "$cur"))
return
;;
- --setprovideroutputsource|--setprovideroffloadsink)
+ --setprovideroutputsource | --setprovideroffloadsink)
local providers=$("$1" --listproviders 2>/dev/null |
command sed -ne 's/.* name:\([^ ]*\).*/\1/p')
- COMPREPLY=( $(compgen -W "$providers" -- "$cur") )
+ COMPREPLY=($(compgen -W "$providers" -- "$cur"))
# TODO 2nd arg needed, is that a provider as well?
return
;;
esac
- COMPREPLY=( $(compgen -W '$("$1" -help 2>&1 |
+ COMPREPLY=($(compgen -W '$("$1" -help 2>&1 |
command sed -e "s/ or / /g" -e "s/<[^>]*>]//g" | _parse_help -)' \
- -- "$cur") )
+ -- "$cur"))
} &&
-complete -F _xrandr xrandr
+ complete -F _xrandr xrandr
# ex: filetype=sh
diff --git a/completions/xrdb b/completions/xrdb
index d9f11439..f46f90b9 100644
--- a/completions/xrdb
+++ b/completions/xrdb
@@ -6,22 +6,22 @@ _xrdb()
_init_completion || return
case $prev in
- -backup|-display|-help)
+ -backup | -display | -help)
return
;;
- -cpp|-edit)
+ -cpp | -edit)
_filedir
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 _xrdb xrdb
+ complete -F _xrdb xrdb
# ex: filetype=sh
diff --git a/completions/xsltproc b/completions/xsltproc
index dbe68c45..4cb70719 100644
--- a/completions/xsltproc
+++ b/completions/xsltproc
@@ -6,7 +6,7 @@ _xsltproc()
_init_completion || return
case $prev in
- --output|-o)
+ --output | -o)
_filedir
return
;;
@@ -16,11 +16,11 @@ _xsltproc()
;;
--encoding)
# some aliases removed
- COMPREPLY=( $(compgen -X '@(UTF[1378]|8859|ISO[0-9_])*' \
- -W "$(iconv -l | command sed -e 's/\/.*//')" -- "$cur") )
+ COMPREPLY=($(compgen -X '@(UTF[1378]|8859|ISO[0-9_])*' \
+ -W "$(iconv -l | command sed -e 's/\/.*//')" -- "$cur"))
return
;;
- --param|--stringparam)
+ --param | --stringparam)
return
;;
# not really like --writesubtree
@@ -34,16 +34,16 @@ _xsltproc()
;;
esac
- [[ $cword -gt 2 && `_get_cword '' 2` == --?(string)param ]] && return
+ [[ $cword -gt 2 && $(_get_cword '' 2) == --?(string)param ]] && return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
- COMPREPLY=( "${COMPREPLY[@]%:}" )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
+ COMPREPLY=("${COMPREPLY[@]%:}")
else
# TODO: 1st file xsl|xslt, 2nd XML
_filedir '@(xsl|xslt|xml|dbk|docbook|page)'
fi
} &&
-complete -F _xsltproc xsltproc
+ complete -F _xsltproc xsltproc
# ex: filetype=sh
diff --git a/completions/xvfb-run b/completions/xvfb-run
index 162c66ed..ed2788a9 100644
--- a/completions/xvfb-run
+++ b/completions/xvfb-run
@@ -6,7 +6,7 @@ _xvfb_run()
_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,10 +15,10 @@ _xvfb_run()
done
case $prev in
- --help|--server-num|--xauth-protocol|--server-args|-!(-*)[hnps])
+ --help | --server-num | --xauth-protocol | --server-args | -!(-*)[hnps])
return
;;
- --error-file|--auth-file|-!(-*)[ef])
+ --error-file | --auth-file | -!(-*)[ef])
_filedir
return
;;
@@ -26,11 +26,11 @@ _xvfb_run()
$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 _xvfb_run xvfb-run
+ complete -F _xvfb_run xvfb-run
# ex: filetype=sh
diff --git a/completions/xxd b/completions/xxd
index f6bcb4a2..a470bb0d 100644
--- a/completions/xxd
+++ b/completions/xxd
@@ -6,18 +6,18 @@ _xxd()
_init_completion || return
case $prev in
- -h|-help|-c|-cols|-g|-groupsize|-l|-len|-s|-seek|-v|-version)
+ -h | -help | -c | -cols | -g | -groupsize | -l | -len | -s | -seek | -v | -version)
return
;;
esac
if [[ $cur == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" -h)' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur"))
return
fi
_filedir
} &&
-complete -F _xxd xxd
+ complete -F _xxd xxd
# ex: filetype=sh
diff --git a/completions/xz b/completions/xz
index b64921f1..73958c50 100644
--- a/completions/xz
+++ b/completions/xz
@@ -8,40 +8,40 @@ _xz()
local xspec="*.@(xz|lzma|txz|tlz)"
case $prev in
- --decompress|--list|--test|-!(-*)[dlt]*)
+ --decompress | --list | --test | -!(-*)[dlt]*)
xspec="!"$xspec
;;
- --files|--files0)
+ --files | --files0)
_filedir
return
;;
- --check|-!(-*)C)
- COMPREPLY=( $(compgen -W 'crc32 crc64 sha256 none' -- "$cur") )
+ --check | -!(-*)C)
+ COMPREPLY=($(compgen -W 'crc32 crc64 sha256 none' -- "$cur"))
return
;;
- --format|-!(-*)F)
- COMPREPLY=( $(compgen -W 'auto xz lzma raw' -- "$cur") )
+ --format | -!(-*)F)
+ COMPREPLY=($(compgen -W 'auto xz lzma raw' -- "$cur"))
return
;;
- --threads|-!(-*)T)
- COMPREPLY=( $(compgen -W "{0..$(_ncpus)}" -- "$cur") )
+ --threads | -!(-*)T)
+ COMPREPLY=($(compgen -W "{0..$(_ncpus)}" -- "$cur"))
return
;;
- --memlimit|--memlimit-compress|--memlimit-decompress|--memory|\
- --suffix|--delta|--lzma1|--lzma2|-!(-*)[MS])
+ --memlimit | --memlimit-compress | --memlimit-decompress | --memory | \
+ --suffix | --delta | --lzma1 | --lzma2 | -!(-*)[MS])
return
;;
- --help|--long-help|--version|--info-memory|-!(-*)[hHV])
+ --help | --long-help | --version | --info-memory | -!(-*)[hHV])
return
;;
esac
$split && return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '$(_parse_help "$1" --long-help) {-1..-9}' \
- -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '$(_parse_help "$1" --long-help) {-1..-9}' \
+ -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
@@ -49,8 +49,8 @@ _xz()
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 _xz xz pxz
+ complete -F _xz xz pxz
# ex: filetype=sh
diff --git a/completions/xzdec b/completions/xzdec
index 6b402eb3..993bd2b2 100644
--- a/completions/xzdec
+++ b/completions/xzdec
@@ -6,24 +6,24 @@ _xzdec()
_init_completion -s || return
case $prev in
- --memory|-!(-*)M)
+ --memory | -!(-*)M)
return
;;
- --help|--version|-!(-*)[hV])
+ --help | --version | -!(-*)[hV])
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
_filedir xz # no lzma support here as of xz 4.999.9beta
} &&
-complete -F _xzdec xzdec
+ complete -F _xzdec xzdec
# ex: filetype=sh
diff --git a/completions/ypmatch b/completions/ypmatch
index 655390f2..13249f06 100644
--- a/completions/ypmatch
+++ b/completions/ypmatch
@@ -12,15 +12,15 @@ _ypmatch()
if [[ $cmd == ypmatch && $cword -eq 1 && ${#words[@]} -eq 3 ]]; then
map=${words[2]}
- COMPREPLY=( $(compgen -W '$(ypcat $map 2>/dev/null | \
- cut -d':' -f 1)' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(ypcat $map 2>/dev/null | \
+ cut -d':' -f 1)' -- "$cur"))
else
[[ $cmd == ypmatch && $cword -ne 2 ]] && return
- COMPREPLY=( $(compgen -W \
+ COMPREPLY=($(compgen -W \
'$(printf "%s\n" $(ypcat -x 2>/dev/null | \
- cut -d"\"" -f 2))' -- "$cur") )
+ cut -d"\"" -f 2))' -- "$cur"))
fi
} &&
-complete -F _ypmatch ypmatch ypcat
+ complete -F _ypmatch ypmatch ypcat
# ex: filetype=sh
diff --git a/completions/yum-arch b/completions/yum-arch
index f2b902a3..883c77e1 100644
--- a/completions/yum-arch
+++ b/completions/yum-arch
@@ -5,12 +5,12 @@ _yum_arch()
local cur prev words cword
_init_completion || return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '-d -v -vv -n -c -z -s -l -q' -- "$cur") )
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '-d -v -vv -n -c -z -s -l -q' -- "$cur"))
else
_filedir -d
fi
} &&
-complete -F _yum_arch yum-arch
+ complete -F _yum_arch yum-arch
# ex: filetype=sh
diff --git a/completions/zopfli b/completions/zopfli
index 3c7ea403..8c02885e 100644
--- a/completions/zopfli
+++ b/completions/zopfli
@@ -11,10 +11,10 @@ _zopfli()
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W \
- '$(_parse_help "$1" -h | command sed -e "s/#$//")' -- "$cur") )
- [[ $COMPREPLY == --i ]] && compopt -o nospace
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W \
+ '$(_parse_help "$1" -h | command sed -e "s/#$//")' -- "$cur"))
+ [[ ${COMPREPLY-} == --i ]] && compopt -o nospace
return
fi
@@ -22,8 +22,8 @@ _zopfli()
local IFS=$'\n' xspec="*.@(gz|t[ag]z)"
compopt -o filenames
- COMPREPLY=( $(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur") )
+ COMPREPLY=($(compgen -f -X "$xspec" -- "$cur") $(compgen -d -- "$cur"))
} &&
-complete -F _zopfli zopfli
+ complete -F _zopfli zopfli
# ex: filetype=sh
diff --git a/completions/zopflipng b/completions/zopflipng
index 3d815404..4526cd92 100644
--- a/completions/zopflipng
+++ b/completions/zopflipng
@@ -6,34 +6,34 @@ _zopflipng()
_init_completion -s || return
case $prev in
- -h|--help)
+ -h | --help)
return
;;
--splitting)
- COMPREPLY=( $(compgen -W '{0..3}' -- "$cur") )
+ COMPREPLY=($(compgen -W '{0..3}' -- "$cur"))
return
;;
esac
$split && return
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(_parse_help "$1" -h) )
- COMPREPLY=( $(compgen -W '${COMPREPLY[@]%:}' -- "$cur") )
- [[ $COMPREPLY == *= ]] && compopt -o nospace
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(_parse_help "$1" -h))
+ COMPREPLY=($(compgen -W '${COMPREPLY[@]%:}' -- "$cur"))
+ [[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- if [[ "${words[*]}" != *\ --prefix=* ]]; then
+ if [[ ${words[*]} != *\ --prefix=* ]]; then
# 2 png args only if --prefix not given
local args
_count_args
- [[ $args -lt 3 ]] && _filedir png
+ ((args < 3)) && _filedir png
else
# otherwise arbitrary number of png args
_filedir png
fi
} &&
-complete -F _zopflipng zopflipng
+ complete -F _zopflipng zopflipng
# ex: filetype=sh
diff --git a/configure.ac b/configure.ac
index 570c85a8..9f1abc27 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
AC_PREREQ([2.60])
-AC_INIT([bash-completion], [2.10])
+AC_INIT([bash-completion], [2.11])
AM_INIT_AUTOMAKE([foreign dist-xz no-dist-gzip -Wall -Wno-portability -Werror])
AC_PROG_LN_S
AC_PROG_MKDIR_P
diff --git a/doc/styleguide.txt b/doc/styleguide.txt
index 31ad4469..2251e773 100644
--- a/doc/styleguide.txt
+++ b/doc/styleguide.txt
@@ -61,7 +61,7 @@ need that kind of processing (e.g. file and command names). The
_filedir and _filedir_xspec helpers do this automatically whenever
they return some completions.
-&#91;[ $COMPREPLY == *= ]] && compopt -o nospace
+&#91;[ ${COMPREPLY-} == *= ]] && compopt -o nospace
------------------------------------------------
The above is functionally a shorthand for:
@@ -95,6 +95,29 @@ explicitly handled (non-completed) in the $prev handling block because
--foo=bar options can often be written without the equals sign, and in
that case the long option splitting does not occur.
+Use arithmetic evaluation
+-------------------------
+
+When dealing with numeric data, take advantage of arithmetic evaluation.
+In essence, use (( ... )) whenever it can replace [[ ... ]] because the
+syntax is more readable; no need for $-prefixes, numeric comparison etc
+operators are more familiar and easier on the eye.
+
+Array subscript access
+----------------------
+
+Array subscripts are arithmetic expressions, take advantage of that.
+E.g. write ${foo[bar]}, not ${foo[$bar]}, and similarly ${foo[bar+1]}
+vs ${foo[((bar+1))]} or ${foo[$((bar+1))]}, ${foo[--i]} vs ${foo[((--i))]}.
+
+Loop variable names
+-------------------
+
+Use i, j, k for loop-local indices; n and m for lengths; some other descriptive
+name typically based on array name but in singular when looping over actual
+values. If an index or value is to be accessed later on instead of being just
+locally for looping, use a more descriptive and specific name for it.
+
/////////////////////////////////////////
case/esac vs if
---------------
diff --git a/doc/testing.txt b/doc/testing.txt
index c3a1f00a..3ec7c97f 100644
--- a/doc/testing.txt
+++ b/doc/testing.txt
@@ -7,14 +7,8 @@ The bash-completion package contains an automated test suite. Running the
tests should help verifying that bash-completion works as expected. The tests
are also very helpful in uncovering software regressions at an early stage.
-The original, "legacy" bash-completion test suite is written on top of the
-http://www.gnu.org/software/dejagnu/[DejaGnu] testing framework. DejaGnu is
-written in http://expect.nist.gov[Expect], which in turn uses
-http://tcl.sourceforge.net[Tcl] -- Tool command language.
-
-Most of the test framework has been ported over to use
-https://pytest.org/[pytest] and https://pexpect.readthedocs.io/[pexpect].
-Eventually, all of it should be ported.
+The test suite is written in Python, using https://pytest.org/[pytest]
+and https://pexpect.readthedocs.io/[pexpect].
Coding Style Guide
@@ -22,10 +16,7 @@ Coding Style Guide
For the Python part, all of it is formatted using
https://github.com/ambv/black[Black], and we also run
-http://flake8.pycqa.org/[Flake8] on it.
-
-The legacy test suite tries to adhere to this
-http://wiki.tcl.tk/708[Tcl Style Guide].
+https://flake8.pycqa.org/[Flake8] on it.
Installing dependencies
@@ -45,7 +36,7 @@ Debian/Ubuntu
On Debian/Ubuntu you can use `apt-get`:
-------------
-sudo apt-get install python3-pytest python3-pexpect dejagnu tcllib
+sudo apt-get install python3-pytest python3-pexpect
-------------
This should also install the necessary dependencies. Only Debian testing
(buster) and Ubuntu 18.10 (cosmic) and later have an appropriate version
@@ -56,7 +47,7 @@ Fedora/RHEL/CentOS
On Fedora and RHEL/CentOS (with EPEL) you can try `yum` or `dnf`:
-------------
-sudo yum install python3-pytest python3-pexpect dejagnu tcllib
+sudo yum install python3-pytest python3-pexpect
-------------
This should also install the necessary dependencies. At time of writing, only
Fedora 29 comes with recent enough pytest.
@@ -66,49 +57,19 @@ Fedora 29 comes with recent enough pytest.
Structure
---------
-Pytest tests are in the `t/` subdirectory, with `t/test_\*.py` being
-completion tests, and `t/unit/test_unit_\*.py` unit tests.
-
-Legacy tests are grouped into different areas, called _tool_ in DejaGnu:
-
-*completion*::
- Functional tests per completion.
-*install*::
- Functional tests for installation and caching of the main bash-completion
- package.
-*unit*::
- Unit tests for bash-completion helper functions.
+Tests are in the `t/` subdirectory, with `t/test_\*.py` being completion
+tests, and `t/unit/test_unit_\*.py` unit tests.
Running the tests
-----------------
-Python based tests are run by calling `pytest` on the desired test directories
-or individual files, for example in the project root directory:
+Tests are run by calling `pytest` on the desired test directories or
+individual files, for example in the project root directory:
-----------------------
pytest test/t
-----------------------
-Legacy tests are run by calling `runtest` command in the test directory:
------------------------
-runtest --outdir log --tool completion
-runtest --outdir log --tool install
-runtest --outdir log --tool unit
------------------------
-The commands above are already wrapped up in shell scripts within the `test`
-directory:
------------------------
-./runCompletion
-./runInstall
-./runUnit
------------------------
-To run a particular test, specify file name of your test as an argument to
-`runCompletion` script:
------------------------
-./runCompletion ssh.exp
------------------------
-That will run `test/completion/ssh.exp`.
-
See `test/docker/docker-script.sh` for how and what we run and test in CI.
@@ -142,10 +103,10 @@ Naming conventions
Test suite or testsuite
^^^^^^^^^^^^^^^^^^^^^^^
The primary Wikipedia page is called
-http://en.wikipedia.org/wiki/Test_suite[test suite] and not testsuite, so
+https://en.wikipedia.org/wiki/Test_suite[test suite] and not testsuite, so
that's what this document sticks to.
script/generate
^^^^^^^^^^^^^^^
The name and location of this code generation script come from Ruby on Rails'
-http://en.wikibooks.org/wiki/Ruby_on_Rails/Tools/Generators[script/generate].
+https://en.wikibooks.org/wiki/Ruby_on_Rails/Tools/Generators[script/generate].
diff --git a/extra/git-post-commit.sh b/extra/git-post-commit.sh
index 18238585..e74c2948 100755
--- a/extra/git-post-commit.sh
+++ b/extra/git-post-commit.sh
@@ -12,8 +12,8 @@ url=$(git config bash-completion.docker-hub-trigger-url)
test "$(git symbolic-ref --short HEAD 2>/dev/null)" = master
-git diff-tree -r --name-only --no-commit-id HEAD | \
- grep -qxE 'completions/Makefile\.am|test/requirements\.txt'
+git diff-tree -r --name-only --no-commit-id HEAD |
+ grep -qxE 'test/test-cmd-list\.txt'
curl \
--silent --show-error \
diff --git a/extra/git-pre-push.sh b/extra/git-pre-push.sh
index 27de6013..52d990eb 100755
--- a/extra/git-pre-push.sh
+++ b/extra/git-pre-push.sh
@@ -11,20 +11,23 @@
url=$(git config bash-completion.docker-hub-trigger-url) || exit 0
branch=master
-files="completions/Makefile\.am|test/requirements\.txt"
+files="test/test-cmd-list\.txt"
trigger=false
z40=0000000000000000000000000000000000000000
while read local_ref local_sha remote_ref remote_sha; do
case $remote_ref in */$branch) ;; *) continue ;; esac
- [ $local_sha != $z40 ] || continue # delete not handled (yet?)
+ [ $local_sha != $z40 ] || continue # delete not handled (yet?)
if [ $remote_sha = $z40 ]; then
list_files="git ls-tree -r --name-only $local_sha"
else
list_files="git diff --name-only $remote_sha..$local_sha"
fi
- ! $list_files | grep -qEx $files || { trigger=true; break; }
+ ! $list_files | grep -qEx $files || {
+ trigger=true
+ break
+ }
done
if $trigger; then
diff --git a/extra/make-changelog.py b/extra/make-changelog.py
index bb589775..c66b7048 100755
--- a/extra/make-changelog.py
+++ b/extra/make-changelog.py
@@ -1,30 +1,38 @@
#!/usr/bin/python3
-# -*- encoding: utf-8 -*-
+import sys
from collections import defaultdict
from email.utils import formatdate
-import sys
from textwrap import wrap
+from typing import Dict, List
import git
-repo = git.Repo('.')
-changelog = defaultdict(list)
+repo = git.Repo(".")
+changelog = defaultdict(list) # type: Dict[str, List[str]]
+
+if len(sys.argv) != 2:
+ print("Usage: %s SINCE-TAG" % __file__, file=sys.stderr)
+ sys.exit(2)
-for id in repo.iter_commits('%s..HEAD' % sys.argv[1]):
+for id in repo.iter_commits("%s..HEAD" % sys.argv[1]):
commit = repo.commit(id)
if not commit.summary.startswith("Merge pull request "):
changelog[commit.author.name].append(commit.summary)
-print('bash-completion (X.Y)')
-print('')
+print("bash-completion (X.Y)")
+print("")
for author in sorted(changelog.keys()):
- print(' [ %s ]' % author)
+ print(" [ %s ]" % author)
for log in changelog[author]:
- print('\n'.join(
- wrap(log, initial_indent=' * ', subsequent_indent=' ')))
- print('')
+ print(
+ "\n".join(
+ wrap(log, initial_indent=" * ", subsequent_indent=" ")
+ )
+ )
+ print("")
-print(' -- Ville Skyttä <ville.skytta@iki.fi> %s' %
- formatdate(localtime=True))
+print(
+ " -- Ville Skyttä <ville.skytta@iki.fi> %s" % formatdate(localtime=True)
+)
diff --git a/helpers/python b/helpers/python
index 9e268252..a74387f3 100644
--- a/helpers/python
+++ b/helpers/python
@@ -11,4 +11,4 @@ else:
walker = pkgutil.iter_modules
for mod in walker():
- print (mod[1]) # noqa: E211
+ print(mod[1]) # noqa: E211
diff --git a/setup-symlinks.sh b/setup-symlinks.sh
index 71eb92d5..806de810 100755
--- a/setup-symlinks.sh
+++ b/setup-symlinks.sh
@@ -1,7 +1,9 @@
#!/bin/sh -eu
-targetdir="$1"; shift
-target="$1"; shift
+targetdir="$1"
+shift
+target="$1"
+shift
for file in "$@"; do
rm -f "$targetdir/$file"
diff --git a/test/.gitignore b/test/.gitignore
index aa9a8096..c428b949 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -1,7 +1,2 @@
-log/
tmp/
-dbg.log
-xtrace.log
-site.exp
-site.bak
pytestdebug.log
diff --git a/test/Makefile.am b/test/Makefile.am
index 003ec132..591c8f7c 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,21 +1,14 @@
-AUTOMAKE_OPTIONS = dejagnu
-DEJATOOL = completion install unit
-AM_RUNTESTFLAGS = --outdir log --ignore $(PACKAGE).log
-
SUBDIRS = t
-EXTRA_DIST = completion \
- config \
+EXTRA_DIST = config \
fixtures \
- lib \
- setup.cfg \
- unit
+ setup.cfg
all:
- $(MKDIR_P) log tmp
+ $(MKDIR_P) tmp
CLEANFILES = \
fixtures/make/extra_makefile
clean-local:
- $(RM) -rf log tmp
+ $(RM) -rf tmp
diff --git a/test/completion/alias.exp b/test/completion/alias.exp
deleted file mode 100644
index ee7cf4bc..00000000
--- a/test/completion/alias.exp
+++ /dev/null
@@ -1 +0,0 @@
-assert_source_completions alias
diff --git a/test/completion/cd.exp b/test/completion/cd.exp
deleted file mode 100644
index 94c3c598..00000000
--- a/test/completion/cd.exp
+++ /dev/null
@@ -1 +0,0 @@
-assert_source_completions cd
diff --git a/test/completion/chown.exp b/test/completion/chown.exp
deleted file mode 100644
index 53d497c2..00000000
--- a/test/completion/chown.exp
+++ /dev/null
@@ -1 +0,0 @@
-assert_source_completions chown
diff --git a/test/completion/finger.exp b/test/completion/finger.exp
deleted file mode 100644
index 7c7b8a26..00000000
--- a/test/completion/finger.exp
+++ /dev/null
@@ -1 +0,0 @@
-assert_source_completions finger
diff --git a/test/completion/scp.exp b/test/completion/scp.exp
deleted file mode 100644
index e025a9dd..00000000
--- a/test/completion/scp.exp
+++ /dev/null
@@ -1 +0,0 @@
-assert_source_completions scp
diff --git a/test/completion/sftp.exp b/test/completion/sftp.exp
deleted file mode 100644
index 448cd218..00000000
--- a/test/completion/sftp.exp
+++ /dev/null
@@ -1 +0,0 @@
-assert_source_completions sftp
diff --git a/test/completion/slapt-get.exp b/test/completion/slapt-get.exp
deleted file mode 100644
index 6c37d523..00000000
--- a/test/completion/slapt-get.exp
+++ /dev/null
@@ -1 +0,0 @@
-assert_source_completions slapt-get
diff --git a/test/completion/slapt-src.exp b/test/completion/slapt-src.exp
deleted file mode 100644
index 90abfd5f..00000000
--- a/test/completion/slapt-src.exp
+++ /dev/null
@@ -1 +0,0 @@
-assert_source_completions slapt-src
diff --git a/test/completion/ssh.exp b/test/completion/ssh.exp
deleted file mode 100644
index 0477cba5..00000000
--- a/test/completion/ssh.exp
+++ /dev/null
@@ -1 +0,0 @@
-assert_source_completions ssh
diff --git a/test/completion/sudo.exp b/test/completion/sudo.exp
deleted file mode 100644
index 2a8015ff..00000000
--- a/test/completion/sudo.exp
+++ /dev/null
@@ -1 +0,0 @@
-assert_source_completions sudo
diff --git a/test/completion/umount.exp b/test/completion/umount.exp
deleted file mode 100644
index 39c4d114..00000000
--- a/test/completion/umount.exp
+++ /dev/null
@@ -1 +0,0 @@
-assert_source_completions umount
diff --git a/test/completion/upgradepkg.exp b/test/completion/upgradepkg.exp
deleted file mode 100644
index 4b181a86..00000000
--- a/test/completion/upgradepkg.exp
+++ /dev/null
@@ -1 +0,0 @@
-assert_source_completions upgradepkg
diff --git a/test/completion/xhost.exp b/test/completion/xhost.exp
deleted file mode 100644
index 159782b2..00000000
--- a/test/completion/xhost.exp
+++ /dev/null
@@ -1 +0,0 @@
-assert_source_completions xhost
diff --git a/test/config/bashrc b/test/config/bashrc
index dad96335..141dddc5 100644
--- a/test/config/bashrc
+++ b/test/config/bashrc
@@ -1,7 +1,7 @@
# bashrc file for bash-completion test suite
# Note that we do some initialization that would be too late to do here in
-# library.exp's start_bash() and conftest.py.
+# conftest.py.
# Use emacs key bindings
set -o emacs
@@ -9,6 +9,9 @@ set -o emacs
# Use bash strict mode
set -o posix
+# Raise error on uninitialized variables
+set -o nounset
+
# Unset `command_not_found_handle' as defined on Debian/Ubuntu, because this
# troubles and slows down testing
unset -f command_not_found_handle
@@ -32,7 +35,10 @@ export BASH_COMPLETION_USER_FILE=/dev/null
# but simple xspec completions are only installed if a separate one is not
# found in any completion dirs. Therefore we also point the "system" dirs to
# locations that should not yield valid completions and helpers paths either.
-export BASH_COMPLETION_USER_DIR=$(cd "$SRCDIR/.."; pwd)
+export BASH_COMPLETION_USER_DIR=$(
+ cd "$SRCDIR/.." || exit 1
+ pwd
+)
# /var/empty isn't necessarily actually always empty :P
export BASH_COMPLETION_COMPAT_DIR=/var/empty/bash_completion.d
export XDG_DATA_DIRS=/var/empty
@@ -44,8 +50,11 @@ unset -v \
COMP_KNOWN_HOSTS_WITH_HOSTFILE \
COMP_TAR_INTERNAL_PATHS
-# Load bash testsuite helper functions
-. $SRCDIR/lib/library.sh
+# @param $1 Char to add to $COMP_WORDBREAKS
+add_comp_wordbreak_char()
+{
+ [[ "${COMP_WORDBREAKS//[^$1]/}" ]] || COMP_WORDBREAKS+=$1
+}
# Local variables:
# mode: shell-script
diff --git a/test/config/default.exp b/test/config/default.exp
deleted file mode 100644
index 246499b4..00000000
--- a/test/config/default.exp
+++ /dev/null
@@ -1,21 +0,0 @@
-# Set default expect fallback routines
-expect_after {
- eof {
- if {[info exists test]} {
- fail "$test at eof"
- } elseif {[info level] > 0} {
- fail "[info level 1] at eof"
- } else {
- fail "eof"
- }
- }
- timeout {
- if {[info exists test]} {
- fail "$test at timeout"
- } elseif {[info level] > 0} {
- fail "[info level 1] at timeout"
- } else {
- fail "timeout"
- }
- }
-}
diff --git a/test/config/inputrc b/test/config/inputrc
index 5992491a..da896f56 100644
--- a/test/config/inputrc
+++ b/test/config/inputrc
@@ -1,17 +1,21 @@
-# Readline init file for DejaGnu testsuite
+# Readline init file for bash-completion test suite
# See: info readline
- # Press TAB once (instead of twice) to auto-complete
+# Press TAB once (instead of twice) to auto-complete
set show-all-if-ambiguous on
- # No bell. No ^G in output
+
+# No bell. No ^G in output
set bell-style none
- # Don't query user about viewing the number of possible completions
+
+# Don't query user about viewing the number of possible completions
set completion-query-items -1
- # Display completions sorted horizontally, not vertically
-set print-completions-horizontally on
- # Don't use pager when showing completions
+
+# Don't use pager when showing completions
set page-completions off
+# Print each completion on its own line
+set completion-display-width 0
+
# Local variables:
# mode: shell-script
# End:
diff --git a/test/docker/docker-script.sh b/test/docker/docker-script.sh
index 681f2429..b3f351fa 100755
--- a/test/docker/docker-script.sh
+++ b/test/docker/docker-script.sh
@@ -1,20 +1,5 @@
#!/bin/sh -ex
-if [ $DIST = tools ]; then
- rc=0
- perlcritic helpers/perl; rc=$((rc+$?))
- perltidy -nst -nse helpers/perl; rc=$((rc+$?))
- if [ -e helpers/perl.ERR ]; then
- cat helpers/perl.ERR
- rc=$((rc+1))
- fi
- flake8 helpers/python test test/generate; rc=$((rc+$?))
- black --check -t py27 -t py33 -t py34 -t py35 -t py36 -t py37 -t py38 \
- helpers/python; rc=$((rc+$?))
- black --check test test/generate; rc=$((rc+$?))
- exit $rc
-fi
-
if [ "$BSD" ]; then
PATH=/usr/local/lib/bsd-bin:$PATH
export PATH
@@ -28,5 +13,4 @@ autoreconf -i
make -j
xvfb-run make distcheck \
- PYTESTFLAGS="--numprocesses=auto --dist=loadfile" \
- RUNTESTFLAGS="--all --verbose"
+ PYTESTFLAGS="--verbose --numprocesses=auto --dist=loadfile"
diff --git a/test/fixtures/_known_hosts_real/.ssh/config_asterisk_1 b/test/fixtures/_known_hosts_real/.ssh/config_asterisk_1
new file mode 100644
index 00000000..fc09eb03
--- /dev/null
+++ b/test/fixtures/_known_hosts_real/.ssh/config_asterisk_1
@@ -0,0 +1 @@
+Host asterisk_1
diff --git a/test/fixtures/_known_hosts_real/.ssh/config_asterisk_2 b/test/fixtures/_known_hosts_real/.ssh/config_asterisk_2
new file mode 100644
index 00000000..42243ad2
--- /dev/null
+++ b/test/fixtures/_known_hosts_real/.ssh/config_asterisk_2
@@ -0,0 +1 @@
+Host asterisk_2
diff --git a/test/fixtures/_known_hosts_real/.ssh/config_question_mark b/test/fixtures/_known_hosts_real/.ssh/config_question_mark
new file mode 100644
index 00000000..08e1201f
--- /dev/null
+++ b/test/fixtures/_known_hosts_real/.ssh/config_question_mark
@@ -0,0 +1 @@
+Host question_mark
diff --git a/test/fixtures/_known_hosts_real/config b/test/fixtures/_known_hosts_real/config
index 1231dd79..fe3fb54a 100644
--- a/test/fixtures/_known_hosts_real/config
+++ b/test/fixtures/_known_hosts_real/config
@@ -1,7 +1,7 @@
- UserKnownHostsFile fixtures/_known_hosts_real/known_hosts
+ UserKnownHostsFile _known_hosts_real/known_hosts
# Unindented
-Host gee jar
+Host gee* jar?this-part-we-do-not-complete-at-least-yet
HostName %h.example.com
# Indented
- Host hus # With comment
+ Host hus%%eth0 !negated #not-a-comment
diff --git a/test/fixtures/_known_hosts_real/config_include b/test/fixtures/_known_hosts_real/config_include
index fe6f537e..a1ae7633 100644
--- a/test/fixtures/_known_hosts_real/config_include
+++ b/test/fixtures/_known_hosts_real/config_include
@@ -3,3 +3,5 @@
Include ~/config_full_path
# Include with relative path
Include config_relative_path
+# Include with wildcards, and more than one on same row
+Include config_asterisk* config_?uestion_mark
diff --git a/test/fixtures/_known_hosts_real/config_tilde b/test/fixtures/_known_hosts_real/config_tilde
index 0893515b..4181aaf5 100644
--- a/test/fixtures/_known_hosts_real/config_tilde
+++ b/test/fixtures/_known_hosts_real/config_tilde
@@ -1,4 +1,4 @@
# With quotes and tilde
-UserKnownHostsFile "~/fixtures/_known_hosts_real/known_hosts2"
+UserKnownHostsFile "~/_known_hosts_real/known_hosts2"
# Without quotes, with tilde, and another on the same line
-UserKnownHostsFile ~/fixtures/_known_hosts_real/known_hosts3 fixtures/_known_hosts_real/known_hosts4
+UserKnownHostsFile ~/_known_hosts_real/known_hosts3 _known_hosts_real/known_hosts4
diff --git a/test/fixtures/slackware/etc/slapt-get/slapt-getrc b/test/fixtures/_known_hosts_real/gee-filename-canary
index e69de29b..e69de29b 100644
--- a/test/fixtures/slackware/etc/slapt-get/slapt-getrc
+++ b/test/fixtures/_known_hosts_real/gee-filename-canary
diff --git a/test/fixtures/_known_hosts_real/localhost_config b/test/fixtures/_known_hosts_real/localhost_config
index 1e751338..30b6623b 100644
--- a/test/fixtures/_known_hosts_real/localhost_config
+++ b/test/fixtures/_known_hosts_real/localhost_config
@@ -1 +1 @@
-UserKnownHostsFile fixtures/_known_hosts_real/localhost_hosts
+UserKnownHostsFile _known_hosts_real/localhost_hosts
diff --git a/test/fixtures/_known_hosts_real/spaced conf b/test/fixtures/_known_hosts_real/spaced conf
index f484f0e3..566b92c2 100644
--- a/test/fixtures/_known_hosts_real/spaced conf
+++ b/test/fixtures/_known_hosts_real/spaced conf
@@ -1,9 +1,8 @@
# Unindented
Host gee
- UserKnownHostsFile "fixtures/_known_hosts_real/spaced known_hosts"
+ UserKnownHostsFile "_known_hosts_real/spaced known_hosts"
# Indented
- Host hus # With comment
- UserKnownHostsFile "fixtures/_known_hosts_real/known_hosts2"
-
+ Host hus #not-a-comment
+ UserKnownHostsFile "_known_hosts_real/known_hosts2"
diff --git a/test/fixtures/_longopt/various.txt b/test/fixtures/_longopt/various.txt
new file mode 100644
index 00000000..04c2c256
--- /dev/null
+++ b/test/fixtures/_longopt/various.txt
@@ -0,0 +1,5 @@
+---
+----nonono
+--foo_bar
+--foo-
+--foo=bar
diff --git a/test/fixtures/ant/.gitignore b/test/fixtures/ant/.gitignore
index 459f1019..3a08258b 100644
--- a/test/fixtures/ant/.gitignore
+++ b/test/fixtures/ant/.gitignore
@@ -1,2 +1 @@
-.ant-targets-build.xml
-.ant-targets-named-build.xml
+.ant-targets-*.xml
diff --git a/test/fixtures/slackware/etc/slapt-get/slapt-srcrc b/test/fixtures/dpkg/bash-completion-test-nonsubject.txt
index e69de29b..e69de29b 100644
--- a/test/fixtures/slackware/etc/slapt-get/slapt-srcrc
+++ b/test/fixtures/dpkg/bash-completion-test-nonsubject.txt
diff --git a/test/fixtures/lftp/.lftp/bookmarks b/test/fixtures/lftp/.lftp/bookmarks
index 31ec9303..074f8120 100644
--- a/test/fixtures/lftp/.lftp/bookmarks
+++ b/test/fixtures/lftp/.lftp/bookmarks
@@ -1 +1,3 @@
lftptest ftp://ftp.funet.fi/
+spacetest ftp://ftp.sunet.se/
+badbookmark
diff --git a/test/fixtures/lilo/lilo.conf b/test/fixtures/lilo/lilo.conf
new file mode 100644
index 00000000..c8901758
--- /dev/null
+++ b/test/fixtures/lilo/lilo.conf
@@ -0,0 +1,34 @@
+# global options:
+boot=/dev/hda
+prompt
+timeout=150
+lba32
+compact
+vga=normal
+root=/dev/hda1
+read-only
+menu-title=" John's Computer "
+#
+### bootable kernel images ###
+image=/boot/vmlinuz-2.6.29-1-i386
+ label=try
+ initrd=/boot/initrd.img-2.6.29-1-i386
+#image=/boot/vmlinuz-2.4.33-1-i386
+# label=2.4.33
+image=/tamu/vmlinuz
+ label=tamu
+ initrd=/tamu/initrd.img
+ root=/dev/hdb2
+ vga=ask
+#
+### other operating systems ###
+other=/dev/hda3
+ label=PCDOS
+ boot-as=0x80 # must be C:
+other=/dev/hdb1
+ label=WinXP
+ boot-as=0x80 # must be C:
+other=/dev/hdb5
+ label=oldDOS
+ loader=chain
+ table=/dev/hdb5
diff --git a/test/fixtures/nmap/nmap-h.txt b/test/fixtures/nmap/nmap-h.txt
new file mode 100644
index 00000000..0301d374
--- /dev/null
+++ b/test/fixtures/nmap/nmap-h.txt
@@ -0,0 +1,114 @@
+Nmap 7.60 ( https://nmap.org )
+Usage: nmap [Scan Type(s)] [Options] {target specification}
+TARGET SPECIFICATION:
+ Can pass hostnames, IP addresses, networks, etc.
+ Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254
+ -iL <inputfilename>: Input from list of hosts/networks
+ -iR <num hosts>: Choose random targets
+ --exclude <host1[,host2][,host3],...>: Exclude hosts/networks
+ --excludefile <exclude_file>: Exclude list from file
+HOST DISCOVERY:
+ -sL: List Scan - simply list targets to scan
+ -sn: Ping Scan - disable port scan
+ -Pn: Treat all hosts as online -- skip host discovery
+ -PS/PA/PU/PY[portlist]: TCP SYN/ACK, UDP or SCTP discovery to given ports
+ -PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes
+ -PO[protocol list]: IP Protocol Ping
+ -n/-R: Never do DNS resolution/Always resolve [default: sometimes]
+ --dns-servers <serv1[,serv2],...>: Specify custom DNS servers
+ --system-dns: Use OS's DNS resolver
+ --traceroute: Trace hop path to each host
+SCAN TECHNIQUES:
+ -sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans
+ -sU: UDP Scan
+ -sN/sF/sX: TCP Null, FIN, and Xmas scans
+ --scanflags <flags>: Customize TCP scan flags
+ -sI <zombie host[:probeport]>: Idle scan
+ -sY/sZ: SCTP INIT/COOKIE-ECHO scans
+ -sO: IP protocol scan
+ -b <FTP relay host>: FTP bounce scan
+PORT SPECIFICATION AND SCAN ORDER:
+ -p <port ranges>: Only scan specified ports
+ Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080,S:9
+ --exclude-ports <port ranges>: Exclude the specified ports from scanning
+ -F: Fast mode - Scan fewer ports than the default scan
+ -r: Scan ports consecutively - don't randomize
+ --top-ports <number>: Scan <number> most common ports
+ --port-ratio <ratio>: Scan ports more common than <ratio>
+SERVICE/VERSION DETECTION:
+ -sV: Probe open ports to determine service/version info
+ --version-intensity <level>: Set from 0 (light) to 9 (try all probes)
+ --version-light: Limit to most likely probes (intensity 2)
+ --version-all: Try every single probe (intensity 9)
+ --version-trace: Show detailed version scan activity (for debugging)
+SCRIPT SCAN:
+ -sC: equivalent to --script=default
+ --script=<Lua scripts>: <Lua scripts> is a comma separated list of
+ directories, script-files or script-categories
+ --script-args=<n1=v1,[n2=v2,...]>: provide arguments to scripts
+ --script-args-file=filename: provide NSE script args in a file
+ --script-trace: Show all data sent and received
+ --script-updatedb: Update the script database.
+ --script-help=<Lua scripts>: Show help about scripts.
+ <Lua scripts> is a comma-separated list of script-files or
+ script-categories.
+OS DETECTION:
+ -O: Enable OS detection
+ --osscan-limit: Limit OS detection to promising targets
+ --osscan-guess: Guess OS more aggressively
+TIMING AND PERFORMANCE:
+ Options which take <time> are in seconds, or append 'ms' (milliseconds),
+ 's' (seconds), 'm' (minutes), or 'h' (hours) to the value (e.g. 30m).
+ -T<0-5>: Set timing template (higher is faster)
+ --min-hostgroup/max-hostgroup <size>: Parallel host scan group sizes
+ --min-parallelism/max-parallelism <numprobes>: Probe parallelization
+ --min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <time>: Specifies
+ probe round trip time.
+ --max-retries <tries>: Caps number of port scan probe retransmissions.
+ --host-timeout <time>: Give up on target after this long
+ --scan-delay/--max-scan-delay <time>: Adjust delay between probes
+ --min-rate <number>: Send packets no slower than <number> per second
+ --max-rate <number>: Send packets no faster than <number> per second
+FIREWALL/IDS EVASION AND SPOOFING:
+ -f; --mtu <val>: fragment packets (optionally w/given MTU)
+ -D <decoy1,decoy2[,ME],...>: Cloak a scan with decoys
+ -S <IP_Address>: Spoof source address
+ -e <iface>: Use specified interface
+ -g/--source-port <portnum>: Use given port number
+ --proxies <url1,[url2],...>: Relay connections through HTTP/SOCKS4 proxies
+ --data <hex string>: Append a custom payload to sent packets
+ --data-string <string>: Append a custom ASCII string to sent packets
+ --data-length <num>: Append random data to sent packets
+ --ip-options <options>: Send packets with specified ip options
+ --ttl <val>: Set IP time-to-live field
+ --spoof-mac <mac address/prefix/vendor name>: Spoof your MAC address
+ --badsum: Send packets with a bogus TCP/UDP/SCTP checksum
+OUTPUT:
+ -oN/-oX/-oS/-oG <file>: Output scan in normal, XML, s|<rIpt kIddi3,
+ and Grepable format, respectively, to the given filename.
+ -oA <basename>: Output in the three major formats at once
+ -v: Increase verbosity level (use -vv or more for greater effect)
+ -d: Increase debugging level (use -dd or more for greater effect)
+ --reason: Display the reason a port is in a particular state
+ --open: Only show open (or possibly open) ports
+ --packet-trace: Show all packets sent and received
+ --iflist: Print host interfaces and routes (for debugging)
+ --append-output: Append to rather than clobber specified output files
+ --resume <filename>: Resume an aborted scan
+ --stylesheet <path/URL>: XSL stylesheet to transform XML output to HTML
+ --webxml: Reference stylesheet from Nmap.Org for more portable XML
+ --no-stylesheet: Prevent associating of XSL stylesheet w/XML output
+MISC:
+ -6: Enable IPv6 scanning
+ -A: Enable OS detection, version detection, script scanning, and traceroute
+ --datadir <dirname>: Specify custom Nmap data file location
+ --send-eth/--send-ip: Send using raw ethernet frames or IP packets
+ --privileged: Assume that the user is fully privileged
+ --unprivileged: Assume the user lacks raw socket privileges
+ -V: Print version number
+ -h: Print this help summary page.
+EXAMPLES:
+ nmap -v -A scanme.nmap.org
+ nmap -v -sn 192.168.0.0/16 10.0.0.0/8
+ nmap -v -iR 10000 -Pn -p 80
+SEE THE MAN PAGE (https://nmap.org/book/man.html) FOR MORE OPTIONS AND EXAMPLES
diff --git a/test/fixtures/perl/Devel/BashCompletion.pm b/test/fixtures/perl/Devel/BashCompletion.pm
index 0afc6045..f8e829d8 100644
--- a/test/fixtures/perl/Devel/BashCompletion.pm
+++ b/test/fixtures/perl/Devel/BashCompletion.pm
@@ -1 +1,3 @@
+use strict;
+use warnings;
1;
diff --git a/test/fixtures/perldoc/BashCompletionModule.pm b/test/fixtures/perldoc/BashCompletionModule.pm
index e69de29b..b9208f34 100644
--- a/test/fixtures/perldoc/BashCompletionModule.pm
+++ b/test/fixtures/perldoc/BashCompletionModule.pm
@@ -0,0 +1,4 @@
+package BashCompletionModule;
+use strict;
+use warnings;
+1;
diff --git a/test/fixtures/pytest/test_async.py b/test/fixtures/pytest/test_async.py
new file mode 100644
index 00000000..48f91e08
--- /dev/null
+++ b/test/fixtures/pytest/test_async.py
@@ -0,0 +1,17 @@
+"""Async function pytest completion fixture."""
+
+
+async def test_positive():
+ pass
+
+
+async def non_test_negative():
+ pass
+
+
+class Testing:
+ async def test_positive(self):
+ pass
+
+ async def non_test_negative(self):
+ pass
diff --git a/test/fixtures/ssh-copy-id/.ssh/id_rsa b/test/fixtures/ssh-copy-id/.ssh/id_rsa
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/fixtures/ssh-copy-id/.ssh/id_rsa
diff --git a/test/lib/completion.exp b/test/lib/completion.exp
deleted file mode 100644
index 88e92d50..00000000
--- a/test/lib/completion.exp
+++ /dev/null
@@ -1,24 +0,0 @@
-source $::srcdir/lib/library.exp
-
-
-proc completion_exit {} {
- send "\rexit\r"
-}
-
-
-proc completion_init {test_file_name} {
- # Call completion_start() only once
- if {! [info exists ::BASH_VERSINFO]} {
- completion_start
- }
-}
-
-
-proc completion_start {} {
- start_interactive_test
-}
-
-
-proc completion_version {} {
- puts "$::TESTDIR, bash-$::BASH_VERSION"
-}
diff --git a/test/lib/completions/alias.exp b/test/lib/completions/alias.exp
deleted file mode 100644
index c41417f1..00000000
--- a/test/lib/completions/alias.exp
+++ /dev/null
@@ -1,32 +0,0 @@
-proc setup {} {
- assert_bash_exec "unalias -a"; # Remove all aliases
- assert_bash_exec "alias foo=bar"
- assert_bash_exec "alias bar='foo foo'"
- save_env
-}
-
-
-proc teardown {} {
- assert_bash_exec "unalias -a"; # Remove all aliases
- assert_env_unmodified
-}
-
-
-setup
-
-
-set test "Tab should complete alias at cursor position"
- # Try completion
-set cmd "alias foo"
-append cmd \002\002\002; # \002 = ^B = Move cursor left in bash emacs mode
-send "$cmd\t"
-expect {
- -re "^alias foo\b\b\b\r\nbar +foo *\r\n/@alias foo\b\b\b$" { pass "$test" }
- -re "^alias foo\b\b\bfoo=foo\b\b\b$" { fail "$test: Wrong cursor position" }
- -re /@ { unresolved "$test" }
- default { unresolved "$test" }
-}
-sync_after_int
-
-
-teardown
diff --git a/test/lib/completions/cd.exp b/test/lib/completions/cd.exp
deleted file mode 100644
index ded094c3..00000000
--- a/test/lib/completions/cd.exp
+++ /dev/null
@@ -1,31 +0,0 @@
-proc setup {} {
- save_env
-}
-
-
-proc teardown {} {
- assert_env_unmodified {/OLDPWD=/d}
-}
-
-
-setup
-
-
-set test "Tab should complete cd at cursor position"
- # Try completion
-set cmd "cd $::srcdir/fixtures/shared/default/foo"
-append cmd \002\002\002; # \002 = ^B = Move cursor left in bash emacs mode
-#append cmd \033\0133D; # Escape-[-D = Cursor left
-send "$cmd\t"
-expect {
- -re "cd $::srcdir/fixtures/shared/default/foo\b\b\b\r\n(\.svn/ +|)bar bar.d/ +foo.d/ *(\.svn/ *|)\r\n/@cd $::srcdir/fixtures/shared/default/foo\b\b\b$" { pass "$test" }
- -re "^cd $::srcdir/fixtures/shared/default/foo\b\b\bfoo.d/foo\b\b\b$" { fail "$test: Wrong cursor position" }
- -re /@ { unresolved "$test at prompt" }
- default { unresolved "$test" }
-}
-
-
-sync_after_int
-
-
-teardown
diff --git a/test/lib/completions/chown.exp b/test/lib/completions/chown.exp
deleted file mode 100644
index 792d52a9..00000000
--- a/test/lib/completions/chown.exp
+++ /dev/null
@@ -1,43 +0,0 @@
-proc setup {} {
- # fake root command to get all users/groups completed at least for now
- assert_bash_exec {root_command=sudo}
- save_env
-}
-
-proc teardown {} {
- assert_env_unmodified
-}
-
-
-setup
-
-
-# Find user/group suitable for testing.
-set failed_find_unique_completion 0
-foreach ug {user group} {
- # compgen -A is used because it's a bash builtin and available everywhere.
- # The || true part prevents exec from throwing an exception if nothing is
- # found (very very unlikely).
- set list [split [exec bash -c "compgen -A $ug || true"] "\n"]
- if {![find_unique_completion_pair $list part$ug full$ug]} {
- untested "Not running complex chown tests; no suitable test $ug found."
- set failed_find_unique_completion 1
- }
-}
-
-# These tests require an unique completion.
-if {!$failed_find_unique_completion} {
-
- foreach prefix {
- "funky\\ user:" "funky.user:" "funky\\.user:" "fu\\ nky.user:"
- "f\\ o\\ o\\.\\bar:" "foo\\_b\\ a\\.r\\ :"
- } {
- set test "Check preserve special chars in $prefix$partgroup<TAB>"
- #assert_complete_into "chown $prefix$partgroup" "chown $prefix$fullgroup " $test
- assert_complete $prefix$fullgroup "chown $prefix$partgroup" $test
- sync_after_int
- }
-}
-
-
-teardown
diff --git a/test/lib/completions/finger.exp b/test/lib/completions/finger.exp
deleted file mode 100644
index c055f354..00000000
--- a/test/lib/completions/finger.exp
+++ /dev/null
@@ -1,41 +0,0 @@
-proc setup {} {
- save_env
-}
-
-
-proc teardown {} {
- assert_env_unmodified
-}
-
-
-setup
-
-
-sync_after_int
-
-
-set test "Tab should complete partial hostname"
-# Build string list of hostnames, starting with the character of the first
-# host, unless host starts with a COMP_WORDBREAKS character, e.g. a colon (:).
-# Hosts starting with a COMP_WORDBREAKS character are left out because these
-# are exceptional cases, requiring specific tests.
-set hosts {}
-set char ""
-foreach h [get_known_hosts] {
- set first [string range $h 0 0]
- if {$char == "" && [string first $first $::COMP_WORDBREAKS] == -1} {set char $first}
- if {$char != ""} {
- # Only append unique hostnames starting with $char
- if {$first == $char && [lsearch -exact $hosts "test@$h"] == -1} {
- # Prefix hosts with username 'test@'
- lappend hosts "test@$h"
- }
- }
-}
-assert_complete $hosts "finger test@$char" $test -expect-cmd-minus "test@$char"
-
-
-sync_after_int
-
-
-teardown
diff --git a/test/lib/completions/scp.exp b/test/lib/completions/scp.exp
deleted file mode 100644
index 1497a7fb..00000000
--- a/test/lib/completions/scp.exp
+++ /dev/null
@@ -1,117 +0,0 @@
-proc setup {} {
- save_env
- # NOTE: Changing dir to $SRCDIR is necessary because file locations in the
- # ssh config files (e.g. UserKnownHostsFile) are relative to $SRCDIR.
- assert_bash_exec {cd $SRCDIR/fixtures/scp}
-}
-
-
-proc teardown {} {
- assert_bash_exec {cd $TESTDIR}
- assert_env_unmodified {
- /BASH_LINENO=/d
- /BASH_SOURCE=/d
- /OLDPWD=/d
- }
-}
-
-
-setup
-
-
-set test "Tab should complete remote pwd"
-set host bash_completion
-
- # Retrieving home directory (host_pwd) from ssh-host `bash_completion'
- # yields error?
-if {
- [catch {
- exec -- ssh -o "Batchmode yes" -o "ConnectTimeout 1" $host pwd 2>>/dev/null
- } host_pwd]
-} {
- # Yes, retrieving pwd from ssh yields error; reset `host_pwd'
- # Indicate host pwd is unknown and test is unsupported
- # NOTE: To support this test, set the hostname "bash_completion"
- # in `$HOME/.ssh/config' or `/etc/ssh_config'
- set host_pwd ""
- unsupported $test
-}
-
-
- # Try completion
-set cmd "scp $host:"
-send "$cmd\t"
-sync_after_tab
-expect {
- -re "^$cmd$host_pwd.*$" { pass "$test" }
- -re /@ { unresolved "$test at prompt" }
-}
-
-
-sync_after_int
-
-
-set test "Tab should complete known-hosts"
-
- # Build string list of expected completions
- # Get hostnames and give them a colon (:) suffix
- # Hosts `gee' and `hut' are defined in ./fixtures/scp/config
- # Hosts `blah', `doo' and `ike' are defined in ./fixtures/scp/known_hosts
-set expected {}
-foreach host [get_hosts] {
- lappend expected "$host:"
-}
-lappend expected blah: doo: gee: hut: ike:
- # Append local filenames
-lappend expected config known_hosts "spaced\\ \\ conf"
-assert_complete $expected "scp -F config " $test
-
-
-sync_after_int
-
-
-set test "-F without space shouldn't error"
- # Try completion
-set cmd "scp -F"
-send "$cmd\t "
-expect {
- -re "^${cmd}bash: option requires an argument -- F" { fail "$test" }
- -re "^$cmd\r\n.*\r\n/@" { pass "$test" }
- -re /@ { unresolved "$test at prompt" }
- default { unresolved "$test" }
-}
-
-
-sync_after_int
-
-
-set test "Config file containing space should work"
- # Build string list of expected completions
- # Get hostnames and give them a colon (:) suffix
-set expected {}
-foreach host [get_hosts] {
- lappend expected "$host:"
-}
- # Hosts `gee', `hus' and `jar' are defined in "./fixtures/scp/spaced conf"
- # Hosts `blah', `doo' and `ike' are defined in ./fixtures/scp/known_hosts
-lappend expected blah: doo: gee: hus: ike: jar:
- # Append local filenames
-lappend expected config known_hosts "spaced\\ \\ conf"
-set cmd "scp -F 'spaced conf' "
-send "$cmd\t"
-expect -ex "$cmd\r\n"
-if {[match_items [lsort -unique $expected] -bash-sort]} {
- expect {
- -re /@ { pass "$test" }
- -re eof { unresolved "eof" }
- default { fail "$test" }
- }
-}
-sync_after_int
-assert_bash_exec {cd "$TESTDIR"}
-
-
-sync_after_int
-
-
-teardown
diff --git a/test/lib/completions/sftp.exp b/test/lib/completions/sftp.exp
deleted file mode 100644
index c5c0919f..00000000
--- a/test/lib/completions/sftp.exp
+++ /dev/null
@@ -1,60 +0,0 @@
-proc setup {} {
- save_env
- # NOTE: Changing dir to $SRCDIR is necessary because file locations in the
- # ssh config files (e.g. UserKnownHostsFile) are relative to $SRCDIR.
- assert_bash_exec {cd $SRCDIR/fixtures/sftp}
-}
-
-
-proc teardown {} {
- assert_bash_exec {cd $TESTDIR}
- assert_env_unmodified {
- /BASH_LINENO=/d
- /BASH_SOURCE=/d
- /OLDPWD=/d
- }
-}
-
-
-setup
-
-
- # Build string list of expected completions
-set expected [get_hosts]
- # Hosts `gee' and `hut' are defined in ./fixtures/sftp/config
- # Hosts `10.10.10.10', `doo' and `ike' are defined in ./fixtures/sftp/known_hosts
-lappend expected 10.10.10.10 doo gee hut ike
-assert_complete $expected "sftp -F config "
-
-
-sync_after_int
-
-
-set test "-F without space shouldn't error"
- # Try completion
-set cmd "sftp -F"
-send "$cmd\t "
-expect {
- -re "^${cmd}bash: option requires an argument -- F" { fail "$test" }
- -re "^$cmd\r\n.*\r\n/@" { pass "$test" }
- -re /@ { unresolved "$test at prompt" }
- default { unresolved "$test" }
-}
-
-
-sync_after_int
-
-
- # Build string list of expected completions
- # Get hostnames and give them a colon (:) suffix
-set expected [get_hosts]
- # Hosts `gee' and `jar' are defined in "./fixtures/sftp/spaced conf"
- # Hosts `10.10.10.10', `doo' and `ike' are defined in ./fixtures/sftp/known_hosts
-lappend expected 10.10.10.10 doo gee ike jar
-assert_complete $expected "sftp -F spaced\\ \\ conf "
-
-
-sync_after_int
-
-
-teardown
diff --git a/test/lib/completions/slapt-get.exp b/test/lib/completions/slapt-get.exp
deleted file mode 100644
index 4522610d..00000000
--- a/test/lib/completions/slapt-get.exp
+++ /dev/null
@@ -1,32 +0,0 @@
-proc setup {} {
- save_env
-}
-
-
-proc teardown {} {
- assert_env_unmodified
-}
-
-
-setup
-
-
-set test "--install should complete available packages"
-set config $::srcdir/fixtures/slackware/etc/slapt-get/slapt-getrc
-set workdir [file normalize $::srcdir/fixtures/slackware/var/slapt-get/]
-set pkg_data "$workdir/package_data"
-# write simple config
-set f [open $config w]
-puts $f "WORKINGDIR=$workdir"
-puts $f "SOURCE=file:///home/"
-close $f
-set packages [split [exec bash -c "sed -n \
- '/^PACKAGE NAME:/{s/^PACKAGE NAME: \\{1,\\}\\(.*\\).t\[gbxl\]z/\\1/;p}' \
- $pkg_data"] "\n"]
-assert_complete $packages "slapt-get -c $config --install " $test
-
-
-sync_after_int
-
-
-teardown
diff --git a/test/lib/completions/slapt-src.exp b/test/lib/completions/slapt-src.exp
deleted file mode 100644
index b66385ef..00000000
--- a/test/lib/completions/slapt-src.exp
+++ /dev/null
@@ -1,29 +0,0 @@
-proc setup {} {
- save_env
-}
-
-
-proc teardown {} {
- assert_env_unmodified
-}
-
-
-setup
-
-
-set test "--install should complete available packages"
-set config $::srcdir/fixtures/slackware/etc/slapt-get/slapt-srcrc
-set workdir [file normalize $::srcdir/fixtures/slackware/usr/src/slapt-src/]
-set slb_data "$workdir/slackbuilds_data"
-set f [open $config w]; puts $f "BUILDDIR=$workdir"; close $f
-set slackbuilds [split [exec bash -c "sed -n \
- -e '/^SLACKBUILD NAME: /{s/^SLACKBUILD NAME: \\{1,\\}//;p}' \
- -e '/^SLACKBUILD VERSION: /{s/^SLACKBUILD VERSION: \\{1,\\}//;p}' \
- $slb_data | sed -e 'N;s/\\n/:/'"] "\n"]
-assert_complete $slackbuilds "slapt-src --config $config --install " $test
-
-
-sync_after_int
-
-
-teardown
diff --git a/test/lib/completions/ssh.exp b/test/lib/completions/ssh.exp
deleted file mode 100644
index 1702371c..00000000
--- a/test/lib/completions/ssh.exp
+++ /dev/null
@@ -1,61 +0,0 @@
-proc setup {} {
- save_env
- # NOTE: Changing dir to $SRCDIR is necessary because file locations in the
- # ssh config files (e.g. UserKnownHostsFile) are relative to $SRCDIR.
- assert_bash_exec {cd $SRCDIR/fixtures/ssh}
-}
-
-
-proc teardown {} {
- assert_bash_exec {cd $TESTDIR}
- assert_env_unmodified {
- /BASH_LINENO=/d
- /BASH_SOURCE=/d
- /OLDPWD=/d
- }
-}
-
-
-setup
-
-
-set test "-F without space shouldn't error"
- # Try completion
-set cmd "ssh -F"
-send "$cmd\t "
-set expected "^$cmd $"
-expect {
- -re "^${cmd}bash: option requires an argument -- F" { fail "$test" }
- -re "^$cmd\r\n.*\r\n/@" { pass "$test" }
- -re /@ { unresolved "$test at prompt" }
- default { unresolved "$test" }
-}
-
-
-sync_after_int
-
-
-set test "First argument should complete partial hostname"
-# Build string list of hostnames, starting with the character of the first
-# host, unless host starts with a COMP_WORDBREAKS character, e.g. a colon (:).
-# Hosts starting with a COMP_WORDBREAKS character are left out because these
-# are exceptional cases, requiring specific tests.
-set hosts {}
-set char ""
-foreach h [get_known_hosts] {
- set first [string range $h 0 0]
- if {$char == "" && [string first $first $::COMP_WORDBREAKS] == -1} {set char $first}
- if {$char != ""} {
- # Only append unique hostnames starting with $char
- if {$first == $char && [lsearch -exact $hosts "$h"] == -1} {
- lappend hosts "$h"
- }
- }
-}
-assert_complete $hosts "ssh $char" $test -ltrim-colon-completions -expect-cmd-minus "$char"
-
-
-sync_after_int
-
-
-teardown
diff --git a/test/lib/completions/sudo.exp b/test/lib/completions/sudo.exp
deleted file mode 100644
index 73e485d6..00000000
--- a/test/lib/completions/sudo.exp
+++ /dev/null
@@ -1,42 +0,0 @@
-proc setup {} {
- save_env
-}
-
-
-proc teardown {} {
- assert_env_unmodified {/OLDPWD/d}
-}
-
-
-setup
-
-
-# Find user/group suitable for testing.
-set failed_find_unique_completion 0
-foreach ug {user group} {
- # compgen -A is used because it's a bash builtin and available everywhere.
- # The || true part prevents exec from throwing an exception if nothing is
- # found (very very unlikely).
- set list [split [exec bash -c "compgen -A $ug || true"] "\n"]
- if {![find_unique_completion_pair $list part$ug full$ug]} {
- untested "Not running complex chown tests; no suitable test $ug found."
- set failed_find_unique_completion 1
- }
-}
-
-# These tests require an unique completion.
-if {!$failed_find_unique_completion} {
-
- foreach prefix {
- "funky\\ user:" "funky.user:" "funky\\.user:" "fu\\ nky.user:"
- "f\\ o\\ o\\.\\bar:" "foo\\_b\\ a\\.r\\ :"
- } {
- set test "Check preserve special chars in $prefix$partgroup<TAB>"
- #assert_complete_into "chown $prefix$partgroup" "chown $prefix$fullgroup " $test
- assert_complete $prefix$fullgroup "sudo chown $prefix$partgroup" $test
- sync_after_int
- }
-}
-
-
-teardown
diff --git a/test/lib/completions/umount.exp b/test/lib/completions/umount.exp
deleted file mode 100644
index 03144355..00000000
--- a/test/lib/completions/umount.exp
+++ /dev/null
@@ -1,95 +0,0 @@
-# umount completion from fstab can't be tested directly because it
-# (correctly) uses absolute paths. So we create a custom completion which
-# reads from a file in our text fixture instead.
-proc setup_dummy_mnt {} {
- assert_bash_exec {unset COMPREPLY cur}
- assert_bash_exec {unset -f _mnt}
-
- assert_bash_exec { \
- _mnt() { \
- local cur=$(_get_cword); \
- _linux_fstab $(_get_pword) < "$SRCDIRABS/fixtures/mount/test-fstab"; \
- }; \
- complete -F _mnt mnt \
- }
-}
-
-
-proc teardown_dummy_mnt {} {
- assert_bash_exec {unset COMPREPLY cur}
- assert_bash_exec {unset -f _mnt}
- assert_bash_exec {complete -r mnt}
-}
-
-
-proc setup {} {
- save_env
- setup_dummy_mnt
-}
-
-
-proc teardown {} {
- teardown_dummy_mnt
- assert_env_unmodified {/OLDPWD/d}
-}
-
-
-setup
-
-
-set test "Testing internal __linux_fstab_unescape function for umount"
-# One round of slashes is for bash.
-assert_bash_exec {var=one\'two\\040three\\}
-assert_bash_exec {__linux_fstab_unescape var}
-set cmd {echo $var}
-send "$cmd\r"
-expect {
- -ex "$cmd\r\none'two three\\" { pass $test }
-# default { fail $test }
-}
-sync_after_int
-assert_bash_exec {unset var}
-
-
-sync_after_int
-
-
-# Begin testing through mnt (see setup_dummy_mnt).
-assert_complete {/mnt/nice-test-path} {mnt /mnt/nice-test-p}
-sync_after_int
-
-assert_complete {/mnt/nice\ test-path} {mnt /mnt/nice\ test-p}
-sync_after_int
-
-assert_complete {/mnt/nice\$test-path} {mnt /mnt/nice\$test-p}
-sync_after_int
-
-assert_complete {/mnt/nice\ test\\path} {mnt /mnt/nice\ test\\p}
-sync_after_int
-
-assert_complete {{/mnt/nice\ test\\path} {/mnt/nice\ test-path}} \
- {mnt /mnt/nice\ } "" -expect-cmd-minus {/mnt/nice\ }
-sync_after_int
-
-assert_complete {/mnt/nice\$test-path} {mnt /mnt/nice\$}
-sync_after_int
-
-assert_complete {/mnt/nice\'test-path} {mnt /mnt/nice\'}
-sync_after_int
-
-assert_complete {/mnt/other\'test\ path} {mnt /mnt/other}
-sync_after_int
-
-assert_complete {Ubuntu\ Karmic} {mnt -L Ubu}
-sync_after_int
-
-assert_complete {Debian-it\'s\ awesome} {mnt -L Deb}
-sync_after_int
-
-# This does not work. Proper support for this requires smarter parsing of
-# $COMP_LINE and it's not worth doing just for umount.
-#assert_complete {$'/mnt/nice\ntest-path'} {mnt $'/mnt/nice\n}
-#sync_after_int
-
-
-teardown
diff --git a/test/lib/completions/upgradepkg.exp b/test/lib/completions/upgradepkg.exp
deleted file mode 100644
index ffb4ba28..00000000
--- a/test/lib/completions/upgradepkg.exp
+++ /dev/null
@@ -1,26 +0,0 @@
-proc setup {} {
- save_env
-}
-
-
-proc teardown {} {
- assert_env_unmodified {/OLDPWD=/d}
-}
-
-
-setup
-
-
-set test "should complete *.t\[gbxl\]z files and dirs after % sign"
-set oldpkg "xx-2.0-i486-2"
-set dir $::srcdir/fixtures/slackware/home
-set files [split [exec bash -c "cd $dir && find . -mindepth 1 -maxdepth 1 \
- \\( -type d -printf '$oldpkg%%%P/\\n' \\) -o \
- \\( -type f -name '*.t\[bglx\]z' -printf '$oldpkg%%%P\\n' \\)"] "\n"]
-assert_complete_dir $files "upgradepkg $oldpkg%" $dir $test
-
-
-sync_after_int
-
-
-teardown
diff --git a/test/lib/completions/xhost.exp b/test/lib/completions/xhost.exp
deleted file mode 100644
index 02aa4cb2..00000000
--- a/test/lib/completions/xhost.exp
+++ /dev/null
@@ -1,95 +0,0 @@
-proc setup {} {
- assert_bash_exec {HOME=$TESTDIR}
- save_env
-}
-
-
-proc teardown {} {
- assert_env_unmodified
-}
-
-
-setup
-
-
-set test "Tab should complete hostnames"
-assert_complete [get_hosts] "xhost " $test
-
-
-sync_after_int
-
-
-set test "Tab should complete partial hostname"
-# Build string list of hostnames, starting with the character of the first hostname
-set hosts {}
-set char ""
-foreach h [get_hosts] {
- if {$char == ""} {set char [string range $h 0 0]}
- # Only append hostname if starting with $char
- if {[string range $h 0 0] == "$char"} {
- lappend hosts $h
- }
-}
-assert_complete $hosts "xhost $char" $test -expect-cmd-minus "$char"
-
-
-sync_after_int
-
-
-set test "Tab should complete hostnames prefixed with +"
-# Build string list of hostnames, prefixed with plus (+)
-set hosts {}
-foreach h [get_hosts] {
- lappend hosts "+$h"
-}
-assert_complete $hosts "xhost \+" $test
-
-
-sync_after_int
-
-
-set test "Tab should complete partial hostname prefixed with +"
- # Build string list of hostnames, starting with character of first host.
-set hosts {}
-foreach h [get_hosts] {
- if {$char == ""} {set char [string range $h 0 0]}
- # Only append hostname if starting with $char
- if {[string range $h 0 0] == "$char"} {
- lappend hosts "+$h"
- }
-}
-assert_complete $hosts "xhost +$char" $test -expect-cmd-minus "\+$char"
-
-
-sync_after_int
-
-
-set test "Tab should complete hostnames prefixed with -"
- # Build string list of hostnames, prefix with minus (-)
-set hosts {}
-foreach h [get_hosts] {
- lappend hosts "-$h"
-}
-assert_complete $hosts "xhost -" $test
-
-
-sync_after_int
-
-
-set test "Tab should complete partial hostname prefixed with -"
- # Build list of hostnames, starting with character of first host
-set hosts {}
-foreach h [get_hosts] {
- if {$char == ""} {set char [string range $h 0 0]}
- # Only append hostname if starting with $char
- if {[string range $h 0 0] == "$char"} {
- lappend hosts "-$h"
- }
-}
-assert_complete $hosts "xhost -$char" $test -expect-cmd-minus "-$char"
-
-
-sync_after_int
-
-
-teardown
diff --git a/test/lib/library.exp b/test/lib/library.exp
deleted file mode 100644
index c90c927c..00000000
--- a/test/lib/library.exp
+++ /dev/null
@@ -1,970 +0,0 @@
-# Source `init.tcl' again to restore the `unknown' procedure
-# NOTE: DejaGnu has an old `unknown' procedure which unfortunately disables
-# tcl auto-loading.
-source [file join [info library] init.tcl]
-package require cmdline
-package require textutil::string
-
-
-
-# Execute a bash command and make sure the exit status is successful.
-# If not, output the error message.
-# @param string $cmd Bash command line to execute. If empty string (""), the
-# exit status of the previously executed bash command will be
-# checked; specify `title' to adorn the error message.
-# @param string $title (optional) Command title. If empty, `cmd' is used.
-# @param string $prompt (optional) Bash prompt. Default is "/@"
-# @param mixed $out (optional) Reference to (tcl) variable to hold output.
-# If variable equals -1 (default) the bash command is expected
-# to return no output. If variable equals 0, any output
-# from the bash command is disregarded.
-proc assert_bash_exec {{aCmd ""} {title ""} {prompt /@} {out -1}} {
- if {$out != 0 && $out != -1} {upvar $out results}
- if {[string length $aCmd] != 0} {
- send "$aCmd\r"
- expect -ex "$aCmd\r\n"
- }
- if {[string length $title] == 0} {set title $aCmd}
- expect -ex $prompt
- set results $expect_out(buffer); # Catch output
- # Remove $prompt suffix from output
- set results [
- string range $results 0 [
- expr [string length $results] - [string length $prompt] - 1
- ]
- ]
- if {$out == -1 && [string length $results] > 0} {
- fail "ERROR Unexpected output from bash command \"$title\""
- }
-
- set cmd "echo $?"
- send "$cmd\r"
- expect {
- -ex "$cmd\r\n0\r\n$prompt" {}
- $prompt {fail "ERROR executing bash command \"$title\""}
- }
-}
-
-
-# Test `type ...' in bash
-# Indicate "unsupported" if `type' exits with error status.
-# @param string $command Command to locate
-proc assert_bash_type {command} {
- set test "$command should be available in bash"
- set cmd "type $command &>/dev/null && echo -n 0 || echo -n 1"
- send "$cmd\r"
- expect "$cmd\r\n"
- expect {
- -ex 0 { set result true }
- -ex 1 { set result false; unsupported "$test" }
- }
- expect "/@"
- return $result
-}
-
-
-# Make sure the expected list matches the real list, as returned by executing
-# the specified bash command.
-# Specify `-sort' if the real list is sorted.
-# @param list $expected Expected list items
-# @param string $cmd Bash command to execute in order to generate real list
-# items
-# @param string $test Test title. Becomes "$cmd should show expected output"
-# if empty string.
-# @param list $args Options:
-# -sort Compare list sorted. Default is unsorted
-# -prompt Bash prompt. Default is `/@'
-# -chunk-size N Compare list N items at a time. Default
-# is 20.
-proc assert_bash_list {expected cmd test {args {}}} {
- array set arg [::cmdline::getoptions args {
- {sort "compare list sorted"}
- {prompt.arg /@ "bash prompt"}
- {chunk-size.arg 20 "compare N list items at a time"}
- }]
- set prompt $arg(prompt)
- if {$test == ""} {set test "$cmd should show expected output"}
- if {[llength $expected] == 0} {
- assert_no_output $cmd $test $prompt
- } else {
- send "$cmd\r"
- expect -ex "$cmd\r\n"
- if {$arg(sort)} {set bash_sort "-bash-sort"} {set bash_sort ""}
- if {[
- eval match_items \$expected $bash_sort -chunk-size \
- \$arg(chunk-size) -end-newline -end-prompt \
- -prompt \$prompt
- ]} {
- pass "$test"
- } else {
- fail "$test"
- }
- }
-}
-
-
-# Make sure the expected list matches the real list, as returned by executing
-# the specified bash command within the specified directory.
-# Specify `-sort' if the real list is sorted.
-# @param list $expected Expected list items
-# @param string $cmd Bash command to generate real list items
-# @param string $dir Directory to execute $cmd within
-# @param string $test Test title. Becomes "$cmd should show expected output"
-# if empty string.
-# @param list $args Options:
-# -sort Compare list sorted. Default is unsorted
-# -prompt Bash prompt. Default is `/@'
-# -chunk-size N Compare list N items at a time. Default
-# is 20.
-proc assert_bash_list_dir {expected cmd dir test {args {}}} {
- array set arg [::cmdline::getoptions args {
- {sort "compare list sorted"}
- {prompt.arg "/@" "bash prompt"}
- {chunk-size.arg 20 "compare N list items at a time"}
- }]
- set prompt $arg(prompt)
- if {$arg(sort)} {set arg_sort "-sort"} else {set arg_sort ""}
- assert_bash_exec "cd $dir" "" $prompt
- assert_bash_list $expected $cmd $test $arg_sort \
- -chunk-size $arg(chunk-size) -prompt $prompt
- sync_after_int $prompt
- assert_bash_exec {cd "$TESTDIR"}
-}
-
-
-# Make sure the expected items are returned by TAB-completing the specified
-# command. If the number of expected items is one, expected is:
-#
-# $cmd<TAB>$expected[<SPACE>]
-#
-# SPACE is not expected if -nospace is specified.
-#
-# If the number of expected items is greater than one, expected is:
-#
-# $cmd<TAB>\n
-# $expected\n
-# $prompt + ($cmd - AUTO) + longest-common-prefix-of-$expected
-#
-# AUTO is calculated like this: If $cmd ends with non-whitespace, and
-# the last argument of $cmd equals the longest-common-prefix of
-# $expected, $cmd minus this argument will be expected.
-#
-# If the algorithm above fails, you can manually specify the CWORD to be
-# subtracted from $cmd specifying `-expect-cmd-minus CWORD'. Known cases where
-# this is useful are when:
-# - the last whitespace is escaped, e.g. "finger foo\ " or "finger
-# 'foo "
-#
-# @param list $expected Expected completions.
-# @param string $cmd Command given to generate items
-# @param string $test Test title
-# @param list $args Options:
-# -prompt PROMPT Bash prompt. Default is `/@'
-# -chunk-size CHUNK-SIZE Compare list CHUNK-SIZE items at
-# a time. Default is 20.
-# -nospace Don't expect space character to be output after completion match.
-# Valid only if a single completion is expected.
-# -ltrim-colon-completions Left-trim completions with cword containing
-# colon (:)
-# -expect-cmd-minus DWORD Expect $cmd minus DWORD to be echoed.
-# Expected is:
-#
-# $cmd<TAB>\n
-# $expected\n
-# $prompt + ($cmd - DWORD) + longest-common-prefix-of-$expected
-#
-proc assert_complete {expected cmd {test ""} {args {}}} {
- set args_orig $args
- array set arg [::cmdline::getoptions args {
- {prompt.arg "/@" "bash prompt"}
- {chunk-size.arg 20 "compare N list items at a time"}
- {nospace "don't expect space after completion"}
- {ltrim-colon-completions "left-trim completions with cword containing :"}
- {expect-cmd-minus.arg "" "Expect cmd minus DWORD after prompt"}
- }]
- if {[llength $expected] == 0} {
- assert_no_complete $cmd $test
- } elseif {[llength $expected] == 1} {
- eval assert_complete_one \$expected \$cmd \$test $args_orig
- } else {
- eval assert_complete_many \$expected \$cmd \$test $args_orig
- }
-}
-
-
-# Make sure the expected multiple items are returned by TAB-completing the
-# specified command.
-# @see assert_complete()
-proc assert_complete_many {expected cmd {test ""} {args {}}} {
- array set arg [::cmdline::getoptions args {
- {prompt.arg "/@" "bash prompt"}
- {chunk-size.arg 20 "compare N list items at a time"}
- {nospace "don't expect space after completion"}
- {ltrim-colon-completions "left-trim completions with cword containing :"}
- {expect-cmd-minus.arg "" "Expect cmd minus CWORD after prompt"}
- }]
- if {$test == ""} {set test "$cmd should show completions"}
- set prompt $arg(prompt)
- set dword ""
- if {$arg(expect-cmd-minus) != ""} {set dword $arg(expect-cmd-minus)}
-
- send "$cmd\t"
- expect -ex "$cmd\r\n"
-
- # Make sure expected items are unique
- set expected [lsort -unique $expected]
-
- # Determine common prefix of completions
- set common [::textutil::string::longestCommonPrefixList $expected]
-
- if {$arg(ltrim-colon-completions)} {
- # If partial contains colon (:), remove partial from begin of items
- _ltrim_colon_completions $cmd expected dword
- }
- set cmd2 [_remove_cword_from_cmd $cmd $dword $common]
-
- set prompt "$prompt$cmd2$common"
- if {$arg(nospace)} {set endspace ""} else {set endspace "-end-space"}
- set endprompt "-end-prompt"
- if {[
- eval match_items \$expected -bash-sort -chunk-size \
- \$arg(chunk-size) $endprompt $endspace -prompt \$prompt
- ]} {
- pass "$test"
- } else {
- fail "$test"
- }
-}
-
-
-# Make sure the expected single item is returned by TAB-completing the
-# specified command.
-# @see assert_complete()
-proc assert_complete_one {expected cmd {test ""} {args {}}} {
- array set arg [::cmdline::getoptions args {
- {prompt.arg "/@" "bash prompt"}
- {chunk-size.arg 20 "compare N list items at a time"}
- {nospace "don't expect space after completion"}
- {ltrim-colon-completions "left-trim completions with cword containing :"}
- {expect-cmd-minus.arg "" "Expect cmd minus CWORD after prompt"}
- }]
- set prompt $arg(prompt)
-
- if {$test == ""} {set test "$cmd should show completion"}
- send "$cmd\t"
- expect -ex "$cmd"
- set trimmed false
- if {$arg(ltrim-colon-completions)} {
- # If partial contains colon (:), remove partial from begin of items
- set trimmed [_ltrim_colon_completions $cmd expected cword]
- }
- if {! $trimmed} {
- set cur ""; # Default to empty word to complete on
- set words [split_words_bash $cmd]
- if {[llength $words] > 1} {
- # Assume last word of `$cmd' is word to complete on.
- set index [expr [llength $words] - 1]
- set cur [lindex $words $index]
- }
- # Remove second word from beginning of $expected
- if {[string first $cur $expected] == 0} {
- set expected [list [string range $expected [string length $cur] end]]
- }
- }
-
- if {$arg(nospace)} {set endspace ""} else {set endspace "-end-space"}
- if {[
- eval match_items \$expected -bash-sort -chunk-size \
- \$arg(chunk-size) $endspace -prompt \$prompt
- ]} {
- pass "$test"
- } else {
- fail "$test"
- }
-}
-
-
-# @param string $cmd Command to remove current-word-to-complete from.
-# @param string $dword (optional) Manually specify current-word-to-complete,
-# i.e. word to remove from $cmd. If empty string (default),
-# `_remove_cword_from_cmd' autodetects if the last argument is the
-# current-word-to-complete by checking if $cmd doesn't end with whitespace.
-# Specifying `dword' is only necessary if this autodetection fails, e.g.
-# when the last whitespace is escaped or quoted, e.g. "finger foo\ " or
-# "finger 'foo "
-# @param string $common (optional) Common prefix of expected completions.
-# @return string Command with current-word-to-complete removed
-proc _remove_cword_from_cmd {cmd {dword ""} {common ""}} {
- set cmd2 $cmd
- # Is $dword specified?
- if {[string length $dword] > 0} {
- # Remove $dword from end of $cmd
- if {[string last $dword $cmd] == [string length $cmd] - [string length $dword]} {
- set cmd2 [string range $cmd 0 [expr [string last $dword $cmd] - 1]]
- }
- } else {
- # No, $dword not specified;
- # Check if last argument is really a word-to-complete, i.e.
- # doesn't end with whitespace.
- # NOTE: This check fails if trailing whitespace is escaped or quoted,
- # e.g. "finger foo\ " or "finger 'foo ". Specify parameter
- # $dword in those cases.
- # Is last char whitespace?
- if {! [string is space [string range $cmd end end]]} {
- # No, last char isn't whitespace;
- set cmds [split $cmd]
- # Does word-to-complete start with $common?
- if {[string first $common [lrange $cmds end end]] == 0} {
- # Remove word-to-complete from end of $cmd
- set cmd2 [lrange $cmds 0 end-1]
- append cmd2 " "
- }
- }
- }
- return $cmd2
-}
-
-
-# Escape regexp special characters
-proc _escape_regexp_chars {var} {
- upvar $var str
- regsub -all {([\^$+*?.|(){}[\]\\])} $str {\\\1} str
-}
-
-# Make sure any completions are returned
-proc assert_complete_any {cmd {test ""} {prompt /@}} {
- if {$test == ""} {set test "$cmd should show completions"}
- send "$cmd\t"
- expect -ex "$cmd"
- _escape_regexp_chars cmd
- expect {
- -timeout 1
- # Match completions, multiple words
- # NOTE: The `\S*' (zero or more non-whitespace characters) matches a
- # longest common prefix of the completions shown.
- # E.g. `fmt -' becomes `fmt --' (two dashes) when completing
- -re "^\r\n.*$prompt$cmd\\S*$" { pass "$test" }
- timeout {
- expect {
- # Match completion, single word. This word is shown on the
- # same line as the command.
- -re "^\\S* $" { pass "$test" }
- # Try matching multiple words again, with new timeout
- -re "^\r\n.*$prompt$cmd\\S*$" { pass "$test" }
- }
- }
- -re $prompt { unresolved "$test at prompt" }
- eof { unresolved "eof" }
- }
-}
-
-
-# Make sure the expected files are returned by TAB-completing the specified
-# command in the specified subdirectory. Be prepared to filter out OLDPWD
-# changes when calling assert_env_unmodified() after using this procedure.
-# @param list $expected
-# @param string $cmd Command given to generate items
-# @param string $dir Subdirectory to attempt completion in. The directory must be relative from the $TESTDIR and without a trailing slash. E.g. `fixtures/evince'
-# @param string $test Test title
-# @param list $args See: assert_complete()
-# @result boolean True if successful, False if not
-proc assert_complete_dir {expected cmd dir {test ""} {args {}}} {
- set prompt "/@"
- assert_bash_exec "cd $dir" "" $prompt
- eval assert_complete \$expected \$cmd \$test $args
- sync_after_int $prompt
- assert_bash_exec {cd "$TESTDIR"}
-}
-
-
-
-# If cword contains colon (:), left-trim completions with cword
-# @param string $cmd Command to complete
-# @param list $items Reference to list of completions to trim
-# @param string $dword Reference to variable to contain word to remove from
-# expected cmd.
-# See also: bash_completion._ltrim_colon_completions
-proc _ltrim_colon_completions {cmd items dword} {
- upvar 1 $items items_out
- upvar 1 $dword dword_out
-
- set cur ""; # Default to empty word to complete on
- set words [split_words_bash $cmd]
- if {[llength $words] > 1} {
- # Assume last word of `$cmd' is word to complete on.
- set index [expr [llength $words] - 1]
- set cur [lindex $words $index]
- }
- # If word-to-complete contains a colon,
- # and COMP_WORDBREAKS contains a colon
- if {
- [string first : $cur] > -1 && [string first ":" $::COMP_WORDBREAKS] > -1
- } {
- set dword_out $cur
- for {set i 0} {$i < [llength $items_out]} {incr i} {
- set item [lindex $items_out $i]
- if {[string first $cur $item] == 0} {
- # Strip colon-prefix
- lset items_out $i [string range $item [string length $cur] end]
- }
- }
- return true
- }
- return false
-}
-
-
-# Make sure the bash environment hasn't changed between now and the last call
-# to `save_env()'.
-# @param string $sed Sed commands to preprocess diff output.
-# Example calls:
-#
-# # Replace `COMP_PATH=.*' with `COMP_PATH=PATH'
-# assert_env_unmodified {s/COMP_PATH=.*/COMP_PATH=PATH/}
-#
-# # Remove lines containing `OLDPWD='
-# assert_env_unmodified {/OLDPWD=/d}
-#
-# @param string $file Filename to generate environment save file from. See
-# `gen_env_filename()'.
-# @param string $diff Expected diff output (after being processed by $sed)
-# @see save_env()
-proc assert_env_unmodified {{sed ""} {file ""} {diff ""}} {
- set test "Environment should not be modified"
- _save_env [gen_env_filename $file 2]
-
- # Prepare sed script
-
- # Escape special bash characters ("\)
- regsub -all {([\"\\])} $sed {\\\1} sed; #"# (fix Vim syntax highlighting)
- # Escape newlines
- regsub -all {\n} [string trim $sed] "\r\n" sed
-
- # Prepare diff script
-
- # If diff is filled, escape newlines and make sure it ends with a newline
- if {[string length [string trim $diff]]} {
- regsub -all {\n} [string trim $diff] "\r\n" diff
- append diff "\r\n"
- } else {
- set diff ""
- }
-
- # Execute diff
-
- # NOTE: The dummy argument 'LAST-ARG' sets bash variable $_ (last argument) to
- # 'LAST-ARG' so that $_ doesn't mess up the diff (as it would if $_
- # was the (possibly multi-lined) sed script).
- set cmd "diff_env \"[gen_env_filename $file 1]\" \"[gen_env_filename $file 2]\" \"$sed\" LAST-ARG"
- send "$cmd\r"
- expect "LAST-ARG\r\n"
-
- expect {
- -re "^$diff[wd]@$" { pass "$test" }
- -re [wd]@ {
- fail "$test"
-
- # Show diff to user
-
- set diff $expect_out(buffer)
- # Remove possible `\r\n[wd]@' from end of diff
- if {[string last "\r\n[wd]@" $diff] == [string length $diff] - [string length "\r\n[wd]@"]} {
- set diff [string range $diff 0 [expr [string last "\r\n[wd]@" $diff] - 1]]
- }
- send_user $diff;
- }
- }
-}
-
-
-# Check that no completion is attempted on a certain command.
-# Params:
-# @cmd The command to attempt to complete.
-# @test Optional parameter with test name.
-proc assert_no_complete {{cmd} {test ""}} {
- if {[string length $test] == 0} {
- set test "$cmd shouldn't complete"
- }
-
- send "$cmd\t"
- expect -ex "$cmd"
-
- # We can't anchor on $, simulate typing a magical string instead.
- set endguard "Magic End Guard"
- send "$endguard"
- expect {
- -re "^$endguard$" { pass "$test" }
- default { fail "$test" }
- timeout { fail "$test" }
- }
-}
-
-
-# Check that no output is generated on a certain command.
-# @param string $cmd The command to attempt to complete.
-# @param string $test Optional parameter with test name.
-# @param string $prompt (optional) Bash prompt. Default is "/@"
-proc assert_no_output {{cmd} {test ""} {prompt /@}} {
- if {[string length $test] == 0} {
- set test "$cmd shouldn't generate output"
- }
-
- send "$cmd\r"
- expect -ex "$cmd"
-
- expect {
- -re "^\r\n$prompt$" { pass "$test" }
- default { fail "$test" }
- timeout { fail "$test" }
- }
-}
-
-
-# Source/run file with additional tests if completion for the specified command
-# is installed in bash, and the command is available.
-# @param string $command Command to check completion availability for.
-# @param string $file (optional) File to source/run. Default is
-# "lib/completions/$cmd.exp".
-proc assert_source_completions {command {file ""}} {
- if {[assert_bash_type $command]
- && [assert_install_completion_for $command]} {
- if {[string length $file] == 0} {
- set file "$::srcdir/lib/completions/$command.exp"
- }
- source $file
- } else {
- untested $command
- }
-}
-
-
-# Sort list.
-# `exec sort' is used instead of `lsort' to achieve exactly the
-# same sort order as in bash.
-# @param list $items
-# @return list Sort list
-proc bash_sort {items} {
- return [split [exec sort << [join $items "\n"]] "\n"]
-}
-
-
-# Get 'known' hostnames. Looks also in ssh's 'known_hosts' files.
-# @param string cword (optional) Word, hosts should start with.
-# @return list Hostnames
-# @see get_hosts()
-proc get_known_hosts {{cword ''}} {
- assert_bash_exec "_known_hosts_real '$cword'; echo_array COMPREPLY" \
- {} /@ result
- return $result
-}
-
-
-# Get hostnames
-# @param list $args Options:
-# -unsorted Do not sort unique. Default is sort unique.
-# @return list Hostnames
-# @see get_known_hosts()
-proc get_hosts {{args {}}} {
- array set arg [::cmdline::getoptions args {
- {unsorted "do not sort unique"}
- }]
- set sort "| sort -u"
- if {$arg(unsorted)} {set sort ""}
- set hosts [exec bash -c "compgen -A hostname $sort"]
- # NOTE: Circumventing var `avahi_hosts' and appending directly to `hosts'
- # causes an empty element to be inserted in `hosts'.
- # -- FVu, Fri Jul 17 23:11:46 CEST 2009
- set avahi_hosts [get_hosts_avahi]
- if {[llength $avahi_hosts] > 0} {
- lappend hosts $avahi_hosts
- }
- return $hosts
-}
-
-
-# Get hostnames according to avahi
-# @return list Hostnames
-proc get_hosts_avahi {} {
- # Retrieving hosts is successful?
- if { [catch {exec bash -c {
- type avahi-browse >&/dev/null \
- && avahi-browse -cpr _workstation._tcp 2>/dev/null | command grep ^= | cut -d\; -f7 | sort -u
- }} hosts] } {
- # No, retrieving hosts yields error;
- # Reset hosts
- set hosts {}
- }
- return $hosts
-}
-
-
-# Initialize tcl globals with bash variables
-proc init_tcl_bash_globals {} {
- global BASH_VERSINFO BASH_VERSION COMP_WORDBREAKS LC_CTYPE
- assert_bash_exec {printf "%s" "$COMP_WORDBREAKS"} {} /@ COMP_WORDBREAKS
- assert_bash_exec {printf "%s " "${BASH_VERSINFO[@]}"} "" /@ BASH_VERSINFO
- set BASH_VERSINFO [eval list $BASH_VERSINFO]
- assert_bash_exec {printf "%s" "$BASH_VERSION"} "" /@ BASH_VERSION
- assert_bash_exec {printf "%s" "$TESTDIR"} "" /@ TESTDIR
- assert_bash_exec {eval $(locale); printf "%s" "$LC_CTYPE"} "" /@ LC_CTYPE
-}
-
-
-# Try installing completion for the specified command.
-# @param string $command Command to install completion for.
-# @return boolean True (1) if completion is installed, False (0) if not.
-proc assert_install_completion_for {command} {
- set test "$command should have completion installed in bash"
- set cmd "__load_completion $command ; complete -p $command &>/dev/null && echo -n 0 || echo -n 1"
- send "$cmd\r"
- expect "$cmd\r\n"
- expect {
- -ex 0 { set result true }
- -ex 1 { set result false }
- }
- expect "/@"
- return $result
-}
-
-
-# Detect if test suite is running under Cygwin/Windows
-proc is_cygwin {} {
- expr {[string first [string tolower [exec uname -s]] cygwin] >= 0}
-}
-
-
-# Expect items, a limited number (20) at a time.
-# Break items into chunks because `expect' seems to have a limited buffer size
-# @param list $items Expected list items
-# @param list $args Options:
-# -bash-sort Compare list bash-sorted. Default is
-# unsorted
-# -prompt PROMPT Bash prompt. Default is `/@'
-# -chunk-size CHUNK-SIZE Compare list CHUNK-SIZE items at
-# a time. Default is 20.
-# -end-newline Expect newline after last item.
-# Default is not.
-# -end-prompt Expect prompt after last item.
-# Default is not.
-# -end-space Expect single space after last item.
-# Default is not. Valid only if
-# `end-newline' not set.
-# @result boolean True if successful, False if not
-proc match_items {items {args {}}} {
- array set arg [::cmdline::getoptions args {
- {bash-sort "compare list sorted"}
- {prompt.arg "/@" "bash prompt"}
- {chunk-size.arg 20 "compare N list items at a time"}
- {end-newline "expect newline after last item"}
- {end-prompt "expect prompt after last item"}
- {end-space "expect space ater last item"}
- }]
- set prompt $arg(prompt)
- set size $arg(chunk-size)
- if {$arg(bash-sort)} {set items [bash_sort $items]}
- set result false
- for {set i 0} {$i < [llength $items]} {set i [expr {$i + $size}]} {
- # For chunks > 1, allow leading whitespace
- if {$i > $size} { set expected "\\s*" } else { set expected "" }
- for {set j 0} {$j < $size && $i + $j < [llength $items]} {incr j} {
- set item "[lindex $items [expr {$i + $j}]]"
- _escape_regexp_chars item
- append expected $item
- if {[llength $items] > 1} {append expected {\s+}}
- }
- if {[llength $items] == 1} {
- if {$arg(end-prompt)} {set end $prompt} {set end ""}
- # Both trailing space and newline are specified?
- if {$arg(end-newline) && $arg(end-space)} {
- # Indicate both trailing space or newline are ok
- set expected2 "|^$expected $end$"; # Include space
- append expected "\r\n$end"; # Include newline
- } else {
- if {$arg(end-newline)} {append expected "\r\n$end"}
- if {$arg(end-space)} {append expected " $end"}
- set expected2 ""
- }
- expect {
- -re "^$expected$$expected2" { set result true }
- -re "^$prompt$" {set result false; break }
- default { set result false; break }
- timeout { set result false; break }
- }
- } else {
- set end ""
- if {$arg(end-prompt) && $i + $j == [llength $items]} {
- set end "$prompt"
- _escape_regexp_chars end
- # \$ matches real end of expect_out buffer
- set end "$end\$"
- }
- expect {
- -re "^$expected$end" { set result true }
- default { set result false; break }
- timeout { set result false; break }
- }
- }
- }
- return $result
-}
-
-
-# Generate filename to save environment to.
-# @param string $file File-basename to save environment to. If the file has a
-# `.exp' suffix, it is removed. E.g.:
-# - "file.exp" becomes "file.env1~"
-# - "" becomes "env.env1~"
-# - "filename" becomes "filename.env1~"
-# The file will be stored in the $TESTDIR/tmp directory.
-# @param integer $seq Sequence number. Must be either 1 or 2.
-proc gen_env_filename {{file ""} {seq 1}} {
- if {[string length $file] == 0} {
- set file "env"
- } else {
- # Remove possible directories
- set file [file tail $file]
- # Remove possible '.exp' suffix from filename
- if {[string last ".exp" $file] == [string length $file] - [string length ".exp"]} {
- set file [string range $file 0 [expr [string last ".exp" $file] - 1]]
- }
- }
- return "\$TESTDIR/tmp/$file.env$seq~"
-}
-
-
-# Save the environment for later comparison
-# @param string $file Filename to generate environment save file from. See
-# `gen_env_filename()'.
-proc save_env {{file ""}} {
- _save_env [gen_env_filename $file 1]
-}
-
-
-# Save the environment for later comparison
-# @param string File to save the environment to. Default is "$TESTDIR/tmp/env1~".
-# @see assert_env_unmodified()
-proc _save_env {{file ""}} {
- assert_bash_exec "{ (set -o posix ; set); declare -F; shopt -p; set -o; } > \"$file\""
-}
-
-
-# Source bash_completion package
-proc source_bash_completion {} {
- assert_bash_exec {source $(cd "$SRCDIR/.."; pwd)/bash_completion}
-}
-
-
-# Split line into words, disregarding backslash escapes (e.g. \b (backspace),
-# \g (bell)), but taking backslashed spaces into account.
-# Aimed for simulating bash word splitting.
-# Example usage:
-#
-# % set a {f cd\ \be}
-# % split_words $a
-# f {cd\ \be}
-#
-# @param string Line to split
-# @return list Words
-proc split_words_bash {line} {
- set words {}
- set glue false
- foreach part [split $line] {
- set glue_next false
- # Does `part' end with a backslash (\)?
- if {[string last "\\" $part] == [string length $part] - [string length "\\"]} {
- # Remove end backslash
- set part [string range $part 0 [expr [string length $part] - [string length "\\"] - 1]]
- # Indicate glue on next run
- set glue_next true
- }
- # Must `part' be appended to latest word (= glue)?
- if {[llength $words] > 0 && [string is true $glue]} {
- # Yes, join `part' to latest word;
- set zz [lindex $words [expr [llength $words] - 1]]
- # Separate glue with backslash-space (\ );
- lset words [expr [llength $words] - 1] "$zz\\ $part"
- } else {
- # No, don't append word to latest word;
- # Append `part' as separate word
- lappend words $part
- }
- set glue $glue_next
- }
- return $words
-}
-
-
-# Given a list of items this proc finds a (part, full) pair so that when
-# completing from $part $full will be the only option.
-#
-# Arguments:
-# list The list of full completions.
-# partName Output parameter for the partial string.
-# fullName Output parameter for the full string, member of item.
-#
-# Results:
-# 1, or 0 if no suitable result was found.
-proc find_unique_completion_pair {{list} {partName} {fullName}} {
- upvar $partName part
- upvar $fullName full
- set bestscore 0
- # Uniquify the list, that's what completion does too.
- set list [lsort -unique $list]
- set n [llength $list]
- for {set i 0} {$i < $n} {incr i} {
- set cur [lindex $list $i]
- set curlen [string length $cur]
-
- set prev [lindex $list [expr {$i - 1}]]
- set next [lindex $list [expr {$i + 1}]]
- set diffprev [expr {$prev == ""}]
- set diffnext [expr {$next == ""}]
-
- # Analyse each item of the list and look for the minimum length of the
- # partial prefix which is distinct from both $next and $prev. The list
- # is sorted so the prefix will be unique in the entire list.
- #
- # In the worst case we analyse every character in the list 3 times.
- # That's actually very fast, sorting could take more.
- for {set j 0} {$j < $curlen} {incr j} {
- set curchar [string index $cur $j]
- if {!$diffprev && [string index $prev $j] != $curchar} {
- set diffprev 1
- }
- if {!$diffnext && [string index $next $j] != $curchar} {
- set diffnext 1
- }
- if {$diffnext && $diffprev} {
- break
- }
- }
-
- # At the end of the loop $j is the index of last character of
- # the unique partial prefix. The length is one plus that.
- set parlen [expr {$j + 1}]
- if {$parlen >= $curlen} {
- continue
- }
-
- # Try to find the most "readable pair"; look for a long pair where
- # $part is about half of $full.
- if {$parlen < $curlen / 2} {
- set parlen [expr {$curlen / 2}]
- }
- set score [expr {$curlen - $parlen}]
- if {$score > $bestscore} {
- set bestscore $score
- set part [string range $cur 0 [expr {$parlen - 1}]]
- set full $cur
- }
- }
- return [expr {$bestscore != 0}]
-}
-
-
-# Start bash running as test environment.
-proc start_bash {} {
- global TESTDIR TOOL_EXECUTABLE spawn_id env srcdirabs
- set TESTDIR [pwd]
- set srcdirabs [file normalize $::srcdir]; # Absolute srcdir
- # If `--tool_exec' option not specified, use "bash"
- if {! [info exists TOOL_EXECUTABLE]} {set TOOL_EXECUTABLE bash}
- set env(SRCDIR) $::srcdir
- set env(SRCDIRABS) $::srcdirabs
-
- # PS1, INPUTRC, TERM and stty columns must be initialized
- # *before* starting bash to take proper effect.
-
- # Set fixed prompt `/@'
- set env(PS1) "/@"
- # Configure readline
- set env(INPUTRC) "$::srcdir/config/inputrc"
- # Avoid escape junk at beginning of line from readline,
- # see e.g. http://bugs.gentoo.org/246091
- set env(TERM) "dumb"
- # Ensure enough columns so expect doesn't have to care about line breaks
- set stty_init "columns 150"
-
- exp_spawn $TOOL_EXECUTABLE --norc
- assert_bash_exec {} "$TOOL_EXECUTABLE --norc"
- assert_bash_exec "source $::srcdir/config/bashrc"
-}
-
-
-# Redirect xtrace output to a file.
-#
-# 'set -x' can be very useful for debugging but by default it writes to
-# stderr.
-#
-# This function uses file descriptor 6. This will break if any completion
-# tries to use the same descriptor.
-proc init_bash_xtrace {{fname xtrace.log}} {
- verbose "Enabling bash xtrace output to '$fname'"
- assert_bash_exec "exec 6>'$fname'"
- assert_bash_exec "BASH_XTRACEFD=6"
- assert_bash_exec "set -o xtrace"
-}
-
-
-# Setup test environment
-#
-# Common initialization for unit and completion tests.
-proc start_interactive_test {} {
- start_bash
- source_bash_completion
- init_tcl_bash_globals
-
- global OPT_BASH_XTRACE
- if {[info exists OPT_BASH_XTRACE]} {
- init_bash_xtrace
- }
- global OPT_BUFFER_SIZE
- if {![info exists OPT_BUFFER_SIZE]} {
- set OPT_BUFFER_SIZE 20000
- }
- verbose "Changing default expect match buffer size to $OPT_BUFFER_SIZE"
- match_max $OPT_BUFFER_SIZE
- global OPT_TIMEOUT
- if {[info exists OPT_TIMEOUT]} {
- global timeout
- verbose "Changing default expect timeout from $timeout to $OPT_TIMEOUT"
- set timeout $OPT_TIMEOUT
- }
-}
-
-
-# Interrupt completion and sync with prompt.
-# Send signals QUIT & INT.
-# @param string $prompt (optional) Bash prompt. Default is "/@"
-proc sync_after_int {{prompt /@}} {
- set test "Sync after INT"
- sleep .1
- send \031\003; # QUIT/INT
- # Wait to allow bash to become ready
- # See also: http://lists.alioth.debian.org/pipermail/bash-completion-devel/
- # 2010-February/002566.html
- sleep .1
- # NOTE: Regexp `.*' causes `expect' to discard previous unknown output.
- # This is necessary if a completion doesn't match expectations.
- # For instance with `filetype_xspec' completion (e.g. `kdvi') if
- # one expects `.txt' as a completion (wrong, because it isn't
- # there), the unmatched completions need to be cleaned up.
- expect -re ".*$prompt$"
-}
-
-
-proc sync_after_tab {} {
- # NOTE: Wait in case completion returns nothing - because `units' isn't
- # installed, so that "^$cdm.*$" doesn't match too early - before
- # comp_install has finished
- sleep .4
-}
-
-
-# Return current working directory with `TESTDIR' stripped
-# @return string Working directory. E.g. /, or /fixtures/
-proc wd {} {
- global TESTDIR
- # Remove `$TESTDIR' prefix from current working directory
- set wd [string replace [pwd] 0 [expr [string length $TESTDIR] - 1]]/
-}
diff --git a/test/lib/library.sh b/test/lib/library.sh
deleted file mode 100644
index ed5a85d4..00000000
--- a/test/lib/library.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-# Bash library for bash-completion DejaGnu testsuite
-
-
-# @param $1 Char to add to $COMP_WORDBREAKS
-add_comp_wordbreak_char() {
- [[ "${COMP_WORDBREAKS//[^$1]}" ]] || COMP_WORDBREAKS+=$1
-} # add_comp_wordbreak_char()
-
-
-# Diff environment files to detect if environment is unmodified
-# @param $1 File 1
-# @param $2 File 2
-# @param $3 Additional sed script
-diff_env() {
- diff "$1" "$2" | sed -e "
-# Remove diff line indicators
- /^[0-9,]\{1,\}[acd]/d
-# Remove diff block separators
- /---/d
-# Remove underscore variable
- /[<>] _=/d
-# Remove PPID bash variable
- /[<>] PPID=/d
-# Remove BASH_REMATCH bash variable
- /[<>] BASH_REMATCH=/d
-# Remove functions starting with underscore
- /[<>] declare -f _/d
- $3"
-} # diff_env()
-
-
-# Output array elements, sorted and separated by newline
-# Unset variable after outputting.
-# @param $1 Name of array variable to process
-echo_array() {
- local name=$1[@]
- printf "%s\n" "${!name}" | sort
-} # echo_array()
diff --git a/test/lib/unit.exp b/test/lib/unit.exp
deleted file mode 100644
index e113e1b5..00000000
--- a/test/lib/unit.exp
+++ /dev/null
@@ -1,25 +0,0 @@
-source $::srcdir/lib/library.exp
-
-
-proc unit_exit {} {
- # Exit bash
- send "\rexit\r"
-}
-
-
-proc unit_init {test_file_name} {
- # Call unit_start() only once
- if {! [info exists ::BASH_VERSINFO]} {
- unit_start
- }
-}
-
-
-proc unit_start {} {
- start_interactive_test
-}
-
-
-proc unit_version {} {
- puts "$::TESTDIR, bash-$::BASH_VERSION"
-}
diff --git a/test/requirements-dev.txt b/test/requirements-dev.txt
new file mode 100644
index 00000000..f34f10fb
--- /dev/null
+++ b/test/requirements-dev.txt
@@ -0,0 +1,4 @@
+# Python >= 3.6.1 required here
+-r requirements.txt
+black==19.10b0
+pre-commit>=2.4.0
diff --git a/test/requirements.txt b/test/requirements.txt
index 70d77d02..df56f4e0 100644
--- a/test/requirements.txt
+++ b/test/requirements.txt
@@ -1,4 +1,4 @@
-black>=19.10b0;python_version>"3.6"
+# Python >= 3.4 required here
pexpect>=4
pytest>=3.6
pytest-xdist
diff --git a/test/run b/test/run
deleted file mode 100755
index 6180bbbf..00000000
--- a/test/run
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/bash
-
-
-# Print some helpful messages.
-usage() {
- echo "Run bash-completion tests"
- echo
- echo "The 'tool' is determined automatically from filenames."
- echo "Unrecognized options are passed through to dejagnu by default."
- echo
- echo "Interesting options:"
- echo " --tool_exec= Test against a different bash executable."
- echo " --buffer-size Change expect match buffer size from our default of 20000 bytes."
- echo " --debug Create a dbg.log in the test directory with detailed expect match information."
- echo " --timeout Change expect timeout from the default of 10 seconds."
- echo " --debug-xtrace Create an xtrace.log in the test directory with set -x output."
- echo
- echo "Example run: ./run unit/_get_cword.exp unit/compgen.exp"
-}
-
-
-# Try to set the tool variable; or fail if trying to set different values.
-set_tool() {
- if [[ $tool ]]; then
- if [[ $tool != $1 ]]; then
- echo "Tool spec mismatch ('$tool' and '$1'). See --usage."
- exit 1
- fi
- else
- tool=$1
- fi
-}
-
-
-cd "$(dirname "${BASH_SOURCE[0]}")"
-
-
-# Loop over the arguments.
-args=()
-while [[ $# > 0 ]]; do
- case "$1" in
- --help|--usage) usage; exit 1;;
- --buffer-size) shift; buffer_size=$1;;
- --buffer-size=*) buffer_size=${1/--buffer-size=};;
- --debug-xtrace) args+=(OPT_BASH_XTRACE=1);;
- --timeout) shift; timeout=$1;;
- --timeout=*) timeout=${1/--timeout=};;
- --tool=*) set_tool "${1#/--tool=}";;
- --tool) shift; set_tool "$1";;
- completion/*.exp|*/completion/*.exp|unit/*.exp|*/unit/*.exp)
- arg=${1%/*}
- set_tool "${arg##*/}"
- args+=("${1##*/}")
- ;;
- *) args+=("$1")
- esac
- shift
-done
-
-[[ -n $buffer_size ]] && args+=("OPT_BUFFER_SIZE=$buffer_size")
-[[ -n $timeout ]] && args+=("OPT_TIMEOUT=$timeout")
-[[ -z $tool ]] && { echo "Must specify tool somehow"; exit 1; }
-
-runtest --outdir log --tool $tool "${args[@]}"
-rc=$?
-[[ $rc -ne 0 && -n "$CI" ]] && cat log/$tool.log
-exit $rc
diff --git a/test/run-shellcheck b/test/run-shellcheck
deleted file mode 100755
index cae7b809..00000000
--- a/test/run-shellcheck
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh -eu
-cd "$(dirname $0)/.."
-exec docker run --network none -tv "$PWD:/mnt:ro" \
- koalaman/shellcheck -S error "$@"
diff --git a/test/runCompletion b/test/runCompletion
deleted file mode 100755
index 38a82622..00000000
--- a/test/runCompletion
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-# NOTE: I tried setting up bash_completion_lib within ./lib files, but DejaGnu
-# isn't initialized at that point (i.e. output of `expect' is shown on
-# stdout - `open_logs' hasn't run yet?). And running code from a library
-# file isn't probably a good idea either.
-exec "${bashcomp_bash:-$BASH}" \
- "$(dirname "${BASH_SOURCE[0]}")/run" --tool completion $*
diff --git a/test/runInstall b/test/runInstall
deleted file mode 100755
index 87aea589..00000000
--- a/test/runInstall
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-# NOTE: I tried setting up bash_completion_lib within ./lib files, but DejaGnu
-# isn't initialized at that point (i.e. output of `expect' is shown on
-# stdout - `open_logs' hasn't run yet?). And running code from a library
-# file isn't probably a good idea either.
-exec runtest --outdir log --tool install $*
diff --git a/test/runLint b/test/runLint
index a84c46d8..95c3887e 100755
--- a/test/runLint
+++ b/test/runLint
@@ -1,10 +1,10 @@
-#!/bin/bash
+#!/bin/bash -u
gitgrep()
{
- local out=$(git grep -I -P -n "$1" | \
- grep -E '^(bash_completion|completions/|test/)' | \
- grep -Fv 'test/runLint')
+ local out=$(git grep -I -P -n "$1" |
+ grep -E '^(bash_completion|completions/|test/)' |
+ grep -Ev "^test/runLint\>${filter_out:+|$filter_out}")
if [ -n "$out" ]; then
printf '***** %s\n' "$2"
printf '%s\n\n' "$out"
@@ -12,9 +12,10 @@ gitgrep()
}
unset CDPATH
-cd $(dirname "$0") ; cd ..
+cd $(dirname "$0")/..
cmdstart='(^|[[:space:]]|\()'
+filter_out=
gitgrep $cmdstart"awk\b.*-F([[:space:]]|[[:space:]]*[\"'][^\"']{2,})" \
'awk with -F char or -F ERE, use -Fchar instead (Solaris)'
@@ -45,3 +46,6 @@ gitgrep '(?<!command)'$cmdstart'(grep|ls|sed)(\s|$)' \
'invoke grep, ls, and sed through "command", e.g. "command grep"'
gitgrep '<<<' 'herestrings use temp files, use some other way'
+
+filter_out='^(test/|bash_completion\.sh)' gitgrep ' \[ ' \
+ 'use [[ ]] instead of [ ]'
diff --git a/test/runUnit b/test/runUnit
deleted file mode 100755
index 5df06227..00000000
--- a/test/runUnit
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-# NOTE: I tried setting up bash_completion_lib within ./lib files, but DejaGnu
-# isn't initialized at that point (i.e. output of `expect' is shown on
-# stdout - `open_logs' hasn't run yet?). And running code from a library
-# file isn't probably a good idea either.
-exec "${bashcomp_bash:-$BASH}" \
- "$(dirname "${BASH_SOURCE[0]}")/run" --tool unit $*
diff --git a/test/setup.cfg b/test/setup.cfg
index ef9c755e..6abd7d3a 100644
--- a/test/setup.cfg
+++ b/test/setup.cfg
@@ -7,3 +7,12 @@ markers =
[mypy]
python_version = 3.4
ignore_missing_imports = true
+
+[isort]
+known_first_party = conftest
+known_third_party = pexpect,pytest
+profile = black
+line_length = 79
+
+[flake8]
+extend-ignore = D202,E203,E501
diff --git a/test/t/Makefile.am b/test/t/Makefile.am
index 0ce46b12..801841fb 100644
--- a/test/t/Makefile.am
+++ b/test/t/Makefile.am
@@ -45,6 +45,7 @@ EXTRA_DIST = \
test_bind.py \
test_bison.py \
test_bk.py \
+ test_bmake.py \
test_brctl.py \
test_btdownloadcurses_py.py \
test_btdownloadgui_py.py \
@@ -132,6 +133,7 @@ EXTRA_DIST = \
test_dot.py \
test_dpkg.py \
test_dpkg_deb.py \
+ test_dpkg_query.py \
test_dpkg_reconfigure.py \
test_dpkg_source.py \
test_dropdb.py \
@@ -249,6 +251,7 @@ EXTRA_DIST = \
test_invoke_rc_d.py \
test_ionice.py \
test_ip.py \
+ test_ipcalc.py \
test_iperf.py \
test_ipmitool.py \
test_ipsec.py \
@@ -456,6 +459,7 @@ EXTRA_DIST = \
test_povray.py \
test_pr.py \
test_prelink.py \
+ test_printenv.py \
test_protoc.py \
test_psql.py \
test_ptx.py \
@@ -523,9 +527,11 @@ EXTRA_DIST = \
test_sbcl.py \
test_sbcl_mt.py \
test_sbopkg.py \
+ test_scp.py \
test_screen.py \
test_scrub.py \
test_sdptool.py \
+ test_secret_tool.py \
test_sed.py \
test_seq.py \
test_service.py \
@@ -589,11 +595,13 @@ EXTRA_DIST = \
test_time.py \
test_timeout.py \
test_tipc.py \
+ test_totem.py \
test_touch.py \
test_tox.py \
test_tr.py \
test_tracepath.py \
test_tshark.py \
+ test_tsig_keygen.py \
test_tune2fs.py \
test_udevadm.py \
test_ulimit.py \
@@ -657,6 +665,7 @@ EXTRA_DIST = \
test_xdg_settings.py \
test_xfreerdp.py \
test_xgamma.py \
+ test_xhost.py \
test_xm.py \
test_xmllint.py \
test_xmlwf.py \
diff --git a/test/t/conftest.py b/test/t/conftest.py
index 20942e87..5c1603d5 100644
--- a/test/t/conftest.py
+++ b/test/t/conftest.py
@@ -3,18 +3,18 @@ import os
import re
import shlex
import subprocess
-from typing import Iterable, List, Optional, Tuple, Union
+import time
+from typing import Callable, Iterable, Iterator, List, Optional, Tuple
import pexpect
import pytest
-
PS1 = "/@"
MAGIC_MARK = "__MaGiC-maRKz!__"
def find_unique_completion_pair(
- items: Iterable[str]
+ items: Iterable[str],
) -> Optional[Tuple[str, str]]:
result = None
bestscore = 0
@@ -56,10 +56,22 @@ def find_unique_completion_pair(
@pytest.fixture(scope="class")
-def part_full_user(bash: pexpect.spawn) -> Optional[Tuple[str, str]]:
- res = (
- assert_bash_exec(bash, "compgen -u", want_output=True).strip().split()
- )
+def output_sort_uniq(bash: pexpect.spawn) -> Callable[[str], List[str]]:
+ def _output_sort_uniq(command: str) -> List[str]:
+ return sorted(
+ set( # weed out possible duplicates
+ assert_bash_exec(bash, command, want_output=True).split()
+ )
+ )
+
+ return _output_sort_uniq
+
+
+@pytest.fixture(scope="class")
+def part_full_user(
+ bash: pexpect.spawn, output_sort_uniq: Callable[[str], List[str]]
+) -> Optional[Tuple[str, str]]:
+ res = output_sort_uniq("compgen -u")
pair = find_unique_completion_pair(res)
if not pair:
pytest.skip("No suitable test user found")
@@ -67,10 +79,10 @@ def part_full_user(bash: pexpect.spawn) -> Optional[Tuple[str, str]]:
@pytest.fixture(scope="class")
-def part_full_group(bash: pexpect.spawn) -> Optional[Tuple[str, str]]:
- res = (
- assert_bash_exec(bash, "compgen -g", want_output=True).strip().split()
- )
+def part_full_group(
+ bash: pexpect.spawn, output_sort_uniq: Callable[[str], List[str]]
+) -> Optional[Tuple[str, str]]:
+ res = output_sort_uniq("compgen -g")
pair = find_unique_completion_pair(res)
if not pair:
pytest.skip("No suitable test user found")
@@ -78,6 +90,82 @@ def part_full_group(bash: pexpect.spawn) -> Optional[Tuple[str, str]]:
@pytest.fixture(scope="class")
+def hosts(bash: pexpect.spawn) -> List[str]:
+ output = assert_bash_exec(bash, "compgen -A hostname", want_output=True)
+ return sorted(set(output.split() + _avahi_hosts(bash)))
+
+
+@pytest.fixture(scope="class")
+def avahi_hosts(bash: pexpect.spawn) -> List[str]:
+ return _avahi_hosts(bash)
+
+
+def _avahi_hosts(bash: pexpect.spawn) -> List[str]:
+ output = assert_bash_exec(
+ bash,
+ "! type avahi-browse &>/dev/null || "
+ "avahi-browse -cpr _workstation._tcp 2>/dev/null "
+ "| command grep ^= | cut -d';' -f7",
+ want_output=None,
+ )
+ return sorted(set(output.split()))
+
+
+@pytest.fixture(scope="class")
+def known_hosts(bash: pexpect.spawn) -> List[str]:
+ output = assert_bash_exec(
+ bash,
+ '_known_hosts_real ""; '
+ r'printf "%s\n" "${COMPREPLY[@]}"; unset COMPREPLY',
+ want_output=True,
+ )
+ return sorted(set(output.split()))
+
+
+@pytest.fixture(scope="class")
+def user_home(bash: pexpect.spawn) -> Tuple[str, str]:
+ user = assert_bash_exec(
+ bash, 'id -un 2>/dev/null || echo "$USER"', want_output=True
+ ).strip()
+ home = assert_bash_exec(bash, 'echo "$HOME"', want_output=True).strip()
+ return (user, home)
+
+
+def partialize(
+ bash: pexpect.spawn, items: Iterable[str]
+) -> Tuple[str, List[str]]:
+ """
+ Get list of items starting with the first char of first of items.
+
+ Disregard items starting with a COMP_WORDBREAKS character
+ (e.g. a colon ~ IPv6 address), they are special cases requiring
+ special tests.
+ """
+ first_char = None
+ comp_wordbreaks = assert_bash_exec(
+ bash,
+ 'printf "%s" "$COMP_WORDBREAKS"',
+ want_output=True,
+ want_newline=False,
+ )
+ partial_items = []
+ for item in sorted(items):
+ if first_char is None:
+ if item[0] not in comp_wordbreaks:
+ first_char = item[0]
+ partial_items.append(item)
+ elif item.startswith(first_char):
+ partial_items.append(item)
+ else:
+ break
+ if first_char is None:
+ pytest.skip("Could not generate partial items list from %s" % items)
+ # superfluous/dead code to assist mypy; pytest.skip always raises
+ assert first_char is not None
+ return first_char, partial_items
+
+
+@pytest.fixture(scope="class")
def bash(request) -> pexpect.spawn:
logfile = None
@@ -135,7 +223,7 @@ def bash(request) -> pexpect.spawn:
skipif = marker.kwargs.get("skipif")
if skipif:
try:
- assert_bash_exec(bash, skipif)
+ assert_bash_exec(bash, skipif, want_output=None)
except AssertionError:
pass
else:
@@ -144,7 +232,7 @@ def bash(request) -> pexpect.spawn:
xfail = marker.kwargs.get("xfail")
if xfail:
try:
- assert_bash_exec(bash, xfail)
+ assert_bash_exec(bash, xfail, want_output=None)
except AssertionError:
pass
else:
@@ -182,7 +270,7 @@ def bash(request) -> pexpect.spawn:
logfile.close()
-def is_testable(bash: pexpect.spawn, cmd: str) -> bool:
+def is_testable(bash: pexpect.spawn, cmd: Optional[str]) -> bool:
if not cmd:
pytest.fail("Could not resolve name of command to test")
return False
@@ -214,8 +302,14 @@ def load_completion_for(bash: pexpect.spawn, cmd: str) -> bool:
def assert_bash_exec(
- bash: pexpect.spawn, cmd: str, want_output: bool = False, want_newline=True
+ bash: pexpect.spawn,
+ cmd: str,
+ want_output: Optional[bool] = False,
+ want_newline=True,
) -> str:
+ """
+ :param want_output: if None, don't care if got output or not
+ """
# Send command
bash.sendline(cmd)
@@ -243,16 +337,17 @@ def assert_bash_exec(
status,
output,
)
- if output:
- assert want_output, (
- 'Unexpected output from "%s": exit status=%s, output="%s"'
- % (cmd, status, output)
- )
- else:
- assert not want_output, (
- 'Expected output from "%s": exit status=%s, output="%s"'
- % (cmd, status, output)
- )
+ if want_output is not None:
+ if output:
+ assert want_output, (
+ 'Unexpected output from "%s": exit status=%s, output="%s"'
+ % (cmd, status, output)
+ )
+ else:
+ assert not want_output, (
+ 'Expected output from "%s": exit status=%s, output="%s"'
+ % (cmd, status, output)
+ )
return output
@@ -293,76 +388,52 @@ def diff_env(before: List[str], after: List[str], ignore: str):
assert not diff, "Environment should not be modified"
-class CompletionResult:
+class CompletionResult(Iterable[str]):
"""
Class to hold completion results.
"""
- def __init__(self, output: str, items: Optional[Iterable[str]] = None):
+ def __init__(self, output: Optional[str] = None):
"""
- When items are specified, they are used as the base for comparisons
- provided by this class. When not, regular expressions are used instead.
- This is because it is not always possible to unambiguously split a
- completion output string into individual items, for example when the
- items contain whitespace.
-
:param output: All completion output as-is.
- :param items: Completions as individual items. Should be specified
- only in cases where the completions are robustly known to be
- exactly the specified ones.
"""
- self.output = output
- self._items = None if items is None else sorted(items)
+ self.output = output or ""
def endswith(self, suffix: str) -> bool:
return self.output.endswith(suffix)
- def __eq__(self, expected: Union[str, Iterable[str]]) -> bool:
+ def startswith(self, prefix: str) -> bool:
+ return self.output.startswith(prefix)
+
+ def _items(self) -> List[str]:
+ return [x.strip() for x in self.output.strip().splitlines()]
+
+ def __eq__(self, expected: object) -> bool:
"""
Returns True if completion contains expected items, and no others.
Defining __eq__ this way is quite ugly, but facilitates concise
testing code.
"""
- expiter = [expected] if isinstance(expected, str) else expected
- if self._items is not None:
- return self._items == expiter
- return bool(
- re.match(
- r"^\s*" + r"\s+".join(re.escape(x) for x in expiter) + r"\s*$",
- self.output,
- )
- )
+ if isinstance(expected, str):
+ expiter = [expected] # type: Iterable
+ elif not isinstance(expected, Iterable):
+ return False
+ else:
+ expiter = expected
+ return self._items() == expiter
def __contains__(self, item: str) -> bool:
- if self._items is not None:
- return item in self._items
- return bool(
- re.search(r"(^|\s)%s(\s|$)" % re.escape(item), self.output)
- )
+ return item in self._items()
- def __iter__(self) -> Iterable[str]:
- """
- Note that iteration over items may not be accurate when items were not
- specified to the constructor, if individual items in the output contain
- whitespace. In those cases, it errs on the side of possibly returning
- more items than there actually are, and intends to never return fewer.
- """
- return iter(
- self._items
- if self._items is not None
- else re.split(r" {2,}|\r\n", self.output.strip())
- )
+ def __iter__(self) -> Iterator[str]:
+ return iter(self._items())
def __len__(self) -> int:
- """
- Uses __iter__, see caveat in it. While possibly inaccurate, this is
- good enough for truthiness checks.
- """
- return len(list(iter(self)))
+ return len(self._items())
def __repr__(self) -> str:
- return "<CompletionResult %s>" % list(self)
+ return "<CompletionResult %s>" % self._items()
def assert_complete(
@@ -371,7 +442,7 @@ def assert_complete(
skipif = kwargs.get("skipif")
if skipif:
try:
- assert_bash_exec(bash, skipif)
+ assert_bash_exec(bash, skipif, want_output=None)
except AssertionError:
pass
else:
@@ -379,7 +450,7 @@ def assert_complete(
xfail = kwargs.get("xfail")
if xfail:
try:
- assert_bash_exec(bash, xfail)
+ assert_bash_exec(bash, xfail, want_output=None)
except AssertionError:
pass
else:
@@ -393,57 +464,63 @@ def assert_complete(
# Back up environment and apply new one
assert_bash_exec(
bash,
- " ".join('%s%s="$%s"' % (env_prefix, k, k) for k in env.keys()),
+ " ".join('%s%s="${%s-}"' % (env_prefix, k, k) for k in env.keys()),
)
assert_bash_exec(
bash,
"export %s" % " ".join("%s=%s" % (k, v) for k, v in env.items()),
)
- bash.send(cmd + "\t")
- bash.expect_exact(cmd)
- bash.send(MAGIC_MARK)
- got = bash.expect(
- [
- # 0: multiple lines, result in .before
- r"\r\n" + re.escape(PS1 + cmd) + ".*" + MAGIC_MARK,
- # 1: no completion
- r"^" + MAGIC_MARK,
- # 2: on same line, result in .match
- r"^([^\r]+)%s$" % MAGIC_MARK,
- pexpect.EOF,
- pexpect.TIMEOUT,
- ]
- )
- if got == 0:
- output = bash.before
- if output.endswith(MAGIC_MARK):
- output = bash.before[: -len(MAGIC_MARK)]
- result = CompletionResult(output)
- elif got == 2:
- output = bash.match.group(1)
- result = CompletionResult(output, [shlex.split(cmd + output)[-1]])
- else:
- # TODO: warn about EOF/TIMEOUT?
- result = CompletionResult("", [])
- bash.sendintr()
- bash.expect_exact(PS1)
- if env:
- # Restore environment, and clean up backup
- # TODO: Test with declare -p if a var was set, backup only if yes, and
- # similarly restore only backed up vars. Should remove some need
- # for ignore_env.
- assert_bash_exec(
- bash,
- "export %s"
- % " ".join('%s="$%s%s"' % (k, env_prefix, k) for k in env.keys()),
- )
- assert_bash_exec(
- bash,
- "unset -v %s"
- % " ".join("%s%s" % (env_prefix, k) for k in env.keys()),
+ try:
+ bash.send(cmd + "\t")
+ # Sleep a bit if requested, to avoid `.*` matching too early
+ time.sleep(kwargs.get("sleep_after_tab", 0))
+ bash.expect_exact(cmd)
+ bash.send(MAGIC_MARK)
+ got = bash.expect(
+ [
+ # 0: multiple lines, result in .before
+ r"\r\n" + re.escape(PS1 + cmd) + ".*" + re.escape(MAGIC_MARK),
+ # 1: no completion
+ r"^" + re.escape(MAGIC_MARK),
+ # 2: on same line, result in .match
+ r"^([^\r]+)%s$" % re.escape(MAGIC_MARK),
+ pexpect.EOF,
+ pexpect.TIMEOUT,
+ ]
)
- if cwd:
- assert_bash_exec(bash, "cd - >/dev/null")
+ if got == 0:
+ output = bash.before
+ if output.endswith(MAGIC_MARK):
+ output = bash.before[: -len(MAGIC_MARK)]
+ result = CompletionResult(output)
+ elif got == 2:
+ output = bash.match.group(1)
+ result = CompletionResult(output)
+ else:
+ # TODO: warn about EOF/TIMEOUT?
+ result = CompletionResult()
+ finally:
+ bash.sendintr()
+ bash.expect_exact(PS1)
+ if env:
+ # Restore environment, and clean up backup
+ # TODO: Test with declare -p if a var was set, backup only if yes, and
+ # similarly restore only backed up vars. Should remove some need
+ # for ignore_env.
+ assert_bash_exec(
+ bash,
+ "export %s"
+ % " ".join(
+ '%s="$%s%s"' % (k, env_prefix, k) for k in env.keys()
+ ),
+ )
+ assert_bash_exec(
+ bash,
+ "unset -v %s"
+ % " ".join("%s%s" % (env_prefix, k) for k in env.keys()),
+ )
+ if cwd:
+ assert_bash_exec(bash, "cd - >/dev/null")
return result
@@ -451,7 +528,7 @@ def assert_complete(
def completion(request, bash: pexpect.spawn) -> CompletionResult:
marker = request.node.get_closest_marker("complete")
if not marker:
- return CompletionResult("", [])
+ return CompletionResult()
for pre_cmd in marker.kwargs.get("pre_cmds", []):
assert_bash_exec(bash, pre_cmd)
cmd = getattr(request.cls, "cmd", None)
@@ -467,9 +544,61 @@ def completion(request, bash: pexpect.spawn) -> CompletionResult:
) % ((cmd,) * 2)
if marker.kwargs.get("require_cmd") and not is_bash_type(bash, cmd):
pytest.skip("Command not found")
+
+ if "trail" in marker.kwargs:
+ return assert_complete_at_point(
+ bash, cmd=marker.args[0], trail=marker.kwargs["trail"]
+ )
+
return assert_complete(bash, marker.args[0], **marker.kwargs)
+def assert_complete_at_point(
+ bash: pexpect.spawn, cmd: str, trail: str
+) -> CompletionResult:
+ # TODO: merge to assert_complete
+ fullcmd = "%s%s%s" % (
+ cmd,
+ trail,
+ "\002" * len(trail),
+ ) # \002 = ^B = cursor left
+ bash.send(fullcmd + "\t")
+ bash.send(MAGIC_MARK)
+ bash.expect_exact(fullcmd.replace("\002", "\b"))
+
+ got = bash.expect_exact(
+ [
+ # 0: multiple lines, result in .before
+ PS1 + fullcmd.replace("\002", "\b"),
+ # 1: no completion
+ MAGIC_MARK,
+ pexpect.EOF,
+ pexpect.TIMEOUT,
+ ]
+ )
+ if got == 0:
+ output = bash.before
+ result = CompletionResult(output)
+
+ # At this point, something weird happens. For most test setups, as
+ # expected (pun intended!), MAGIC_MARK follows as is. But for some
+ # others (e.g. CentOS 6, Ubuntu 14 test containers), we get MAGIC_MARK
+ # one character a time, followed each time by trail and the corresponding
+ # number of \b's. Don't know why, but accept it until/if someone finds out.
+ # Or just be fine with it indefinitely, the visible and practical end
+ # result on a terminal is the same anyway.
+ repeat = "(%s%s)?" % (re.escape(trail), "\b" * len(trail))
+ fullexpected = "".join(
+ "%s%s" % (re.escape(x), repeat) for x in MAGIC_MARK
+ )
+ bash.expect(fullexpected)
+ else:
+ # TODO: warn about EOF/TIMEOUT?
+ result = CompletionResult()
+
+ return result
+
+
def in_container() -> bool:
try:
container = subprocess.check_output(
diff --git a/test/t/test_2to3.py b/test/t/test_2to3.py
index 030fb261..4bce44e6 100644
--- a/test/t/test_2to3.py
+++ b/test/t/test_2to3.py
@@ -6,6 +6,6 @@ class Test2to3:
def test_1(self, completion):
assert completion
- @pytest.mark.complete("2to3 -", require_cmd=True)
+ @pytest.mark.complete("2to3 -", require_cmd=True, require_longopt=True)
def test_2(self, completion):
assert completion
diff --git a/test/t/test_7z.py b/test/t/test_7z.py
index c6e73890..d4308d95 100644
--- a/test/t/test_7z.py
+++ b/test/t/test_7z.py
@@ -8,12 +8,11 @@ class Test7z:
@pytest.mark.complete("7z a ar -tzi")
def test_2(self, completion):
- assert completion == "-tzip"
+ assert completion == "p"
- @pytest.mark.xfail # TODO: whitespace split issue
@pytest.mark.complete(r"7z x -wa\ ", cwd="_filedir")
def test_3(self, completion):
- assert completion == r"-wa\ b/"
+ assert completion == "b/"
assert not completion.endswith(" ")
@pytest.mark.complete("7z x ", cwd="7z")
diff --git a/test/t/test_alias.py b/test/t/test_alias.py
index da9ecc33..cc592a8c 100644
--- a/test/t/test_alias.py
+++ b/test/t/test_alias.py
@@ -15,3 +15,7 @@ class TestAlias:
def test_2(self, completion):
assert completion == "foo='bar'"
assert not completion.endswith(" ")
+
+ @pytest.mark.complete("alias ", trail="foo")
+ def test_alias_at_point(self, completion):
+ assert completion == "bar foo".split()
diff --git a/test/t/test_ant.py b/test/t/test_ant.py
index b14beb94..94acea11 100644
--- a/test/t/test_ant.py
+++ b/test/t/test_ant.py
@@ -1,5 +1,7 @@
import pytest
+from conftest import assert_bash_exec
+
@pytest.mark.bashcomp(ignore_env=r"^\+ANT_ARGS=")
class TestAnt:
@@ -18,8 +20,15 @@ class TestAnt:
@pytest.mark.complete(
"ant ", cwd="ant", env=dict(ANT_ARGS="'-f named-build.xml'")
)
- def test_4(self, completion):
- assert completion == "named-build"
+ def test_4(self, bash, completion):
+ output = assert_bash_exec(bash, "complete -p ant", want_output=True)
+ if "complete-ant-cmd.pl" in output:
+ # Some versions of complete-ant-cmd.pl don't treat ANT_ARGS right;
+ # in those cases we get the correct completion produced by _ant
+ # plus whatever complete-ant-cmd.pl was able to get from build.xml
+ assert "named-build" in completion
+ else:
+ assert completion == "named-build"
@pytest.mark.complete("ant -l ")
def test_5(self, completion):
diff --git a/test/t/test_apt_cache.py b/test/t/test_apt_cache.py
index a1c29cda..f9329f22 100644
--- a/test/t/test_apt_cache.py
+++ b/test/t/test_apt_cache.py
@@ -5,9 +5,13 @@ import pytest
class TestAptCache:
@pytest.mark.complete("apt-cache ")
def test_1(self, completion):
- assert completion
+ assert "search" in completion
@pytest.mark.complete("apt-cache showsrc [", require_cmd=True)
def test_2(self, completion):
# Doesn't actually fail on grep errors, but takes a long time.
assert not completion
+
+ @pytest.mark.complete("apt-cache ", trail=" add foo")
+ def test_special_at_point(self, completion):
+ assert not completion
diff --git a/test/t/test_apt_get.py b/test/t/test_apt_get.py
index ccdff6cd..dc8299a9 100644
--- a/test/t/test_apt_get.py
+++ b/test/t/test_apt_get.py
@@ -9,4 +9,8 @@ class TestAptGet:
@pytest.mark.complete("apt-get install ./", cwd="dpkg")
def test_2(self, completion):
- assert completion == "./bash-completion-test-subject.deb"
+ assert completion == "bash-completion-test-subject.deb"
+
+ @pytest.mark.complete("apt-get build-dep ")
+ def test_build_dep_dirs(self, completion):
+ assert "dpkg/" in completion
diff --git a/test/t/test_aptitude.py b/test/t/test_aptitude.py
index c59c3580..29569f15 100644
--- a/test/t/test_aptitude.py
+++ b/test/t/test_aptitude.py
@@ -5,3 +5,19 @@ class TestAptitude:
@pytest.mark.complete("aptitude ")
def test_1(self, completion):
assert completion
+
+ @pytest.mark.complete("aptitude -", require_cmd=True)
+ def test_options(self, completion):
+ assert completion
+
+ @pytest.mark.complete("aptitude --", require_cmd=True)
+ def test_long_options(self, completion):
+ assert completion
+
+ @pytest.mark.complete("aptitude -u -")
+ def test_no_i_with_u(self, completion):
+ assert "-i" not in completion
+
+ @pytest.mark.complete("aptitude -i -")
+ def test_no_u_with_i(self, completion):
+ assert "-u" not in completion
diff --git a/test/t/test_arpspoof.py b/test/t/test_arpspoof.py
index c8955f8d..74c09a43 100644
--- a/test/t/test_arpspoof.py
+++ b/test/t/test_arpspoof.py
@@ -2,6 +2,11 @@ import pytest
class TestArpspoof:
- @pytest.mark.complete("arpspoof -", require_cmd=True)
+ @pytest.mark.complete(
+ "arpspoof -",
+ require_cmd=True,
+ # May require privileges even for outputting the usage message
+ skipif="arpspoof 2>&1 | command grep -qF libnet_open_link",
+ )
def test_1(self, completion):
assert completion
diff --git a/test/t/test_bmake.py b/test/t/test_bmake.py
new file mode 100644
index 00000000..bc885d31
--- /dev/null
+++ b/test/t/test_bmake.py
@@ -0,0 +1,7 @@
+import pytest
+
+
+class TestBmake:
+ @pytest.mark.complete("bmake -", require_cmd=True)
+ def test_options(self, completion):
+ assert completion
diff --git a/test/t/test_ccache.py b/test/t/test_ccache.py
index 64620ef4..ef55d0d8 100644
--- a/test/t/test_ccache.py
+++ b/test/t/test_ccache.py
@@ -12,15 +12,15 @@ class TestCcache:
@pytest.mark.complete("ccache stt")
def test_3(self, completion):
- assert "stty" in completion
+ assert completion == "y" or "stty" in completion
@pytest.mark.complete("ccache --zero-stats stt")
def test_4(self, completion):
- assert "stty" in completion
+ assert completion == "y" or "stty" in completion
@pytest.mark.complete("ccache --hel", require_cmd=True)
def test_5(self, completion):
- assert "--help" in completion
+ assert completion == "p" or "--help" in completion
@pytest.mark.complete("ccache --zero-stats sh +")
def test_6(self, completion):
diff --git a/test/t/test_cd.py b/test/t/test_cd.py
index fd532312..5b7789ae 100644
--- a/test/t/test_cd.py
+++ b/test/t/test_cd.py
@@ -9,7 +9,7 @@ class TestCd:
@pytest.mark.complete("cd fo", env=dict(CDPATH="shared/default"))
def test_2(self, completion):
- assert completion == "foo.d/"
+ assert completion == "o.d/"
@pytest.mark.complete("cd fo")
def test_3(self, completion):
@@ -20,3 +20,7 @@ class TestCd:
)
def test_4(self, completion):
assert not completion # No subdirs nor CDPATH
+
+ @pytest.mark.complete("cd shared/default/", trail="foo")
+ def test_dir_at_point(self, completion):
+ assert completion == ["bar bar.d/", "foo.d/"]
diff --git a/test/t/test_chown.py b/test/t/test_chown.py
index 37221cfa..9643f3eb 100644
--- a/test/t/test_chown.py
+++ b/test/t/test_chown.py
@@ -2,7 +2,7 @@ import getpass
import pytest
-from conftest import assert_bash_exec, assert_complete
+from conftest import assert_complete
@pytest.mark.bashcomp(
@@ -16,10 +16,8 @@ class TestChown:
getpass.getuser() != "root", reason="Only root can chown to all users"
)
@pytest.mark.complete("chown ")
- def test_1(self, bash, completion):
- users = sorted(
- assert_bash_exec(bash, "compgen -A user", want_output=True).split()
- )
+ def test_1(self, bash, completion, output_sort_uniq):
+ users = output_sort_uniq("compgen -u")
assert completion == users
@pytest.mark.complete("chown foo: shared/default/")
@@ -33,37 +31,39 @@ class TestChown:
def test_4(self, bash, part_full_user):
part, full = part_full_user
completion = assert_complete(bash, "chown %s" % part)
- assert completion == full
+ assert completion == full[len(part) :]
assert completion.endswith(" ")
def test_5(self, bash, part_full_user, part_full_group):
_, user = part_full_user
partgroup, fullgroup = part_full_group
completion = assert_complete(bash, "chown %s:%s" % (user, partgroup))
- assert completion == "%s:%s" % (user, fullgroup)
+ assert completion == fullgroup[len(partgroup) :]
assert completion.output.endswith(" ")
def test_6(self, bash, part_full_group):
part, full = part_full_group
completion = assert_complete(bash, "chown dot.user:%s" % part)
- assert completion == "dot.user:%s" % full
+ assert completion == full[len(part) :]
assert completion.output.endswith(" ")
- @pytest.mark.xfail # TODO check escaping, whitespace
- def test_7(self, bash, part_full_group):
- """Test preserving special chars in $prefix$partgroup<TAB>."""
- part, full = part_full_group
- for prefix in (
+ @pytest.mark.parametrize(
+ "prefix",
+ [
r"funky\ user:",
"funky.user:",
r"funky\.user:",
r"fu\ nky.user:",
r"f\ o\ o\.\bar:",
r"foo\_b\ a\.r\ :",
- ):
- completion = assert_complete(bash, "chown %s%s" % (prefix, part))
- assert completion == "%s%s" % (prefix, full)
- assert completion.output.endswith(" ")
+ ],
+ )
+ def test_7(self, bash, part_full_group, prefix):
+ """Test preserving special chars in $prefix$partgroup<TAB>."""
+ part, full = part_full_group
+ completion = assert_complete(bash, "chown %s%s" % (prefix, part))
+ assert completion == full[len(part) :]
+ assert completion.output.endswith(" ")
def test_8(self, bash, part_full_user, part_full_group):
"""Test giving up on degenerate cases instead of spewing junk."""
diff --git a/test/t/test_complete.py b/test/t/test_complete.py
index 036f954e..7ff56b41 100644
--- a/test/t/test_complete.py
+++ b/test/t/test_complete.py
@@ -5,3 +5,7 @@ class TestComplete:
@pytest.mark.complete("complete -")
def test_1(self, completion):
assert completion
+
+ @pytest.mark.complete(r"\complete -")
+ def test_2(self, completion):
+ assert completion
diff --git a/test/t/test_cpan2dist.py b/test/t/test_cpan2dist.py
index f456c0ce..1ab5de13 100644
--- a/test/t/test_cpan2dist.py
+++ b/test/t/test_cpan2dist.py
@@ -2,6 +2,8 @@ import pytest
class TestCpan2dist:
- @pytest.mark.complete("cpan2dist -", require_cmd=True)
+ @pytest.mark.complete(
+ "cpan2dist -", require_cmd=True, require_longopt=True
+ )
def test_1(self, completion):
assert completion
diff --git a/test/t/test_cpio.py b/test/t/test_cpio.py
index 1b9e37df..0b739663 100644
--- a/test/t/test_cpio.py
+++ b/test/t/test_cpio.py
@@ -1,7 +1,5 @@
import pytest
-from conftest import assert_bash_exec
-
class TestCpio:
@pytest.mark.complete("cpio --")
@@ -9,10 +7,6 @@ class TestCpio:
assert completion
@pytest.mark.complete("cpio -R ")
- def test_2(self, bash, completion):
- users = sorted(
- assert_bash_exec(bash, "compgen -A user", want_output=True)
- .strip()
- .splitlines()
- )
- assert list(completion) == users
+ def test_2(self, bash, completion, output_sort_uniq):
+ users = output_sort_uniq("compgen -u")
+ assert completion == users
diff --git a/test/t/test_cppcheck.py b/test/t/test_cppcheck.py
index da770786..73e64f5e 100644
--- a/test/t/test_cppcheck.py
+++ b/test/t/test_cppcheck.py
@@ -20,12 +20,12 @@ class TestCppcheck:
@pytest.mark.complete("cppcheck --enable=al")
def test_5(self, completion):
- assert completion == "--enable=all"
+ assert completion == "l"
@pytest.mark.complete("cppcheck --enable=xx,styl")
def test_6(self, completion):
- assert completion == "--enable=xx,style"
+ assert completion == "e"
@pytest.mark.complete("cppcheck --enable=xx,yy,styl")
def test_7(self, completion):
- assert completion == "--enable=xx,yy,style"
+ assert completion == "e"
diff --git a/test/t/test_crontab.py b/test/t/test_crontab.py
index 098fd9e0..a476694c 100644
--- a/test/t/test_crontab.py
+++ b/test/t/test_crontab.py
@@ -5,3 +5,12 @@ class TestCrontab:
@pytest.mark.complete("crontab ")
def test_1(self, completion):
assert completion
+
+ @pytest.mark.complete("crontab -l -")
+ def test_only_u_with_l(self, completion):
+ assert completion == "u"
+
+ @pytest.mark.complete("crontab -r -")
+ def test_no_l_with_r(self, completion):
+ assert completion
+ assert "-l" not in completion
diff --git a/test/t/test_curl.py b/test/t/test_curl.py
index ebccca95..63e969f9 100644
--- a/test/t/test_curl.py
+++ b/test/t/test_curl.py
@@ -8,11 +8,11 @@ class TestCurl:
@pytest.mark.complete("curl -o f", cwd="shared/default/foo.d")
def test_2(self, completion):
- assert completion == "foo"
+ assert completion == "oo"
@pytest.mark.complete("curl -LRo f", cwd="shared/default/foo.d")
def test_3(self, completion):
- assert completion == "foo"
+ assert completion == "oo"
@pytest.mark.complete("curl --o f")
def test_4(self, completion):
@@ -20,9 +20,9 @@ class TestCurl:
@pytest.mark.complete("curl --data @", cwd="shared/default/foo.d")
def test_data_atfile(self, completion):
- assert completion == "@foo"
+ assert completion == "foo"
@pytest.mark.complete("curl --data @foo.", cwd="shared/default")
def test_data_atfile_dir(self, completion):
- assert completion == "@foo.d/"
+ assert completion == "d/"
assert not completion.endswith(" ")
diff --git a/test/t/test_cvs.py b/test/t/test_cvs.py
index ab7fead8..97361e9e 100644
--- a/test/t/test_cvs.py
+++ b/test/t/test_cvs.py
@@ -13,7 +13,7 @@ class TestCvs:
@pytest.mark.complete("cvs diff foo/", cwd="cvs")
def test_3(self, completion):
- assert completion == "foo/bar"
+ assert completion == "bar"
@pytest.mark.complete("cvs -", require_cmd=True)
def test_4(self, completion):
diff --git a/test/t/test_dd.py b/test/t/test_dd.py
index be1829d3..e082faa9 100644
--- a/test/t/test_dd.py
+++ b/test/t/test_dd.py
@@ -14,4 +14,4 @@ class TestDd:
@pytest.mark.complete("dd bs")
def test_2(self, completion):
- assert completion == "bs="
+ assert completion == "="
diff --git a/test/t/test_dmypy.py b/test/t/test_dmypy.py
index efaef7ca..4c031ddd 100644
--- a/test/t/test_dmypy.py
+++ b/test/t/test_dmypy.py
@@ -2,11 +2,13 @@ import pytest
class TestDmypy:
- @pytest.mark.complete("dmypy ", require_cmd=True)
+ @pytest.mark.complete(
+ "dmypy ", require_cmd=True, xfail="! dmypy --help &>/dev/null"
+ )
def test_commands(self, completion):
assert "help" in completion
assert not any("," in x for x in completion)
- @pytest.mark.complete("dmypy -", require_cmd=True)
+ @pytest.mark.complete("dmypy -", require_cmd=True, require_longopt=True)
def test_options(self, completion):
assert "--help" in completion
diff --git a/test/t/test_dnssec_keygen.py b/test/t/test_dnssec_keygen.py
index d52e3af0..f8bd6fb1 100644
--- a/test/t/test_dnssec_keygen.py
+++ b/test/t/test_dnssec_keygen.py
@@ -13,7 +13,7 @@ class TestDnssecKeygen:
@pytest.mark.complete("dnssec-keygen -a ")
def test_2(self, completion):
assert completion
- assert "HMAC-MD5" in completion
+ assert any(x in completion for x in ("HMAC-MD5", "RSASHA1", "ED25519"))
assert "|" not in completion
assert not any(x.startswith("-") for x in completion)
diff --git a/test/t/test_dpkg_deb.py b/test/t/test_dpkg_deb.py
index c1ad8191..9be85eb6 100644
--- a/test/t/test_dpkg_deb.py
+++ b/test/t/test_dpkg_deb.py
@@ -6,3 +6,7 @@ class TestDpkgDeb:
@pytest.mark.complete("dpkg-deb --c", require_cmd=True)
def test_1(self, completion):
assert completion
+
+ @pytest.mark.complete("dpkg-deb --show b", cwd="dpkg")
+ def test_show(self, completion):
+ assert completion == "ash-completion-test-subject.deb"
diff --git a/test/t/test_dpkg_query.py b/test/t/test_dpkg_query.py
new file mode 100644
index 00000000..37c56211
--- /dev/null
+++ b/test/t/test_dpkg_query.py
@@ -0,0 +1,18 @@
+import os.path
+
+import pytest
+
+
+@pytest.mark.bashcomp(cmd="dpkg-query",)
+class TestDpkgQuery:
+ @pytest.mark.complete("dpkg-query --", require_cmd=True)
+ def test_options(self, completion):
+ assert completion
+
+ @pytest.mark.xfail(
+ not os.path.exists("/etc/debian_version"),
+ reason="Likely fails on systems not based on Debian",
+ )
+ @pytest.mark.complete("dpkg-query -W dpk", require_cmd=True)
+ def test_show(self, completion):
+ assert "dpkg" in completion
diff --git a/test/t/test_feh.py b/test/t/test_feh.py
index 51bd77b6..f2d5317b 100644
--- a/test/t/test_feh.py
+++ b/test/t/test_feh.py
@@ -16,11 +16,11 @@ class TestFeh:
@pytest.mark.complete("feh -S pix")
def test_3(self, completion):
- assert completion == "pixels"
+ assert completion == "els"
@pytest.mark.complete("feh --zoom ma")
def test_4(self, completion):
- assert completion == "max"
+ assert completion == "x"
@pytest.mark.complete("feh -g 640")
def test_5(self, completion):
diff --git a/test/t/test_find.py b/test/t/test_find.py
index a94e0e0d..9968ade7 100644
--- a/test/t/test_find.py
+++ b/test/t/test_find.py
@@ -14,10 +14,9 @@ class TestFind:
def test_3(self, completion):
assert completion
- @pytest.mark.xfail # TODO: whitespace split issue
@pytest.mark.complete("find -wholename ", cwd="shared/default")
def test_4(self, completion):
- assert completion == ["bar", "bar bar.d/", "foo", "foo foo.d/"]
+ assert completion == ["bar", "bar bar.d/", "foo", "foo.d/"]
@pytest.mark.complete("find -uid ")
def test_5(self, completion):
@@ -26,3 +25,13 @@ class TestFind:
@pytest.mark.complete("find -gid ")
def test_6(self, completion):
assert not [x for x in completion if not x.isdigit()]
+
+ @pytest.mark.complete("find -exec shared/bin/ar")
+ def test_exec(self, completion):
+ assert completion == "p"
+
+ # sh +: something that produces completions also when command is not
+ # available, and the chosen completion is not one of find's
+ @pytest.mark.complete("find /some/where -exec sh +")
+ def test_exec_args(self, completion):
+ assert "+o" in completion
diff --git a/test/t/test_finger.py b/test/t/test_finger.py
index 92c983fa..d765fdd7 100644
--- a/test/t/test_finger.py
+++ b/test/t/test_finger.py
@@ -1,16 +1,12 @@
import pytest
-from conftest import assert_bash_exec
+from conftest import assert_complete, partialize
class TestFinger:
@pytest.fixture(scope="class")
- def users_at(self, bash):
- return sorted(
- assert_bash_exec(
- bash, "compgen -A user -S @", want_output=True
- ).split()
- )
+ def users_at(self, bash, output_sort_uniq):
+ return output_sort_uniq("compgen -u -S @")
@pytest.mark.complete("finger ")
def test_1(self, bash, completion, users_at):
@@ -21,5 +17,17 @@ class TestFinger:
if not any(x.startswith("r") for x in users_at):
pytest.skip("No users starting with r")
assert completion
- assert all(x.startswith("r") for x in completion)
+ idx = 1 if len(completion) == 1 else 0
+ assert completion == sorted(
+ x[idx:] for x in users_at if x.startswith("r")
+ )
assert not completion.endswith(" ")
+
+ def test_partial_hostname(self, bash, known_hosts):
+ first_char, partial_hosts = partialize(bash, known_hosts)
+ user = "test"
+ completion = assert_complete(bash, "finger %s@%s" % (user, first_char))
+ if len(completion) == 1:
+ assert completion == partial_hosts[0][1:]
+ else:
+ assert completion == ["%s@%s" % (user, x) for x in partial_hosts]
diff --git a/test/t/test_gcc.py b/test/t/test_gcc.py
index 87f25797..50906db5 100644
--- a/test/t/test_gcc.py
+++ b/test/t/test_gcc.py
@@ -24,7 +24,7 @@ class TestGcc:
@pytest.mark.complete("gcc -fsanitize=add")
def test_enum_value(self, completion, gcc_with_completion):
- assert completion == "-fsanitize=address"
+ assert completion == "ress"
@pytest.mark.complete("gcc -fsanitize=")
def test_enum_value_with_eq(self, completion, gcc_with_completion):
@@ -48,15 +48,12 @@ class TestGcc:
@pytest.mark.complete("gcc --param=lto-max-p")
def test_param_with_eq(self, completion, gcc_with_completion):
- # starting with GCC 10.1 param end with =
- assert (
- completion == "--param=lto-max-partition"
- or completion == "--param=lto-max-partition="
- )
+ # starting with GCC 10.1 param ends with =
+ assert completion in ("artition", "artition=")
@pytest.mark.complete("gcc -march=amd")
def test_march(self, completion, gcc_with_completion, gcc_x86):
- assert completion == "-march=amdfam10"
+ assert completion == "fam10"
@pytest.mark.complete("gcc -march=")
def test_march_native(self, completion, gcc_with_completion):
diff --git a/test/t/test_ip.py b/test/t/test_ip.py
index 20752505..320647f4 100644
--- a/test/t/test_ip.py
+++ b/test/t/test_ip.py
@@ -9,3 +9,7 @@ class TestIp:
@pytest.mark.complete("ip a ")
def test_2(self, completion):
assert completion
+
+ @pytest.mark.complete("ip route replace ")
+ def test_r_r(self, completion):
+ assert completion
diff --git a/test/t/test_ipcalc.py b/test/t/test_ipcalc.py
new file mode 100644
index 00000000..5611674c
--- /dev/null
+++ b/test/t/test_ipcalc.py
@@ -0,0 +1,23 @@
+import pytest
+
+
+class TestIpcalc:
+ @pytest.mark.complete("ipcalc -", require_cmd=True)
+ def test_options(self, completion):
+ assert any(x in completion for x in "--help -h".split())
+
+ @pytest.mark.complete("ipcalc --split -")
+ def test_split_3args_1(self, completion):
+ assert not completion
+
+ @pytest.mark.complete("ipcalc --split 1 -")
+ def test_split_3args_2(self, completion):
+ assert not completion
+
+ @pytest.mark.complete("ipcalc --split 1 2 -")
+ def test_split_3args_3(self, completion):
+ assert not completion
+
+ @pytest.mark.complete("ipcalc --split 1 2 3 -", require_cmd=True)
+ def test_split_3args_4(self, completion):
+ assert any(x in completion for x in "--help -h".split())
diff --git a/test/t/test_irb.py b/test/t/test_irb.py
index 03a83c66..801d3739 100644
--- a/test/t/test_irb.py
+++ b/test/t/test_irb.py
@@ -6,6 +6,6 @@ class TestIrb:
def test_1(self, completion):
assert completion
- @pytest.mark.complete("irb -", require_cmd=True)
+ @pytest.mark.complete("irb -", require_longopt=True)
def test_options(self, completion):
assert completion
diff --git a/test/t/test_iscsiadm.py b/test/t/test_iscsiadm.py
index 932ffeb5..885ca0ab 100644
--- a/test/t/test_iscsiadm.py
+++ b/test/t/test_iscsiadm.py
@@ -2,6 +2,6 @@ import pytest
class TestIscsiadm:
- @pytest.mark.complete("iscsiadm --mode")
+ @pytest.mark.complete("iscsiadm --mod")
def test_1(self, completion):
- assert completion
+ assert completion == "e" or "--mode" in completion
diff --git a/test/t/test_isort.py b/test/t/test_isort.py
index 9f7a6524..b142d1c4 100644
--- a/test/t/test_isort.py
+++ b/test/t/test_isort.py
@@ -6,6 +6,6 @@ class TestIsort:
def test_1(self, completion):
assert completion
- @pytest.mark.complete("isort -", require_cmd=True)
+ @pytest.mark.complete("isort -", require_cmd=True, require_longopt=True)
def test_2(self, completion):
assert completion
diff --git a/test/t/test_jsonschema.py b/test/t/test_jsonschema.py
index 9e3929e6..6027f5d6 100644
--- a/test/t/test_jsonschema.py
+++ b/test/t/test_jsonschema.py
@@ -6,6 +6,8 @@ class TestJsonschema:
def test_1(self, completion):
assert completion
- @pytest.mark.complete("jsonschema -", require_cmd=True)
+ @pytest.mark.complete(
+ "jsonschema -", require_cmd=True, require_longopt=True
+ )
def test_2(self, completion):
assert completion
diff --git a/test/t/test_kcov.py b/test/t/test_kcov.py
index 3c7d3dfa..3e377ebe 100644
--- a/test/t/test_kcov.py
+++ b/test/t/test_kcov.py
@@ -8,7 +8,7 @@ class TestKcov:
@pytest.mark.complete("kcov --exclude-patter", require_cmd=True)
def test_2(self, completion):
- assert completion == "--exclude-pattern="
+ assert completion == "n="
assert completion.endswith("=")
@pytest.mark.complete("kcov -l 42,")
diff --git a/test/t/test_ldd.py b/test/t/test_ldd.py
index 70e295a5..7f7201bd 100644
--- a/test/t/test_ldd.py
+++ b/test/t/test_ldd.py
@@ -6,6 +6,8 @@ class TestLdd:
def test_1(self, completion):
assert completion
- @pytest.mark.complete("ldd -", require_cmd=True)
+ @pytest.mark.complete(
+ "ldd -", require_cmd=True, xfail="! ldd --help &>/dev/null"
+ )
def test_options(self, completion):
assert completion
diff --git a/test/t/test_less.py b/test/t/test_less.py
index 0b14e21e..70833c34 100644
--- a/test/t/test_less.py
+++ b/test/t/test_less.py
@@ -5,3 +5,7 @@ class TestLess:
@pytest.mark.complete("less --", require_longopt=True)
def test_1(self, completion):
assert completion
+
+ @pytest.mark.complete("less --", require_longopt=True)
+ def test_no_dashdashdash(self, completion):
+ assert all(not x.startswith("---") for x in completion)
diff --git a/test/t/test_lftp.py b/test/t/test_lftp.py
index 765e51e1..f775a4c6 100644
--- a/test/t/test_lftp.py
+++ b/test/t/test_lftp.py
@@ -1,17 +1,15 @@
import pytest
-from conftest import assert_bash_exec
-
@pytest.mark.bashcomp(pre_cmds=("HOME=$PWD/lftp",))
class TestLftp:
- @pytest.mark.complete("lftp ")
- def test_1(self, bash, completion):
- hosts = assert_bash_exec(
- bash, "compgen -A hostname", want_output=True
- ).split()
+ @pytest.mark.complete("lftp ", require_cmd=True)
+ def test_1(self, bash, completion, output_sort_uniq):
+ hosts = output_sort_uniq("compgen -A hostname")
assert all(x in completion for x in hosts)
- assert "lftptest" in completion # defined in lftp/.lftp/bookmarks
+ # defined in lftp/.lftp/bookmarks
+ assert all(x in completion for x in "lftptest spacetest".split())
+ assert "badbookmark" not in completion
@pytest.mark.complete("lftp -", require_cmd=True)
def test_2(self, completion):
diff --git a/test/t/test_lilo.py b/test/t/test_lilo.py
index 9783f506..2c698212 100644
--- a/test/t/test_lilo.py
+++ b/test/t/test_lilo.py
@@ -5,3 +5,12 @@ class TestLilo:
@pytest.mark.complete("lilo -")
def test_1(self, completion):
assert completion
+
+ @pytest.mark.complete("lilo -C lilo/lilo.conf -D ")
+ def test_labels(self, completion):
+ # Note that 2.4.33 should not be here, it's commented out
+ assert completion == sorted("try tamu PCDOS WinXP oldDOS".split())
+
+ @pytest.mark.complete("lilo -C -D ")
+ def test_labels_incorrect_command(self, completion):
+ assert not completion
diff --git a/test/t/test_ls.py b/test/t/test_ls.py
index 7e2d1f35..8abcb59d 100644
--- a/test/t/test_ls.py
+++ b/test/t/test_ls.py
@@ -36,5 +36,5 @@ class TestLs:
return
part, full = part_full
completion = assert_complete(bash, "ls ~%s" % part)
- assert completion == "~%s" % full
+ assert completion == full[len(part) :]
assert completion.endswith(" ")
diff --git a/test/t/test_lspci.py b/test/t/test_lspci.py
index ac18da3f..aba7b5a4 100644
--- a/test/t/test_lspci.py
+++ b/test/t/test_lspci.py
@@ -6,6 +6,8 @@ class TestLspci:
def test_1(self, completion):
assert completion
- @pytest.mark.complete("lspci -A ", require_cmd=True)
+ @pytest.mark.complete(
+ "lspci -A ", require_cmd=True, skipif="! lspci -A help &>/dev/null"
+ )
def test_2(self, completion):
assert completion
diff --git a/test/t/test_make.py b/test/t/test_make.py
index e6e043cd..19861b00 100644
--- a/test/t/test_make.py
+++ b/test/t/test_make.py
@@ -2,21 +2,19 @@ import os
import pytest
-from conftest import in_container
-
class TestMake:
@pytest.mark.complete("make -f Ma", cwd="make")
def test_1(self, completion):
- assert completion == "Makefile"
+ assert completion == "kefile"
- @pytest.mark.complete("make .", cwd="make")
+ @pytest.mark.complete("make .", cwd="make", require_cmd=True)
def test_2(self, bash, completion):
"""Hidden targets."""
assert completion == ".cache/ .test_passes".split()
os.remove("%s/make/%s" % (bash.cwd, "extra_makefile"))
- @pytest.mark.complete("make .cache/", cwd="make")
+ @pytest.mark.complete("make .cache/", cwd="make", require_cmd=True)
def test_3(self, bash, completion):
assert completion == "1 2".split()
os.remove("%s/make/%s" % (bash.cwd, "extra_makefile"))
@@ -29,22 +27,17 @@ class TestMake:
def test_5(self, completion):
assert completion
- @pytest.mark.complete("make ", cwd="make")
+ @pytest.mark.complete("make ", cwd="make", require_cmd=True)
def test_6(self, bash, completion):
assert completion == "all clean extra_makefile install sample".split()
os.remove("%s/make/%s" % (bash.cwd, "extra_makefile"))
- @pytest.mark.xfail(
- in_container() and os.environ.get("DIST") == "centos6",
- reason="Fails for some unknown reason on CentOS 6, "
- "even though the behavior appears to be correct",
- )
- @pytest.mark.complete("make .cache/.", cwd="make")
+ @pytest.mark.complete("make .cache/.", cwd="make", require_cmd=True)
def test_7(self, bash, completion):
assert completion == ".1 .2".split()
os.remove("%s/make/%s" % (bash.cwd, "extra_makefile"))
- @pytest.mark.complete("make -C make ")
+ @pytest.mark.complete("make -C make ", require_cmd=True)
def test_8(self, bash, completion):
assert completion == "all clean extra_makefile install sample".split()
os.remove("%s/make/%s" % (bash.cwd, "extra_makefile"))
diff --git a/test/t/test_man.py b/test/t/test_man.py
index ad36d96e..1ff9f84b 100644
--- a/test/t/test_man.py
+++ b/test/t/test_man.py
@@ -1,8 +1,6 @@
-import os
-
import pytest
-from conftest import assert_bash_exec, in_container
+from conftest import assert_bash_exec
@pytest.mark.bashcomp(
@@ -36,24 +34,16 @@ class TestMan:
require_cmd=True,
)
def test_1(self, completion):
- assert completion == "bash-completion-testcase"
+ assert completion == "e"
@pytest.mark.complete("man man1/f", cwd="man", env=dict(MANPATH=manpath))
def test_2(self, completion):
- assert completion == "man1/foo.1"
+ assert completion == "oo.1"
@pytest.mark.complete("man man/", cwd="man", env=dict(MANPATH=manpath))
def test_3(self, completion):
- assert completion == "man/quux.8"
-
- @pytest.mark.xfail(
- in_container() and os.environ.get("DIST") == "centos6",
- reason="TODO: Fails in CentOS for some reason, unknown "
- "how to trigger same behavior as tests show (is "
- "different and correct when tried manually, but here "
- "at least in CI completes things it should not with "
- "this MANPATH setting)",
- )
+ assert completion == "quux.8"
+
@pytest.mark.complete(
"man %s" % assumed_present,
cwd="shared/empty_dir",
@@ -82,7 +72,7 @@ class TestMan:
env=dict(MANPATH="%s:" % manpath),
)
def test_6(self, completion):
- assert completion == "bash-completion-testcase"
+ assert completion == "e"
@pytest.mark.complete(
"man %s" % assumed_present,
@@ -100,7 +90,7 @@ class TestMan:
env=dict(MANPATH=":%s" % manpath),
)
def test_8(self, completion):
- assert completion == "bash-completion-testcase"
+ assert completion == "e"
@pytest.mark.complete(
"man %s" % assumed_present,
@@ -118,7 +108,7 @@ class TestMan:
env=dict(MANPATH="%s:../tmp/man" % manpath),
)
def test_10(self, bash, colonpath, completion):
- assert completion == "Bash::Completion"
+ assert completion == "ompletion"
@pytest.mark.complete("man -", require_cmd=True)
def test_11(self, completion):
diff --git a/test/t/test_mkdir.py b/test/t/test_mkdir.py
index 1b9cb9dc..afc3fd04 100644
--- a/test/t/test_mkdir.py
+++ b/test/t/test_mkdir.py
@@ -6,10 +6,9 @@ class TestMkdir:
def test_1(self, completion):
assert completion
- @pytest.mark.xfail # TODO: whitespace split issue
@pytest.mark.complete("mkdir ", cwd="shared/default")
def test_2(self, completion):
- assert completion == ["bar bar.d/", "foo", "foo.d/"]
+ assert completion == ["bar", "bar bar.d/", "foo", "foo.d/"]
@pytest.mark.xfail # TODO: why path in completion, basename in .output?
@pytest.mark.complete("mkdir shared/default/foo.d/")
diff --git a/test/t/test_modprobe.py b/test/t/test_modprobe.py
index 38d290ae..9201119d 100644
--- a/test/t/test_modprobe.py
+++ b/test/t/test_modprobe.py
@@ -6,7 +6,7 @@ import pytest
class TestModprobe:
@pytest.mark.complete("modprobe --al")
def test_1(self, completion):
- assert completion == "--all"
+ assert completion == "l"
# "in": intel*, ...
@pytest.mark.complete(
diff --git a/test/t/test_mount.py b/test/t/test_mount.py
index fbd6dcae..8254fd40 100644
--- a/test/t/test_mount.py
+++ b/test/t/test_mount.py
@@ -12,7 +12,7 @@ class TestMount:
@pytest.mark.complete("mount /dev/sda1 def", cwd="shared")
def test_3(self, completion):
- assert completion == "default/"
+ assert completion == "ault/"
assert not completion.endswith(" ")
@pytest.mark.complete(
diff --git a/test/t/test_mr.py b/test/t/test_mr.py
index 768e1b35..bfad643f 100644
--- a/test/t/test_mr.py
+++ b/test/t/test_mr.py
@@ -19,7 +19,7 @@ class TestMr:
"mr -c shared/default/foo.d/", xfail="! man -h &>/dev/null"
)
def test_3(self, completion):
- assert completion == "shared/default/foo.d/foo"
+ assert completion == "foo"
@pytest.mark.complete(
"mr bootstrap shared/default/",
@@ -29,18 +29,21 @@ class TestMr:
def test_4(self, completion):
assert completion == ["bar", "bar bar.d/", "foo", "foo.d/"]
- @pytest.mark.xfail # "clean" doesn't exist before mr 1.20141023
@pytest.mark.complete(
- "mr clean -", require_cmd=True, xfail="! man -h &>/dev/null"
+ "mr clean -",
+ require_cmd=True,
+ xfail="! man -h &>/dev/null",
+ # "clean" does not exist before mr 1.20141023
+ skipif="! mr help 2>&1 | command grep -qwF clean",
)
def test_5(self, completion):
- assert completion == "-f"
+ assert completion == "f"
@pytest.mark.complete(
"mr commit -", require_cmd=True, xfail="! man -h &>/dev/null"
)
def test_6(self, completion):
- assert completion == "-m"
+ assert completion == "m"
@pytest.mark.complete(
"mr status ", require_cmd=True, xfail="! man -h &>/dev/null"
diff --git a/test/t/test_mypy.py b/test/t/test_mypy.py
index 63fc916c..11628c1d 100644
--- a/test/t/test_mypy.py
+++ b/test/t/test_mypy.py
@@ -6,7 +6,7 @@ class TestMypy:
def test_1(self, completion):
assert completion
- @pytest.mark.complete("mypy --", require_cmd=True)
+ @pytest.mark.complete("mypy --", require_cmd=True, require_longopt=True)
def test_2(self, completion):
assert completion
diff --git a/test/t/test_nmap.py b/test/t/test_nmap.py
index a4d8a899..9aff8b29 100644
--- a/test/t/test_nmap.py
+++ b/test/t/test_nmap.py
@@ -1,7 +1,47 @@
import pytest
+from conftest import assert_bash_exec
+
class TestNmap:
- @pytest.mark.complete("nmap --v")
- def test_1(self, completion):
+ @pytest.fixture(scope="class")
+ def functions(self, request, bash):
+ assert_bash_exec(bash, "_mock_nmap() { cat nmap/nmap-h.txt; }")
+ assert_bash_exec(bash, "complete -F _nmap _mock_nmap")
+
+ @pytest.mark.complete("nmap --v", require_cmd=True)
+ def test_live_options(self, completion):
+ assert completion
+
+ @pytest.mark.complete("nmap ")
+ def test_hosts(self, completion):
assert completion
+
+ @pytest.mark.complete("_mock_nmap -")
+ def test_mock_options(self, completion, functions):
+ assert completion == sorted(
+ "-iL -iR --exclude --excludefile -sL -sn -Pn -PS -PA -PU -PY -PE "
+ "-PP -PM -PO -n -R --dns-servers --system-dns --traceroute -sS "
+ "-sT -sA -sW -sM -sU -sN -sF -sX --scanflags -sI -sY -sZ -sO -b "
+ "-p --exclude-ports -F -r --top-ports --port-ratio -sV "
+ "--version-intensity --version-light --version-all "
+ "--version-trace -sC --script= --script-args= --script-args-file= "
+ "--script-trace --script-updatedb --script-help= -O "
+ "--osscan-limit --osscan-guess "
+ # TODO: -T known mishandled; should expand -T<0-5> to -T0 ... -T5
+ "-T --min-hostgroup --max-hostgroup --min-parallelism "
+ "--max-parallelism --min-rtt-timeout --max-rtt-timeout "
+ "--initial-rtt-timeout --max-retries --host-timeout --scan-delay "
+ "--max-scan-delay --min-rate --max-rate -f --mtu -D -S -e -g "
+ "--source-port --proxies --data --data-string --data-length "
+ "--ip-options --ttl --spoof-mac --badsum -oN -oX -oS -oG -oA -v "
+ "-d --reason --open --packet-trace --iflist --append-output "
+ "--resume --stylesheet --webxml --no-stylesheet -6 -A --datadir "
+ "--send-eth --send-ip --privileged --unprivileged -V -h"
+ "".strip().split()
+ )
+
+ @pytest.mark.complete("_mock_nmap --script-args-f")
+ def test_mock_nospace(self, completion, functions):
+ assert completion == "ile="
+ assert completion.endswith("=") # no space appended
diff --git a/test/t/test_openssl.py b/test/t/test_openssl.py
index e3af3530..3eaf6d47 100644
--- a/test/t/test_openssl.py
+++ b/test/t/test_openssl.py
@@ -6,10 +6,11 @@ class TestOpenssl:
def test_1(self, completion):
assert completion
- @pytest.mark.complete("openssl pkey -cipher ")
+ @pytest.mark.complete("openssl pkey -cipher ", require_cmd=True)
def test_2(self, completion):
assert completion
- @pytest.mark.complete("openssl dgst -s")
+ @pytest.mark.complete("openssl dgst -s", require_cmd=True)
def test_3(self, completion):
assert completion
+ assert any(x.startswith("-sha") for x in completion)
diff --git a/test/t/test_perl.py b/test/t/test_perl.py
index c8baa2f3..049c91ea 100644
--- a/test/t/test_perl.py
+++ b/test/t/test_perl.py
@@ -63,7 +63,7 @@ class TestPerl:
@pytest.mark.complete("perl -xshared/default/b")
def test_14(self, completion):
"""-x without space should complete dirs."""
- assert completion == ["-xshared/default/bar bar.d/"]
+ assert completion == r"ar\ bar.d/"
@pytest.mark.complete("perl -x shared/default/b")
def test_15(self, completion):
diff --git a/test/t/test_pgrep.py b/test/t/test_pgrep.py
index 9c233311..9a998edb 100644
--- a/test/t/test_pgrep.py
+++ b/test/t/test_pgrep.py
@@ -11,3 +11,25 @@ class TestPgrep:
@pytest.mark.complete("pgrep -", require_cmd=True)
def test_2(self, completion):
assert completion
+
+ @pytest.mark.complete(
+ "pgrep --nslist ",
+ require_cmd=True,
+ skipif=(
+ "! pgrep --help 2>&1 | command grep -qF 'Available namespaces'"
+ ),
+ )
+ def test_nslist(self, completion):
+ assert completion
+ assert not any("," in x for x in completion)
+
+ @pytest.mark.complete(
+ "pgrep --nslist foo,",
+ require_cmd=True,
+ skipif=(
+ "! pgrep --help 2>&1 | command grep -qF 'Available namespaces'"
+ ),
+ )
+ def test_nslist_after_comma(self, completion):
+ assert completion
+ assert not any("," in x for x in completion)
diff --git a/test/t/test_postfix.py b/test/t/test_postfix.py
index 67a898d1..10020b0b 100644
--- a/test/t/test_postfix.py
+++ b/test/t/test_postfix.py
@@ -1,3 +1,5 @@
+import getpass
+
import pytest
@@ -6,7 +8,15 @@ class TestPostfix:
def test_1(self, completion):
assert completion
- @pytest.mark.xfail # see TODO in completion
- @pytest.mark.complete("postfix -", require_cmd=True)
- def test_2(self, completion):
+ @pytest.mark.xfail(
+ getpass.getuser() != "root",
+ reason="Likely outputs usage only for root",
+ )
+ @pytest.mark.complete(
+ "postfix -",
+ require_cmd=True,
+ xfail="! type unbuffer &>/dev/null",
+ sleep_after_tab=2, # postfix is slow to output usage
+ )
+ def test_options(self, completion):
assert completion
diff --git a/test/t/test_printenv.py b/test/t/test_printenv.py
new file mode 100644
index 00000000..540c4f64
--- /dev/null
+++ b/test/t/test_printenv.py
@@ -0,0 +1,19 @@
+import pytest
+
+
+class TestPrintenv:
+ @pytest.mark.complete("printenv ")
+ def test_empty(self, completion):
+ assert completion
+
+ @pytest.mark.complete("printenv PAT")
+ def test_path(self, completion):
+ assert completion == "H" or "PATH" in completion
+
+ @pytest.mark.complete(
+ "printenv -",
+ require_cmd=True,
+ xfail="! printenv --help 2>&1 | command grep -qF -- ' -'",
+ )
+ def test_options(self, completion):
+ assert completion
diff --git a/test/t/test_protoc.py b/test/t/test_protoc.py
index e890c56a..744b99f4 100644
--- a/test/t/test_protoc.py
+++ b/test/t/test_protoc.py
@@ -9,3 +9,12 @@ class TestProtoc:
@pytest.mark.complete("protoc -", require_cmd=True)
def test_2(self, completion):
assert completion
+ assert any(
+ x.endswith("_out") or x.endswith("_out=") for x in completion
+ )
+
+ @pytest.mark.complete(
+ "protoc --non_existent_plugin_out ", cwd="shared/default"
+ )
+ def test_all_out(self, completion):
+ assert completion == ["bar bar.d/", "foo.d/"]
diff --git a/test/t/test_pydocstyle.py b/test/t/test_pydocstyle.py
index caa87902..1f443208 100644
--- a/test/t/test_pydocstyle.py
+++ b/test/t/test_pydocstyle.py
@@ -6,6 +6,8 @@ class TestPydocstyle:
def test_1(self, completion):
assert completion
- @pytest.mark.complete("pydocstyle -", require_cmd=True)
+ @pytest.mark.complete(
+ "pydocstyle -", require_cmd=True, require_longopt=True
+ )
def test_2(self, completion):
assert completion
diff --git a/test/t/test_pylint.py b/test/t/test_pylint.py
index 4b799532..43a4c43f 100644
--- a/test/t/test_pylint.py
+++ b/test/t/test_pylint.py
@@ -2,7 +2,7 @@ import pytest
class TestPylint:
- @pytest.mark.complete("pylint --v", require_cmd=True)
+ @pytest.mark.complete("pylint --v", require_cmd=True, require_longopt=True)
def test_1(self, completion):
assert completion
diff --git a/test/t/test_pytest.py b/test/t/test_pytest.py
index 69d01820..e70c7a5d 100644
--- a/test/t/test_pytest.py
+++ b/test/t/test_pytest.py
@@ -1,3 +1,5 @@
+import inspect
+
import pytest
@@ -9,3 +11,40 @@ class TestPytest:
@pytest.mark.complete("pytest -")
def test_2(self, completion):
assert completion
+
+ @pytest.mark.complete("pytest ../t/test_pytest.py:")
+ def test_classes_and_functions(self, completion):
+ assert completion == ":TestPytest :test_function_canary".split()
+
+ @pytest.mark.complete("pytest ../t/test_pytest.py::TestPytest::")
+ def test_class_methods(self, completion):
+ methods = [
+ x[0]
+ for x in inspect.getmembers(self, predicate=inspect.ismethod)
+ if x[0].startswith("test_")
+ ]
+ assert completion == methods
+
+ @pytest.mark.complete("pytest pytest/test_async.py:")
+ def test_classes_and_async_functions(self, completion):
+ assert completion == ":Testing :test_positive".split()
+
+ @pytest.mark.complete("pytest pytest/test_async.py::Testing::")
+ def test_async_class_methods(self, completion):
+ assert completion == "test_positive"
+
+ def non_test_cananary_method(self):
+ pass
+
+
+def test_function_canary():
+ pass
+
+
+def non_test_canary():
+ pass
+
+
+class NonTestCanaryClass:
+ def test_is_this_function_not(self):
+ pass
diff --git a/test/t/test_python.py b/test/t/test_python.py
index 57802721..5308dcb1 100644
--- a/test/t/test_python.py
+++ b/test/t/test_python.py
@@ -33,3 +33,7 @@ class TestPython:
@pytest.mark.complete("python -m sy", require_cmd=True)
def test_8(self, completion):
assert completion
+
+ @pytest.mark.complete("python -m json.", require_cmd=True)
+ def test_9(self, completion):
+ assert "json.tool" in completion
diff --git a/test/t/test_python3.py b/test/t/test_python3.py
index b968a34e..a4f6d966 100644
--- a/test/t/test_python3.py
+++ b/test/t/test_python3.py
@@ -33,3 +33,7 @@ class TestPython3:
@pytest.mark.complete("python3 -m sy", require_cmd=True)
def test_8(self, completion):
assert completion
+
+ @pytest.mark.complete("python3 -m json.", require_cmd=True)
+ def test_9(self, completion):
+ assert "json.tool" in completion
diff --git a/test/t/test_ri.py b/test/t/test_ri.py
index 9430b667..420b6cbb 100644
--- a/test/t/test_ri.py
+++ b/test/t/test_ri.py
@@ -13,4 +13,4 @@ class TestRi:
@pytest.mark.complete("ri BashCompletio", require_cmd=True)
def test_3(self, completion):
- assert completion == "BashCompletion"
+ assert completion == "n"
diff --git a/test/t/test_sbcl.py b/test/t/test_sbcl.py
index cce4cba3..f05741a7 100644
--- a/test/t/test_sbcl.py
+++ b/test/t/test_sbcl.py
@@ -2,7 +2,6 @@ import pytest
class TestSbcl:
- @pytest.mark.xfail # TODO: whitespace split issue
@pytest.mark.complete("sbcl shared/default/")
def test_1(self, completion):
- assert completion == ["bar", "bar bar.d/", "foo", "foo foo.d/"]
+ assert completion == ["bar", "bar bar.d/", "foo", "foo.d/"]
diff --git a/test/t/test_sbcl_mt.py b/test/t/test_sbcl_mt.py
index d8049f3f..c3965393 100644
--- a/test/t/test_sbcl_mt.py
+++ b/test/t/test_sbcl_mt.py
@@ -3,7 +3,6 @@ import pytest
@pytest.mark.bashcomp(cmd="sbcl-mt")
class TestSbclMt:
- @pytest.mark.xfail # TODO: whitespace split issue
@pytest.mark.complete("sbcl-mt shared/default/")
def test_1(self, completion):
- assert completion == ["bar", "bar bar.d/", "foo", "foo foo.d/"]
+ assert completion == ["bar", "bar bar.d/", "foo", "foo.d/"]
diff --git a/test/t/test_scp.py b/test/t/test_scp.py
new file mode 100644
index 00000000..66b8da22
--- /dev/null
+++ b/test/t/test_scp.py
@@ -0,0 +1,79 @@
+from itertools import chain
+
+import pytest
+
+from conftest import assert_bash_exec
+
+LIVE_HOST = "bash_completion"
+
+
+class TestScp:
+ @pytest.mark.complete("scp -F config ", cwd="scp")
+ def test_basic(self, hosts, completion):
+ expected = sorted(
+ chain(
+ (
+ "%s:" % x
+ for x in chain(
+ hosts,
+ # From fixtures/scp/config
+ "gee hut".split(),
+ # From fixtures/scp/known_hosts
+ "blah doo ike".split(),
+ )
+ ),
+ # Local filenames
+ ["config", "known_hosts", r"spaced\ \ conf"],
+ )
+ )
+ assert completion == expected
+
+ @pytest.mark.complete("scp -F 'spaced conf' ", cwd="scp")
+ def test_basic_spaced_conf(self, hosts, completion):
+ expected = sorted(
+ chain(
+ (
+ "%s:" % x
+ for x in chain(
+ hosts,
+ # From "fixtures/scp/spaced conf"
+ "gee jar".split(),
+ # From fixtures/scp/known_hosts
+ "blah doo ike".split(),
+ )
+ ),
+ # Local filenames
+ ["config", "known_hosts", r"spaced\ \ conf"],
+ )
+ )
+ assert completion == expected
+
+ @pytest.mark.complete("scp -F")
+ def test_capital_f_without_space(self, completion):
+ assert completion
+ assert not any(
+ "option requires an argument -- F" in x for x in completion
+ )
+
+ @pytest.fixture(scope="class")
+ def live_pwd(self, bash):
+ try:
+ return assert_bash_exec(
+ bash,
+ "ssh -o 'Batchmode yes' -o 'ConnectTimeout 1' "
+ "%s pwd 2>/dev/null" % LIVE_HOST,
+ want_output=True,
+ ).strip()
+ except AssertionError:
+ pytest.skip("Live host %s not available" % LIVE_HOST)
+
+ @pytest.mark.complete("scp %s:" % LIVE_HOST, sleep_after_tab=2)
+ def test_live(self, live_pwd, completion):
+ """
+ To support this test, configure a HostName entry for LIVE_HOST
+ in ssh's configs, e.g. ~/.ssh/config or /etc/ssh/ssh_config.
+
+ Connection to it must open sufficiently quickly for the
+ ConnectTimeout and sleep_after_tab settings.
+ """
+ assert completion == "%s:%s/" % (LIVE_HOST, live_pwd)
diff --git a/test/t/test_screen.py b/test/t/test_screen.py
index d9254bda..3e98837f 100644
--- a/test/t/test_screen.py
+++ b/test/t/test_screen.py
@@ -19,17 +19,17 @@ class TestScreen:
def test_4(self, completion):
assert completion
- @pytest.mark.complete("screen -T foo cat")
+ @pytest.mark.complete("screen -T foo ca")
def test_5(self, completion):
- assert completion
+ assert completion == "t" or "cat" in completion
@pytest.mark.complete("screen //")
def test_telnet(self, completion):
- assert completion == "//telnet"
+ assert completion == "telnet"
@pytest.mark.complete("screen cat //")
def test_not_telnet(self, completion):
- assert completion != "//telnet"
+ assert completion != "telnet"
@pytest.mark.complete("screen //telnet ", env=dict(HOME="$PWD/shared"))
def test_telnet_first_arg(self, completion):
diff --git a/test/t/test_secret_tool.py b/test/t/test_secret_tool.py
new file mode 100644
index 00000000..cbfc0cbc
--- /dev/null
+++ b/test/t/test_secret_tool.py
@@ -0,0 +1,12 @@
+import pytest
+
+
+@pytest.mark.bashcomp(cmd="secret-tool",)
+class TestSecretTool:
+ @pytest.mark.complete("secret-tool ", require_cmd=True)
+ def test_modes(self, completion):
+ assert "store" in completion
+
+ @pytest.mark.complete("secret-tool search ")
+ def test_no_complete(self, completion):
+ assert not completion
diff --git a/test/t/test_sftp.py b/test/t/test_sftp.py
index 0c039399..a421a449 100644
--- a/test/t/test_sftp.py
+++ b/test/t/test_sftp.py
@@ -1,11 +1,46 @@
+from itertools import chain
+
import pytest
class TestSftp:
@pytest.mark.complete("sftp -Fsp", cwd="sftp")
def test_1(self, completion):
- assert completion == "-Fspaced conf"
+ assert completion == r"aced\ \ conf"
@pytest.mark.complete("sftp -", require_cmd=True)
def test_2(self, completion):
assert completion
+
+ @pytest.mark.complete("sftp -F config ", cwd="sftp")
+ def test_hosts(self, hosts, completion):
+ expected = sorted(
+ chain(
+ hosts,
+ # From fixtures/sftp/config
+ "gee hut".split(),
+ # From fixtures/sftp/known_hosts
+ "10.10.10.10 doo ike".split(),
+ )
+ )
+ assert completion == expected
+
+ @pytest.mark.complete(r"sftp -F spaced\ \ conf ", cwd="sftp")
+ def test_hosts_spaced_conf(self, hosts, completion):
+ expected = sorted(
+ chain(
+ hosts,
+ # From "fixtures/sftp/spaced conf"
+ "gee jar".split(),
+ # From fixtures/sftp/known_hosts
+ "10.10.10.10 doo ike".split(),
+ )
+ )
+ assert completion == expected
+
+ @pytest.mark.complete("sftp -F")
+ def test_capital_f_without_space(self, completion):
+ assert completion
+ assert not any(
+ "option requires an argument -- F" in x for x in completion
+ )
diff --git a/test/t/test_slapt_get.py b/test/t/test_slapt_get.py
index 626dde9e..92449711 100644
--- a/test/t/test_slapt_get.py
+++ b/test/t/test_slapt_get.py
@@ -1,8 +1,26 @@
+import os.path
+from tempfile import mkstemp
+
import pytest
+from conftest import assert_complete, is_bash_type
+
@pytest.mark.bashcomp(cmd="slapt-get")
class TestSlaptGet:
+ @pytest.fixture(scope="class")
+ def slapt_getrc(self, request, bash):
+ fd, fname = mkstemp(prefix="slapt-getrc.", text=True)
+ request.addfinalizer(lambda: os.remove(fname))
+ with os.fdopen(fd, "w") as f:
+ print(
+ "WORKINGDIR=%s/"
+ % os.path.join(bash.cwd, *"slackware var slapt-get".split()),
+ file=f,
+ )
+ print("SOURCE=file:///home/", file=f)
+ return fname
+
@pytest.mark.complete("slapt-get -", require_cmd=True)
def test_1(self, completion):
assert completion
@@ -14,3 +32,13 @@ class TestSlaptGet:
@pytest.mark.complete("slapt-get -c non-existent-file --install ")
def test_3(self, completion):
assert not completion
+
+ def test_install(self, bash, slapt_getrc):
+ if not is_bash_type(bash, "slapt-get"):
+ pytest.skip("slapt-get not found")
+ completion = assert_complete(
+ bash, "slapt-get -c %s --install " % slapt_getrc
+ )
+ assert completion == sorted(
+ "abc-4-i686-1 ran-1.2-noarch-1 qwe-2.1-i486-1".split()
+ )
diff --git a/test/t/test_slapt_src.py b/test/t/test_slapt_src.py
index dd443b04..b55b722d 100644
--- a/test/t/test_slapt_src.py
+++ b/test/t/test_slapt_src.py
@@ -1,16 +1,43 @@
+import os
+from tempfile import mkstemp
+
import pytest
+from conftest import assert_complete, is_bash_type
+
@pytest.mark.bashcomp(cmd="slapt-src")
class TestSlaptSrc:
+ @pytest.fixture(scope="class")
+ def slapt_srcrc(self, request, bash):
+ fd, fname = mkstemp(prefix="slapt-srcrc.", text=True)
+ request.addfinalizer(lambda: os.remove(fname))
+ with os.fdopen(fd, "w") as f:
+ print(
+ "BUILDDIR=%s/"
+ % os.path.join(
+ bash.cwd, *"slackware usr src slapt-src".split()
+ ),
+ file=f,
+ )
+ return fname
+
@pytest.mark.complete("slapt-src -", require_cmd=True)
def test_1(self, completion):
assert completion
@pytest.mark.complete("slapt-src --bu", require_cmd=True)
def test_2(self, completion):
- assert completion == "--build"
+ assert completion == "ild" or "--build" in completion
@pytest.mark.complete("slapt-src --ins", require_cmd=True)
def test_3(self, completion):
- assert completion == "--install"
+ assert completion == "tall" or "--install" in completion
+
+ def test_install(self, bash, slapt_srcrc):
+ if not is_bash_type(bash, "slapt-src"):
+ pytest.skip("slapt-src not found")
+ completion = assert_complete(
+ bash, "slapt-src --config %s --install " % slapt_srcrc
+ )
+ assert completion == "abc:4 qwe:2.1".split()
diff --git a/test/t/test_ssh.py b/test/t/test_ssh.py
index 204b7c7c..8e958195 100644
--- a/test/t/test_ssh.py
+++ b/test/t/test_ssh.py
@@ -1,10 +1,12 @@
import pytest
+from conftest import assert_complete, partialize
+
class TestSsh:
@pytest.mark.complete("ssh -Fsp", cwd="ssh")
def test_1(self, completion):
- assert completion == "-Fspaced conf"
+ assert completion == r"aced\ \ conf"
@pytest.mark.complete("ssh -F config ls", cwd="ssh")
def test_2(self, completion):
@@ -32,3 +34,27 @@ class TestSsh:
@pytest.mark.complete("ssh -", require_cmd=True)
def test_6(self, completion):
assert completion
+
+ @pytest.mark.complete("ssh -F")
+ def test_capital_f_without_space(self, completion):
+ assert completion
+ assert not any(
+ "option requires an argument -- F" in x for x in completion
+ )
+
+ @pytest.mark.complete("ssh -F nonexistent ")
+ def test_capital_f_nonexistent(self, completion):
+ assert completion
+
+ def test_partial_hostname(self, bash, known_hosts):
+ first_char, partial_hosts = partialize(bash, known_hosts)
+ completion = assert_complete(bash, "ssh %s" % first_char)
+ if len(completion) == 1:
+ assert completion == partial_hosts[0][1:]
+ else:
+ assert completion == sorted(x for x in partial_hosts)
+
+ @pytest.mark.parametrize("protocol", "4 6 9".split())
+ def test_protocol_option_bundling(self, bash, protocol):
+ completion = assert_complete(bash, "ssh -%sF ssh/" % protocol)
+ assert "config" in completion
diff --git a/test/t/test_ssh_keygen.py b/test/t/test_ssh_keygen.py
index 2d53f5f8..b773ab4f 100644
--- a/test/t/test_ssh_keygen.py
+++ b/test/t/test_ssh_keygen.py
@@ -6,3 +6,54 @@ class TestSshKeygen:
@pytest.mark.complete("ssh-keygen -", require_cmd=True)
def test_1(self, completion):
assert completion
+
+ @pytest.mark.complete("ssh-keygen -s foo_key ssh-copy-id/.ssh/")
+ def test_filedir_pub_at_end_of_s(self, completion):
+ assert completion
+ assert all(x.endswith(".pub") for x in completion)
+
+ @pytest.mark.complete("ssh-keygen -s foo_key -n foo,")
+ def test_usernames_for_n(self, completion):
+ assert completion
+ assert not any("," in x for x in completion)
+ # TODO check that these are usernames
+
+ @pytest.mark.complete("ssh-keygen -s foo_key -h -n foo,")
+ def test_host_for_h_n(self, completion):
+ assert completion
+ assert not any("," in x for x in completion)
+ # TODO check that these are hostnames
+
+ @pytest.mark.complete("ssh-keygen -Y foo -n ")
+ def test_n_with_Y(self, completion):
+ assert not completion
+
+ @pytest.mark.complete("ssh-keygen -r ")
+ def test_r_without_Y(self, completion):
+ assert not completion
+
+ @pytest.mark.complete("ssh-keygen -Y foo -r ")
+ def test_r_with_Y(self, completion):
+ assert "ssh/" in completion
+
+ @pytest.mark.complete("ssh-keygen -t ecdsa -b ")
+ def test_ecdsa_b(self, completion):
+ assert completion
+
+ @pytest.mark.complete("ssh-keygen -t ecdsa-sk -b ")
+ def test_ecdsa_sk_b(self, completion):
+ assert not completion
+
+ @pytest.mark.complete("ssh-keygen -O ")
+ def test_O(self, completion):
+ assert completion
+ assert any(x.endswith("=") for x in completion)
+
+ @pytest.mark.complete("ssh-keygen -O force-command=bas")
+ def test_O_force_command(self, completion):
+ assert completion
+ assert not completion.startswith("force-command=")
+
+ @pytest.mark.complete("ssh-keygen -O unknown=")
+ def test_O_unknown(self, completion):
+ assert not completion
diff --git a/test/t/test_sudo.py b/test/t/test_sudo.py
index ced6662e..a3494664 100644
--- a/test/t/test_sudo.py
+++ b/test/t/test_sudo.py
@@ -10,27 +10,27 @@ class TestSudo:
@pytest.mark.complete("sudo cd fo", cwd="shared/default")
def test_2(self, completion):
- assert completion == "foo.d/"
+ assert completion == "o.d/"
assert not completion.endswith(" ")
@pytest.mark.complete("sudo sh share")
def test_3(self, completion):
- assert completion == "shared/"
+ assert completion == "d/"
assert not completion.endswith(" ")
@pytest.mark.complete("sudo mount /dev/sda1 def", cwd="shared")
def test_4(self, completion):
- assert completion == "default/"
+ assert completion == "ault/"
assert not completion.endswith(" ")
@pytest.mark.complete("sudo -e -u root bar foo", cwd="shared/default")
def test_5(self, completion):
- assert completion == ["foo", "foo.d/"]
+ assert completion == "foo foo.d/".split()
def test_6(self, bash, part_full_user):
part, full = part_full_user
completion = assert_complete(bash, "sudo chown %s" % part)
- assert completion == full
+ assert completion == full[len(part) :]
assert completion.endswith(" ")
def test_7(self, bash, part_full_user, part_full_group):
@@ -39,32 +39,32 @@ class TestSudo:
completion = assert_complete(
bash, "sudo chown %s:%s" % (user, partgroup)
)
- assert completion == "%s:%s" % (user, fullgroup)
+ assert completion == fullgroup[len(partgroup) :]
assert completion.endswith(" ")
def test_8(self, bash, part_full_group):
part, full = part_full_group
completion = assert_complete(bash, "sudo chown dot.user:%s" % part)
- assert completion == "dot.user:%s" % full
+ assert completion == full[len(part) :]
assert completion.endswith(" ")
- @pytest.mark.xfail # TODO check escaping, whitespace
- def test_9(self, bash, part_full_group):
- """Test preserving special chars in $prefix$partgroup<TAB>."""
- part, full = part_full_group
- for prefix in (
+ @pytest.mark.parametrize(
+ "prefix",
+ [
r"funky\ user:",
"funky.user:",
r"funky\.user:",
r"fu\ nky.user:",
r"f\ o\ o\.\bar:",
r"foo\_b\ a\.r\ :",
- ):
- completion = assert_complete(
- bash, "sudo chown %s%s" % (prefix, part)
- )
- assert completion == "%s%s" % (prefix, full)
- assert completion.endswith(" ")
+ ],
+ )
+ def test_9(self, bash, part_full_group, prefix):
+ """Test preserving special chars in $prefix$partgroup<TAB>."""
+ part, full = part_full_group
+ completion = assert_complete(bash, "sudo chown %s%s" % (prefix, part))
+ assert completion == full[len(part) :]
+ assert completion.endswith(" ")
def test_10(self, bash, part_full_user, part_full_group):
"""Test giving up on degenerate cases instead of spewing junk."""
diff --git a/test/t/test_tar.py b/test/t/test_tar.py
index 309bcc76..4518d0bd 100644
--- a/test/t/test_tar.py
+++ b/test/t/test_tar.py
@@ -77,28 +77,22 @@ class TestTar:
@pytest.mark.complete("tar --add-fil")
def test_15(self, completion, gnu_tar):
- assert completion == "--add-file="
+ assert completion == "e="
assert not completion.endswith(" ")
@pytest.mark.complete("tar -cf /dev/null --posi")
def test_16(self, completion, gnu_tar):
- assert completion == "--posix"
+ assert completion == "x"
assert completion.endswith(" ")
@pytest.mark.complete("tar --owner=")
- def test_17(self, bash, completion, gnu_tar):
- users = sorted(
- assert_bash_exec(bash, "compgen -A user", want_output=True).split()
- )
+ def test_17(self, bash, completion, gnu_tar, output_sort_uniq):
+ users = output_sort_uniq("compgen -u")
assert completion == users
@pytest.mark.complete("tar --group=")
- def test_18(self, bash, completion, gnu_tar):
- groups = sorted(
- assert_bash_exec(
- bash, "compgen -A group", want_output=True
- ).split()
- )
+ def test_18(self, bash, completion, gnu_tar, output_sort_uniq):
+ groups = output_sort_uniq("compgen -g")
assert completion == groups
# Use -b for this as -b is still not handled by tar's completion
@@ -121,6 +115,6 @@ class TestTar:
@pytest.mark.complete(r"tar tf escape.tar a/b\'", cwd="tar")
def test_22(self, bash, completion):
"""Test listing escaped chars in old option."""
- assert completion == "a/b'c/"
+ assert completion == "c/"
# TODO: "tar tf escape.tar a/b"
diff --git a/test/t/test_totem.py b/test/t/test_totem.py
new file mode 100644
index 00000000..f6fb26fe
--- /dev/null
+++ b/test/t/test_totem.py
@@ -0,0 +1,7 @@
+import pytest
+
+
+class TestTotem:
+ @pytest.mark.complete("totem ")
+ def test_basic(self, completion):
+ assert completion
diff --git a/test/t/test_tshark.py b/test/t/test_tshark.py
index 8ed881ee..f49533e0 100644
--- a/test/t/test_tshark.py
+++ b/test/t/test_tshark.py
@@ -13,9 +13,8 @@ class TestTshark:
@pytest.mark.complete("tshark -O foo,htt", require_cmd=True)
def test_3(self, completion):
- # When there's only one completion, it's be the one with "foo," prefix;
- # when multiple (e.g. http and http2), it's the completion alone.
- assert completion == "foo,http" or "http" in completion
+ # p: one completion only; http: e.g. http and http2
+ assert completion == "p" or "http" in completion
@pytest.mark.complete("tshark -o tcp", require_cmd=True)
def test_4(self, completion):
@@ -29,3 +28,7 @@ class TestTshark:
def test_6(self, completion):
"""Test there are no URLs in completions."""
assert not any("://" in x for x in completion)
+
+ @pytest.mark.complete("tshark -r ")
+ def test_input_files(self, completion):
+ assert completion
diff --git a/test/t/test_tsig_keygen.py b/test/t/test_tsig_keygen.py
new file mode 100644
index 00000000..8c8a64ac
--- /dev/null
+++ b/test/t/test_tsig_keygen.py
@@ -0,0 +1,12 @@
+import pytest
+
+
+@pytest.mark.bashcomp(cmd="tsig-keygen")
+class TestTsigKeygen:
+ @pytest.mark.complete("tsig-keygen ")
+ def test_basic(self, completion):
+ assert not completion
+
+ @pytest.mark.complete("tsig-keygen -", require_cmd=True)
+ def test_options(self, completion):
+ assert completion
diff --git a/test/t/test_umount.py b/test/t/test_umount.py
index dd4ae0b5..2baf0dac 100644
--- a/test/t/test_umount.py
+++ b/test/t/test_umount.py
@@ -1,7 +1,85 @@
import pytest
+from conftest import assert_bash_exec
+
class TestUmount:
+ @pytest.fixture(scope="class")
+ def dummy_mnt(self, request, bash):
+ """
+ umount completion from fstab can't be tested directly because it
+ (correctly) uses absolute paths. So we create a custom completion which
+ reads from a file in our text fixture instead.
+ """
+ assert_bash_exec(bash, "unset COMPREPLY cur; unset -f _mnt_completion")
+ assert_bash_exec(
+ bash,
+ "_mnt_completion() { "
+ "local cur=$(_get_cword); "
+ "_linux_fstab $(_get_pword) < mount/test-fstab; "
+ "} && complete -F _mnt_completion _mnt",
+ )
+ request.addfinalizer(
+ lambda: assert_bash_exec(
+ bash, "complete -r _mnt; unset -f _mnt_completion"
+ )
+ )
+
@pytest.mark.complete("umount ")
def test_1(self, completion):
assert completion
+
+ @pytest.mark.complete("_mnt /mnt/nice-test-p")
+ def test_mnt_basic(self, completion, dummy_mnt):
+ assert completion == "ath"
+
+ # Note in tests below that return only one result, that the result
+ # is shell unescaped due to how assert_complete handles the
+ # "one result on same line case".
+
+ @pytest.mark.complete(r"_mnt /mnt/nice\ test-p")
+ def test_mnt_space(self, completion, dummy_mnt):
+ assert completion == r"ath"
+
+ @pytest.mark.complete(r"_mnt /mnt/nice\$test-p")
+ def test_mnt_dollar(self, completion, dummy_mnt):
+ assert completion == "ath"
+
+ @pytest.mark.complete(r"_mnt /mnt/nice\ test\\p")
+ def test_mnt_backslash(self, completion, dummy_mnt):
+ assert completion == "ath"
+
+ @pytest.mark.complete(r"_mnt /mnt/nice\ ")
+ def test_mnt_after_space(self, completion, dummy_mnt):
+ assert completion == sorted(
+ (r"/mnt/nice\ test\\path", r"/mnt/nice\ test-path")
+ )
+
+ @pytest.mark.complete(r"_mnt /mnt/nice\$")
+ def test_mnt_at_dollar(self, completion, dummy_mnt):
+ assert completion == "test-path"
+
+ @pytest.mark.complete(r"_mnt /mnt/nice\'")
+ def test_mnt_at_quote(self, completion, dummy_mnt):
+ assert completion == "test-path"
+
+ @pytest.mark.complete("_mnt /mnt/other")
+ def test_mnt_other(self, completion, dummy_mnt):
+ assert completion == r"\'test\ path"
+
+ @pytest.mark.complete("_mnt -L Ubu")
+ def test_mnt_label_space(self, completion, dummy_mnt):
+ assert completion == r"ntu\ Karmic"
+
+ @pytest.mark.complete("_mnt -L Deb")
+ def test_mnt_label_quote(self, completion, dummy_mnt):
+ assert completion == r"ian-it\'s\ awesome"
+
+ def test_linux_fstab_unescape(self, bash):
+ assert_bash_exec(bash, r"var=one\'two\\040three\\")
+ assert_bash_exec(bash, "__linux_fstab_unescape var")
+ output = assert_bash_exec(
+ bash, r'printf "%s\n" "$var"', want_output=True
+ )
+ assert output.strip() == "one'two three\\"
+ assert_bash_exec(bash, "unset var")
diff --git a/test/t/test_upgradepkg.py b/test/t/test_upgradepkg.py
index 4c72a158..87fe8e4c 100644
--- a/test/t/test_upgradepkg.py
+++ b/test/t/test_upgradepkg.py
@@ -32,3 +32,20 @@ class TestUpgradepkg:
]
)
assert completion == expected
+
+ @pytest.mark.complete("upgradepkg foo%", cwd="slackware/home")
+ def test_after_percent(self, completion):
+ expected = sorted(
+ [
+ "%s/" % x
+ for x in os.listdir("slackware/home")
+ if os.path.isdir("./slackware/home/%s" % x)
+ ]
+ + [
+ x
+ for x in os.listdir("slackware/home")
+ if os.path.isfile("./slackware/home/%s" % x)
+ and fnmatch.fnmatch(x, "*.t[bglx]z")
+ ]
+ )
+ assert completion == ["foo%%%s" % x for x in expected]
diff --git a/test/t/test_userdel.py b/test/t/test_userdel.py
index 718c6629..3405e127 100644
--- a/test/t/test_userdel.py
+++ b/test/t/test_userdel.py
@@ -6,6 +6,6 @@ class TestUserdel:
def test_1(self, completion):
assert completion
- @pytest.mark.complete("userdel root")
+ @pytest.mark.complete("userdel roo")
def test_2(self, completion):
- assert "root" in completion
+ assert completion == "t" or "root" in completion
diff --git a/test/t/test_valgrind.py b/test/t/test_valgrind.py
index c7c979dd..0553b556 100644
--- a/test/t/test_valgrind.py
+++ b/test/t/test_valgrind.py
@@ -16,13 +16,13 @@ class TestValgrind:
@pytest.mark.complete("valgrind --tool=memche", require_cmd=True)
def test_3(self, completion):
- assert "--tool=memcheck" in completion
+ assert completion == "ck" or "--tool=memcheck" in completion
@pytest.mark.complete(
"valgrind --tool=helgrind --history-l", require_cmd=True
)
def test_4(self, completion):
- assert "--history-level=" in completion
+ assert completion == "evel=" or "--history-level=" in completion
assert not completion.endswith(" ")
@pytest.mark.complete(r"valgrind --log-file=v\ 0.log ./bin/", cwd="shared")
diff --git a/test/t/test_wol.py b/test/t/test_wol.py
index b7a622ee..bf04f76e 100644
--- a/test/t/test_wol.py
+++ b/test/t/test_wol.py
@@ -5,14 +5,15 @@ import pytest
class TestWol:
@pytest.mark.complete("wol ")
def test_1(self, completion):
- assert (
- completion == "00:00:00:00:00:00 11:11:11:11:11:11 "
+ assert all(
+ x in completion
+ for x in "00:00:00:00:00:00 11:11:11:11:11:11 "
"22:22:22:22:22:22 33:33:33:33:33:33".split()
)
@pytest.mark.complete("wol 00:")
def test_2(self, completion):
- assert completion == "00:00:00:00:00:00"
+ assert any(x.endswith("00:00:00:00:00") for x in completion)
@pytest.mark.complete("wol -", require_cmd=True)
def test_3(self, completion):
diff --git a/test/t/test_write.py b/test/t/test_write.py
index 8f0886e4..fc4bfa00 100644
--- a/test/t/test_write.py
+++ b/test/t/test_write.py
@@ -2,6 +2,6 @@ import pytest
class TestWrite:
- @pytest.mark.complete("write root")
+ @pytest.mark.complete("write roo")
def test_1(self, completion):
- assert "root" in completion
+ assert completion == "t" or "root" in completion
diff --git a/test/t/test_xfreerdp.py b/test/t/test_xfreerdp.py
index a8435d6c..56162714 100644
--- a/test/t/test_xfreerdp.py
+++ b/test/t/test_xfreerdp.py
@@ -5,10 +5,20 @@ from conftest import assert_bash_exec
class TestXfreerdp:
def _help(self, bash):
- return assert_bash_exec(bash, "xfreerdp --help || :", want_output=True)
+ return assert_bash_exec(
+ bash, "xfreerdp --help 2>&1 || :", want_output=True
+ )
@pytest.fixture(scope="class")
- def slash_syntax(self, bash):
+ def help_success(self, bash):
+ output = self._help(bash)
+ # Example from our CentOS 7 container
+ # [04:51:31:663] [238:238] [ERROR][com.freerdp.client.x11] - Failed to get pixmap info
+ if not output or "ERROR" in output.strip().splitlines()[0]:
+ pytest.skip("--help errored")
+
+ @pytest.fixture(scope="class")
+ def slash_syntax(self, bash, help_success):
if "/help" not in self._help(bash):
pytest.skip("Not slash syntax")
@@ -18,27 +28,31 @@ class TestXfreerdp:
pytest.skip("Not dash syntax")
@pytest.mark.complete("xfreerdp /", require_cmd=True)
- def test_1(self, bash, completion, slash_syntax):
+ def test_1(self, bash, completion, help_success, slash_syntax):
assert completion
@pytest.mark.complete("xfreerdp -", require_cmd=True)
- def test_2(self, completion):
+ def test_2(self, completion, help_success):
assert completion
@pytest.mark.complete("xfreerdp +", require_cmd=True)
- def test_3(self, bash, completion, slash_syntax):
+ def test_3(self, bash, completion, help_success, slash_syntax):
assert completion
- @pytest.mark.complete("xfreerdp /kbd:", require_cmd=True)
- def test_4(self, bash, completion, slash_syntax):
+ @pytest.mark.complete(
+ "xfreerdp /kbd:",
+ require_cmd=True,
+ skipif='test -z "$(xfreerdp /kbd-list 2>/dev/null)"',
+ )
+ def test_4(self, bash, completion, help_success, slash_syntax):
assert completion
@pytest.mark.complete("xfreerdp /help ", require_cmd=True)
- def test_5(self, completion):
+ def test_5(self, completion, help_success):
assert not completion
@pytest.mark.complete("xfreerdp -k ", require_cmd=True)
- def test_6(self, bash, completion, dash_syntax):
+ def test_6(self, bash, completion, help_success, dash_syntax):
assert completion
@pytest.mark.complete("xfreerdp --help ", require_cmd=True)
diff --git a/test/t/test_xgamma.py b/test/t/test_xgamma.py
index beb684f8..151e2d36 100644
--- a/test/t/test_xgamma.py
+++ b/test/t/test_xgamma.py
@@ -8,5 +8,5 @@ class TestXgamma:
@pytest.mark.complete("xgamma -gam", require_cmd=True)
def test_2(self, completion):
- assert completion == "-gamma"
+ assert completion == "ma"
assert completion.endswith(" ")
diff --git a/test/t/test_xhost.py b/test/t/test_xhost.py
new file mode 100644
index 00000000..bb2df82a
--- /dev/null
+++ b/test/t/test_xhost.py
@@ -0,0 +1,22 @@
+import pytest
+
+from conftest import assert_complete, partialize
+
+
+@pytest.mark.bashcomp(pre_cmds=("HOME=$PWD",))
+class TestXhost:
+ @pytest.mark.parametrize("prefix", ["+", "-", ""])
+ def test_hosts(self, bash, hosts, prefix):
+ completion = assert_complete(bash, "xhost %s" % prefix)
+ assert completion == ["%s%s" % (prefix, x) for x in hosts]
+
+ @pytest.mark.parametrize("prefix", ["+", "-", ""])
+ def test_partial_hosts(self, bash, hosts, prefix):
+ first_char, partial_hosts = partialize(bash, hosts)
+ completion = assert_complete(bash, "xhost %s%s" % (prefix, first_char))
+ if len(completion) == 1:
+ assert completion == partial_hosts[0][1:]
+ else:
+ assert completion == sorted(
+ "%s%s" % (prefix, x) for x in partial_hosts
+ )
diff --git a/test/t/unit/Makefile.am b/test/t/unit/Makefile.am
index b96b326c..3eb652af 100644
--- a/test/t/unit/Makefile.am
+++ b/test/t/unit/Makefile.am
@@ -8,12 +8,15 @@ EXTRA_DIST = \
test_unit_get_cword.py \
test_unit_init_completion.py \
test_unit_ip_addresses.py \
+ test_unit_known_hosts_real.py \
test_unit_longopt.py \
test_unit_parse_help.py \
test_unit_parse_usage.py \
test_unit_quote.py \
+ test_unit_quote_readline.py \
test_unit_tilde.py \
- test_unit_variables.py
+ test_unit_variables.py \
+ test_unit_xinetd_services.py
all:
diff --git a/test/t/unit/test_unit_count_args.py b/test/t/unit/test_unit_count_args.py
index c0afe736..56bce2cb 100644
--- a/test/t/unit/test_unit_count_args.py
+++ b/test/t/unit/test_unit_count_args.py
@@ -1,6 +1,6 @@
import pytest
-from conftest import assert_bash_exec, TestUnitBase
+from conftest import TestUnitBase, assert_bash_exec
@pytest.mark.bashcomp(
@@ -11,7 +11,7 @@ class TestUnitCountArgs(TestUnitBase):
return self._test_unit("_count_args %s; echo $args", *args, **kwargs)
def test_1(self, bash):
- assert_bash_exec(bash, "_count_args >/dev/null")
+ assert_bash_exec(bash, "COMP_CWORD= _count_args >/dev/null")
def test_2(self, bash):
"""a b| should set args to 1"""
diff --git a/test/t/unit/test_unit_expand.py b/test/t/unit/test_unit_expand.py
index 7c0a9836..d2a3ebc4 100644
--- a/test/t/unit/test_unit_expand.py
+++ b/test/t/unit/test_unit_expand.py
@@ -3,7 +3,7 @@ import pytest
from conftest import assert_bash_exec
-@pytest.mark.bashcomp(cmd=None)
+@pytest.mark.bashcomp(cmd=None, ignore_env=r"^[+-](cur|COMPREPLY)=")
class TestUnitExpand:
def test_1(self, bash):
assert_bash_exec(bash, "_expand >/dev/null")
@@ -11,3 +11,21 @@ class TestUnitExpand:
def test_2(self, bash):
"""Test environment non-pollution, detected at teardown."""
assert_bash_exec(bash, "foo() { _expand; }; foo; unset foo")
+
+ def test_user_home_compreply(self, bash, user_home):
+ user, home = user_home
+ output = assert_bash_exec(
+ bash,
+ r'cur="~%s"; _expand; printf "%%s\n" "$COMPREPLY"' % user,
+ want_output=True,
+ )
+ assert output.strip() == home
+
+ def test_user_home_cur(self, bash, user_home):
+ user, home = user_home
+ output = assert_bash_exec(
+ bash,
+ r'cur="~%s/a"; _expand; printf "%%s\n" "$cur"' % user,
+ want_output=True,
+ )
+ assert output.strip() == "%s/a" % home
diff --git a/test/t/unit/test_unit_expand_tilde_by_ref.py b/test/t/unit/test_unit_expand_tilde_by_ref.py
index fbc172df..17bdedfe 100644
--- a/test/t/unit/test_unit_expand_tilde_by_ref.py
+++ b/test/t/unit/test_unit_expand_tilde_by_ref.py
@@ -3,7 +3,7 @@ import pytest
from conftest import assert_bash_exec
-@pytest.mark.bashcomp(cmd=None)
+@pytest.mark.bashcomp(cmd=None, ignore_env=r"^[+-]var=")
class TestUnitExpandTildeByRef:
def test_1(self, bash):
assert_bash_exec(bash, "__expand_tilde_by_ref >/dev/null")
@@ -14,3 +14,33 @@ class TestUnitExpandTildeByRef:
bash,
'_x() { local aa="~"; __expand_tilde_by_ref aa; }; _x; unset _x',
)
+
+ @pytest.mark.parametrize("plain_tilde", (True, False))
+ @pytest.mark.parametrize(
+ "suffix_expanded",
+ (
+ ("", True),
+ ("/foo", True),
+ (r"/\$HOME", True),
+ ("/a b", True),
+ ("/*", True),
+ (";echo hello", False),
+ ("/a;echo hello", True),
+ ),
+ )
+ def test_expand(self, bash, user_home, plain_tilde, suffix_expanded):
+ user, home = user_home
+ suffix, expanded = suffix_expanded
+ if plain_tilde:
+ user = ""
+ if not suffix or not expanded:
+ home = "~"
+ elif not expanded:
+ home = "~%s" % user
+ output = assert_bash_exec(
+ bash,
+ r'var="~%s%s"; __expand_tilde_by_ref var; printf "%%s\n" "$var"'
+ % (user, suffix),
+ want_output=True,
+ )
+ assert output.strip() == "%s%s" % (home, suffix.replace(r"\$", "$"),)
diff --git a/test/t/unit/test_unit_filedir.py b/test/t/unit/test_unit_filedir.py
index 7f14f294..b847efc2 100644
--- a/test/t/unit/test_unit_filedir.py
+++ b/test/t/unit/test_unit_filedir.py
@@ -1,3 +1,9 @@
+import os
+import shutil
+import sys
+import tempfile
+from pathlib import Path
+
import pytest
from conftest import assert_bash_exec, assert_complete
@@ -24,102 +30,206 @@ class TestUnitFiledir:
"complete -F _fd fd",
)
+ @pytest.fixture(scope="class")
+ def non_windows_testdir(self, request, bash):
+ if sys.platform.startswith("win"):
+ pytest.skip("Filenames not allowed on Windows")
+ tempdir = Path(tempfile.mkdtemp(prefix="bash-completion_filedir"))
+ request.addfinalizer(lambda: shutil.rmtree(str(tempdir)))
+ subdir = tempdir / 'a"b'
+ subdir.mkdir()
+ (subdir / "d").touch()
+ subdir = tempdir / "a*b"
+ subdir.mkdir()
+ (subdir / "j").touch()
+ subdir = tempdir / r"a\b"
+ subdir.mkdir()
+ (subdir / "g").touch()
+ return tempdir
+
+ @pytest.fixture(scope="class")
+ def utf8_ctype(self, bash):
+ # TODO: this likely is not the right thing to do. Instead we should
+ # grab the setting from the running shell, possibly eval $(locale)
+ # in a subshell and grab LC_CTYPE from there. That doesn't seem to work
+ # either everywhere though.
+ lc_ctype = os.environ.get("LC_CTYPE", "")
+ if "UTF-8" not in lc_ctype:
+ pytest.skip("Applicable only in LC_CTYPE=UTF-8 setups")
+ return lc_ctype
+
def test_1(self, bash):
assert_bash_exec(bash, "_filedir >/dev/null")
@pytest.mark.parametrize("funcname", "f f2".split())
def test_2(self, bash, functions, funcname):
completion = assert_complete(bash, "%s ab/" % funcname, cwd="_filedir")
- assert completion == "ab/e"
+ assert completion == "e"
@pytest.mark.parametrize("funcname", "f f2".split())
def test_3(self, bash, functions, funcname):
completion = assert_complete(
bash, r"%s a\ b/" % funcname, cwd="_filedir"
)
- assert completion == "a b/i"
+ assert completion == "i"
@pytest.mark.parametrize("funcname", "f f2".split())
def test_4(self, bash, functions, funcname):
completion = assert_complete(
bash, r"%s a\'b/" % funcname, cwd="_filedir"
)
- assert completion == "a'b/c"
+ assert completion == "c"
@pytest.mark.parametrize("funcname", "f f2".split())
def test_5(self, bash, functions, funcname):
completion = assert_complete(
bash, r"%s a\&b/" % funcname, cwd="_filedir"
)
- assert completion == "a&b/f"
+ assert completion == "f"
@pytest.mark.parametrize("funcname", "f f2".split())
def test_6(self, bash, functions, funcname):
completion = assert_complete(
bash, r"%s a\$" % funcname, cwd="_filedir"
)
- assert completion == "a$b/"
+ assert completion == "b/"
@pytest.mark.parametrize("funcname", "f f2".split())
def test_7(self, bash, functions, funcname):
completion = assert_complete(
bash, r"%s 'ab/" % funcname, cwd="_filedir"
)
- assert completion == "ab/e"
+ assert completion == "e'"
@pytest.mark.parametrize("funcname", "f f2".split())
def test_8(self, bash, functions, funcname):
completion = assert_complete(
bash, r"%s 'a b/" % funcname, cwd="_filedir"
)
- assert completion == "a b/i"
+ assert completion == "i'"
@pytest.mark.parametrize("funcname", "f f2".split())
def test_9(self, bash, functions, funcname):
completion = assert_complete(
bash, r"%s 'a$b/" % funcname, cwd="_filedir"
)
- assert completion == "a$b/h"
+ assert completion == "h'"
@pytest.mark.parametrize("funcname", "f f2".split())
def test_10(self, bash, functions, funcname):
completion = assert_complete(
bash, r"%s 'a&b/" % funcname, cwd="_filedir"
)
- assert completion == "a&b/f"
+ assert completion == "f'"
@pytest.mark.parametrize("funcname", "f f2".split())
def test_11(self, bash, functions, funcname):
completion = assert_complete(
bash, r'%s "ab/' % funcname, cwd="_filedir"
)
- assert completion == "ab/e"
+ assert completion == 'e"'
@pytest.mark.parametrize("funcname", "f f2".split())
def test_12(self, bash, functions, funcname):
completion = assert_complete(
bash, r'%s "a b/' % funcname, cwd="_filedir"
)
- assert completion == "a b/i"
+ assert completion == 'i"'
@pytest.mark.parametrize("funcname", "f f2".split())
def test_13(self, bash, functions, funcname):
completion = assert_complete(
bash, "%s \"a'b/" % funcname, cwd="_filedir"
)
- assert completion == "a'b/c"
+ assert completion == 'c"'
@pytest.mark.parametrize("funcname", "f f2".split())
def test_14(self, bash, functions, funcname):
completion = assert_complete(
bash, '%s "a&b/' % funcname, cwd="_filedir"
)
- assert completion == "a&b/f"
+ assert completion == 'f"'
@pytest.mark.complete(r"fd a\ ", cwd="_filedir")
def test_15(self, functions, completion):
- assert completion == "a b/"
+ assert completion == "b/"
@pytest.mark.complete("g ", cwd="_filedir/ext")
def test_16(self, functions, completion):
assert completion == sorted("ee.e1 foo/ gg.e1 ii.E1".split())
+
+ @pytest.mark.parametrize("funcname", "f f2".split())
+ def test_17(self, bash, functions, funcname):
+ completion = assert_complete(
+ bash, r"%s a\$b/" % funcname, cwd="_filedir"
+ )
+ assert completion == "h"
+
+ @pytest.mark.parametrize("funcname", "f f2".split())
+ def test_18(self, bash, functions, funcname):
+ completion = assert_complete(
+ bash, r"%s \[x" % funcname, cwd="_filedir/brackets"
+ )
+ assert completion == r"\]"
+
+ @pytest.mark.parametrize("funcname", "f f2".split())
+ def test_19(self, bash, functions, funcname, non_windows_testdir):
+ completion = assert_complete(
+ bash, '%s a\\"b/' % funcname, cwd=non_windows_testdir
+ )
+ assert completion == "d"
+
+ @pytest.mark.parametrize("funcname", "f f2".split())
+ def test_20(self, bash, functions, funcname, non_windows_testdir):
+ completion = assert_complete(
+ bash, r"%s a\\b/" % funcname, cwd=non_windows_testdir
+ )
+ assert completion == "g"
+
+ @pytest.mark.parametrize("funcname", "f f2".split())
+ def test_21(self, bash, functions, funcname, non_windows_testdir):
+ completion = assert_complete(
+ bash, "%s 'a\"b/" % funcname, cwd=non_windows_testdir
+ )
+ assert completion == "d'"
+
+ @pytest.mark.parametrize("funcname", "f f2".split())
+ def test_22(self, bash, functions, funcname, non_windows_testdir):
+ completion = assert_complete(
+ bash, r"%s '%s/a\b/" % (funcname, non_windows_testdir)
+ )
+ assert completion == "g'"
+
+ @pytest.mark.parametrize("funcname", "f f2".split())
+ def test_23(self, bash, functions, funcname, non_windows_testdir):
+ completion = assert_complete(
+ bash, r'%s "a\"b/' % funcname, cwd=non_windows_testdir
+ )
+ assert completion == 'd"'
+
+ @pytest.mark.parametrize("funcname", "f f2".split())
+ def test_24(self, bash, functions, funcname, non_windows_testdir):
+ completion = assert_complete(
+ bash, r'%s "a\\b/' % funcname, cwd=non_windows_testdir
+ )
+ assert completion == 'g"'
+
+ @pytest.mark.parametrize("funcname", "f f2".split())
+ def test_25(self, bash, functions, funcname):
+ completion = assert_complete(
+ bash, r'%s "a\b/' % funcname, cwd="_filedir"
+ )
+ assert completion == '\b\b\bb/e"'
+
+ @pytest.mark.parametrize("funcname", "f f2".split())
+ def test_26(self, bash, functions, funcname):
+ completion = assert_complete(
+ bash, r'%s "a\$b/' % funcname, cwd="_filedir"
+ )
+ assert completion == 'h"'
+
+ @pytest.mark.xfail(reason="TODO: non-ASCII issues with test suite?")
+ @pytest.mark.parametrize("funcname", "f f2".split())
+ def test_27(self, bash, functions, funcname, utf8_ctype):
+ completion = assert_complete(bash, "%s aé/" % funcname, cwd="_filedir")
+ assert completion == "g"
diff --git a/test/t/unit/test_unit_get_comp_words_by_ref.py b/test/t/unit/test_unit_get_comp_words_by_ref.py
index 1603bad6..b6498fa7 100644
--- a/test/t/unit/test_unit_get_comp_words_by_ref.py
+++ b/test/t/unit/test_unit_get_comp_words_by_ref.py
@@ -1,16 +1,17 @@
import pytest
-from conftest import assert_bash_exec, TestUnitBase
+from conftest import TestUnitBase, assert_bash_exec
@pytest.mark.bashcomp(
- cmd=None, ignore_env=r"^(\+(cur|prev)|[+-]COMP_(WORDS|CWORD|LINE|POINT))="
+ cmd=None,
+ ignore_env=r"^(\+(words|cword|cur|prev)|[+-]COMP_(WORDS|CWORD|LINE|POINT))=",
)
class TestUnitGetCompWordsByRef(TestUnitBase):
def _test(self, bash, *args, **kwargs):
assert_bash_exec(bash, "unset cur prev")
output = self._test_unit(
- "_get_comp_words_by_ref %s cur prev; echo $cur,$prev",
+ "_get_comp_words_by_ref %s cur prev; echo $cur,${prev-}",
bash,
*args,
**kwargs
@@ -18,7 +19,11 @@ class TestUnitGetCompWordsByRef(TestUnitBase):
return output.strip()
def test_1(self, bash):
- assert_bash_exec(bash, "_get_comp_words_by_ref cur >/dev/null")
+ assert_bash_exec(
+ bash,
+ "COMP_WORDS=() COMP_CWORD= COMP_POINT= COMP_LINE= "
+ "_get_comp_words_by_ref cur >/dev/null",
+ )
def test_2(self, bash):
"""a b|"""
@@ -165,3 +170,91 @@ class TestUnitGetCompWordsByRef(TestUnitBase):
"""a 'b&c|"""
output = self._test(bash, '(a "\'b&c")', 1, "a 'b&c", 6)
assert output == "'b&c,a"
+
+ def test_30(self, bash):
+ """a b| to all vars"""
+ assert_bash_exec(bash, "unset words cword cur prev")
+ output = self._test_unit(
+ "_get_comp_words_by_ref words cword cur prev%s; "
+ 'echo "${words[@]}",$cword,$cur,$prev',
+ bash,
+ "(a b)",
+ 1,
+ "a b",
+ 3,
+ )
+ assert output == "a b,1,b,a"
+
+ def test_31(self, bash):
+ """a b| to alternate vars"""
+ assert_bash_exec(bash, "unset words2 cword2 cur2 prev2")
+ output = self._test_unit(
+ "_get_comp_words_by_ref -w words2 -i cword2 -c cur2 -p prev2%s; "
+ 'echo $cur2,$prev2,"${words2[@]}",$cword2',
+ bash,
+ "(a b)",
+ 1,
+ "a b",
+ 3,
+ )
+ assert output == "b,a,a b,1"
+ assert_bash_exec(bash, "unset words2 cword2 cur2 prev2")
+
+ def test_32(self, bash):
+ """a b : c| with wordbreaks -= :"""
+ assert_bash_exec(bash, "unset words")
+ output = self._test_unit(
+ '_get_comp_words_by_ref -n : words%s; echo "${words[@]}"',
+ bash,
+ "(a b : c)",
+ 3,
+ "a b : c",
+ 7,
+ )
+ assert output == "a b : c"
+
+ def test_33(self, bash):
+ """a b: c| with wordbreaks -= :"""
+ assert_bash_exec(bash, "unset words")
+ output = self._test_unit(
+ '_get_comp_words_by_ref -n : words%s; echo "${words[@]}"',
+ bash,
+ "(a b : c)",
+ 3,
+ "a b: c",
+ 6,
+ )
+ assert output == "a b: c"
+
+ def test_34(self, bash):
+ """a b :c| with wordbreaks -= :"""
+ assert_bash_exec(bash, "unset words")
+ output = self._test_unit(
+ '_get_comp_words_by_ref -n : words%s; echo "${words[@]}"',
+ bash,
+ "(a b : c)",
+ 3,
+ "a b :c",
+ 6,
+ )
+ assert output == "a b :c"
+
+ def test_35(self, bash):
+ r"""a b\ :c| with wordbreaks -= :"""
+ assert_bash_exec(bash, "unset words")
+ output = self._test_unit(
+ '_get_comp_words_by_ref -n : words%s; echo "${words[@]}"',
+ bash,
+ "(a 'b ' : c)",
+ 3,
+ r"a b\ :c",
+ 7,
+ )
+ assert output == "a b :c"
+
+ def test_unknown_arg_error(self, bash):
+ with pytest.raises(AssertionError) as ex:
+ _ = assert_bash_exec(
+ bash, "_get_comp_words_by_ref dummy", want_output=True
+ )
+ ex.match("dummy.* unknown argument")
diff --git a/test/t/unit/test_unit_get_cword.py b/test/t/unit/test_unit_get_cword.py
index 3042dd29..0b56d163 100644
--- a/test/t/unit/test_unit_get_cword.py
+++ b/test/t/unit/test_unit_get_cword.py
@@ -1,17 +1,22 @@
+import pexpect
import pytest
-from conftest import assert_bash_exec, TestUnitBase
+from conftest import PS1, TestUnitBase, assert_bash_exec
@pytest.mark.bashcomp(
- cmd=None, ignore_env=r"^[+-]COMP_(WORDS|CWORD|LINE|POINT)="
+ cmd=None, ignore_env=r"^[+-](COMP_(WORDS|CWORD|LINE|POINT)|_scp_path_esc)="
)
class TestUnitGetCword(TestUnitBase):
def _test(self, *args, **kwargs):
return self._test_unit("_get_cword %s; echo", *args, **kwargs)
def test_1(self, bash):
- assert_bash_exec(bash, "_get_cword >/dev/null")
+ assert_bash_exec(
+ bash,
+ "COMP_WORDS=() COMP_CWORD= COMP_LINE= COMP_POINT= "
+ "_get_cword >/dev/null",
+ )
def test_2(self, bash):
"""a b| should return b"""
@@ -133,3 +138,17 @@ class TestUnitGetCword(TestUnitBase):
"""a 'b&c| should return 'b&c"""
output = self._test(bash, '(a "\'b&c")', 1, "a 'b&c", 6)
assert output == "'b&c"
+
+ @pytest.mark.xfail(reason="TODO: non-ASCII issues with test suite?")
+ def test_24(self, bash):
+ """Index shouldn't drop below 0"""
+ bash.send("scp ääää§ se\t\r\n")
+ got = bash.expect_exact(
+ [
+ "index: substring expression < 0",
+ PS1,
+ pexpect.EOF,
+ pexpect.TIMEOUT,
+ ]
+ )
+ assert got == 1
diff --git a/test/t/unit/test_unit_init_completion.py b/test/t/unit/test_unit_init_completion.py
index 64f3b511..64a5a790 100644
--- a/test/t/unit/test_unit_init_completion.py
+++ b/test/t/unit/test_unit_init_completion.py
@@ -1,6 +1,6 @@
import pytest
-from conftest import assert_bash_exec, TestUnitBase
+from conftest import TestUnitBase, assert_bash_exec, assert_complete
@pytest.mark.bashcomp(
@@ -13,12 +13,22 @@ class TestUnitInitCompletion(TestUnitBase):
"""Test environment non-pollution, detected at teardown."""
assert_bash_exec(
bash,
- "foo() { local cur prev words cword; _init_completion; }; "
+ "foo() { "
+ "local cur prev words cword "
+ "COMP_WORDS=() COMP_CWORD=0 COMP_LINE= COMP_POINT=0; "
+ "_init_completion; }; "
"foo; unset foo",
)
def test_2(self, bash):
output = self._test_unit(
- "_init_completion %s; echo $cur,$prev", bash, "(a)", 0, "a", 0
+ "_init_completion %s; echo $cur,${prev-}", bash, "(a)", 0, "a", 0
)
assert output == ","
+
+ @pytest.mark.parametrize("redirect", "> >> 2> < &>".split())
+ def test_redirect(self, bash, redirect):
+ completion = assert_complete(
+ bash, "%s " % redirect, cwd="shared/default"
+ )
+ assert all(x in completion for x in "foo bar".split())
diff --git a/test/t/unit/test_unit_known_hosts_real.py b/test/t/unit/test_unit_known_hosts_real.py
new file mode 100644
index 00000000..ac5205e1
--- /dev/null
+++ b/test/t/unit/test_unit_known_hosts_real.py
@@ -0,0 +1,158 @@
+from itertools import chain
+
+import pytest
+
+from conftest import assert_bash_exec
+
+
+@pytest.mark.bashcomp(
+ cmd=None,
+ ignore_env="^[+-](COMP(REPLY|_KNOWN_HOSTS_WITH_HOSTFILE)|OLDHOME)=",
+)
+class TestUnitKnownHostsReal:
+ @pytest.mark.parametrize(
+ "prefix,colon_flag,hostfile",
+ [("", "", True), ("", "", False), ("user@", "c", True)],
+ )
+ def test_basic(
+ self, bash, hosts, avahi_hosts, prefix, colon_flag, hostfile
+ ):
+ expected = (
+ "%s%s%s" % (prefix, x, ":" if colon_flag else "")
+ for x in chain(
+ hosts if hostfile else avahi_hosts,
+ # fixtures/_known_hosts_real/config
+ "gee hus jar #not-a-comment".split(),
+ # fixtures/_known_hosts_real/known_hosts
+ (
+ "doo",
+ "ike",
+ "jub",
+ "10.0.0.1",
+ "kyl",
+ "100.0.0.2",
+ "10.10.0.3",
+ "blah",
+ "fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555",
+ "fe80::123:0xff:dead:beef%eth0",
+ "1111:2222:3333:4444:5555:6666:xxxx:abab",
+ "11xx:2222:3333:4444:5555:6666:xxxx:abab",
+ "::42",
+ ),
+ )
+ )
+ assert_bash_exec(
+ bash,
+ "unset -v COMP_KNOWN_HOSTS_WITH_HOSTFILE"
+ if hostfile
+ else "COMP_KNOWN_HOSTS_WITH_HOSTFILE=",
+ )
+ output = assert_bash_exec(
+ bash,
+ "_known_hosts_real -a%sF _known_hosts_real/config '%s'; "
+ r'printf "%%s\n" "${COMPREPLY[@]}"; unset COMPREPLY'
+ % (colon_flag, prefix),
+ want_output=True,
+ )
+ assert sorted(set(output.split())) == sorted(expected)
+
+ @pytest.mark.parametrize(
+ "family,result",
+ (
+ ("4", "127.0.0.1 localhost"),
+ ("6", "::1 localhost"),
+ ("46", "localhost"),
+ ),
+ )
+ def test_ip_filtering(self, bash, family, result):
+ assert_bash_exec(
+ bash, "unset -v COMPREPLY COMP_KNOWN_HOSTS_WITH_HOSTFILE"
+ )
+ output = assert_bash_exec(
+ bash,
+ "COMP_KNOWN_HOSTS_WITH_HOSTFILE= "
+ "_known_hosts_real -%sF _known_hosts_real/localhost_config ''; "
+ r'printf "%%s\n" "${COMPREPLY[@]}"' % family,
+ want_output=True,
+ )
+ assert sorted(set(output.strip().split())) == sorted(result.split())
+
+ def test_consecutive_spaces(self, bash, hosts):
+ expected = hosts.copy()
+ # fixtures/_known_hosts_real/spaced conf
+ expected.extend("gee hus #not-a-comment".split())
+ # fixtures/_known_hosts_real/known_hosts2
+ expected.extend("two two2 two3 two4".split())
+ # fixtures/_known_hosts_/spaced known_hosts
+ expected.extend("doo ike".split())
+
+ output = assert_bash_exec(
+ bash,
+ "unset -v COMPREPLY COMP_KNOWN_HOSTS_WITH_HOSTFILE; "
+ "_known_hosts_real -aF '_known_hosts_real/spaced conf' ''; "
+ r'printf "%s\n" "${COMPREPLY[@]}"',
+ want_output=True,
+ )
+ assert sorted(set(output.strip().split())) == sorted(expected)
+
+ def test_files_starting_with_tilde(self, bash, hosts):
+ expected = hosts.copy()
+ # fixtures/_known_hosts_real/known_hosts2
+ expected.extend("two two2 two3 two4".split())
+ # fixtures/_known_hosts_real/known_hosts3
+ expected.append("three")
+ # fixtures/_known_hosts_real/known_hosts4
+ expected.append("four")
+
+ assert_bash_exec(bash, 'OLDHOME="$HOME"; HOME="%s"' % bash.cwd)
+ output = assert_bash_exec(
+ bash,
+ "unset -v COMPREPLY COMP_KNOWN_HOSTS_WITH_HOSTFILE; "
+ "_known_hosts_real -aF _known_hosts_real/config_tilde ''; "
+ r'printf "%s\n" "${COMPREPLY[@]}"',
+ want_output=True,
+ )
+ assert_bash_exec(bash, 'HOME="$OLDHOME"')
+ assert sorted(set(output.strip().split())) == sorted(expected)
+
+ def test_included_configs(self, bash, hosts):
+ expected = hosts.copy()
+ # fixtures/_known_hosts_real/config_include_recursion
+ expected.append("recursion")
+ # fixtures/_known_hosts_real/.ssh/config_relative_path
+ expected.append("relative_path")
+ # fixtures/_known_hosts_real/.ssh/config_asterisk_*
+ expected.extend("asterisk_1 asterisk_2".split())
+ # fixtures/_known_hosts_real/.ssh/config_question_mark
+ expected.append("question_mark")
+
+ assert_bash_exec(
+ bash, 'OLDHOME="$HOME"; HOME="%s/_known_hosts_real"' % bash.cwd
+ )
+ output = assert_bash_exec(
+ bash,
+ "unset -v COMPREPLY COMP_KNOWN_HOSTS_WITH_HOSTFILE; "
+ "_known_hosts_real -aF _known_hosts_real/config_include ''; "
+ r'printf "%s\n" "${COMPREPLY[@]}"',
+ want_output=True,
+ )
+ assert_bash_exec(bash, 'HOME="$OLDHOME"')
+ assert sorted(set(output.strip().split())) == sorted(expected)
+
+ def test_no_globbing(self, bash):
+ assert_bash_exec(
+ bash, 'OLDHOME="$HOME"; HOME="%s/_known_hosts_real"' % bash.cwd
+ )
+ output = assert_bash_exec(
+ bash,
+ "cd _known_hosts_real; "
+ "unset -v COMPREPLY COMP_KNOWN_HOSTS_WITH_HOSTFILE; "
+ "_known_hosts_real -aF config ''; "
+ r'printf "%s\n" "${COMPREPLY[@]}"; '
+ "cd - &>/dev/null",
+ want_output=True,
+ )
+ assert_bash_exec(bash, 'HOME="$OLDHOME"')
+ completion = sorted(set(output.strip().split()))
+ assert "gee" in completion
+ assert "gee-filename-canary" not in completion
diff --git a/test/t/unit/test_unit_longopt.py b/test/t/unit/test_unit_longopt.py
index ac0ac836..c5488e34 100644
--- a/test/t/unit/test_unit_longopt.py
+++ b/test/t/unit/test_unit_longopt.py
@@ -11,6 +11,8 @@ class TestUnitLongopt:
def functions(self, request, bash):
assert_bash_exec(bash, "_grephelp() { cat _longopt/grep--help.txt; }")
assert_bash_exec(bash, "complete -F _longopt _grephelp")
+ assert_bash_exec(bash, "_various() { cat _longopt/various.txt; }")
+ assert_bash_exec(bash, "complete -F _longopt _various")
@pytest.mark.complete("_grephelp --")
def test_1(self, functions, completion):
@@ -32,3 +34,19 @@ class TestUnitLongopt:
assert completion
assert any(x.endswith("=") for x in completion)
assert any(not x.endswith("=") for x in completion)
+
+ @pytest.mark.complete("_various --")
+ def test_no_dashdashdash(self, functions, completion):
+ assert all(not x.startswith("---") for x in completion)
+
+ @pytest.mark.complete("_various --")
+ def test_no_trailingdash(self, functions, completion):
+ assert all(not x.endswith("-") for x in completion)
+
+ @pytest.mark.complete("_various --")
+ def test_underscore(self, functions, completion):
+ assert "--foo_bar" in completion
+
+ @pytest.mark.complete("_various --")
+ def test_equals(self, functions, completion):
+ assert "--foo=" in completion
diff --git a/test/t/unit/test_unit_quote.py b/test/t/unit/test_unit_quote.py
index e9f81c2d..b280bd68 100644
--- a/test/t/unit/test_unit_quote.py
+++ b/test/t/unit/test_unit_quote.py
@@ -1,6 +1,6 @@
import pytest
-from conftest import assert_bash_exec, TestUnitBase
+from conftest import TestUnitBase, assert_bash_exec
@pytest.mark.bashcomp(cmd=None)
diff --git a/test/t/unit/test_unit_quote_readline.py b/test/t/unit/test_unit_quote_readline.py
new file mode 100644
index 00000000..e2b437e3
--- /dev/null
+++ b/test/t/unit/test_unit_quote_readline.py
@@ -0,0 +1,15 @@
+import pytest
+
+from conftest import assert_bash_exec
+
+
+@pytest.mark.bashcomp(cmd=None)
+class TestUnitQuoteReadline:
+ def test_exec(self, bash):
+ assert_bash_exec(bash, "quote_readline '' >/dev/null")
+
+ def test_env_non_pollution(self, bash):
+ """Test environment non-pollution, detected at teardown."""
+ assert_bash_exec(
+ bash, "foo() { quote_readline meh >/dev/null; }; foo; unset foo"
+ )
diff --git a/test/t/unit/test_unit_variables.py b/test/t/unit/test_unit_variables.py
index dd7a4219..d62bc4a4 100644
--- a/test/t/unit/test_unit_variables.py
+++ b/test/t/unit/test_unit_variables.py
@@ -18,11 +18,11 @@ class TestUnitVariables:
@pytest.mark.complete(": $___v")
def test_simple_variable_name(self, functions, completion):
- assert completion == "$___var".split()
+ assert completion == "ar"
@pytest.mark.complete(": ${assoc1[")
def test_single_array_index(self, functions, completion):
- assert completion == "${assoc1[idx]}".split()
+ assert completion == "idx]}"
@pytest.mark.complete(": ${assoc2[")
def test_multiple_array_indexes(self, functions, completion):
@@ -30,12 +30,12 @@ class TestUnitVariables:
@pytest.mark.complete(": ${assoc1[bogus]")
def test_closing_curly_after_square(self, functions, completion):
- assert completion == "${assoc1[bogus]}".split()
+ assert completion == "}"
@pytest.mark.complete(": ${assoc1[@")
def test_closing_brackets_after_at(self, functions, completion):
- assert completion == "${assoc1[@]}".split()
+ assert completion == "]}"
@pytest.mark.complete(": ${#___v")
def test_hash_prefix(self, functions, completion):
- assert completion == "${#___var}".split()
+ assert completion == "ar}"
diff --git a/test/t/unit/test_unit_xinetd_services.py b/test/t/unit/test_unit_xinetd_services.py
new file mode 100644
index 00000000..7a90cb7f
--- /dev/null
+++ b/test/t/unit/test_unit_xinetd_services.py
@@ -0,0 +1,22 @@
+import pytest
+
+from conftest import assert_bash_exec
+
+
+@pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+COMPREPLY=")
+class TestUnitXinetdServices:
+ def test_direct(self, bash):
+ assert_bash_exec(bash, "_xinetd_services >/dev/null")
+
+ def test_env_non_pollution(self, bash):
+ """Test environment non-pollution, detected at teardown."""
+ assert_bash_exec(bash, "foo() { _xinetd_services; }; foo; unset foo")
+
+ def test_basic(self, bash):
+ output = assert_bash_exec(
+ bash,
+ "foo() { local BASHCOMP_XINETDDIR=$PWD/shared/bin;unset COMPREPLY; "
+ '_xinetd_services; printf "%s\\n" "${COMPREPLY[@]}"; }; foo; unset foo',
+ want_output=True,
+ )
+ assert sorted(output.split()) == ["arp", "ifconfig"]
diff --git a/test/test-cmd-list.txt b/test/test-cmd-list.txt
new file mode 100644
index 00000000..eb8398e0
--- /dev/null
+++ b/test/test-cmd-list.txt
@@ -0,0 +1,687 @@
+2to3
+7z
+a2ps
+a2x
+abook
+aclocal
+acpi
+acroread
+adb
+add_members
+alias
+alpine
+animate
+ant
+apache2ctl
+appdata-validate
+apt-build
+apt-cache
+apt-get
+aptitude
+arch
+arp
+arping
+arpspoof
+asciidoc
+aspell
+autoconf
+autoheader
+automake
+autoreconf
+autorpm
+autoscan
+autossh
+autoupdate
+avctrl
+awk
+badblocks
+base64
+bash
+bc
+/bin/chroot
+bind
+/bin/rmdir
+bison
+bk
+bmake
+brctl
+bsdtar
+btdownloadcurses.py
+btdownloadgui.py
+btdownloadheadless.py
+bts
+bzip2
+c++
+cal
+cancel
+cardctl
+carton
+cat
+cc
+ccache
+ccze
+cd
+cdrecord
+cfagent
+cfrun
+chage
+change_pw
+check_db
+check_perms
+checksec
+chfn
+chgrp
+chkconfig
+chmod
+chown
+chpasswd
+chromium-browser
+chronyc
+chroot
+chrpath
+chsh
+ci
+ciptool
+civclient
+civserver
+cksfv
+cleanarch
+clisp
+clone_member
+co
+colordiff
+compare
+compgen
+complete
+composite
+config_list
+configure
+conjure
+convert
+cowsay
+cp
+cpan2dist
+cpio
+cppcheck
+createdb
+createuser
+crontab
+cryptsetup
+csplit
+curl
+cut
+cvs
+cvsps
+date
+dcop
+dd
+declare
+deja-dup
+desktop-file-validate
+df
+dfutool
+dhclient
+dict
+diff
+dir
+display
+dmesg
+dmypy
+dnssec-keygen
+dnsspoof
+dot
+dpkg
+dpkg-deb
+dpkg-query
+dpkg-reconfigure
+dpkg-source
+dropdb
+dropuser
+dselect
+dsniff
+du
+dumpdb
+dumpe2fs
+e2freefrag
+e2label
+ebtables
+ecryptfs-migrate-home
+eject
+enscript
+env
+eog
+etherwake
+ether-wake
+evince
+expand
+explodepkg
+export
+faillog
+fbgs
+fbi
+feh
+file
+filefrag
+file-roller
+filesnarf
+find
+find_member
+finger
+fio
+firefox
+flake8
+fmt
+fold
+freebsd-update
+freeciv
+freeciv-server
+function
+fusermount
+g++
+g4
+g77
+gcc
+gcj
+gcl
+gdb
+genaliases
+gendiff
+genisoimage
+geoiplookup
+getconf
+getent
+gkrellm
+gm
+gmplayer
+gnatmake
+gnokii
+gnome-mplayer
+gnome-screenshot
+gpasswd
+gpc
+gperf
+gpg
+gpg2
+gpgv
+gphoto2
+gprof
+grep
+groupadd
+groupdel
+groupmems
+groupmod
+growisofs
+grpck
+grub
+gssdp-discover
+gzip
+hciattach
+hciconfig
+hcitool
+hddtemp
+head
+hexdump
+hid2hci
+host
+hostname
+hping2
+hping3
+htop
+htpasswd
+hunspell
+hwclock
+iconv
+id
+identify
+idn
+ifdown
+ifstat
+iftop
+ifup
+import
+influx
+info
+inject
+inotifywait
+inotifywatch
+insmod
+installpkg
+interdiff
+invoke-rc.d
+ionice
+ip
+ipcalc
+iperf
+iperf3
+ipmitool
+ipsec
+iptables
+ipv6calc
+irb
+iscsiadm
+isort
+isql
+iwconfig
+iwlist
+iwpriv
+iwspy
+jar
+jarsigner
+java
+javac
+javadoc
+javaws
+jpegoptim
+jps
+jq
+jshint
+jsonschema
+json_xs
+k3b
+kcov
+kdvi
+kill
+killall
+kldload
+kldunload
+koji
+kpdf
+kplayer
+ktutil
+l2ping
+larch
+lastlog
+ld
+ldapadd
+ldapcompare
+ldapdelete
+ldapmodrdn
+ldappasswd
+ldapsearch
+ldapvi
+ldapwhoami
+ldd
+less
+lftp
+lftpget
+lilo
+links
+lintian
+lintian-info
+lisp
+list_admins
+list_lists
+list_members
+list_owners
+ln
+locale-gen
+look
+lpq
+lpr
+lrzip
+ls
+lsof
+lspci
+lsscsi
+lsusb
+lua
+luac
+luseradd
+luserdel
+lusermod
+lvchange
+lvcreate
+lvdisplay
+lvextend
+lvm
+lvmdiskscan
+lvreduce
+lvremove
+lvrename
+lvresize
+lvs
+lvscan
+lz4
+lzip
+lzma
+lzop
+m4
+macof
+mailmanctl
+mailsnarf
+make
+makepkg
+man
+mc
+mcrypt
+md5sum
+mdadm
+mdecrypt
+mdtool
+medusa
+mencoder
+mii-diag
+mii-tool
+minicom
+mkdir
+mkfifo
+mkinitrd
+mkisofs
+mknod
+mktemp
+mmsitepass
+mock
+modinfo
+modprobe
+module
+mogrify
+monodevelop
+montage
+mount
+mplayer
+mr
+msgsnarf
+msynctool
+mtx
+munindoc
+munin-node-configure
+munin-run
+mussh
+mutt
+muttng
+mv
+mypy
+mysql
+mysqladmin
+nc
+ncftp
+nethogs
+netstat
+newgrp
+newlist
+newusers
+ngrep
+nl
+nm
+nmap
+nmcli
+nproc
+nslookup
+nsupdate
+ntpdate
+objcopy
+objdump
+od
+oggdec
+op
+openssl
+opera
+optipng
+p4
+pack200
+passwd
+paste
+patch
+pdftotext
+perl
+perlcritic
+perldoc
+perltidy
+pgrep
+phing
+pidof
+pine
+pinfo
+ping
+pkgadd
+pkg-config
+pkg_deinstall
+pkg_delete
+pkg-get
+pkg_info
+pkgrm
+pkgtool
+pkgutil
+pkill
+plague-client
+pm-hibernate
+pm-is-supported
+pm-powersave
+pngfix
+portinstall
+portsnap
+portupgrade
+postcat
+postconf
+postfix
+postmap
+postsuper
+povray
+pr
+prelink
+printenv
+protoc
+psql
+ptx
+puppet
+pushd
+pv
+pvchange
+pvcreate
+pvdisplay
+pvmove
+pvremove
+pvs
+pvscan
+pwck
+pwd
+pwdx
+pwgen
+pycodestyle
+pydoc
+pydocstyle
+pyflakes
+pylint
+pylint-3
+pytest
+python
+python3
+pyvenv
+qemu
+qrunner
+querybts
+quota
+quotacheck
+quotaon
+radvdump
+rcs
+rcsdiff
+rdesktop
+rdict
+readelf
+readonly
+remove_members
+removepkg
+renice
+repomanage
+reportbug
+reptyr
+resolvconf
+rfcomm
+rfkill
+ri
+rlog
+rm
+rmdir
+rmlist
+rmmod
+route
+rpcdebug
+rpm
+rpm2tgz
+rpmbuild
+rrdtool
+rsync
+rtcwake
+runuser
+sbcl
+sbcl-mt
+sbopkg
+scp
+screen
+scrub
+sdptool
+secret-tool
+sed
+seq
+service
+set
+setquota
+sftp
+sh
+sha1sum
+shar
+shellcheck
+sitecopy
+slackpkg
+slapt-get
+slapt-src
+smartctl
+smbcacls
+smbclient
+smbcquotas
+smbget
+smbpasswd
+smbtar
+smbtree
+snownews
+sort
+split
+spovray
+sqlite3
+ss
+ssh
+ssh-add
+ssh-copy-id
+sshfs
+ssh-keygen
+sshmitm
+sshow
+strace
+stream
+strings
+strip
+su
+sudo
+sum
+svcadm
+svk
+svn
+svnadmin
+svnlook
+synclient
+sync_members
+sysbench
+sysctl
+tac
+tail
+tar
+tcpdump
+tcpkill
+tcpnice
+tee
+texindex
+tightvncviewer
+time
+timeout
+tipc
+totem
+touch
+tox
+tr
+tracepath
+tshark
+tsig-keygen
+tune2fs
+udevadm
+ulimit
+umount
+unace
+uname
+unexpand
+uniq
+units
+unpack200
+unrar
+unset
+unshunt
+update-alternatives
+update-rc.d
+upgradepkg
+urlsnarf
+uscan
+useradd
+userdel
+usermod
+valgrind
+vdir
+vgcfgbackup
+vgcfgrestore
+vgchange
+vgck
+vgconvert
+vgcreate
+vgdisplay
+vgexport
+vgextend
+vgimport
+vgmerge
+vgmknodes
+vgreduce
+vgremove
+vgrename
+vgs
+vgscan
+vgsplit
+vi
+vipw
+vmstat
+vncviewer
+vpnc
+watch
+wc
+webmitm
+wget
+who
+wine
+withlist
+wodim
+wol
+write
+wsimport
+wtf
+wvdial
+xdg-mime
+xdg-settings
+xfreerdp
+xgamma
+xm
+xmllint
+xmlwf
+xmms
+xmodmap
+xpovray
+xrandr
+xrdb
+xsltproc
+xvfb-run
+xvnc4viewer
+xxd
+xz
+xzdec
+ypcat
+ypmatch
+yum
+yum-arch
+zopfli
+zopflipng
diff --git a/test/unit/__expand_tilde_by_ref.exp b/test/unit/__expand_tilde_by_ref.exp
deleted file mode 100644
index 5569fe37..00000000
--- a/test/unit/__expand_tilde_by_ref.exp
+++ /dev/null
@@ -1,65 +0,0 @@
-# @param string $out Reference to variable to hold value of bash environment
-# variable $HOME.
-proc setup {home user} {
- upvar $home _home
- upvar $user _user
- save_env
- assert_bash_exec {echo "$HOME"} {} /@ _home
- set _home [string trim $_home]
- assert_bash_exec {id -un 2>/dev/null || echo "$USER"} {} /@ _user
- set _user [string trim $_user]
-}
-
-
-proc teardown {} {
- assert_env_unmodified {
- /var=/d
- }
-}
-
-
-setup home user
-
-
-set test "~user should return $home"
-set cmd [format {var="~%s"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user]
-assert_bash_list "$home" $cmd $test
-sync_after_int
-
-set test "~/foo should return $home/foo"
-set cmd {var='~/foo'; __expand_tilde_by_ref var; printf "%s\n" "$var"}
-assert_bash_list "$home/foo" $cmd $test
-sync_after_int
-
-set test "~user/bar should return $home/bar"
-set cmd [format {var="~%s/bar"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user]
-assert_bash_list "$home/bar" $cmd $test
-sync_after_int
-
-set test "~user/\$HOME should return $home/\$HOME"
-set cmd [format {var="~%s/\$HOME"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user]
-assert_bash_list "$home/\$HOME" $cmd $test
-sync_after_int
-
-set test "'~user/a b' should return '$home/a b'"
-set cmd [format {var="~%s/a b"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user]
-assert_bash_list [list [format {%s/a b} $home]] $cmd $test
-sync_after_int
-
-set test "~user/* should return $home/*"
-set cmd [format {var="~%s/*"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user]
-assert_bash_list "$home/\*" $cmd $test
-sync_after_int
-
-set test "'~user;echo hello' should return '~user;echo hello' (not expanded)"
-set cmd [format {var="~%s;echo hello"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user]
-assert_bash_list [format "~%s;echo hello" $user] $cmd $test
-sync_after_int
-
-set test "'~user/a;echo hello' should return '$home/a;echo hello'"
-set cmd [format {var="~%s/a;echo hello"; __expand_tilde_by_ref var; printf "%%s\n" "$var"} $user]
-assert_bash_list "$home/a;echo hello" $cmd $test
-sync_after_int
-
-
-teardown
diff --git a/test/unit/_expand.exp b/test/unit/_expand.exp
deleted file mode 100644
index 59dbed58..00000000
--- a/test/unit/_expand.exp
+++ /dev/null
@@ -1,33 +0,0 @@
-proc setup {home user} {
- upvar $home _home
- upvar $user _user
- save_env
- assert_bash_exec {echo "$HOME"} {} /@ _home
- set _home [string trim $_home]
- assert_bash_exec {id -un 2>/dev/null || echo "$USER"} {} /@ _user
- set _user [string trim $_user]
-}
-
-proc teardown {} {
- assert_env_unmodified {
- /COMPREPLY=/d
- /cur=/d
- }
-}
-
-
-setup home user
-
-
-set test "~$user should set $home to COMPREPLY"
-set cmd [format {cur="~%s" ; _expand ; printf "%%s\n" "$COMPREPLY"} $user]
-assert_bash_list "$home" $cmd $test
-sync_after_int
-
-set test "~$user/a should set $home/a to cur"
-set cmd [format {cur="~%s/a" ; _expand ; printf "%%s\n" "$cur"} $user]
-assert_bash_list "$home/a" $cmd $test
-sync_after_int
-
-
-teardown
diff --git a/test/unit/_filedir.exp b/test/unit/_filedir.exp
deleted file mode 100644
index 1de49504..00000000
--- a/test/unit/_filedir.exp
+++ /dev/null
@@ -1,124 +0,0 @@
-proc setup {} {
- assert_bash_exec {unset COMPREPLY cur}
- assert_bash_exec {unset -f _f}
- save_env
- # Declare bash completion function `_f'
- assert_bash_exec { \
- _f() { local cur=$(_get_cword); unset COMPREPLY; _filedir; }; \
- complete -F _f f \
- }
- # Declare bash completion function `_f2' with `-o filenames' active.
- assert_bash_exec { \
- complete -F _f -o filenames f2 \
- }
- # Create directories `a"b', `a*b', and `a\b' only when not running on
- # Cygwin/Windows (`"', `*', or `\' aren't allowed in filenames there)
- if {! [is_cygwin]} {
- # Create directory `a"b'
- assert_bash_exec {(cd $TESTDIR/tmp && [ ! -d a\"b ] && mkdir a\"b && touch a\"b/d || true)}
- # Create directory `a*b'
- assert_bash_exec {(cd $TESTDIR/tmp && [ ! -d a\*b ] && mkdir a\*b && touch a\*b/j || true)}
- # Create directory `a\b'
- assert_bash_exec {(cd $TESTDIR/tmp && [ ! -d a\\b ] && mkdir a\\b && touch a\\b/g || true)}
- }
-}
-
-
-proc teardown {} {
- if {! [is_cygwin]} {
- assert_bash_exec {(cd $TESTDIR/tmp && rm -- a\"b/d && rmdir a\"b/ || true)}
- assert_bash_exec {(cd $TESTDIR/tmp && rm -- a\\b/g && rmdir a\\b/ || true)}
- assert_bash_exec {(cd $TESTDIR/tmp && rm -- a\*b/j && rmdir a\*b/ || true)}
- }
- assert_bash_exec {unset COMPREPLY cur}
- assert_bash_exec {unset -f _f}
- assert_bash_exec {complete -r f}
- assert_env_unmodified {
- /OLDPWD/d
- /OLD_CTYPE/d
- }
-}
-
-
-setup
-
-
-foreach name {f f2} {
-
- set test "completing $name a\\\$b/ should return h"
- if {[info exists ::env(CI)] && [info exists ::env(DIST)] && $::env(DIST) == "centos6"} {
- xfail $test
- } else {
- set cmd "$name a\\\$b/"
- assert_complete_dir h $cmd "$::srcdir/fixtures/_filedir" $test
- sync_after_int
- }
-
- if {! [is_cygwin]} { # Illegal characters in file/dir names
- set test "completing $name a\\\"b/ should return d"; #"
- set cmd "$name a\\\"b/"; #"
- assert_complete_dir d $cmd "$TESTDIR/tmp" $test
- sync_after_int
-
- set test "completing $name a\\\\b/ should return g"
- set cmd "$name a\\\\b/"
- assert_complete_dir g $cmd "$TESTDIR/tmp" $test
- sync_after_int
- }
-
- if {! [is_cygwin]} { # Illegal characters in file/dir names
- set cmd "$name 'a\"b/"; #"
- assert_complete_dir {d'} $cmd "$TESTDIR/tmp"
- sync_after_int
-
- set cmd "$name '$TESTDIR/tmp/a\\b/"
- assert_complete_dir {g'} $cmd "$TESTDIR/tmp"
- sync_after_int
- }
-
- if {! [is_cygwin]} { # Illegal characters in file/dir names
- set cmd "$name \"a\\\"b/"; #"
- assert_complete_dir {d"} $cmd "$TESTDIR/tmp"; #"
- sync_after_int
- }
-
- if {[info exists ::env(CI)] && [info exists ::env(DIST)] && $::env(DIST) == "centos6"} {
- xfail "$name \"a\\\$b/ should show completions"
- } else {
- set cmd "$name \"a\\\$b/"; #"
- assert_complete_dir {h"} $cmd "$::srcdir/fixtures/_filedir"; #"
- sync_after_int
- }
-
- set cmd "$name \"a\\b/"; #"
- assert_complete_dir "\b\b\bb/e\\\"" $cmd "$::srcdir/fixtures/_filedir"
- sync_after_int
-
- set cmd "$name \"a\\\\b/"; #"
- assert_complete_dir {g"} $cmd "$TESTDIR/tmp"; #"
- sync_after_int
-
- set cmd "$name \\\[x"
- assert_complete_dir {\[x\]} $cmd "$::srcdir/fixtures/_filedir/brackets"
- sync_after_int
-
-}; # foreach
-
-set test "completing f aé should return g"
-# Execute this test only with LC_CTYPE matching *UTF-8*
-# See also: http://www.mail-archive.com/bash-completion-devel\
-# @lists.alioth.debian.org/msg02265.html
-# Don't execute this test on expect-5.44 cause it will segfault
-# See also: Alioth #312792
-if {
- [string first "UTF-8" $::LC_CTYPE] != -1 &&
- [string first 5.44 [exp_version]] != 0
-} {
- assert_complete_dir g "f aé/" "$::srcdir/fixtures/_filedir"
-} else {
- unsupported "$test"
-}
-sync_after_int
-
-
-teardown
diff --git a/test/unit/_get_comp_words_by_ref.exp b/test/unit/_get_comp_words_by_ref.exp
deleted file mode 100644
index a0e1886b..00000000
--- a/test/unit/_get_comp_words_by_ref.exp
+++ /dev/null
@@ -1,91 +0,0 @@
-proc setup {} {
- assert_bash_exec {unset COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS}
- save_env
-}
-
-
-proc teardown {} {
- assert_bash_exec { \
- unset COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS cur prev words cword \
- cur2 prev2 words2 cword2 \
- }
- # Delete 'COMP_WORDBREAKS' occupying two lines
- assert_env_unmodified {
- /COMP_WORDBREAKS=/{N
- d
- }
- }
-}
-
-
-setup
-
-
-# See also ./lib/completions/alias.exp. Here `_get_cword' is actually tested
-# by moving the cursor left into the current word.
-
-set test {unknown argument should raise error}
-set cmd {_get_comp_words_by_ref dummy}
-assert_bash_list {"bash_completion: _get_comp_words_by_ref: `dummy': unknown argument"} $cmd $test
-sync_after_int
-
-set test "a b| to all vars"; # | = cursor position
-set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=3}
-assert_bash_exec $cmd
-set cmd { \
- _get_comp_words_by_ref words cword prev cur; echo "${words[@]} $cword $cur $prev" \
-}
-assert_bash_list {"a b 1 b a"} $cmd $test
-sync_after_int
-
-set test "a b| to alternate vars"; # | = cursor position
-set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=3;}
-assert_bash_exec $cmd
-set cmd {_get_comp_words_by_ref -c cur2 -p prev2 -w words2 -i cword2}
-assert_bash_exec $cmd
-set cmd {echo "$cur2 $prev2 ${words2[@]} $cword2"}
-assert_bash_list {"b a a b 1"} $cmd $test
-sync_after_int
-
-set test "a b| to alternate vars"; # | = cursor position
-set cmd {COMP_WORDS=(a b); COMP_CWORD=1; COMP_LINE='a b'; COMP_POINT=3;}
-assert_bash_exec $cmd
-set cmd {_get_comp_words_by_ref -c cur2 -p prev2 -w words2 -i cword2}
-assert_bash_exec $cmd
-set cmd {echo "$cur2 $prev2 ${words2[@]} $cword2"}
-assert_bash_list {"b a a b 1"} $cmd $test
-sync_after_int
-
-set test {a b : c| with WORDBREAKS -= :}; # | = cursor position
-set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3; COMP_LINE='a b : c'; COMP_POINT=7}
-assert_bash_exec $cmd $test
-set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"}
-assert_bash_list {"a b : c"} $cmd $test
-sync_after_int
-
-set test {a b: c| with WORDBREAKS -= :}; # | = cursor position
-set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3}
-append cmd {; COMP_LINE='a b: c'; COMP_POINT=6}
-assert_bash_exec $cmd $test
-set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"}
-assert_bash_list {"a b: c"} $cmd $test
-sync_after_int
-
-set test {a b :c| with WORDBREAKS -= :}; # | = cursor position
-set cmd {COMP_WORDS=(a b : c); COMP_CWORD=3}
-append cmd {; COMP_LINE='a b :c'; COMP_POINT=6}
-assert_bash_exec $cmd $test
-set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"}
-assert_bash_list {"a b :c"} $cmd $test
-sync_after_int
-
-set test {a b\ :c| with WORDBREAKS -= :}; # | = cursor position
-set cmd {COMP_WORDS=(a "b\\ " : c); COMP_CWORD=3}
-append cmd {; COMP_LINE='a b\ :c'; COMP_POINT=7}
-assert_bash_exec $cmd $test
-set cmd {_get_comp_words_by_ref -n : words; echo "${words[@]}"}
-assert_bash_list {a "b\\ :c"} $cmd $test
-sync_after_int
-
-
-teardown
diff --git a/test/unit/_get_cword.exp b/test/unit/_get_cword.exp
deleted file mode 100644
index 91bcb44e..00000000
--- a/test/unit/_get_cword.exp
+++ /dev/null
@@ -1,37 +0,0 @@
-proc setup {} {
- assert_bash_exec {unset COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS}
- save_env
-}
-
-
-proc teardown {} {
- assert_bash_exec {unset COMP_CWORD COMP_LINE COMP_POINT COMP_WORDS}
- # Delete 'COMP_WORDBREAKS' occupying two lines
- assert_env_unmodified {
- /COMP_WORDBREAKS=/{N
- d
- }
- /_scp_path_esc=/d
- }
-}
-
-
-setup
-
-
-# See also ./lib/completions/alias.exp. Here `_get_cword' is actually tested
-# by moving the cursor left into the current word.
-
-set test "index shouldn't drop below 0"
-set dir $::srcdir/fixtures/_get_cword
-set cmd "scp"
-send "$cmd ääää§ se\t\r\n"
-expect {
- -re "index: substring expression < 0" { fail "$test" }
- -re /@ { pass "$test" }
- default { unresolved "$test" }
-}
-sync_after_int
-
-
-teardown
diff --git a/test/unit/_known_hosts_real.exp b/test/unit/_known_hosts_real.exp
deleted file mode 100644
index 01b09b6b..00000000
--- a/test/unit/_known_hosts_real.exp
+++ /dev/null
@@ -1,171 +0,0 @@
-proc setup {} {
- # NOTE: Changing dir to $SRCDIR is necessary because file locations in the
- # ssh config files (e.g. UserKnownHostsFile) are relative to $SRCDIR.
- assert_bash_exec {cd $SRCDIR}
- save_env
-}
-
-
-proc teardown {} {
- assert_env_unmodified {
- /COMPREPLY=/d
- /OLDHOME=/d
- }
- assert_bash_exec {cd $TESTDIR}
-}
-
-
-setup
-
-
-set test "Hosts should be put in COMPREPLY"
-set hosts [get_hosts -unsorted]
-# Hosts `gee', `hus' and `jar' are defined in
-# ./fixtures/_known_hosts_real/config
-# doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6
-# test cases in ./fixtures/_known_hosts_real/known_hosts
-lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42
-set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY}
-assert_bash_list $hosts $cmd $test -sort
-sync_after_int
-
-set test "Hosts should have username prefix and colon suffix"
-set hosts [get_hosts -unsorted]
-# Hosts `gee', `hus' and `jar' are defined in
-# ./fixtures/_known_hosts_real/config
-# doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6
-# test cases in ./fixtures/_known_hosts_real/known_hosts
-lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42
-set hosts [lsort -ascii $hosts]
-set expected {}
-foreach host $hosts {
- lappend expected "user@$host:"
-}
-# Call _known_hosts
-set cmd {unset COMPREPLY; _known_hosts_real -acF fixtures/_known_hosts_real/config 'user@'; echo_array COMPREPLY}
-assert_bash_list $expected $cmd $test -sort
-sync_after_int
-
-set test "Files containing consecutive spaces should work"
-set hosts [get_hosts -unsorted]
-set hosts_orig $hosts
-# Hosts `gee' and `hus' are defined in
-#`./fixtures/_known_hosts_real/spaced conf'
-# Hosts `two*' are defined in ./fixtures/_known_hosts_real/known_hosts2
-lappend hosts gee hus two two2 two3 two4
-set hosts_config $hosts
-# Hosts `doo' and `ike' are defined in
-# `./fixtures/_known_hosts_/spaced known_hosts'
-lappend hosts doo ike
-set hosts [join [bash_sort $hosts ] "\\s+"]
-set hosts_orig [join [bash_sort $hosts_orig ] "\\s+"]
-set hosts_config [join [bash_sort $hosts_config] "\\s+"]
-# Call _known_hosts
-set cmd {unset COMPREPLY; _known_hosts_real -aF 'fixtures/_known_hosts_real/spaced conf' ''; echo_array COMPREPLY}
-send "$cmd\r"
-expect -ex "$cmd\r\n"
-expect {
- -re "^$hosts\r\n/@$" { pass "$test" }
- -re "^$hosts_orig\r\n/@$" { fail "$test (config file)" }
- -re "^$hosts_config\r\n/@$" { fail "$test (known hosts file)" }
- -re /@ { unresolved "$test at prompt" }
- default { unresolved "$test" }
-}
-sync_after_int
-
-set test "Files starting with tilde (~) should work"
-set hosts [get_hosts -unsorted]
-# Hosts `two*' are defined in ./fixtures/_known_hosts_real/known_hosts2
-# Host `three' is defined in ./fixtures/_known_hosts_real/known_hosts3
-# Host `four' is defined in ./fixtures/_known_hosts_real/known_hosts4
-lappend hosts two two2 two3 two4 three four
-set hosts [join [bash_sort $hosts] "\\s+"]
-# Setup environment
-set cmd {OLDHOME=$HOME; HOME=$SRCDIRABS}
-send "$cmd\r"
-expect -ex "$cmd\r\n/@"
-# Call _known_hosts
-set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config_tilde ''; echo_array COMPREPLY}
-send "$cmd\r"
-expect -ex "$cmd\r\n"
-expect {
- -re "^$hosts\r\n/@$" { pass "$test" }
- default { unresolved "$test" }
-}
-# Teardown environment
-set cmd {HOME=$OLDHOME}
-send "$cmd\r"
-expect -ex "$cmd\r\n/@"
-sync_after_int
-
-set test "Empty COMP_KNOWN_HOSTS_WITH_HOSTFILE should omit HOSTFILE"
-assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE="
-set hosts [get_hosts_avahi]
-# Hosts `gee', `hus' and `jar' are defined in
-# ./fixtures/_known_hosts_real/config
-# doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6
-# test cases in ./fixtures/_known_hosts_real/known_hosts
-lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42
-# Call _known_hosts
-set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY}
-assert_bash_list $hosts $cmd $test -sort
-sync_after_int
-assert_bash_exec "unset -v COMP_KNOWN_HOSTS_WITH_HOSTFILE"
-sync_after_int
-
-set test "Included config files should work"
-set hosts [get_hosts -unsorted]
-# Host 'recursion' is defined in
-# ./fixtures/_known_hosts_real/config_include_recursion
-# Host 'relative_path' is defined in
-# ./fixtures/_known_hosts_real/.ssh/config_relative_path
-lappend hosts recursion relative_path
-set hosts [join [bash_sort $hosts] "\\s+"]
-# Setup environment
-# Redefined HOME to handle relative path inclusions on $HOME/.ssh
-set cmd {OLDHOME=$HOME; HOME="$SRCDIRABS/fixtures/_known_hosts_real"}
-send "$cmd\r"
-expect -ex "$cmd\r\n/@"
-# Call _known_hosts
-set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config_include ''; echo_array COMPREPLY}
-send "$cmd\r"
-expect -ex "$cmd\r\n"
-expect {
- -re "^$hosts\r\n/@$" { pass "$test" }
- default { unresolved "$test" }
-}
-# Teardown environment
-set cmd {HOME=$OLDHOME}
-send "$cmd\r"
-expect -ex "$cmd\r\n/@"
-sync_after_int
-
-set test "IPv6 filtering should work"
-set hosts "127.0.0.1 localhost"
-assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE="
-set cmd {unset COMPREPLY; _known_hosts_real -4F fixtures/_known_hosts_real/localhost_config ''; echo_array COMPREPLY}
-assert_bash_list $hosts $cmd $test -sort
-sync_after_int
-assert_bash_exec "unset -v COMP_KNOWN_HOSTS_WITH_HOSTFILE"
-sync_after_int
-
-set test "IPv4 filtering should work"
-set hosts "::1 localhost"
-assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE="
-set cmd {unset COMPREPLY; _known_hosts_real -6F fixtures/_known_hosts_real/localhost_config ''; echo_array COMPREPLY}
-assert_bash_list $hosts $cmd $test -sort
-sync_after_int
-assert_bash_exec "unset -v COMP_KNOWN_HOSTS_WITH_HOSTFILE"
-sync_after_int
-
-set test "IPv4+IPv6 filtering should work"
-set hosts "localhost"
-assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE="
-set cmd {unset COMPREPLY; _known_hosts_real -46F fixtures/_known_hosts_real/localhost_config ''; echo_array COMPREPLY}
-assert_bash_list $hosts $cmd $test -sort
-sync_after_int
-assert_bash_exec "unset -v COMP_KNOWN_HOSTS_WITH_HOSTFILE"
-sync_after_int
-
-
-teardown
diff --git a/test/update-test-cmd-list b/test/update-test-cmd-list
new file mode 100755
index 00000000..115ae165
--- /dev/null
+++ b/test/update-test-cmd-list
@@ -0,0 +1,13 @@
+#!/bin/bash -eu
+
+mydir=$(
+ cd "$(dirname "$0")"
+ pwd
+)
+
+cat "$mydir"/t/test_*.py |
+ tr -d '\n' |
+ grep -Eo '@pytest.mark.complete(\([^)]*\))' |
+ sed -ne 's/^[^"]*"\\\?\([^_][^[:space:]"]*\)[[:space:]"].*/\1/p' |
+ sort -u \
+ >"$mydir"/test-cmd-list.txt