Bash if: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
No edit summary
Line 17: Line 17:
fi
fi


</pre>
Example:
<pre>
function my-test() {
}
if my-test; then
    echo "my-test() returned 0"
else
    echo "my-test() returned non-0"
fi
</pre>
</pre>

Revision as of 23:41, 4 September 2016

Internal

Overview


if <command-that-returns-0-or-non-0>; then
    #
    # execute this is the command returned 0
    #
else
    #
    # execute this is the command returned non-0
    #
fi

Example:

function my-test() {
}

if my-test; then
    echo "my-test() returned 0"
else
    echo "my-test() returned non-0"
fi