Skip to content

Do not add PATHEXT environment variable on Unix - #7697

Merged
Ilya (iSazonov) merged 9 commits into
PowerShell:masterfrom
iSazonov:remove-env-pathext
Sep 14, 2018
Merged

Ilya (iSazonov) merged 9 commits into
PowerShell:masterfrom
iSazonov:remove-env-pathext

Conversation

@iSazonov

Copy link
Copy Markdown
Collaborator

PR Summary

Address #3572.

On Windows we use file extensions to detect executables. Windows define a list of the extensions in PATHEXT environment variable by default. If the variable is absent Powershell added env:PATHEXT special variable on all platforms. A problem is that on Unix the PATHEXT is not defined by default and is not needed. The fix exclude creating PATHEXT on Unix.

It is a breaking change in grace area - no PowerShell scripts should depend on PATHEXT on Unix.

PR Checklist

@iSazonov Ilya (iSazonov) added the Breaking-Change breaking change that may affect users label Sep 3, 2018
@iSazonov Ilya (iSazonov) self-assigned this Sep 3, 2018
@iSazonov Ilya (iSazonov) added the Review - Committee The PR/Issue needs a review from the PowerShell Committee label Sep 3, 2018
@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Sep 5, 2018 •

Copy link
Copy Markdown
Member

@PowerShell/powershell-committee reviewed this and it seems that $env:PATHEXT can provide utility on Unix systems if the user creates the environment variable. Example is if user has foo.py and wants PowerShell to execute foo, they can use this.

@SteveL-MSFT Steve Lee (SteveL-MSFT) added Committee-Reviewed PS-Committee has reviewed this and made a decision and removed Review - Committee The PR/Issue needs a review from the PowerShell Committee labels Sep 5, 2018

@rjmholt Rob Holt (rjmholt) left a comment

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.

LGTM!

@SteveL-MSFT Steve Lee (SteveL-MSFT) 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.

Based on @PowerShell/powershell-committee conclusion, we should not make this change as there is utility for an end user to create the PATHEXT env var and use it on non-Windows

@iSazonov

Copy link
Copy Markdown
Collaborator Author

Steve Lee (@SteveL-MSFT) Your request was addressed.

@iSazonov

Copy link
Copy Markdown
Collaborator Author

CI Appveyor temporary failed.

// Now check the extension and see if it's one of the ones in pathext
#if UNIX

if (Platform.NonWindowsIsExecutable(this.Path))

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 not just:

return Platform.NonWindowsIsExecutable(this.Path);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

From PowerShell Committee conclusion we should fallback on Unix to read PATHEXT.

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.

Additional code would need to be added to support something like executing foo where foo.py exists and .py was added to PATHEXT on Unix since Windows takes care of this automatically. That is a feature and not bug fix so certainly out of scope of this PR. I'd also wait until there's customer request for such a feature.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Steve Lee (@SteveL-MSFT) I fixed your request. Tracking issue #7755 .

@iSazonov

Copy link
Copy Markdown
Collaborator Author

Reopen the PR to restart CIs.

@mklement0

Copy link
Copy Markdown
Contributor

Steve Lee (@SteveL-MSFT): I don't think PATHEXT fits into the Unix world - please see #7755 (comment)

@iSazonov

Copy link
Copy Markdown
Collaborator Author

Steve Lee (@SteveL-MSFT) Please update your review. I believe we can merge.

@iSazonov
Ilya (iSazonov) merged commit f90fa8a into PowerShell:master Sep 14, 2018
@iSazonov
Ilya (iSazonov) deleted the remove-env-pathext branch September 14, 2018 03:04
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
…werShell#7697)

* Don't create env:PATHEXT on Unix
* Use IsExecutable()
* Add conditional compile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking-Change breaking change that may affect users Committee-Reviewed PS-Committee has reviewed this and made a decision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants