From 050127f50d6d84e71bd4d9f0feb5168a48ef2932 Mon Sep 17 00:00:00 2001 From: intergrav Date: Thu, 2 Jul 2026 04:29:20 -0400 Subject: [PATCH] feat: sudo-user fallback so that the shell works when running with `--system` --- cmd/restray/restic.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/restray/restic.go b/cmd/restray/restic.go index bd484e2..3e87b4c 100644 --- a/cmd/restray/restic.go +++ b/cmd/restray/restic.go @@ -69,6 +69,16 @@ func findResticFromShell() string { if runtime.GOOS == "windows" { return "" } + if sudoUser := os.Getenv("SUDO_USER"); sudoUser != "" { + out, err := exec.Command("sudo", "-n", "-u", sudoUser, "-i", "which", "restic").Output() + if err == nil { + if p := strings.TrimSpace(string(out)); p != "" { + if _, err := os.Stat(p); err == nil { + return p + } + } + } + } shell := os.Getenv("SHELL") if shell == "" { if runtime.GOOS == "darwin" { -- 2.51.2