Skip to content
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

Path should be escaped when running '-x cmd' #135

Closed
sharkdp opened this issue Oct 19, 2017 · 8 comments
Closed

Path should be escaped when running '-x cmd' #135

sharkdp opened this issue Oct 19, 2017 · 8 comments
Labels

Comments

@sharkdp
Copy link
Owner

sharkdp commented Oct 19, 2017

This seems like a bug to me

> touch 'file with spaces'

> fd -x 'ls "{}"'    # this is fine
file with spaces

> fd -x ls       
ls: cannot access 'file': No such file or directory
ls: cannot access 'with': No such file or directory
ls: cannot access 'spaces': No such file or directory

@mmstick - I'm mentioning you here just in case you are interested. I'm not trying to assign this to you.

@sharkdp sharkdp added the bug label Oct 19, 2017
@mmstick
Copy link
Contributor

mmstick commented Oct 19, 2017

GNU Parallel also implements these flags for this use case -- quoting inputs. Not really a bug, but a convenience flag so you don't have to manually quote it yourself.

@mmstick
Copy link
Contributor

mmstick commented Oct 19, 2017

The --quote flag, that is

@jakwings
Copy link
Contributor

Why not quote it by default?

@mmstick
Copy link
Contributor

mmstick commented Oct 20, 2017

@iology You can have an input that provides multiple arguments. In that case, you don't want quoting to happen.

@mmstick
Copy link
Contributor

mmstick commented Oct 20, 2017

Although I guess when all of your inputs are files, it'd make sense to quote by default.

@sharkdp
Copy link
Owner Author

sharkdp commented Oct 20, 2017

Although I guess when all of your inputs are files, it'd make sense to quote by default.

Yes, I also think so. The flag might be useful for parallel, but it shouldn't be needed here.

@mmstick
Copy link
Contributor

mmstick commented Oct 20, 2017

I'll have this fixed soon. Am going to look for a way of possibly optimizing my solution though. Best way to do this isn't to quote, exactly, but to escape special characters.

@mmstick
Copy link
Contributor

mmstick commented Oct 20, 2017

Am going to convert that paths module into an input module that uses a state machine to generate input strings, only allocating as needed. Will ensure that the programmer doesn't forget to escape the input before using it, preventing a possible logic error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants