Basics of pass

pass is a Unix command that does nothing successfully. It is mainly useful as a placeholder in shell scripts.

Basic usage

pass

Produces no output and exits with status 0.

Check the exit status

pass
echo $?

Output:

0

This makes pass useful when you need a command that intentionally succeeds.

Why use pass?

Placeholder

if [ "$condition" ]; then
    pass
else
    echo "condition failed"
fi

Empty loop body

while read -r line; do
    pass
done < file.txt

No-op in a script

case "$command" in
    start)
        start_service
        ;;
    stop)
        stop_service
        ;;
    status)
        pass
        ;;
esac

pass vs :

: is the more common shell no-op:

:

For example:

if command; then
    :
fi

pass is still useful when you want the intent to be visually obvious:

if command; then
    pass
fi

Important

pass does not mean:

It simply succeeds without producing output.

true       # succeeds
false      # fails
:          # shell no-op; succeeds
pass       # no-op command; succeeds

In shell scripting, : or true is generally preferred for a no-op. pass is mainly useful when readability or an explicitly named placeholder is desired.