there are more other ways
the most common and cleanest way is
Code:
if program; then
echo 0/true
else
echo 1/false
fi
you can also do this
Code:
program && echo true
program && {
more statements if true
}
and also include the false parts like
Code:
program && echo true || echo false
program && {
more statements if true
} || {
more statements if false
}
but i don't recommend the last ones since sometimes the false parts are executed when the true statements return a false value
you must also note that your program should return true and false values. some programs only return true unless they are interrupted or are caught by a signal
if a program exits or is suspended because of a signal, the return value is always 128 + signal number
you can do exit codes in a bash script using exit /b # by the way