Skip to content

true, false and : commands

Terminal window
while true; do
echo ok
done

or

Terminal window
while :; do
echo ok
done

or

Terminal window
until false; do
echo ok
done
Terminal window
function positive() {
return 0
}
function negative() {
return 1
}
Terminal window
if true; then
echo Always executed
fi
if false; then
echo Never executed
fi
  • true, : - always return 0 as exit code.
  • false - always returns 1 as exit code.