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
Allow commands to still be executed even if the current working directory no longer exists #17579
Conversation
|
Working on tests |
|
@PowerShell/wg-powershell-engine should review if there's any concerns on side effects of this change |
src/System.Management.Automation/engine/NativeCommandProcessor.cs
Outdated
Show resolved
Hide resolved
|
Reopen PR to re-trigger the CI runs. |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
…tory doesn't exist
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? |
|
Handy links: |
PR Summary
In the case where the current working directory is deleted, there are two places in the code that fail. The CommandSearcher tries to search the current directory and an exception is thrown. The change is to catch that exception and have the logic continue where current directory is null which is already handled. After this, the NativeCommandProcessor always tries to set the native command process working directory to the current working directory which will fail and an exception is thrown. So if the current working directory doesn't exist, don't set that property. The default for this member is already an empty string.
This change makes pwsh work the same as bash.
PR Context
Fix #2116
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).