Allow hookecho to exit with codes other than 0

This commit is contained in:
Greg Dubicki 2017-11-11 21:05:36 +01:00
parent a40fba5e29
commit 0d3d29055b
2 changed files with 12 additions and 0 deletions

View file

@ -6,6 +6,7 @@ import (
"fmt"
"os"
"strings"
"strconv"
)
func main() {
@ -23,4 +24,14 @@ func main() {
if len(env) > 0 {
fmt.Printf("env: %s\n", strings.Join(env, " "))
}
if (len(os.Args) > 1) && (strings.HasPrefix(os.Args[1], "exit=")) {
exit_code_str := os.Args[1][5:]
exit_code, err := strconv.Atoi(exit_code_str)
if err != nil {
fmt.Printf("Exit code %s not an int!", exit_code_str)
os.Exit(-1)
}
os.Exit(exit_code)
}
}