diff options
Diffstat (limited to 'cmds/external.go')
-rw-r--r-- | cmds/external.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/cmds/external.go b/cmds/external.go index 79c73eb..748ce7d 100644 --- a/cmds/external.go +++ b/cmds/external.go @@ -9,7 +9,7 @@ import ( "gosh/global" ) -func External(args []string) { +func External(args []string) int { cmd := "" found := false for i := range global.Paths { @@ -24,9 +24,13 @@ func External(args []string) { cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - - cmd.Run() - return + + err := cmd.Run() + if exitErr, ok := err.(*exec.ExitError); ok { + return exitErr.ExitCode() + } + return 0 } fmt.Fprintf(os.Stderr, "%s: Command not found\n", args[0]) + return 1 } |