Skip to content

Commit 5cb2d2f

Browse files
hxnykmcastorina
andauthored
handle relative paths (#3967)
Co-authored-by: mcastorina <[email protected]>
1 parent 8710c45 commit 5cb2d2f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,29 @@ func init() {
269269
// Support -h for help
270270
cli.HelpFlag.Short('h')
271271

272+
// Check if the TUI environment variable is set.
273+
if ok, err := strconv.ParseBool(os.Getenv("TUI_PARENT")); err == nil {
274+
usingTUI = ok
275+
}
276+
272277
if isatty.IsTerminal(os.Stdout.Fd()) && (len(os.Args) <= 1 || os.Args[1] == analyzeCmd.FullCommand()) {
273278
args := tui.Run(os.Args[1:])
274279
if len(args) == 0 {
275280
os.Exit(0)
276281
}
277282

283+
binary, err := exec.LookPath("sh")
284+
if err == nil {
285+
// On success, this call will never return. On failure, fallthrough
286+
// to overwriting os.Args.
287+
cmd := strings.Join(append(os.Args[:1], args...), " ")
288+
_ = syscall.Exec(binary, []string{"sh", "-c", cmd}, append(os.Environ(), "TUI_PARENT=true"))
289+
}
290+
278291
// Overwrite the Args slice so overseer works properly.
279292
os.Args = os.Args[:1]
280293
os.Args = append(os.Args, args...)
294+
281295
usingTUI = true
282296
}
283297

0 commit comments

Comments
 (0)