-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
EDIT: 2019-06-25 - Additional conditions and clarifications, corrected expected behavior as requiring the curly quotes to be doubled, added second example demonstrating the tab completion when the first character of the file name is not a quote character, added third example for curly double quotes
I am not sure what is really responsible for tab completion of path names in PowerShell, but here is what I found while testing a similar function in posh-git.
Steps to reproduce
Example 1
echo hello >"`u{2018}hello`u{2019}.txt"
get-content # press tab until file `.\‘hello’.txt` is shownExample 2
echo hello >"hello`u{2019}.txt"
get-content # press tab until file `'.\hello’.txt'` is shownExample 3
echo hello >"hello`u{201C}.txt"
get-content "hello" # press tab until file `".\hello“.txt"` is shownExpected behavior
Example 1
get-content '.\‘‘hello’’.txt'Example 2
get-content '.\hello’’.txt'Example 3
get-content ".\hello““.txt"Actual behavior
Example 1
get-content .\‘hello’.txtThis generates an error saying the file hello.txt cannot be found. Note this particular behavior is regardless of the type of quote used, as long as the quote is a legal filename character and is at the start of the file name and is a special character for PowerShell.
Example 2
get-content '.\hello’.txt'This will cause PSReadLine to want to continue a multiline input because the quoted string is still open.
Example 3
get-content ".\hello“.txt"This will cause PSReadLine to want to continue a multiline input because the quoted string is still open.
Environment data
Name Value
---- -----
PSVersion 6.2.0
PSEdition Core
GitCommitId 6.2.0
OS Microsoft Windows 10.0.18912
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
In dahlbyk/posh-git#683 (comment) @rkeithhill commented that it would be nice if PowerShell has a static method for escaping arguments, and it was that comment that triggered me to test this possibility. I have not tried to test all characters that could be special but found in file names to see if any more are missing escaping.
Another issue with tab completion, server/share names with spaces, #7569, but this only affects the path while it is just '\server\share with a space'...