fix: Run gofmt on terminal files to fix formatting

This commit is contained in:
Peter Steinberger 2025-06-20 16:29:56 +02:00
parent 709330ccde
commit 6e2cd2abcd
5 changed files with 15 additions and 35 deletions

View file

@ -65,42 +65,22 @@ func NewPTY(session *Session) (*PTY, error) {
debugLog("[DEBUG] NewPTY: Set working directory to: %s", session.info.Cwd) debugLog("[DEBUG] NewPTY: Set working directory to: %s", session.info.Cwd)
} }
// Set up environment with filtered variables like Rust implementation // Pass all environment variables like Node.js implementation does
// Only pass safe environment variables // This ensures terminal features, locale settings, and shell prompts work correctly
safeEnvVars := []string{"TERM", "SHELL", "LANG", "LC_ALL", "PATH", "USER", "HOME"} env := os.Environ()
env := make([]string, 0)
// Copy only safe environment variables from parent // Override TERM if specified in session info
for _, v := range os.Environ() { termSet := false
parts := strings.SplitN(v, "=", 2) for i, v := range env {
if len(parts) == 2 {
for _, safe := range safeEnvVars {
if parts[0] == safe {
env = append(env, v)
break
}
}
}
}
// Ensure TERM and SHELL are set
hasTermVar := false
hasShellVar := false
for _, v := range env {
if strings.HasPrefix(v, "TERM=") { if strings.HasPrefix(v, "TERM=") {
hasTermVar = true env[i] = "TERM=" + session.info.Term
} termSet = true
if strings.HasPrefix(v, "SHELL=") { break
hasShellVar = true
} }
} }
if !termSet {
if !hasTermVar {
env = append(env, "TERM="+session.info.Term) env = append(env, "TERM="+session.info.Term)
} }
if !hasShellVar {
env = append(env, "SHELL="+cmdline[0])
}
cmd.Env = env cmd.Env = env