#!/usr/bin/env bash parseparams() { while getopts "hy" opt; do case "${opt}" in y) Y=true ;; *) usage ;; esac done shift $((OPTIND-1)) } config() { YES_ALL=${Y:-false} if [ "$(whoami)" = "root" ] then echo "It is not recommended to run this script as root. As a normal user, elevation will be prompted if needed." [[ "$YES_ALL" = "true" ]] && confirm="y" || read -rp "Continue anyway? (Y/n) " confirm &2 exit 1 } function trap_ctrlc() { echo "Ctrl^C, exiting..." exit 2 } upgrade_redis() { parseparams "$@" config [[ "$YES_ALL" = "true" ]] && confirm="y" || read -rp "Continue with upgrading? (y/N) " confirm