Menu

#5 Improve reg.sh with Error output

1.0
closed
nobody
None
2015-06-23
2015-06-19
Jens Lucius
No

As it is not very nice to look at run.out for every output (and it gets overwritten) here is a suggestion for improving output on reg.sh:

checkSuccess()
{
if [ $1 -ne 0 ]; then
    echo " ERROR: $2" 
    exit 1
else
    echo " INFO: $2"
fi

}

checkFailure()
{
if [ $1 -eq 0 ]; then
    echo " ERROR: $2"
    exit 1
else
    echo " INFO: $2"
fi

Example for functions:

echo "Startup"
OUTPUTMSG="$(./startup -c 2>&1)"
checkSuccess $? "$OUTPUTMSG"

As reg.sh does stop for me after the second test it should be tested if this works correctly.

Discussion

  • Jens Lucius

    Jens Lucius - 2015-06-19

    If this works correctly I can also post a patch to change all functions.

     
  • Ken Goldman

    Ken Goldman - 2015-06-19

    I just added a "cat run.out" on error to the check functions. I think it does the same thing.

    I intentionally stop on error.

    1 - It's a pass/fail script.
    2 - Typically, when it fails, I want to debug from that point. I usually cut and paste the failing line and rerun with -v.
    3 - One failure will likely cause failures in subsequent tests. Error handling would be far too complex for this script's purpose.

     
  • Ken Goldman

    Ken Goldman - 2015-06-23
    • status: open --> closed
     

Log in to post a comment.