mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-27 15:17:38 +00:00
fix: Run gofmt on terminal files to fix formatting
This commit is contained in:
parent
709330ccde
commit
6e2cd2abcd
5 changed files with 15 additions and 35 deletions
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue