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.
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).
Only generate the list of snapshots when
a) the argument must be a snapshot and nothing else, or
b) the argument as typed contains a literal @, or
c) a snapshot is a valid completion and there is only one dataset
matching the argument as entered.
Unfortunately, it seems the `zfs` command itself is extremely primitive
and doesn't support listing snapshots by dataset so when we need to
generate completions, we end up needing to enumerate all snapshots
(ever) across all datasets. I'd be very happy to be proven wrong, but I
think the only other way would be manually parse `zdb` output.
See #7472