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

On Windows, path with spaces are not double quoted. #53

Closed
blemelin opened this issue Sep 14, 2022 · 3 comments
Closed

On Windows, path with spaces are not double quoted. #53

blemelin opened this issue Sep 14, 2022 · 3 comments

Comments

@blemelin
Copy link
Contributor

blemelin commented Sep 14, 2022

Let's say we want to open this file with Visual Studio Code : D:\projects\work 5.txt.

open::with("D:\\projects\\work 5.txt", "code").unwrap();

Doing this ends up opening two files : work and 5.txt. For this to work properly, the path must be inside double quotes like this :

open::with("\"D:\\projects\\work 5.txt\"", "code").unwrap();

Is this the intended behaviour ? On other platforms, this crate seems to handle spaces perfectly fine, so I created a fix for Windows in a fork of this repository. I can open a Pull Request if you are interested. A lot of programs can open multiple files at the same time, but this crate seem to be intended to open one file at a time, hence this issue.

@Byron
Copy link
Owner

Byron commented Sep 15, 2022

Thanks for letting me know, and a fix for this would be greatly appreciated.

This definitely isn't intended behaviour and I believe the difference in handling of arguments might be in the nature of windows programs, maybe. On linux, an argument passed to a program is just that, and it can contain any character including whitespace, no additional splitting is performed as it doesn't go through a shell. On windows, a single string is passed as concatenation of all arguments, as I understood it, which then is split by the program itself. Hence one will always have to escape certain characters to avoid the splitting from happening, which isn't done yet.

@blemelin
Copy link
Contributor Author

I've created the requested pull request. See PR #54. Thanks a lot for your work. 😃

@Byron
Copy link
Owner

Byron commented Sep 16, 2022

Thank you!
The fix is now available in v3.0.3.

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

No branches or pull requests

2 participants