-
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
Set-Location: Match $env:PWD & $PWD on UNIX #8901
Conversation
Set the UNIX Environment variable $env:PWD to the full filesystem path for the current working directory upon Set-Location. This also copes when the current location is set to a PSDrive. In such circumstances the environment variable is expanded to the full FileSystem provider path. Fixes PowerShell#7388 Signed-off-by: Daniel Llewellyn <daniel@bowlhat.net>
98a16f5
to
1805a70
Compare
Signed-off-by: Daniel Llewellyn <daniel@bowlhat.net>
test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1
Outdated
Show resolved
Hide resolved
Signed-off-by: Daniel Llewellyn <daniel@bowlhat.net>
test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Management/Set-Location.Tests.ps1
Outdated
Show resolved
Hide resolved
Replace positional parameters with named equivalents. Signed-off-by: Daniel Llewellyn <daniel@bowlhat.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casing can be changed .
$path --> $Path
and $location --> $Location
. Please do the change for all occurrences. Once again, these are not mandatory for the functionality and PR to get merged.
Signed-off-by: Daniel Llewellyn <daniel@bowlhat.net>
Thanks for the thorough review, @kvprasoon, and for sticking with me while I work through your suggestions :-) |
I think we can not accept the PR because PowerShell can create many runspaces each of which has its own value of $PWD. Note that .Net also has "pwd" which doesn't correlate with PowerShell $PWD. |
@iSazonov it would be better to set |
@vexx32 PowerShell can create many runspaces/threads in the same process and everyone will export |
@iSazonov how do other threaded Unix applications handle this issue? Are there any existing applications we could model behaviour from here? |
@vexx32 |
Using |
An function written in PowerShell that I wrote utilising runspaces can be found here. The runspace pool is created on line #566, and the separate instances are created and invoked on lines #594-#627 This is a bit of a more complex example as I'm batching the tasks to make the best use of it, but it should illustrate the overall idea. 😄 There may be some already-built functions designed to help test these types of cases in amongst some of the existing test files, but I'm not sure of where to look for those. |
OK, run-spaces definitely share the PWD environment, so this PR as it stands is not good-to-go :-) |
This needs rethinking, so I'm closing the PR. |
PR Summary
Update the UNIX Environment variable
PWD
to the current location.PR Context
Fixes #7388
Set the UNIX Environment variable $env:PWD to the full filesystem path
for the current working directory upon Set-Location. This also copes
when the current location is set to a PSDrive. In such circumstances the
environment variable is expanded to the full FileSystem provider path.
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.[feature]
to your commit messages if the change is significant or affects feature tests