A confirmation prompt turns a short response into an explicit decision. The script should map the response before performing the action.

Program

Play the script to choose the confirmation response and see the resulting decision.

confirm_prompt_decision.sh
#!/usr/bin/env bash

response=
case "$response" in
    y|Y) decision="apply" ;;
    *) decision="preview" ;;
esac
echo "$response -> $decision"
#!/usr/bin/env bash

response=
case "$response" in
    y|Y) decision="apply" ;;
    *) decision="preview" ;;
esac
echo "$response -> $decision"
confirmation A confirmation asks the user to approve or decline an action.
case mapping `case` maps a small set of responses to named decisions.
safe default Responses outside the approved branch should choose the safer decision.