-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add input checks to functions #160
Conversation
Because missing arguments could led to undefined behaviour or partly created machines, input checks were added for all methods which require input parameters.
Added function __verify_number_of_arguments to verify the number of command parameters supplied by the user. To utilize this function setup) __verify_number_of_arguments “2” "$#" __setup "$@" exit ;; destroy) __verify_number_of_arguments “2” "$#" “2” __destroy "$@" exit ;; This is my implementation of: pr1ntf/iohyve#160
Might it be better to use a function that gets ran in I was thinking something like this:
And then this gets utilized in
Thoughts? |
I agree with @EpiJunkie on this. This seems easier in the long run, and helps "future proof" the idea. |
@moogle19 I can submit this as a PR if you do not wish to. If you do though, I request you leave my name and handle in the commit message. I know that is pretty vain. Either way, thank you for the effort. |
"You're so vain you probably think this PR is about you" |
lawlz, that should probably be an edition name at some point. |
Yeah, that is possible, but it could be difficult for all functions with flags (like delete), because you first have to check for the flag and than for the number of arguments. That could be a bit too much stuff in the Also the count of arguments is tightly connected to the function. For example if a flag is added or removed and the input check happens in the |
Sorry I was unclear, the " For
Where " Each case in |
But wouldn't that allow something like |
Agreed, I realize my suggestion is not a complete solution but it is a step in the right direction, as is your suggestion. With this PR we are suggesting parameter count verification and not input validity. |
Just thought about it and realized that my comment was stupid, because something like |
It is a valid point. |
@moogle19 makes a very good point on the flags. I think in order to future-proof this idea, we should add a I'll get started on that document if you would like to fix the conflicts, @moogle19. |
AYYYYYYYY only two weeks wait time this time. My bad. |
Because missing arguments could led to undefined behaviour, input checks were added for all methods which require input parameters.
I looked at the 'zfs' output when parameters are missing for the error message format.