util-linux/bash-completion
Kevin Locke 0c8865f843 bash-completion: Add non-canonical device fallback
It is desirable for bash-completion to complete block devices via
symlinks (e.g. under /dev/disk) and with non-canonical locations (e.g.
./sda if $PWD is /dev, and /chroot/dev/sda).

Unfortunately, this is a non-trivial task due to how bash-completion
works.  It is necessary to un-escape the last partial argument, search,
then escape the results, ideally handling tilde and variable
expansion/completion.  See [_get_comp_words_by_ref] and [_filedir] in
the bash-completion project for details.

Given the development costs of a complete and correct implementation,
the annoyance/frustration which would result from an incomplete/buggy
implementation, and the trade-offs between under- and over-completion,
this commit adds fallback to bash default completion if the argument
does not match any canonical device names.  This correctly completes in
the cases mentioned above, although it incorrectly completes on
non-block-device files as well.

[_filedir]: https://github.com/scop/bash-completion/blob/2.9/bash_completion#L552
[_get_comp_words_by_ref]: https://github.com/scop/bash-completion/blob/2.9/bash_completion#L365

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2019-09-19 08:17:09 -06:00
..
Makemodule.am rfkill: add bash-completion file 2017-08-30 20:32:49 +01:00
addpart bash-completion: Add non-canonical device fallback 2019-09-19 08:17:09 -06:00
blkdiscard bash-completion: Add non-canonical device fallback 2019-09-19 08:17:09 -06:00
blkid bash-completion: Add non-canonical device fallback 2019-09-19 08:17:09 -06:00
blkzone bash-completion: Add non-canonical device fallback 2019-09-19 08:17:09 -06:00
blockdev bash-completion: Add non-canonical device fallback 2019-09-19 08:17:09 -06:00
cal bash-completion: add cal --span 2015-11-05 11:34:25 +01:00
cfdisk bash-completion: Add fallback for symlinks/images 2019-09-19 08:16:32 -06:00
chcpu bash-completion: fix few bash set -u issues 2018-04-06 13:03:38 +02:00
chfn bash-completion: Don't offer short options where corresponding long one exists. 2013-04-08 17:06:56 +02:00
chmem lsmem/chmem: add memory zone awareness to bash-completion 2017-10-20 12:37:04 +02:00
choom choom: new command to adjust OOM-killer score value 2018-04-16 12:53:39 +02:00
chrt bash-completion: update chrt completion 2016-04-04 10:26:03 +02:00
chsh bash-completion: Invoke actual commands to be completed, not basenames 2014-11-18 13:58:21 +01:00
col bash-completion: Don't offer short options where corresponding long one exists. 2013-04-08 17:06:56 +02:00
colcrt bash-completion: use '\n' as IFS when ask for filenames 2013-09-30 15:49:00 +02:00
colrm bash-completion: Don't offer short options where corresponding long one exists. 2013-04-08 17:06:56 +02:00
column bash-completion: update column 2018-08-23 14:14:29 +02:00
ctrlaltdel bash-completion: Don't offer any more completions after help or version. 2013-04-08 17:06:52 +02:00
delpart bash-completion: Add non-canonical device fallback 2019-09-19 08:17:09 -06:00
dmesg bash-completion: update options 2019-09-12 19:49:51 +01:00
eject bash-completion: Add non-canonical device fallback 2019-09-19 08:17:09 -06:00
fallocate bash-completion: update sys-utils 2017-04-17 18:26:37 +01:00
fdformat bash-completion: update disk-utils 2017-04-17 18:12:10 +01:00
fdisk bash-completion: Add fallback for symlinks/images 2019-09-19 08:16:32 -06:00
fincore bash-completion: make completions to work when bash set -u is in use 2017-07-15 22:05:42 +01:00
findfs bash-completion: update misc-utils 2017-04-17 18:18:10 +01:00
findmnt bash-completion: add findmnt --real --pseudo 2018-05-11 10:50:19 +02:00
flock bash-completion: update sys-utils 2017-04-17 18:26:37 +01:00
fsck bash-completion: Add fallback for symlinks/images 2019-09-19 08:16:32 -06:00
fsck.cramfs bash-completion: Add fallback for symlinks/images 2019-09-19 08:16:32 -06:00
fsck.minix bash-completion: Add fallback for symlinks/images 2019-09-19 08:16:32 -06:00
fsfreeze bash-completion: Don't offer short options where corresponding long one exists. 2013-04-08 17:06:56 +02:00
fstrim bash-completion: add fstrim --quiet 2019-05-09 13:16:03 +02:00
getopt bash-completion: Don't offer short options where corresponding long one exists. 2013-04-08 17:06:56 +02:00
hardlink bash-completion: add hardlink completion 2019-05-20 19:56:19 +01:00
hexdump bash-completion: update text-utils 2017-04-17 18:40:34 +01:00
hwclock bash-completion: catch up with option changes 2018-10-04 21:36:22 +01:00
ionice bash-completion: update schedutils 2017-04-17 18:20:54 +01:00
ipcmk bash-completion: ipcmk: add missing completion file 2016-03-14 13:15:14 +01:00
ipcrm bash-completion: Don't offer short options where corresponding long one exists. 2013-04-08 17:06:56 +02:00
ipcs bash-completion: Don't offer short options where corresponding long one exists. 2013-04-08 17:06:56 +02:00
isosize bash-completion: fsck.cramfs, isosize: find files an argument 2016-03-14 13:15:13 +01:00
last bash-completion: update login-utils 2017-04-17 18:16:24 +01:00
ldattach bash-completion: update sys-utils 2017-04-17 18:26:37 +01:00
logger bash-completion: update misc-utils 2017-04-17 18:18:10 +01:00
look bash-completion: look for look completions 2017-08-05 09:58:25 +01:00
losetup losetup: add --output-all option 2018-05-03 19:56:20 +01:00
lsblk bash-completion: Add non-canonical device fallback 2019-09-19 08:17:09 -06:00
lscpu bash-completion: update options before release 2019-05-20 19:43:59 +01:00
lsipc bash-completion: make completions to work when bash set -u is in use 2017-07-15 22:05:42 +01:00
lslocks lslocks: add --output-all option 2018-05-03 19:56:20 +01:00
lslogins lslogins: add --output-all option 2018-05-03 19:56:20 +01:00
lsmem lsmem: add --output-all option 2018-05-03 19:56:20 +01:00
lsns lsns: add --output-all option 2018-05-03 19:56:21 +01:00
mcookie bash-completion: update misc-utils 2017-04-17 18:18:10 +01:00
mesg bash-completion: Don't offer short options where corresponding long one exists. 2013-04-08 17:06:56 +02:00
mkfs bash-completion: Add fallback for symlinks/images 2019-09-19 08:16:32 -06:00
mkfs.bfs bash-completion: Add fallback for symlinks/images 2019-09-19 08:16:32 -06:00
mkfs.cramfs bash-completion: Add fallback for symlinks/images 2019-09-19 08:16:32 -06:00
mkfs.minix bash-completion: Add fallback for symlinks/images 2019-09-19 08:16:32 -06:00
mkswap bash-completion: Add fallback for symlinks/images 2019-09-19 08:16:32 -06:00
more bash-completion: use '\n' as IFS when ask for filenames 2013-09-30 15:49:00 +02:00
mount bash-completion: cleanup mount and umount --namespace 2018-10-05 11:48:04 +02:00
mountpoint mountpoint: add --nofollow option 2019-08-02 19:39:05 +01:00
namei bash-completion: use '\n' as IFS when ask for filenames 2013-09-30 15:49:00 +02:00
newgrp bash-completion: Don't offer short options where corresponding long one exists. 2013-04-08 17:06:56 +02:00
nsenter bash-completion: simplify pid listing 2017-08-30 11:21:57 +02:00
partx bash-completion: Add fallback for symlinks/images 2019-09-19 08:16:32 -06:00
pg bash-completion: use '\n' as IFS when ask for filenames 2013-09-30 15:49:00 +02:00
pivot_root bash-completion: use '\n' as IFS when ask for filenames 2013-09-30 15:49:00 +02:00
prlimit bash-completion: simplify pid listing 2017-08-30 11:21:57 +02:00
raw bash-completion: Don't offer short options where corresponding long one exists. 2013-04-08 17:06:56 +02:00
readprofile bash-completion: use '\n' as IFS when ask for filenames 2013-09-30 15:49:00 +02:00
rename bash-completion: catch up with option changes 2018-10-04 21:36:22 +01:00
renice bash-completion: simplify pid listing 2017-08-30 11:21:57 +02:00
resizepart bash-completion: Add non-canonical device fallback 2019-09-19 08:17:09 -06:00
rev bash-completion: use '\n' as IFS when ask for filenames 2013-09-30 15:49:00 +02:00
rfkill rfkill: add --output-all option 2018-05-03 19:56:21 +01:00
rtcwake bash-completion: update sys-utils 2017-04-17 18:26:37 +01:00
script bash-completion: catch up with option changes 2018-10-04 21:36:22 +01:00
scriptreplay bash-completion: update term-utils 2017-04-17 18:34:14 +01:00
setarch bash-completion: update sys-utils 2017-04-17 18:26:37 +01:00
setpriv bash-completion: catch up with option changes 2018-10-04 21:36:22 +01:00
setsid bash-completion: update sys-utils 2017-04-17 18:26:37 +01:00
setterm bash-completion: update term-utils 2017-04-17 18:34:14 +01:00
sfdisk bash-completion: Add fallback for symlinks/images 2019-09-19 08:16:32 -06:00
su bash-completion: catch up with option changes 2018-10-04 21:36:22 +01:00
swaplabel bash-completion: use '\n' as IFS when ask for filenames 2013-09-30 15:49:00 +02:00
swapoff bash-completion: use swapon label and uuid listing support 2014-10-31 10:39:01 +01:00
swapon bash-completion: add swapon specifiers to completion 2018-05-28 13:36:38 +02:00
taskset bash-completion: fix few bash set -u issues 2018-04-06 13:03:38 +02:00
tunelp bash-completion: update uuidgen, wipefs, tunelp, setpriv, and hwclock 2017-09-18 11:04:52 +02:00
ul bash-completion: use '\n' as IFS when ask for filenames 2013-09-30 15:49:00 +02:00
umount bash-completion: umount support relative path and ~ as home shorthands 2019-01-12 19:29:37 +00:00
unshare bash-completion: update options 2019-09-12 19:49:51 +01:00
utmpdump bash-completion: use '\n' as IFS when ask for filenames 2013-09-30 15:49:00 +02:00
uuidd bash-completion: use '\n' as IFS when ask for filenames 2013-09-30 15:49:00 +02:00
uuidgen bash-completion: update uuidgen, wipefs, tunelp, setpriv, and hwclock 2017-09-18 11:04:52 +02:00
uuidparse uuidparse: add bash-completion file 2017-07-15 22:05:00 +01:00
wall wall: check -g GID 2016-12-02 14:11:20 +01:00
wdctl bash-completion: make completions to work when bash set -u is in use 2017-07-15 22:05:42 +01:00
whereis bash-completion: use '\n' as IFS when ask for filenames 2013-09-30 15:49:00 +02:00
wipefs bash-completion: Add fallback for symlinks/images 2019-09-19 08:16:32 -06:00
write bash-completion: update term-utils 2017-04-17 18:34:14 +01:00
zramctl zramctl: add --output-all option 2018-05-03 19:56:21 +01:00