Skip to content

Instantly share code, notes, and snippets.

@Sanix-Darker
Created March 23, 2023 15:08
Show Gist options
  • Save Sanix-Darker/2f907ce43f474bc7eede8c895dc50330 to your computer and use it in GitHub Desktop.
Save Sanix-Darker/2f907ce43f474bc7eede8c895dc50330 to your computer and use it in GitHub Desktop.
#!/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