mirror of
https://github.com/Alexandre1a/GoSH.git
synced 2026-03-09 19:19:46 +01:00
Fixed a problem with 'ghosting' in the shell
This commit is contained in:
parent
b59fb4bf51
commit
5c2adeb8ec
9
main.go
9
main.go
@ -189,22 +189,31 @@ func execInput(input string) error {
|
||||
cmd := exec.Command(args[0], args[1:]...)
|
||||
|
||||
if isInteractiveCommand(args[0]) {
|
||||
// Utiliser un PTY pour les commandes interactives
|
||||
ptmx, err := pty.Start(cmd)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Erreur lors du démarrage du PTY: %v", err)
|
||||
}
|
||||
defer ptmx.Close()
|
||||
|
||||
// Rediriger stdin et stdout
|
||||
go func() {
|
||||
io.Copy(ptmx, os.Stdin)
|
||||
}()
|
||||
io.Copy(os.Stdout, ptmx)
|
||||
} else {
|
||||
// Exécuter directement les commandes non interactives
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdin = os.Stdin
|
||||
|
||||
// Démarrer la commande avant d'attendre sa fin
|
||||
if err := cmd.Start(); err != nil {
|
||||
return fmt.Errorf("Erreur lors du démarrage de la commande: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Attendre la fin du processus
|
||||
if err := cmd.Wait(); err != nil {
|
||||
return fmt.Errorf("Erreur lors de l'exécution de la commande: %v", err)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user