Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #9522 by adding an optional
[-t type]
option gate to thezfs destroy
command. Checks the type of the supplied argument, then checks if the supplied type is the same or one of the aliases that are also used inzfs list
. If the type doesn't match, it prints an error to stderr and exits. I am aware there have been PRs for this before, but I thought a simpler change might be more likely to be accepted.Motivation and Context
This is a (hopefully) uncomplicated solution to the problem from issue #9522. It just checks the type early and exits if the type isn't a match. This makes something like using
zfs list
withgrep
orawk
much less of a footgun for scripting and reduces the chances of destroying a dataset instead of a snapshot. I had written a small utility that does this for my own purposes, but when I saw that #9522 was labeled as good first issue I decided to submit a PR.Description
This change adds a
[-t type]
option that exits if the supplied volume/filesystem/snapshot argument is not of the specified type.How Has This Been Tested?
Tested by adding a functional test in zfs-test suite and running on linux. Passes all Github workflow actions that were not already failing. As an optional flag, should not affect any other items.
Types of changes
Checklist:
Signed-off-by
.