bpmodify: fix os.Exit() shouldn't shadow panic()

The `defer func() { os.Exit() }()` in main() method shadows panic().
Make the exit handler recover() from panic(), log the panic(), and then
gracefully exit.

Test: m bpmodify
Change-Id: Icc89f8fce0b6096489baa0ba0f08c21d1ef623bc
This commit is contained in:
Yo Chiang 2020-03-05 19:45:49 +08:00
parent aa919ddcbb
commit 9342b43c95

View file

@ -223,7 +223,12 @@ func walkDir(path string) {
} }
func main() { func main() {
defer func() { os.Exit(exitCode) }() defer func() {
if err := recover(); err != nil {
report(fmt.Errorf("error: %s", err))
}
os.Exit(exitCode)
}()
flag.Parse() flag.Parse()