Commit Graph

8 Commits

Author SHA1 Message Date
Kevin Locke 6ead91ce1e bash-completion: Add fallback for symlinks/images
For commands which support operating on files (i.e. disk images), it is
desirable for bash-completion to complete matching file names.  It is
also desirable to complete on block device symlinks (e.g. under
/dev/disk).  To complete common use cases, often on canonical device
names, continue to try completion using canonical device names, then
fall back to matching any file incrementally as Bash does by default.[1]

[1]: https://github.com/karelzak/util-linux/issues/842#issuecomment-523450243

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2019-09-19 08:16:32 -06:00
Kevin Locke 559888c873 bash-completion: Standardize fsck/mkfs file/device
Some of the fsck and mkfs commands complete differently than the others,
and differently than the desired behavior.[1]  Standardize on completing
with $(lsblk -pnro name):

* fsck: Don't complete completes on all block devices and device links
  under /dev immediately (which is excessive and prone to search
  problems).
* mkfs, mkfs.bfs: Don't complete "/path/to/file" literally.  I assume
  this was copy/pasted from example code, since it does not appear to be
  a valid argument unless it is a valid path, which is rare.
* fsck.cramfs, mkfs, mkfs.bfs, mkfs.cramfs, mkswap: Don't complete on
  all filenames initially.  The desired behavior is to complete
  filenames only if there are no canonical matches.[1]

Note: A subsequent commit will add the desired fallback behavior.

[1]: https://github.com/karelzak/util-linux/issues/842#issuecomment-523450243

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2019-09-19 07:27:31 -06:00
Kevin Locke d22c1f5332 bash-completion: Exclude /dev/fd from fsck find
When the bash-completion for fsck runs `find -L /dev/ -type b` it
descends into /dev/fd after opening '.' as file descriptor 3.  This
causes find to search through /dev/fd/3/ which includes everything below
the current directory, which can take a very long time.

To avoid this, prune /dev/fd in the find expression.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2017-10-30 14:12:55 -06:00
Richard Yann 219452a47c Fix: list all block device from /dev and all symbolic links to block devices
Before fix "fsck -y /d<tab>" will never show LVM VG from multipath or mapped devices
2016-10-04 14:48:06 +02:00
Boris Egorov 5e3da11b3e bash-completion: remove unused variables [shellcheck]
Fix shellcheck SC2034 warnings.

Signed-off-by: Boris Egorov <egorov@linux.com>
2015-06-08 12:09:54 +02:00
Sami Kerola 53154dae39 bash-completion: stop being clever when listing block devices
Various commands such as blkid, cfdisk, fdisk, delpart, and so on listed
only partitions and missed for example disks and volume groups.  The
right thing to do is to list all block devices in all for all commands
performing operations with them.  This might occasionally list unexpected
devices that I think is lesser bad than missing some.

Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=764488
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-31 10:39:00 +01:00
Ville Skyttä d4f9b8d74c bash-completion: Don't offer any more completions after help or version.
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
2013-04-08 17:06:52 +02:00
Karel Zak 20da58084a bash-completion: rename shell-completion -> bash-completion
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-05 14:58:07 +02:00