// SPDX-FileCopyrightText: Copyright The Lima Authors1// SPDX-License-Identifier: Apache-2.023package osutil45import (6"os"7"os/exec"8)910// HandleExitError calls os.Exit immediately without printing an error, only if the error is an *exec.ExitError (non-nil).11//12// The function does not call os.Exit if the error is of any other type, even if it wraps an *exec.ExitError,13// so that the caller can print the error message.14func HandleExitError(err error) {15if err == nil {16return17}1819// Do not use errors.As, because we want to match only *exec.ExitError, not wrapped ones.20// https://github.com/lima-vm/lima/pull/416821if exitErr, ok := err.(*exec.ExitError); ok {22os.Exit(exitErr.ExitCode()) //nolint:revive // it's intentional to call os.Exit in this function23return24}25}262728