From 5ece420f031bd693fc44e1ce423c7e67fd7b8a09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Tue, 7 Dec 2021 21:30:10 +0100 Subject: [PATCH] contrib/bash_completion.d: fix error spew from __zfs_match_snapshot() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Given: /sbin/zfs list filling/a-zvol -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 -o space,refratio filling/a-zvol filling/a-zvol@ $ /sbin/zfs list filling/a-zvol -o space,refratio Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia ZiemiaƄska Closes #12820 --- contrib/bash_completion.d/zfs.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/bash_completion.d/zfs.in b/contrib/bash_completion.d/zfs.in index 6b467d80ca..72e1092a03 100644 --- a/contrib/bash_completion.d/zfs.in +++ b/contrib/bash_completion.d/zfs.in @@ -69,7 +69,7 @@ __zfs_match_snapshot() else if [ "$cur" != "" ] && __zfs_list_datasets "$cur" &> /dev/null then - $__ZFS_CMD list -H -o name -s name -t filesystem -r "$cur" | tail -n +2 + $__ZFS_CMD list -H -o name -s name -t filesystem,volume -r "$cur" | tail -n +2 # We output the base dataset name even though we might be # completing a command that can only take a snapshot, because it # prevents bash from considering the completion finished when it