Skip to content

Commit

Permalink
convert exit_code to integer in run.json
Browse files Browse the repository at this point in the history
  • Loading branch information
willr3 committed Oct 16, 2024
1 parent effe403 commit d66bc67
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/main/java/io/hyperfoil/tools/qdup/cmd/impl/Sh.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ public void postRun(String output,Context context){

//if the remove shell has exit codes and the response came from the base shell
if(context.getShell()!=null &&
context.getShell().isOpen() &&
/*SshSession.PROMPT.equals(getPreviousPrompt()) &&*/
context.getShell().isPromptShell(getPreviousPrompt()) &&
context.getShell().getHost().isShell())
context.getShell().isOpen() &&
/*SshSession.PROMPT.equals(getPreviousPrompt()) &&*/
context.getShell().isPromptShell(getPreviousPrompt()) &&
context.getShell().getHost().isShell())
{
String response = context.getShell().shSync("export __qdup_ec=$?; echo $__qdup_ec;");
// ensure the output does not contain characters from other processes
Expand All @@ -136,7 +136,17 @@ public void postRun(String output,Context context){
//trying to only run these if the previous shSync had a result to avoid deadlocking
String pwd = context.getShell().shSync("pwd");
context.setCwd(pwd);
context.getCommandTimer().getData().set("exit_code", response);
if(response.matches("\\d+")){
try {
context.getCommandTimer().getData().set("exit_code", Integer.parseInt(response));
}catch (NumberFormatException e){
//this really shouldn't happen but an un-caught exception would be catastrophic
context.getCommandTimer().getData().set("exit_code", response);
}
} else {
//well this would be a surprise but craziness can happen
context.getCommandTimer().getData().set("exit_code", response);
}
//not including this in the profile data atm
//context.getCommandTimer().getData().set("cwd", pwd);
//restore the exit code for any user exit code checking in their script
Expand Down

0 comments on commit d66bc67

Please sign in to comment.