Response Yes | No Case Function

Use this boiler template to make just about any case confirmation function

#! /bin/bash

function confirm () {
    # call with a prompt string or use a default
    read -r -p "${1:-Are you sure you want to continue? [Y/n]} " response
    case $response in
        [yY][eE][sS]|[yY])
          return
            ;;
        *)
          echo "Please do not come back :)"
          exit
            ;;
    esac
}

Fill in the gaps wherever you want to add additional functions from the return prompt

Leave a Reply

RELATED POST

VirtualBox: Create vm from script

Edit a few variables prior to kicking off the script, for instance the host name in the variable VM='RHEL_6_5_5' to…

System Check before shift begins

Here is an oldie but goodie, right before my shift would begin here is a set of items to check…

Virtual Machine Manager: Error starting domain

Starting up the KVM error occurred Error starting domain: Requested operation is not valid: network 'default' is not active Locate…

Git Commands

How to initialize a Git repo: Everything starts from here. The first step is to initialize a new Git repo…