mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-07 11:35:53 +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)
|
||||
}
|
||||
|
||||
// Set up environment with filtered variables like Rust implementation
|
||||
// Only pass safe environment variables
|
||||
safeEnvVars := []string{"TERM", "SHELL", "LANG", "LC_ALL", "PATH", "USER", "HOME"}
|
||||
env := make([]string, 0)
|
||||
// Pass all environment variables like Node.js implementation does
|
||||
// This ensures terminal features, locale settings, and shell prompts work correctly
|
||||
env := os.Environ()
|
||||
|
||||
// Copy only safe environment variables from parent
|
||||
for _, v := range os.Environ() {
|
||||
parts := strings.SplitN(v, "=", 2)
|
||||
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 {
|
||||
// Override TERM if specified in session info
|
||||
termSet := false
|
||||
for i, v := range env {
|
||||
if strings.HasPrefix(v, "TERM=") {
|
||||
hasTermVar = true
|
||||
}
|
||||
if strings.HasPrefix(v, "SHELL=") {
|
||||
hasShellVar = true
|
||||
env[i] = "TERM=" + session.info.Term
|
||||
termSet = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !hasTermVar {
|
||||
if !termSet {
|
||||
env = append(env, "TERM="+session.info.Term)
|
||||
}
|
||||
if !hasShellVar {
|
||||
env = append(env, "SHELL="+cmdline[0])
|
||||
}
|
||||
|
||||
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
|
||||
// but ensure proper signal handling and character processing
|
||||
|
||||
|
||||
// Ensure proper input processing
|
||||
// ICRNL: Map CR to NL on input (important for Enter key)
|
||||
termios.Iflag |= unix.ICRNL
|
||||
|
|
@ -64,7 +64,7 @@ func configurePTYTerminal(ptyFile *os.File) error {
|
|||
termios.Cc[unix.VINTR] = 3 // Ctrl+C
|
||||
termios.Cc[unix.VKILL] = 21 // Ctrl+U
|
||||
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.VTIME] = 0 // Timeout for read
|
||||
|
||||
|
|
|
|||
|
|
@ -7,4 +7,4 @@ import "golang.org/x/sys/unix"
|
|||
const (
|
||||
ioctlGetTermios = unix.TIOCGETA
|
||||
ioctlSetTermios = unix.TIOCSETA
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -7,4 +7,4 @@ import "golang.org/x/sys/unix"
|
|||
const (
|
||||
ioctlGetTermios = unix.TCGETS
|
||||
ioctlSetTermios = unix.TCSETS
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@ const (
|
|||
// Default to Linux constants for other Unix systems
|
||||
ioctlGetTermios = unix.TCGETS
|
||||
ioctlSetTermios = unix.TCSETS
|
||||
)
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue