mirror of
https://github.com/Alexandre1a/GoSH.git
synced 2026-03-10 03:29:47 +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:]...)
|
cmd := exec.Command(args[0], args[1:]...)
|
||||||
|
|
||||||
if isInteractiveCommand(args[0]) {
|
if isInteractiveCommand(args[0]) {
|
||||||
|
// Utiliser un PTY pour les commandes interactives
|
||||||
ptmx, err := pty.Start(cmd)
|
ptmx, err := pty.Start(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Erreur lors du démarrage du PTY: %v", err)
|
return fmt.Errorf("Erreur lors du démarrage du PTY: %v", err)
|
||||||
}
|
}
|
||||||
defer ptmx.Close()
|
defer ptmx.Close()
|
||||||
|
|
||||||
|
// Rediriger stdin et stdout
|
||||||
go func() {
|
go func() {
|
||||||
io.Copy(ptmx, os.Stdin)
|
io.Copy(ptmx, os.Stdin)
|
||||||
}()
|
}()
|
||||||
io.Copy(os.Stdout, ptmx)
|
io.Copy(os.Stdout, ptmx)
|
||||||
} else {
|
} else {
|
||||||
|
// Exécuter directement les commandes non interactives
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
cmd.Stdin = os.Stdin
|
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 {
|
if err := cmd.Wait(); err != nil {
|
||||||
return fmt.Errorf("Erreur lors de l'exécution de la commande: %v", err)
|
return fmt.Errorf("Erreur lors de l'exécution de la commande: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user