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>
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>
fdformat:
Add --from, --to, and --repair options.
Commit: e0402441a1
fdisk:
Add --output [1], --bytes [2], --wipe [3], --wipe-partition [4], and
remove --geom- from from --cylinders, --heads, --sector options [5].
Commit [1]: fff8ad5882
Commit [2]: 354f8cc8cf
Commit [3]: cb9a4b0033
Commit [4]: ba465623d8
Commit [5]: 4b4e391a28
fsck.cramfs:
Broken since first commit.
Commit: bf60993cf2
mkswap:
Provide random uuid when completing --uuid argument.
partx:
Add --sector-size option. Fix also list of known partition types to
match with libblkid blkid_idinfo names. The fix is also applied to
manual page.
Commit: f8a4a0d4f2
Reference: git grep -A 4 blkid_idinfo libblkid/src/partitions | grep name
sfdisk:
Add --reoder, --delete, --mode-dataa, -no-tell-kernel, --wipe, and
--wipe-partitions options. In same go fix some option argument
completions.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This solution can become messy when you have too many options listed,
because it repeats all of them. For example, after invoking completion
with this input:
$ partx --output END,SECTORS,SCHEME,START,
You got these completions:
END,SECTORS,SCHEME,START,FLAGS, END,SECTORS,SCHEME,START,NR,
END,SECTORS,SCHEME,START,TYPE,
END,SECTORS,SCHEME,START,NAME, END,SECTORS,SCHEME,START,SIZE,
END,SECTORS,SCHEME,START,UUID,
Nevertheless, it works even with numbers (listed options properly
excluded from completion). Try to invoke completion after
'chcpu --disable ' or 'lsblk --exclude ' to see it in action.
Few issues remained:
* completion interrupts after encountering ':' in listed option,
like in 'MAJ:MIN' in lsblk, losetup.
* lscpu completion is broken: it inserts space after '--extended',
but lscpu assumes there is no space after this option. It also
doesn't complete '--parse' option.
* some completion options are outdated (for example, lscpu MMHZ). We
need to sync them with code. Fix for lscpu follows.
Signed-off-by: Boris Egorov <egorov@linux.com>
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>
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>