Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ensure running powershell within PowerShell starts instance of currently running PowerShell#4481

Merged
daxian-dbw merged 2 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
SteveL-MSFT:powershell-pathSteveL-MSFT/PowerShell:powershell-pathCopy head branch name to clipboard
Aug 4, 2017
Merged

ensure running powershell within PowerShell starts instance of currently running PowerShell#4481
daxian-dbw merged 2 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
SteveL-MSFT:powershell-pathSteveL-MSFT/PowerShell:powershell-pathCopy head branch name to clipboard

Conversation

@SteveL-MSFT

Copy link
Copy Markdown
Member

modify PATH env var at startup so that $PSHOME is in front

Fix #4194

…ently running PowerShell

modify PATH env var at startup so that $PSHOME is in front
if (!Platform.IsWindows)
{
pathSeparator = ":";
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use Path.PathSeparator.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

pathSeparator = ":";
}
string pshome = Utils.DefaultPowerShellAppBase;
path.Replace(pathSeparator + pshome, "");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that the PWD got appended to the end of PATH so I didn't want it on both ends, looks like that isn't the case. I'll remove.

}
string pshome = Utils.DefaultPowerShellAppBase;
path.Replace(pathSeparator + pshome, "");
path.Insert(0, pshome + pathSeparator);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check if the first path in $env:PATH is pshome, and only insert if it's not. Otherwise, the nested powershell instance will have 2 pshome paths in $env:PATH

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@daxian-dbw daxian-dbw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@daxian-dbw daxian-dbw merged commit d17aaad into PowerShell:master Aug 4, 2017
}
#endif

// put PSHOME in front of PATH so that calling `powershell` within `powershell` always starts the same running version

@iSazonov iSazonov Aug 6, 2017

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Is this right for other applications?
  2. I would prefer more deterministic [System.Diagnostics.Process]::GetCurrentProcess().MainModule.FileName. (Related Improve experience for side-by-side versions of PowerShell #4199 . What about Start-PowerShell cmdlet?)

@SteveL-MSFT SteveL-MSFT deleted the powershell-path branch August 6, 2017 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.