Detecting the Running Shell

Updated

October 31, 2026

Detecting the Running Shell

if [ -n "$BASH_VERSION" ]; then
    echo "Running GNU Bash version $BASH_VERSION"
elif [ -n "$ZSH_VERSION" ]; then
    echo "Running Zsh version $ZSH_VERSION"
else
    echo "Running standard POSIX /bin/sh"
fi