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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ func configurePTYTerminal(ptyFile *os.File) error {
|
||||||
|
|
||||||
// Match node-pty's default behavior: keep most settings from the parent terminal
|
// Match node-pty's default behavior: keep most settings from the parent terminal
|
||||||
// but ensure proper signal handling and character processing
|
// but ensure proper signal handling and character processing
|
||||||
|
|
||||||
// Ensure proper input processing
|
// Ensure proper input processing
|
||||||
// ICRNL: Map CR to NL on input (important for Enter key)
|
// ICRNL: Map CR to NL on input (important for Enter key)
|
||||||
termios.Iflag |= unix.ICRNL
|
termios.Iflag |= unix.ICRNL
|
||||||
|
|
@ -64,7 +64,7 @@ func configurePTYTerminal(ptyFile *os.File) error {
|
||||||
termios.Cc[unix.VINTR] = 3 // Ctrl+C
|
termios.Cc[unix.VINTR] = 3 // Ctrl+C
|
||||||
termios.Cc[unix.VKILL] = 21 // Ctrl+U
|
termios.Cc[unix.VKILL] = 21 // Ctrl+U
|
||||||
termios.Cc[unix.VMIN] = 1 // Minimum characters for read
|
termios.Cc[unix.VMIN] = 1 // Minimum characters for read
|
||||||
termios.Cc[unix.VQUIT] = 28 // Ctrl+\
|
termios.Cc[unix.VQUIT] = 28 // Ctrl+\
|
||||||
termios.Cc[unix.VSUSP] = 26 // Ctrl+Z
|
termios.Cc[unix.VSUSP] = 26 // Ctrl+Z
|
||||||
termios.Cc[unix.VTIME] = 0 // Timeout for read
|
termios.Cc[unix.VTIME] = 0 // Timeout for read
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,4 @@ import "golang.org/x/sys/unix"
|
||||||
const (
|
const (
|
||||||
ioctlGetTermios = unix.TIOCGETA
|
ioctlGetTermios = unix.TIOCGETA
|
||||||
ioctlSetTermios = unix.TIOCSETA
|
ioctlSetTermios = unix.TIOCSETA
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,4 @@ import "golang.org/x/sys/unix"
|
||||||
const (
|
const (
|
||||||
ioctlGetTermios = unix.TCGETS
|
ioctlGetTermios = unix.TCGETS
|
||||||
ioctlSetTermios = unix.TCSETS
|
ioctlSetTermios = unix.TCSETS
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,4 @@ const (
|
||||||
// Default to Linux constants for other Unix systems
|
// Default to Linux constants for other Unix systems
|
||||||
ioctlGetTermios = unix.TCGETS
|
ioctlGetTermios = unix.TCGETS
|
||||||
ioctlSetTermios = unix.TCSETS
|
ioctlSetTermios = unix.TCSETS
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue