From 81916d0f02b33ccba8d7de460de1f7c57caae0b0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 16 Nov 2022 17:44:21 +0530 Subject: [PATCH] Finish implementation of update-self --- tools/cmd/update_self/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/cmd/update_self/main.go b/tools/cmd/update_self/main.go index e36cb1171..27b861d9d 100644 --- a/tools/cmd/update_self/main.go +++ b/tools/cmd/update_self/main.go @@ -4,6 +4,7 @@ package update_self import ( "fmt" + "kitty" "os" "path/filepath" "runtime" @@ -12,6 +13,8 @@ import ( "kitty/tools/tty" "kitty/tools/tui" "kitty/tools/utils" + + "golang.org/x/sys/unix" ) var _ = fmt.Print @@ -38,6 +41,9 @@ func update_self(version string) (err error) { if err != nil { return err } + if !kitty.IsStandaloneBuild { + return fmt.Errorf("This is not a standalone kitty-tool executable. You must update all of kitty instead.") + } rv := "v" + version if version == "nightly" { rv = version @@ -68,7 +74,8 @@ func update_self(version string) (err error) { return err } } - return + fmt.Print("Updated to: ") + return unix.Exec(exe, []string{"kitty-tool", "--version"}, os.Environ()) } func EntryPoint(root *cli.Command) {