Skip to content

Commit

Permalink
Set last exit code outside interactive mode
Browse files Browse the repository at this point in the history
Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
  • Loading branch information
t1m0thyj committed Feb 26, 2025
1 parent 87599ab commit cc3e92b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions native/golang/cmds/cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ import (
)

// HandleConsoleCommandRequest handles a ConsoleCommandRequest by invoking the `zowex console issue` command
func HandleConsoleCommandRequest(_conn utils.StdioConn, params []byte) (result any, e error) {
func HandleConsoleCommandRequest(conn utils.StdioConn, params []byte) (result any, e error) {
request, err := utils.ParseCommandRequest[cmdTypes.IssueConsoleRequest](params)
if err != nil {
return nil, err
}

args := []string{"console", "issue", request.CommandText, "--cn", request.ConsoleName}
out, err := utils.BuildCommandAuthorized(args).Output()
cmd := utils.BuildCommandAuthorized(args)
out, err := cmd.Output()
if err != nil {
e = fmt.Errorf("Failed to execute command: %v", err)
*conn.LastExitCode = cmd.ProcessState.ExitCode()
return
}

Expand Down
3 changes: 2 additions & 1 deletion native/golang/cmds/ds.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func HandleReadDatasetRequest(conn utils.StdioConn, params []byte) (result any,
}

// HandleWriteDatasetRequest handles a WriteDatasetRequest by invoking the `zowex data-set write` command
func HandleWriteDatasetRequest(_conn utils.StdioConn, params []byte) (result any, e error) {
func HandleWriteDatasetRequest(conn utils.StdioConn, params []byte) (result any, e error) {
request, err := utils.ParseCommandRequest[ds.WriteDatasetRequest](params)
if err != nil {
return nil, err
Expand Down Expand Up @@ -88,6 +88,7 @@ func HandleWriteDatasetRequest(_conn utils.StdioConn, params []byte) (result any
_, err = cmd.Output()
if err != nil {
e = fmt.Errorf("Failed to pipe stdin to command: %v", err)
*conn.LastExitCode = cmd.ProcessState.ExitCode()
return
}

Expand Down
1 change: 1 addition & 0 deletions native/golang/cmds/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ func HandleSubmitJclRequest(conn utils.StdioConn, params []byte) (result any, e
out, err := cmd.Output()
if err != nil {
e = fmt.Errorf("Failed to submit JCL: %v", err)
*conn.LastExitCode = cmd.ProcessState.ExitCode()
return
}

Expand Down
3 changes: 2 additions & 1 deletion native/golang/cmds/uss.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func HandleReadFileRequest(conn utils.StdioConn, params []byte) (result any, e e
}

// HandleWriteFileRequest handles a WriteFileRequest by invoking the `zowex uss write` command
func HandleWriteFileRequest(_conn utils.StdioConn, params []byte) (result any, e error) {
func HandleWriteFileRequest(conn utils.StdioConn, params []byte) (result any, e error) {
request, err := utils.ParseCommandRequest[uss.WriteFileRequest](params)
if err != nil {
return nil, err
Expand Down Expand Up @@ -142,6 +142,7 @@ func HandleWriteFileRequest(_conn utils.StdioConn, params []byte) (result any, e
_, err = cmd.Output()
if err != nil {
e = fmt.Errorf("[WriteFileRequest] Error piping stdin to command: %v", err)
*conn.LastExitCode = cmd.ProcessState.ExitCode()
return
}

Expand Down

0 comments on commit cc3e92b

Please sign in to comment.