Files
debos/debug.go
Denis Pynkin ffa64473a5 debug: run interactive shell on error
Launch interactive shell in context of failed action for issues
investigation and debug.

Add options to debos:
--debug-shell -- to start a shell in case of any failure
--shell <path> -- use selected shell instead of default bash

Fixes #30

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
2017-10-25 15:23:16 +03:00

32 lines
567 B
Go

package debos
import (
"fmt"
"log"
"os"
)
/*
DebugShell function launches an interactive shell for
debug and problems investigation.
*/
func DebugShell(context DebosContext) {
if len(context.DebugShell) == 0 {
return
}
pa := os.ProcAttr{
Files: []*os.File{os.Stdin, os.Stdout, os.Stderr},
Dir: context.Scratchdir,
}
// Start an interactive shell for debug.
log.Printf(">>> Starting a debug shell")
if proc, err := os.StartProcess(context.DebugShell, []string{}, &pa); err != nil {
fmt.Printf("Failed: %s\n", err)
} else {
proc.Wait()
}
}