HomeFreeBSD

contrib/bash_completion.d: fix error spew from __zfs_match_snapshot()

Description

contrib/bash_completion.d: fix error spew from __zfs_match_snapshot()

Given:

/sbin/zfs list filling/a-zvol<TAB> -o space,refratio

The rest of the cmdline gets vored by:

/sbin/zfs list filling/a-zvolcannot open 'filling/a-zvol':
operation not applicable to datasets of this type

With -x (fragment):

+ COMPREPLY=($(compgen -W "$(__zfs_match_snapshot)" -- "$cur"))
+++ __zfs_match_snapshot
+++ local base_dataset=filling/dziadtop-nowe-duchy
+++ [[ filling/dziadtop-nowe-duchy != filling/dziadtop-nowe-duchy ]]
+++ [[ filling/dziadtop-nowe-duchy != '' ]]
+++ __zfs_list_datasets filling/dziadtop-nowe-duchy
+++ /sbin/zfs list -H -o name -s name -t filesystem
                   -r filling/dziadtop-nowe-duchy
+++ tail -n +2
cannot open 'filling/dziadtop-nowe-duchy':
operation not applicable to datasets of this type
+++ echo filling/dziadtop-nowe-duchy
+++ echo filling/dziadtop-nowe-duchy@
++ compgen -W 'filling/dziadtop-nowe-duchy

This properly completes with:

$ /sbin/zfs list filling/a-zvol<TAB> -o space,refratio
filling/a-zvol   filling/a-zvol@
$ /sbin/zfs list filling/a-zvol<cursor> -o space,refratio

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Backport-of: 5ece420f031bd693fc44e1ce423c7e67fd7b8a09
Closes #12820

Details

Provenance
наб <nabijaczleweli@nabijaczleweli.xyz>Authored on Dec 7 2021, 8:30 PM
Brian Behlendorf <behlendorf1@llnl.gov>Committed on Jun 18 2023, 2:52 AM
Parents
rG6af79c92dd38: tests: zts-report: issue numbers are numbers
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rGf9a2d94c957d: contrib/bash_completion.d: fix error spew from __zfs_match_snapshot() (authored by наб <nabijaczleweli@nabijaczleweli.xyz>).Jun 18 2023, 2:52 AM