Commit Graph

8 Commits

Author SHA1 Message Date
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
Sami Kerola ba5e7b7e52
bash-completion: update options before release
blkid: 5e91d5dd71 --no-part-details
lsblk: dc4662f0e7 --dedup
lsblk: 0bd05f5ee4 --merge
lscpu: 0e86bc8406 --caches
lscpu: 2011528bce --bytes

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-20 19:43:59 +01:00
Sami Kerola abbcec4fc9
bash-completion: make completions to work when bash set -u is in use
User who want to avoid refering to none-existing variables got earlier the
following error.

$ set -u
$ findmnt --output <tab>bash: OUTPUT: unbound variable

Here is short explanation of this setting.

$ help set
 -u  Treat unset variables as an error when substituting.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-07-15 22:05:42 +01:00
Sami Kerola 15a74f755a
blkid: add long options
This change attempts to make tab completion more reasonable by alloging
memorizable option names.  That also has positive impact to manual page, in
which referrals to other options are now easier to understand.

All short options are kept exactly as they were to avoid ABI breakage.  The
only exception is -f option that getopt(3) recognized, but was not found
from anywhere else.  The -f has been part of blkid since the initial commit.

Commit: 51410fc6de
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-02 23:22:04 +01: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
Karel Zak ce3e6b15e2 bash-completion: use '\n' as IFS when ask for filenames
The bash completion for more(1) treats the space-separated pieces of
filenames as different files.

	$ touch foo\ bar
	$ more foo<TAB>
	bar foo

Reported-by: Ángel González <ingenit@zoho.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-30 15:49:00 +02: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