From 905f30a5983ac38be4167f44542b646709beb3d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Geisend=C3=B6rfer?= Date: Wed, 24 Dec 2025 20:19:42 +0100 Subject: [PATCH] fix: don't inherit PROMPT_COMMAND for bash Fixes #691 --- shell.go | 10 ++++++---- tty.go | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/shell.go b/shell.go index fb836f3a..428bb496 100644 --- a/shell.go +++ b/shell.go @@ -15,15 +15,17 @@ const ( // Shell is a type that contains a prompt and the command to set up the shell. type Shell struct { - Command []string - Env []string + Command []string + Env []string + OverwriteEnv []string } // Shells contains a mapping from shell names to their Shell struct. var Shells = map[string]Shell{ bash: { - Env: []string{"PS1=\\[\\e[38;2;90;86;224m\\]> \\[\\e[0m\\]", "BASH_SILENCE_DEPRECATION_WARNING=1"}, - Command: []string{"bash", "--noprofile", "--norc", "--login", "+o", "history"}, + Env: []string{"PS1=\\[\\e[38;2;90;86;224m\\]> \\[\\e[0m\\]", "BASH_SILENCE_DEPRECATION_WARNING=1"}, + Command: []string{"bash", "--noprofile", "--norc", "--login", "+o", "history"}, + OverwriteEnv: []string{"PROMPT_COMMAND="}, }, zsh: { Env: []string{`PROMPT=%F{#5B56E0}> %F{reset_color}`}, diff --git a/tty.go b/tty.go index b32d19ff..6a31810d 100644 --- a/tty.go +++ b/tty.go @@ -40,7 +40,7 @@ func buildTtyCmd(port int, shell Shell) *exec.Cmd { cmd := exec.Command("ttyd", args...) if shell.Env != nil { - cmd.Env = append(shell.Env, os.Environ()...) + cmd.Env = append(append(shell.Env, os.Environ()...), shell.OverwriteEnv...) } return cmd }