diff --git a/share/functions/__fish_print_zfs_snapshots.fish b/share/functions/__fish_print_zfs_snapshots.fish index 47f331df8..384877685 100644 --- a/share/functions/__fish_print_zfs_snapshots.fish +++ b/share/functions/__fish_print_zfs_snapshots.fish @@ -5,11 +5,13 @@ function __fish_print_zfs_snapshots -d "Lists ZFS snapshots" # Don't retrieve all snapshots for all datasets until an @ is specified, # or if there is only one possible matching dataset. (See #7472) set current_token (commandline --current-token) - set filtered_results (string match -e -- $current_token $fast_results) + set current_dataset (string replace -rf "([^@]+)@?.*" '$1' -- $current_token) + set filtered_results (string match -ie -- $current_dataset $fast_results) if contains -- --force $argv || - not set -q filtered_results[2] || - string match -eq @ -- $current_token + string match -ieq @ -- $current_token || + not set -q filtered_results[2] - zfs list -t snapshot -o name -H + # Ignore errors because the dataset specified could be non-existent + zfs list -t snapshot -o name -H -d 1 $current_dataset 2>/dev/null end end