File tree Expand file tree Collapse file tree 4 files changed +17
-16
lines changed Expand file tree Collapse file tree 4 files changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -48,11 +48,11 @@ func main() {
4848 }
4949 }
5050 err := newApp ().Execute ()
51- server .StopAllExternalDrivers ()
52- osutil .HandleExitError (err )
5351 if err != nil {
54- logrus .Fatal ( err )
52+ logrus .StandardLogger (). Log ( logrus . FatalLevel , err )
5553 }
54+ server .StopAllExternalDrivers ()
55+ os .Exit (osutil .HandleExitError (err ))
5656}
5757
5858func processGlobalFlags (rootCmd * cobra.Command ) error {
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ import (
1313 "strings"
1414
1515 command "github.com/mikefarah/yq/v4/cmd"
16+ "github.com/sirupsen/logrus"
17+
18+ "github.com/lima-vm/lima/v2/pkg/osutil"
1619)
1720
1821func main () {
@@ -24,11 +27,11 @@ func main() {
2427 newArgs := []string {"eval" }
2528 cmd .SetArgs (append (newArgs , os .Args [1 :]... ))
2629 }
27- code := 0
28- if err := cmd . Execute (); err != nil {
29- code = 1
30+ err = cmd . Execute ()
31+ if err != nil {
32+ logrus . StandardLogger (). Log ( logrus . FatalLevel , err )
3033 }
31- os .Exit (code )
34+ os .Exit (osutil . HandleExitError ( err ) )
3235}
3336
3437// MaybeRunYQ runs as `yq` if the program name or first argument is `yq`.
Original file line number Diff line number Diff line change @@ -5,18 +5,17 @@ package osutil
55
66import (
77 "errors"
8- "os"
98 "os/exec"
109)
1110
12- func HandleExitError (err error ) {
11+ func HandleExitError (err error ) int {
1312 if err == nil {
14- return
13+ return 0
1514 }
1615
1716 var exitErr * exec.ExitError
1817 if errors .As (err , & exitErr ) {
19- os .Exit (exitErr .ExitCode ()) //nolint:revive // it's intentional to call os.Exit in this function
20- return
18+ return exitErr .ExitCode ()
2119 }
20+ return 1
2221}
Original file line number Diff line number Diff line change @@ -160,11 +160,10 @@ func (plugin *Plugin) Run(ctx context.Context, args []string) {
160160 cmd .Env = os .Environ ()
161161
162162 err := cmd .Run ()
163- osutil .HandleExitError (err )
164- if err == nil {
165- os .Exit (0 ) //nolint:revive // it's intentional to call os.Exit in this function
163+ if err != nil {
164+ logrus .StandardLogger ().WithError (err ).Logf (logrus .FatalLevel , "external command %q failed" , plugin .Path )
166165 }
167- logrus . Fatalf ( "external command %q failed: %v" , plugin . Path , err )
166+ os . Exit ( osutil . HandleExitError ( err )) //nolint:revive // it's intentional to call os.Exit in this function
168167}
169168
170169var descRegex = regexp .MustCompile (`<limactl-desc>(.*?)</limactl-desc>` )
You can’t perform that action at this time.
0 commit comments