From fdf0de08c4dfc292c5eb2360163c233bf9ec6b59 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Tue, 4 Jun 2024 10:55:27 +0200 Subject: [PATCH] fix(linux): remove support for upgrade resolves #4992 as we are not able to support the upgrade command on linux as updating oh-my-posh from within itself is impossible to due a lock on the executable, unlike on darwin Windows is able to update the executable after we start the installer in the background and exit the current process --- src/cli/upgrade.go | 6 ++++++ src/upgrade/cli.go | 2 ++ src/upgrade/{cli_unix.go => cli_darwin.go} | 2 -- src/upgrade/cli_other.go | 5 +++++ 4 files changed, 13 insertions(+), 2 deletions(-) rename src/upgrade/{cli_unix.go => cli_darwin.go} (97%) create mode 100644 src/upgrade/cli_other.go diff --git a/src/cli/upgrade.go b/src/cli/upgrade.go index 4170328dc1a5..65ce2e3a2bb1 100644 --- a/src/cli/upgrade.go +++ b/src/cli/upgrade.go @@ -2,6 +2,7 @@ package cli import ( "fmt" + "runtime" "github.com/jandedobbeleer/oh-my-posh/src/platform" "github.com/jandedobbeleer/oh-my-posh/src/upgrade" @@ -17,6 +18,11 @@ var upgradeCmd = &cobra.Command{ Long: "Upgrade when a new version is available.", Args: cobra.NoArgs, Run: func(_ *cobra.Command, _ []string) { + if runtime.GOOS == platform.LINUX { + fmt.Print("\n ⚠️ upgrade is not supported on this platform\n\n") + return + } + if force { upgrade.Run() return diff --git a/src/upgrade/cli.go b/src/upgrade/cli.go index cd515b82c7fc..56055489139b 100644 --- a/src/upgrade/cli.go +++ b/src/upgrade/cli.go @@ -1,3 +1,5 @@ +//go:build windows || darwin + package upgrade import ( diff --git a/src/upgrade/cli_unix.go b/src/upgrade/cli_darwin.go similarity index 97% rename from src/upgrade/cli_unix.go rename to src/upgrade/cli_darwin.go index 661e1c8f2b45..55ffd600a2cf 100644 --- a/src/upgrade/cli_unix.go +++ b/src/upgrade/cli_darwin.go @@ -1,5 +1,3 @@ -//go:build !windows - package upgrade import ( diff --git a/src/upgrade/cli_other.go b/src/upgrade/cli_other.go new file mode 100644 index 000000000000..6f3a890678cd --- /dev/null +++ b/src/upgrade/cli_other.go @@ -0,0 +1,5 @@ +//go:build linux || freebsd || openbsd + +package upgrade + +func Run() {}