From cfb8eebf306f7ec7206997b8862767e6e7825c43 Mon Sep 17 00:00:00 2001 From: vilmibm Date: Wed, 15 Jul 2020 11:39:48 -0500 Subject: [PATCH] quietly return exit code of external command --- cmd/gh/main.go | 7 ++++++- command/root.go | 7 +------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/gh/main.go b/cmd/gh/main.go index 2e9614a79..05c2f27bc 100644 --- a/cmd/gh/main.go +++ b/cmd/gh/main.go @@ -6,6 +6,7 @@ import ( "io" "net" "os" + "os/exec" "path" "strings" @@ -49,7 +50,11 @@ func main() { if isShell { err = command.ExecuteShellAlias(expandedArgs) if err != nil { - fmt.Fprintf(stderr, "failed to run alias %q: %s\n", expandedArgs, err) + if ee, ok := err.(*exec.ExitError); ok { + os.Exit(ee.ExitCode()) + } + + fmt.Fprintf(stderr, "failed to run external command: %s", err) os.Exit(3) } diff --git a/command/root.go b/command/root.go index 2b3aa6a4d..ddd4d9834 100644 --- a/command/root.go +++ b/command/root.go @@ -374,12 +374,7 @@ func ExecuteShellAlias(args []string) error { externalCmd.Stdin = os.Stdin preparedCmd := run.PrepareCmd(externalCmd) - err := preparedCmd.Run() - if err != nil { - return fmt.Errorf("failed to run external command: %w", err) - } - - return nil + return preparedCmd.Run() } func findSh() (string, error) {