-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
7.4.0 Breaking Change: Tab expansion no longer converts tildes to full paths, breaking path passing to executables on Windows #20750
Comments
In fact, when this behavior finally appeared in 7.4.0-rc.1, I was glad about it. But perhaps this is not as relevant in Windows as it is in Linux. |
It's very counterproductive in Windows.
PowerShell follows POSIX (partially) and translates ~ before calling executables on Linux/macOS. |
On Linux, all native applications interpret the tilde as a synonym for the user's home directory. It’s just that the command line is shorter due to the fact that it does not expand the path to the full one. The same cannot be said about Windows; most utilities probably simply will not understand what this path is. |
It's worth pointing out that the Unix-y apps on Windows (for example, all the tools that ship with Git) do map Using less version 7.3.9: But this doesn't: 7.4.0: Since PowerShell uses the backslash when tab completing, it's creating command lines that will be broken with these Unix-y tools. |
To be clear, I don't think the use of the backslash is wrong for PowerShell Core on Windows, as the Unix-y tools do work as expected with backslashes but only with fully qualified paths (which Tab completion no longer generates in 7.4.0). |
I was talking specifically about Linux as the actual installed OS. Not WSL, not ported utilities, but about my main OS, which is the only one on the computer (Windows on the older notebook). Therefore, I would like everything to remain as it is, at least on Linux. |
I'm fine with the new behavior being the default, as long as I have a trivial way to opt out. |
Yes, as you've discovered this was an intentional change and there's currently no way to change the behavior. A quick workaround you can implement on your own machine is to update the tabexpansion2 function to replace the Assuming this is something that people want fixed, I can think of the following solutions:
Quick and dirty tabexpansion2 workaround:
|
Let me provide some context: On Unix-like platforms it is the (POSIX-compatible) shell (such as
Given the above, I propose the following variation of @MartinGC94's proposal 1:
While making PowerShell emulate literal |
Taking a step back, re proposal 3 (unquoted
|
For what it's worth, the problem I have is that I don't think you went far enough. I really don't want TabCompletion to replace generic values like How about instead of reverting a good feature, we replace the literal Since PowerShell expands variables when passing arguments to native apps, this gets us the best of all worlds:
NOTE: the catch to this is that it doesn't work if they're single-quoting the path they are tab-completing, in which case we might want to resort to the old behavior... |
I am planning on creating a PR to stop it from replacing variables with their resolved values but that's a separate issue from this.
|
Not exactly true. The tilde is expanded by the shell (bash, sh, zsh etc). The applications don't need to map the tilde in command line arguments. Just like on UNIX the shell expands file wildcards, so the application does not need to enumerate directories, the shell did it for them.
No interpretation by the native app. The shell does not expand if quoted
and
Now that is a gotcha, because shell does expand environment variables within double quotes but not within single quotes. So shell is doing special treatment for tilde, it is not treating it simply as $HOME. |
Thanks, @rhubarb-geek-nz - this has all been covered by my previous comment. @MartinGC94: good point about the provider-specific nature of However, tab-completion was previously already provider-aware and would not expand (On a side note: On Unix-like system, when tilde expansion happens in the context of argument-passing to external programs, the current location's provider does not matter; it is always the value of Given that among the built-in providers only the To me, translating That said, we could avoid this problem if we went with proposal 3, which is the cleanest solution. |
I'm surprised by the number of people who are suggesting that I'm asking for a new feature rather than lamenting of the removal of an old feature. The conversations about "confusions for users" is exactly why we're here: a "breaking" change was made and me (a user) is confused about why it was done and how I can undo it. This was clearly a feature I counted on and would like to have back, even if it is no longer the default behavior. I would be fine with tab completion of (I just deleted a bunch of stuff because I realized that |
I don't see anyone suggesting that. The - intentional - change that was introduced in 7.4.0 discussed here has a real downside on Windows (as you've discovered) - lack of And it sounds like you'd be happy with the new behavior as long as the latter problem is solved. As for variable references in paths: as @MartinGC94 has stated, the plan is to also change the behavior in order to preserve variable references during tab-completion in a future PR. However, if we go with the replace- |
@MartinGC94 I think this really needs to be rolled back to previous behaviour. But thanks for sharing the modified I've created a gist https://gist.github.com/jhoneill/322a77199350c76a5785f5406ea97bac with what I think is a more effective version although I'm not sure about modifying However it does some things which I had in an argument completer previously and had to be bound to whatever cmdlet/function arguments I thought would benefit - a bit tedious
I saw a way to fix #20765 at the same time so I've put that in at the end
|
To provide what I think is the proper framing for this issue:
|
On Windows |
Can the change that caused this issue to become present please get linked to for traceability and also so that we can then also look to update changelogs, docs and any other supporting material as needed. |
I prefixed that with "I think", I'm a very infrequent user of Linux and and non Windows users may have a different view to users of Windows Given there is another issue about the behaviour of ~/path with native Linux tools I can see possible advantages to rolling back there too but that's not where I do my work so others are better places to say. I will try frame something as "O'Neill's nth law" along the lines of "things which get into a product because they seemed like a good idea at the time to a developer are a disproportionate cause of problems". 7.4 seems to have a few of those, and I'd put colourization in the same group. |
Also known as The road to hell is paved with good intentions |
As a Linux and Windows user, I believe that using shortcuts like This is my personal opinion, like everything else I write here, because I'm just an user who cares about the future of PowerShell. Sorry that sometimes my statements seem unclear or even rude - poor knowledge of the language and often incorrect translation are the reason for this. I respect you all and value your opinion. |
@237dmitry, thank you for your clarification that there may be a language barrier and for your expression of respect. Just to recap the previous clarification: it isn't utilities (external programs) that interpret PowerShell (sensibly) chose to emulate this behavior - selectively, for calls to utilities (external programs) only - but currently only on Unix-like platforms. To resume the framing debate:
|
I think this dilemma will be successfully resolved without affecting the already running version on the Unix platform. As you noted in another thread, there are problems with quotation marks, but quoting only part of the path is not that common in everyday interactive practice. |
That makes sense. |
Aren't we losing sight of the original issue? The issue was that Powershell 7.4.0 broke the long-established tab completion of the tilde character in interactive sessions. My understanding is that the OP is specifically concerned about what happens when the tab key is pressed in an interactive terminal session, not how it's interpreted in pre-existing scripts, nor on the nature of whether Powershell is Posix compliant or if it should parrot the behaviour of miscellaneous UNIX-like shells. To put it simply, users like me want the tilde to expand to the full $HOME path in front of our eyes when we press the tab key after entering a path with the tilde in it. We're not interested in the behaviour of the tilde in scripts, nor how the tilde is interpreted in an argument to a cmdlet or native executable. We just want our tilde tab completion back, even as a non-default option. Surely that can't be too difficult, given that we've already been provided a workaround tabexpansion2 function from MartinGC94 in the post earlier: #20750 (comment) |
@AGDownie With zero interaction from the PowerShell team thus far, I'm tempted to just close this issue (given the vitriol some people insisted on spewing into it) and just re-open it again. |
In fact I believe @MartinGC94 is involved in the development, having added some commits on the relevant PR (#19489), and posted perhaps the most useful contribution on this issue. So perhaps we may see progress some time soon. I wouldn't recommend closing the issue and re-opening a new one, as that will probably count against getting anything done. It would be nice to see some further response from the PowerShell team, but in the meantime I'm just using my own variation of MartinGC94's "quick and dirty" workaround tabexpansion2 function to restore the required functionality. It works fine, but it would be preferable if it was at least available as a Set-PSReadlineOption customisation, or even more preferable if it was restored as the default option! |
Sort of. I'm a regular contributor, but I'm not a member of any WG or the actual PS team so my level of influence is the same as you: I can submit my thoughts/ideas through comments and PRs but that's it. If someone with actual power makes a decision on this I would be happy to create a PR for it though. |
Thanks, @MartinGC94. Point taken. But I expect that as a contributor your thoughts/ideas carry more weight than mine as a simple user. |
This will be small consolation, given the time frame: Runtime expansion of unquoted This means that - if it even ever becomes a stable feature (which is to be hoped for) - the first stable version it would land in is v7.5, which is months away. While that won't bring the old behavior back, at least calls to external programs using tab-completed |
@mklement0 Actually that PR is bad (as-is) because it doesn't resolve ~ when it's quoted, and tab expansion with paths with spaces in them will automatically quote (at least it currently does in 7.4.1, even on Linux where such behavior is outright broken, and will soon be broken on Windows with 7.5.0-preview.2). Maybe there's a parallel feature for 7.5.0 that stops quoting paths during tab expansion and just escapes them instead...? |
That However, there are indeed two separate bugs (as previously mentioned) with respect to quoting:
While unfortunate, they only affect paths that contain spaces. |
This has totally broken my workflow.... microsoft/vscode#146116 |
This change has been unexpected and frustrating to me - I didn't spot any information about it happening, and spent some time assuming that I was doing something wrong when my various tools started breaking. I on;y found this issue when I searched for "how do I force Powershell to expand tilde when completing", thinking it was something I'd forgotten to configure. I like the idea of retaining ~ and variables, but expanding them when running an external program. It would still be a slight problem for occasional cases (where I type part of a filename, tab-complete it, and then copy the resulting expanded name into something like an email, or a program that doesn't parse tilde or variables the same way as Powershell does), but I could live with that. However, I think the problems with the current approach are sufficiently annoying (on Windows, at least) that something needs to be done short term - if the long-term solution can't be delivered quickly, IMO there's a good case for reverting the change in behaviour for ~. As a partial stopgap, I've hacked together the following key binding:
It's a mess at the moment - I've never tried to create a custom key handler before - but if anyone can suggest how to make it more robust, it would be useful as a workaround. Problems with this version are that it overwrites the clipboard, and it leaves part of the command line selected. If there were "Get selected text" and "Move cursor to end of current selection" functions, this would fix the issues, but I couldn't find anything like that in the documentation 🙁 |
@pfmoore: @MartinGC94 has posted a temporary fix in the form of a modified |
Sorry, everybody, but I'm closing this issue. I've been nearly half a year with tons of discussion (and way too many heated words), and never once has anybody from the PowerShell team come to say anything about this. It's done and over, and we're not getting it back. |
📣 Hey @bradwilson, how did we do? We would love to hear your feedback with the link below! 🗣️ 🔗 https://aka.ms/PSRepoFeedback |
@bradwilson, as much as I can relate to the I'm-gonna-take-my-ball-and-go-home sentiment, the community is better served by keeping this issue open. The fact that the issue is labeled WG-NeedsReview presumably:
In short: I encourage you to reopen this issue, if only to - for now - increase its visibility to future users. |
You're welcome to open a new issue and even link back here for "history". I have zero confidence that this one will yield any attention. 5 months is long enough to wait for even a simple acknowledgement. |
Thanks for sticking with it as long as you did. I've been affected by other hot-button issues that the pwsh team have refused to acknowledge. This is nothing new for this team. fwiw, I just downgraded to https://github.com/PowerShell/PowerShell/releases/tag/v7.3.12 |
Sadly that's the way the PowerShell team has gone. Not engaging, and indulging in "Developer Driven Development". |
📣 Hey @bradwilson, how did we do? We would love to hear your feedback with the link below! 🗣️ 🔗 https://aka.ms/PSRepoFeedback |
Thank you, thank you, thank you @SteveL-MSFT for the fix! And thanks to @jaredpar for getting it attention. |
That gif is amazing. |
And just when you give up, someone engages and does the right thing :-) Tip-of-the-hat to you Steve. |
Prerequisites
Steps to reproduce
With versions prior to 7.4.0, pressing Tab to get completion on a path with
~
converted that path into the full path for my home folder.Type
dir ~\down
and press Tab:dir C:\Users\bradwilson\Downloads\
dir ~\Downloads\
For built-in commands (like
dir
), this is fine. For executables, this passes a path with~
in it, which makes using such paths impossible unless the executable has its own support for mapping~
to the home folder. For example, if I try to runnotepad ~\.config\git\config
, it will tell me the path isn't found; if I runnotepad C:\Users\bradwilson\.config\git\config
, it will open the file appropriately.This breaks more than a decade of muscle memory expecting
~
to be translated into the correct path, as I've been using PowerShell as my shell since it was called Monad.This appears to have been purposefully introduced in #19489. I cannot find any way to restore the old behavior short of sticking w/ version 7.3.9.
Expected behavior
Actual behavior
Error details
No response
Environment data
Visuals
No response
The text was updated successfully, but these errors were encountered: