M
M
Maxim Kudryavtsev2016-06-20 12:00:32
linux
Maxim Kudryavtsev, 2016-06-20 12:00:32

How to get the exit code of a custom function in an IF?

Good day colleagues.
I have a bash script function like

myCustomFunc()
{
    if ; then
       echo "Some info message"
        return 0
    fi

    return 1
}

Next in the code, I need to check the exit code of this function, i.e. refund me return 0or something. According to all the instructions / guides that Google showed me, this is solved like this:
myCustomFunc
if ; then
    echo "Some success message"
fi

Question: is it possible to myCustomFuncget this function completion code immediately in IFwithout calling it first before it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2016-06-20
@kumaxim

if myCustomFunc; then
    echo "Some success message"
fi

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question