Skip to content

Bash Shell

Overview

Snippets

Define platform type with case-when

Handle different OS with case-when by define from variable name $OSTYPE

case "$OSTYPE" in
    msys*)
        echo "Operation system: Window >"
        declare PY_CMD=python
        declare ACTIVATE_DIR=Scripts
    ;;
    linux*)
        echo "Operation system: Linux >"
        declare PY_CMD=python3
        declare ACTIVATE_DIR=bin
    ;;
    *)
        echo "Not supported for this os: '$OSTYPE'"
    ;;
esac