-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
Multiple arguments to custom verbs. #876
Comments
What would be |
MakeMultipleDirs would be a custom verb. Something like
here I've used square brakets to indicate a list of arguments compared to 1 argument as an example.
|
I'm fairly sure that you don't need to change anything in broot for this. As you might be aware, shell doesn't have a strong distinction between one and multiple args. As far as I can see, broot just passes anything you specify as an arg to the function as a single, un-split string, but there is no rule saying that you can't just split the string yourself, either just using the shell's word-splitting, or by using your own splitting, e.g. by changing the IFS variable. In your case, that would be #!/bin/bash
dir="$1"
shift
for var in $*
do
mkdir -p "$dir/$var"
done Unless I missed or misunderstood something? |
@SamuelSwartzberg That is exactly what I wanted! Thanks a lot! |
This approach does still have 1 issue though - you are unable to use " for arguments in this case, since broot is automatically managing ". I guess a better issue would be to ask for a way to toggle this behaviour depending on the verb. @Canop Should I open a new issue for that or can we reuse this one since it is related? |
What do you mean by 'use "'? Given
as a simple test verb:
So they are preserved. If you mean 'prevent splitting on whitespace', that's true. I'm pretty sure there's a way around this, probably using |
Option to define a verb that could take a list arguments rather than a single argument. Use case would be something like this:
[search pattern] MakeMulipleDirs dir1 dir2 dir3
where the verb in this case wouldn't have only 1 argument "dir1 dir2 dir3", but rather 3 arguments allowing you to create multiple directories with a single verb as you would on the command line.
The text was updated successfully, but these errors were encountered: