: (colon)

Null command — does nothing, always succeeds.

Source: src/execution/builtins.f90:155-157

Synopsis

: [arguments]

Description

The colon builtin is the POSIX null command. It does nothing and always returns success. Any arguments are silently ignored (though they are still subject to expansion).

Common Uses

Infinite loops

while :; do
    echo "running..."
    sleep 1
done

No-op placeholder

if [[ "$DEBUG" == "true" ]]; then
    set -x
else
    :    # Do nothing
fi

Variable expansion side effects

: "${HOME:=/home/default}"    # Set HOME if unset
: "${1:?Missing argument}"    # Error if $1 is unset

Empty function body

placeholder_func() {
    :
}

Exit Status

StatusCondition
0Always

See Also

  • test - Evaluate conditional expressions