Skip to content

Commit

Permalink
return -1 on non ExitError
Browse files Browse the repository at this point in the history
  • Loading branch information
mostlikelee committed Nov 20, 2024
1 parent 300b04d commit f446da7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions orbit/pkg/execuser/execuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func Run(path string, opts ...Option) (lastLogs string, err error) {
// It assumes the caller is running with high privileges (root on UNIX).
//
// It blocks until the child process exits.
// Non ExitError errors return with a -1 exitCode.
func RunWithOutput(path string, opts ...Option) (output []byte, exitCode int, err error) {
var o eopts
for _, fn := range opts {
Expand Down
4 changes: 2 additions & 2 deletions orbit/pkg/execuser/execuser_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func run(path string, opts eopts) (lastLogs string, err error) {
func runWithOutput(path string, opts eopts) (output []byte, exitCode int, err error) {
args, err := getUserAndDisplayArgs(path, opts)
if err != nil {
return nil, 0, fmt.Errorf("get args: %w", err)
return nil, -1, fmt.Errorf("get args: %w", err)
}

args = append(args, path)
Expand All @@ -67,7 +67,7 @@ func runWithOutput(path string, opts eopts) (output []byte, exitCode int, err er
if exitErr, ok := err.(*exec.ExitError); ok {
exitCode = exitErr.ExitCode()

Check failure on line 68 in orbit/pkg/execuser/execuser_linux.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

ineffectual assignment to exitCode (ineffassign)
}
return output, exitCode, fmt.Errorf("%q error: %w", path, err)
return output, -1, fmt.Errorf("%q error: %w", path, err)
}

return output, exitCode, nil
Expand Down
2 changes: 1 addition & 1 deletion orbit/pkg/zenity/zenity.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Zenity struct {
cmdWithWait func(ctx context.Context, args ...string) error
}

// NewZenity creates a new Zenity dialog instance for zenity v4 on Linux.
// New creates a new Zenity dialog instance for zenity v4 on Linux.
// Zenity implements the Dialog interface.
func New() *Zenity {
return &Zenity{
Expand Down

0 comments on commit f446da7

Please sign in to comment.