Created
March 23, 2023 15:08
-
-
Save Sanix-Darker/2f907ce43f474bc7eede8c895dc50330 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# a confirm check before executing anything | |
# _confirm "your message" your command there | |
_confirm(){ | |
args=("${@}") | |
if [[ $NOTINTERACTIVE = "1" ]]; then | |
echo -e "\n$BLUE[+] ${args[0]} $COLOROFF" | |
callback=${args[@]:1} | |
$callback | |
else | |
echo -e "\n$BLUE[-] ${args[0]} $COLOROFF" | |
read -p "[?] (Y/y): " -n 1 -r | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
clear | |
echo -e "\n$BLUE[+] ${args[0]} $COLOROFF" | |
callback=${args[@]:1} | |
# echo ">>" $callback | |
$callback | |
echo -e "\n$BWHITE-----------------------------------------------------------------$COLOROFF" | |
fi | |
fi | |
echo | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment