-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Closed
Labels
O-windowsOperating system: WindowsOperating system: Windows
Description
If a rust windows program has a command-line argument like this: .\myapp -p "C:\Program Files\" -v, it will be parsed as follows: ['.\myapp', '-p', 'C:\\Program Files\\" -v'] instead of ['.\myapp', '-p', 'C:\\Program Files\\', '-v'].
Looking over rust code, this is due to rust adhering to Microsoft standard:
/// Implements the Windows command-line argument parsing algorithm.
///
/// Microsoft's documentation for the Windows CLI argument format can be found at
/// <https://docs.microsoft.com/en-us/previous-versions//17w5ykft(v=vs.85)>.
And the link states:
A double quotation mark preceded by a backslash (") is interpreted as a literal double quotation mark character (").
So everything is behaving to spec. The problem is that if a user is running my app in powershell, tab-completion will automatically add in the trailing backslash in quoted paths. So I have to explain that this doesn't work.
Some observations:
- Tab-completion in command prompt (cmd) does not add trailing backslash
- Microsoft commands like dir, ls don't have a problem with trailing slash (in powershell or cmd). For example
dir "C:\Program Files\" /B - I tried using Windows function
CommandLineToArgvWthrough the winapi crate but it also seems to have the same problem.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
O-windowsOperating system: WindowsOperating system: Windows
Type
Fields
Give feedbackNo fields configured for issues without a type.