stylemistake / runner

Simple, lightweight task runner for Bash.
Other
166 stars 15 forks source link

It doesn't catch exit code #39

Closed oshliaer closed 3 years ago

oshliaer commented 3 years ago

runnerfile

#!/usr/bin/env bash

cd "$(dirname "$0")" || exit
source ./runner

task_bar() {
    exit 0
}

invocation

$> ./runnerfile bar
[10:38:51.574] Starting 'bar'...

There is no 'Finished' log

How can I settings this for valid fulfilled invocation?

stylemistake commented 3 years ago

You are exiting in the middle of the task, so that's expected. What you want is "return".

oshliaer commented 3 years ago

I would like to go back up the call stack. Maybe I can pass some value to the script or should I use conditional branching?

I look at the code of runner and I realize that I cannot interrupt the script with exit.

stylemistake commented 3 years ago

If you return a non-zero value, task will fail and bring all other dependent tasks down. You can also use set -e, but i'm not sure how that behaves on current master.

oshliaer commented 3 years ago

Thank you!

It's expected for me now.

So in general it's a good app!