Commit Graph

6 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 fda59a8d19 bash-completion: do not print eject --cdspeed error messages
Bash completion is proposing --cdspeed option argument from 'eject
--listspeed /dev/cdrom' output.  Nowadays it is common not to have such
device, and this results to an unwanted error message to stderr merely
messing up command line.  Lets stop that.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-04-06 13:03:38 +02:00
Ville Skyttä 396a6d7df5 bash-completion: Invoke actual commands to be completed, not basenames
Addresses partially: http://bugs.debian.org/769462
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
2014-11-18 13:58:21 +01:00
Ville Skyttä 0d5b9b8ab1 bash-completion: Don't offer short options where corresponding long one exists.
Users who know the short options can just hit the short option instead
of tab, and it's not likely that it would be helpful to present a list
of single character options to users who don't know them, doing so
just unnecessarily trashes the list of suggestions.

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
2013-04-08 17:06:56 +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