-
-
Notifications
You must be signed in to change notification settings - Fork 125
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
Handle special characters in commands - maybe skip the shell #158
Comments
The problem is, that passing arguments to commands on a shell as if it isn't on a shell can be tricky. Right now, we simply do this:
This is fairly straight forward, since we don't have to do any additional argument parsing. Let's take for instance this command: In this case, we would get this command string:
Now we have to do manual parsing of this argument-string similar to the shell's argument parsing. The end result should look something like this:
To be honest, I already thought about implementing something like this, but I never felt confident enough about any parsing approach. But I imagine that there are quite a few weird edge-cases, where argument parsing can become tricky, such as Anyway, I think that this is something that would be nice to have, |
Ah there's one thing we would have to test with your example mentioned above. Pueue get's the command that's passed to it as a The That would then look like this:
Which should result in this
It feels like I'm missing something. Is it really that easy? |
There's a few other things that make this really tricky though. Whenever we insert, for instance, an alias or whenever we edit the command, we lose any information on which part of the concatenated string belongs to which argument. This would mean, that we wouldn't be able to use aliases or edit commands for tasks with Furthermore, this makes internal handling of a command pretty ugly. If we decided to add this additional logic, we would have to change that to |
Another solution for your problem might be to offer shell-escape on given parameters for the user. I.e. you get this String input vector:
When providing a flag
Which could then be concatenated to a working shell command: To be honest, I really like this approach. Are there any good shell escaping libraries out there? |
Quite frankly, I think the only sane way is to require the end user to pass exactly as many strings to pueue as they would want passed to the underlying executable. So it's up to me to pass multiple strings if that's what I want to be run. That would fit your I honestly don't understand what you mean by aliases - I suppose this is a feature of pueue I have never used? I don't see anything that sounds like it would be very handy for shell escaping in crates.io - only for splitting into "shell words" which I suppose is unnecessary. |
For now, I feel like doing an internal rework on how commands and processes are handled is just to much work. The I created a draft and tested it with various scenarios. It should do the job for your use-case :) |
Looks good to me, it compiles and runs but I'll wait for my current queue to finish to try it on my current use case. Thanks Arne! |
You're welcome :) |
I'm using this command to do some video transcoding, and many of the filenames include parenthesis, single and double quotes and spaces.
Right now, I have to pipe them through
sed
because all of those are interpreted by the shell when pueue calls it. I wouldn't think much of it except that if the shell weren't involved at all, this wouldn't be a problem.Is it reasonable to opt-out of a shell for new commands, or is the shell too central to pueue for that?
This is the specific case I'm encountering at the moment, to give an idea.
This is an example how I add tasks now:
But I think it would make significantly more sense if I could skip the shell and run something more like
The text was updated successfully, but these errors were encountered: