From 2b9620ab3c584f637e7abfcf3588c92e5231a3e1 Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Tue, 2 Nov 2021 15:14:11 +0100 Subject: [PATCH 1/4] Fix powershell script for non windows users --- install.ps1 | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/install.ps1 b/install.ps1 index 1bf0980..ba2b1d5 100644 --- a/install.ps1 +++ b/install.ps1 @@ -1,7 +1,24 @@ $ErrorActionPreference = "Stop" -$jabbaHome = if ($env:JABBA_HOME) { $env:JABBA_HOME } else { if ($env:JABBA_DIR) { $env:JABBA_DIR } else { "$env:USERPROFILE\.jabba" } } +$jabbaHome = if ($env:JABBA_HOME) { + $env:JABBA_HOME +} else { + if ($env:JABBA_DIR) { + $env:JABBA_DIR + } else { + if($env:USERPROFILE){ + "$env:USERPROFILE\.jabba" + }else{ + "$env:HOME\.jabba" + } + } +} $jabbaVersion = if ($env:JABBA_VERSION) { $env:JABBA_VERSION } else { "latest" } +# The Windows values of the Platform enum are: +# 0 (Win32NT), 1 (Win32S), 2 (Win32Windows) and 3 (WinCE). +# Other values are larger and indicate non Windows operating systems +$isOnWindows = [System.Environment]::OSVersion.Platform.value__ > 3 +$jabbaExecutableName = $isOnWindows ? "jabba.exe" : "jabba" if ($jabbaVersion -eq "latest") { @@ -25,11 +42,27 @@ if ($env:JABBA_MAKE_INSTALL -eq "true") } else { - Invoke-WebRequest https://github.com/shyiko/jabba/releases/download/$jabbaVersion/jabba-$jabbaVersion-windows-amd64.exe -UseBasicParsing -OutFile $jabbaHome/bin/jabba.exe + # $isOnWindows, see top of the file + # MacOSX enum value: 6 + if($isOnWindows){ + Invoke-WebRequest https://github.com/shyiko/jabba/releases/download/$jabbaVersion/jabba-$jabbaVersion-windows-amd64.exe -UseBasicParsing -OutFile $jabbaHome/bin/$jabbaExecutableName + } + elseif([System.Environment]::OSVersion.Platform.value__ -eq 6){ + Invoke-WebRequest https://github.com/shyiko/jabba/releases/download/$jabbaVersion/jabba-$jabbaVersion-darwin-amd64 -UseBasicParsing -OutFile $jabbaHome/bin/$jabbaExecutableName + }else{ + $osArch = [System.Environment]::Is64BitOperatingSystem ? "amd64" : "386" + Invoke-WebRequest https://github.com/shyiko/jabba/releases/download/$jabbaVersion/jabba-$jabbaVersion-linux-${OSARCH} -UseBasicParsing -OutFile $jabbaHome/bin/$jabbaExecutableName + } } $ErrorActionPreference="SilentlyContinue" -& $jabbaHome\bin\jabba.exe --version | Out-Null + +if($isOnWindows){ + & $jabbaHome\bin\jabba --version | Out-Null +} +else{ + & $jabbaHome\bin\jabba.exe --version | Out-Null +} $binaryValid = $? $ErrorActionPreference="Continue" if (-not $binaryValid) @@ -49,7 +82,7 @@ if the problem persists - please create a ticket at https://github.com/shyiko/ja function jabba { `$fd3=`$([System.IO.Path]::GetTempFileName()) - `$command="& '$jabbaHome\bin\jabba.exe' `$args --fd3 ```"`$fd3```"" + `$command="& '$jabbaHome\bin\$jabbaExecutableName' `$args --fd3 ```"`$fd3```"" & { `$env:JABBA_SHELL_INTEGRATION="ON"; Invoke-Expression `$command } `$fd3content=`$(Get-Content `$fd3) if (`$fd3content) { @@ -81,6 +114,6 @@ else Write-Host @" -Installation completed +Installation completed (you might need to restart your terminal for the jabba command to be available) (if you have any problems please report them at https://github.com/shyiko/jabba/issues) "@ From 5b2c999cac64e40b0b7845d6ef77003e842ef00a Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Tue, 2 Nov 2021 15:54:24 +0100 Subject: [PATCH 2/4] Fix script not making file executable --- install.ps1 | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/install.ps1 b/install.ps1 index ba2b1d5..d41ef07 100644 --- a/install.ps1 +++ b/install.ps1 @@ -1,5 +1,6 @@ $ErrorActionPreference = "Stop" +$sep = [IO.Path]::DirectorySeparatorChar $jabbaHome = if ($env:JABBA_HOME) { $env:JABBA_HOME } else { @@ -7,9 +8,9 @@ $jabbaHome = if ($env:JABBA_HOME) { $env:JABBA_DIR } else { if($env:USERPROFILE){ - "$env:USERPROFILE\.jabba" + "$env:USERPROFILE" + $sep + ".jabba" }else{ - "$env:HOME\.jabba" + "$env:HOME" + $sep + ".jabba" } } } @@ -43,11 +44,11 @@ if ($env:JABBA_MAKE_INSTALL -eq "true") else { # $isOnWindows, see top of the file - # MacOSX enum value: 6 + # MacOSX enum value: 4 if($isOnWindows){ Invoke-WebRequest https://github.com/shyiko/jabba/releases/download/$jabbaVersion/jabba-$jabbaVersion-windows-amd64.exe -UseBasicParsing -OutFile $jabbaHome/bin/$jabbaExecutableName } - elseif([System.Environment]::OSVersion.Platform.value__ -eq 6){ + elseif([System.Environment]::OSVersion.Platform.value__ -eq 4){ Invoke-WebRequest https://github.com/shyiko/jabba/releases/download/$jabbaVersion/jabba-$jabbaVersion-darwin-amd64 -UseBasicParsing -OutFile $jabbaHome/bin/$jabbaExecutableName }else{ $osArch = [System.Environment]::Is64BitOperatingSystem ? "amd64" : "386" @@ -58,17 +59,18 @@ else $ErrorActionPreference="SilentlyContinue" if($isOnWindows){ - & $jabbaHome\bin\jabba --version | Out-Null -} -else{ - & $jabbaHome\bin\jabba.exe --version | Out-Null + & "$jabbaHome\bin\$jabbaExecutableName" --version | Out-Null +}else{ + chmod a+x "$jabbaHome/bin/$jabbaExecutableName" + & "$jabbaHome/bin/$jabbaExecutableName" --version | Out-Null } + $binaryValid = $? $ErrorActionPreference="Continue" if (-not $binaryValid) { - Write-Host @" -$jabbaHome\bin\jabba does not appear to be a valid binary. + Write-Host -ForegroundColor Yellow @" +$jabbaHome\bin\$jabbaExecutableName does not appear to be a valid binary. Check your Internet connection / proxy settings and try again. if the problem persists - please create a ticket at https://github.com/shyiko/jabba/issues. From 5a040a3e393f529b1bcf92488f78fe36230e0c96 Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Tue, 2 Nov 2021 15:57:07 +0100 Subject: [PATCH 3/4] Update readme to include pwsh for unix based systems --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 879e5a2..f52be6d 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,14 @@ Make sure to source `jabba.sh` in your environment if you skip it: ```sh [ -s "$JABBA_HOME/jabba.sh" ] && source "$JABBA_HOME/jabba.sh" ``` +> (in powershell) + +```powershell +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +Invoke-Expression ( + Invoke-WebRequest https://github.com/shyiko/jabba/raw/master/install.ps1 -UseBasicParsing +).Content +``` > In [fish](https://fishshell.com/) command looks a little bit different - `curl -sL https://github.com/shyiko/jabba/raw/master/install.sh | bash; and . ~/.jabba/jabba.fish` From eedc1c62b00778e8d96333d9ee7514e2704ca3e8 Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Tue, 2 Nov 2021 15:57:45 +0100 Subject: [PATCH 4/4] Make macOS check more inclusive --- install.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install.ps1 b/install.ps1 index d41ef07..4912d4b 100644 --- a/install.ps1 +++ b/install.ps1 @@ -44,11 +44,12 @@ if ($env:JABBA_MAKE_INSTALL -eq "true") else { # $isOnWindows, see top of the file - # MacOSX enum value: 4 + # macOS enum value: 6 + # Unix enum value: 4 if($isOnWindows){ Invoke-WebRequest https://github.com/shyiko/jabba/releases/download/$jabbaVersion/jabba-$jabbaVersion-windows-amd64.exe -UseBasicParsing -OutFile $jabbaHome/bin/$jabbaExecutableName } - elseif([System.Environment]::OSVersion.Platform.value__ -eq 4){ + elseif([System.Environment]::OSVersion.Platform.value__ -eq 4 || [System.Environment]::OSVersion.Platform.value__ -eq 6){ Invoke-WebRequest https://github.com/shyiko/jabba/releases/download/$jabbaVersion/jabba-$jabbaVersion-darwin-amd64 -UseBasicParsing -OutFile $jabbaHome/bin/$jabbaExecutableName }else{ $osArch = [System.Environment]::Is64BitOperatingSystem ? "amd64" : "386"