Repository navigation
Description
When using both the console host and an editor like VSCode, completions are provided for
environment variables that differ across platforms. In the case of VSCode, I know it tries to
make recommendations for scripts that help them work cross-platform, and this seems to
fit in that category. Of course, plenty of environment variables are just not cross-platform, but
for things like $env:PSModulePath that come with PowerShell, it would make sense.
Given that Linux requires variable names that Windows tolerates but no vice-versa, perhaps we
should prefer those?
I wouldn't necessarily characterise this as a bug, but it might help obviate some bugs if changed. See #2937 and #2677. I know I have personally run into this when tests I wrote failed because I used
$env:PSModulePath, my reasoning being that the completion of a variable name would be the
canonical name for the variable.
Steps to reproduce
In a PowerShell terminal or editor with completions enter the input:
$env:PSM<Tab>Expected behavior
The same completed variable name across platforms.
Actual behavior
On Windows:
$env:PSModulePathOn Linux:
$env:PSMODULEPATHEnvironment data
> $PSVersionTable
Name Value
---- -----
GitCommitId v6.0.0-alpha.16-28-g136213d6b4767370f0b6340ffbefa130fdc55327
WSManStackVersion 3.0
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSEdition Core
BuildVersion 3.0.0.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PSVersion 6.0.0-alpha
CLRVersion
Activity
SteveL-MSFT commentedon Mar 1, 2017
This is an easy fix, but like many things Env are case sensitive on Linux. It seems that by convention, they tend to use all uppercase. For script portability (although perhaps they shouldn't modify psmodulepath), we should consider having consistency with Windows.
SteveL-MSFT commentedon Mar 2, 2017
@PowerShell/powershell-committee discussed this and decided to maintain compatibility for existing scripts, it would be best to keep the mixed casing and change it in PSCore6 on Linux.
corrected use of PSModulePath casing to be consistent with Windows Po…
iSazonov commentedon Mar 9, 2017
Existing scripts is Windows scripts and it is case-insensitive: we are free to use
PSModulepath,PSmodulepath,psmodulepath,PsMoDuLePaThand so on.If the conclusion was "to maintain compatibility for existing scripts" all above must work on Unix too.
SteveL-MSFT commentedon Mar 9, 2017
Ilya (@iSazonov) you are correct that on Windows, env vars are case-insensitive, but we are only optimizing for the tab-complete case which we expect is the majority of use.
iSazonov commentedon Mar 9, 2017
Steve Lee (@SteveL-MSFT) Yes, I see your fix. But it seems the issue was originally broadly: Windows user type
PSModulePathin other case and catch failure on Unix.SteveL-MSFT commentedon Mar 9, 2017
Ilya (@iSazonov) we are trying to find a balance between interop, app-compat, and conforming to Unix/Linux norms and this is what the committee decided fit that balance. If there is customer feedback that we need to do more here, we are open to listening.
iSazonov commentedon Mar 9, 2017
Steve Lee (@SteveL-MSFT) Thanks for clarify!
corrected use of PSModulePath casing to be consistent with Windows Po…
iSazonov commentedon Mar 16, 2017
Steve Lee (@SteveL-MSFT) It seems the PR is not full solution. Maybe reopen the Issue?
SteveL-MSFT commentedon Mar 16, 2017
Ilya (@iSazonov) the @PowerShell/powershell-committee decision is to only address the scenario of using tab-complete to author a script (most likely profile script) that uses
$env:PSModulePathand have that consistent across platforms. The general problem is no different from callingPowerShellconsole host on Windows which won't work as the file system is generally case sensitive on Linux so it has to bepowershell.iSazonov commentedon Mar 17, 2017
If you generalize so much the problem then I agree to close the Issue.
corrected use of PSModulePath casing to be consistent with Windows Po…