Skip to content

Enhance 'install-powershell.ps1' to work on Linux/MacOS - #5411

Merged
Dongbo Wang (daxian-dbw) merged 4 commits into
PowerShell:masterfrom
daxian-dbw:enhance
Nov 11, 2017
Merged

Enhance 'install-powershell.ps1' to work on Linux/MacOS#5411
Dongbo Wang (daxian-dbw) merged 4 commits into
PowerShell:masterfrom
daxian-dbw:enhance

Conversation

@daxian-dbw

Copy link
Copy Markdown
Member

Enhance 'install-powershell.ps1' to work on Linux/MacOS.

When -AddToPath is specified:

  • On Windows, add the absolute destination path to the 'User' scope environment variable 'Path';
  • On Linux, make the symlink '/usr/bin/pwsh' points to "$Destination/pwsh";
  • On MacOS, make the symlink '/usr/local/bin/pwsh' points to "$Destination/pwsh".

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.

Some non-blocking comments

$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
$userPath = $Destination + [System.IO.Path]::PathSeparator + $userPath
[System.Environment]::SetEnvironmentVariable("Path", $userPath, "User")
Write-Verbose "'$Destination' is added to the Path" -Verbose

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.

I think, since we have CmdletBinding() we should not force -verbose

@daxian-dbw Dongbo Wang (daxian-dbw) Nov 10, 2017

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.

These messages are actually intentionally written out so that a user roughly knows what the script is doing when running it.


Expand-Archive -Path $packagePath -DestinationPath $Destination
if ($IsWinEnv) {
Expand-Archive -Path $packagePath -DestinationPath $Destination

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.

Should we delete the compressed package after expansion?

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.

The compressed package will be deleted. The compressed package is downloaded to $tempDir which will be deleted in the finally block at the end of the script.

@daxian-dbw

Copy link
Copy Markdown
Member Author

Linux job succeeded, but the macOS job was canceled again.
Currently install-powershell.ps1 is only used in AppVeyor bootstrapping (install latest powershell core if not found), so it won't affect macOS CI run. Given that, I will merge this PR.

@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 2f399e2 into PowerShell:master Nov 11, 2017
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
)

Enhance 'install-powershell.ps1' to work on Linux and macOS too. A user can install release version or daily powershell core on Linux and macOS.
When `-AddToPath` is specified:
- On Windows, add the absolute destination path to the 'User' scope environment variable 'Path';
- On Linux, make the symlink '/usr/bin/pwsh' points to "$Destination/pwsh";
- On MacOS, make the symlink '/usr/local/bin/pwsh' points to "$Destination/pwsh".
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.

3 participants