Skip to content

Fix powershell to update the PATH environment variable only if PATH exists - #5021

Merged
Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
SteveL-MSFT:crash-nopath
Oct 5, 2017
Merged

Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
SteveL-MSFT:crash-nopath

Conversation

@SteveL-MSFT

Copy link
Copy Markdown
Member

Linux service calling powershell may not have PATH set
only use PATH if it's not null
also fixed a test case using -TestCases without unique test name

Fix #5019

fixed code that expected PATH env var to exist
also fixed a test case using -TestCases without unique test name

@anmenaga Andrew (anmenaga) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit ba7dfcc into PowerShell:master Oct 5, 2017
@daxian-dbw Dongbo Wang (daxian-dbw) changed the title fix powershell host crash when PATH is not set Fix powershell to update the PATH environment variable only if PATH exists Oct 5, 2017
@SteveL-MSFT
Steve Lee (SteveL-MSFT) deleted the crash-nopath branch October 16, 2017 21:53
@chipzoller

Copy link
Copy Markdown

There still seems to be an issue with this after being rolled into beta 9. For example, if PATH is not set, a test script fails when calling $myvar = hostname on Linux.

"hostname : The term 'hostname' is not recognized as the name of a cmdlet, funct
ion, script file, or operable program."

If PATH is set, the script executes correctly.

@SteveL-MSFT

Copy link
Copy Markdown
Member Author

PATH needs to be set for PowerShell to find exe's not in $PSHOME or current working directory, try setting $myvar to full path to hostname

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
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.

Failure when being run with no PATH variable

4 participants