Reputation: 329
I have a function like this
function backup {
do_backup
printf "success"
do_more_backup
echo "success"
if ... ; then
echo 1
else
echo 0
fi
}
And I have a conditional statement like that
if [[ ! $(backup) ]]; then
...
I can't get the output from function into the shell, but it's evaluating all commands - I've checked in debug mode. I want to evaluate the function, so it does her purpose and in a meanwhile print out some log messages, then to check on exit code of this function if everything succeed. How to approach this problem in bash? And how to avoid printing out last echo, which is a status, or an exit code of a function for evaluation purposes in conditional statement.
Upvotes: 0
Views: 696