This patch adds completions for the values of properties, emitted once the
current token matches the name of a zfs property in full, for the various places
where such a property can be assigned.
e.g.
zfs set canmoun<TAB> continues to only provide "canmount" as a completion, but
zfs set canmount<TAB> will provide a list of all valid values for the property.
The existing code made an attempt to complete the values for the specific case
of `zfs set PROP=` but I could never get it to work for me under FreeBSD, so I
presume it was Linux-specific. This patch should be cross-platform and extends
the completions to anywhere where a property may be set.
The previous behavior vs the current (hopefully ideal) behavior:
* zpool attach [lists pools and devices - should list only pools]
* zpool attach tank [lists pools and devices - should list only devices already
part of pool "tank"]
* zpool attach tank da1 [lists pools and devices - should list only devices not
already part of pool "tank" or any pool, depending on -f flag to attach]
As of FreeBSD 13 (released April 2021), FreeBSD has rebased its zfs support on
top of the OpenZFS distribution previously used only/chiefly by Linux;
accordingly, it has gained support for some previously Linux-only completions.
This patch changes some completions previously predicated on a Linux ZFS
installation to the presence of an OpenZFS installation. Note that there
continue to be (and probably always will be) separate Linux-only and
FreeBSD-only completions (and not just when it comes to interacting with the
device subsystem, etc).
Cursory experiments reveal that there are only three color options where
the background color is not ignored (though I didn't check all of them).
For these three options, the foreground color is ignored. Similar for
bold/italics/underline.
Teach set completions to only show the colors that won't be ignored.
Unrelated observation: we write
-a '--background=(set_color --print-colors)'
instead of
-l background -a '(set_color --print-colors)'
because we want all colors to show straight away (there are no other
meaningful arguments).
4b018a760 (set completions: add more special variables, fix colors, 2021-12-13)
changed a global variable to a local, which is no longer visible to this
function. Fix this, so "set LANG <TAB>" works again.
Add completions that are correct on darwin and probably bsd.
Add missing -H, -L, -P completions to GNU chown.
Remove errant GNU completion claiming -h is short for --help.
The regex for task names was a bit off, so
- include uppercase letters, to support `TMessagesProj:assembleMiniRelease`
- don't include characters like `[]` (which happen to lie between ASCII `A` and `z`)
- include numbers, which are presumably valid in an identifier
- explicitly include the optional ` - ` bit in the regex