refactor(mkdir): Simplify mode argument parsing #8406
Merged
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.
This pull request refactors the argument parsing for the
mkdir
utility on the--mode
(-m
) option.What does this PR do?
Previously, the utility relied on a manual function (
strip_minus_from_mode
) to process mode values that begin with a hyphen (e.g.,-rwx
). This required manipulating the raw argument list before it was parsed byclap
.This change removes the manual parsing logic and uses
clap
's built-in.allow_hyphen_values(true)
setting instead. This approach is cleaner, more robust, and relies directly on the features of the argument parsing library.Changes made:
strip_minus_from_mode
function and its related logic.clap
argument for--mode
to use.allow_hyphen_values(true)
.uumain
andget_mode
functions by removing the now-unnecessary variables and parameters.How to test
I have manually tested the changes to ensure that creating directories with and without a mode flag works as expected. The following commands were used for verification:
All commands behaved as expected.