Make user functions more robust

This commit is contained in:
2023-04-07 10:37:03 -04:00
parent 1bde2a2478
commit 49365cb712
3 changed files with 11 additions and 12 deletions

View File

@@ -9,13 +9,12 @@
ask_ok() {
read -r -p "$* [y/N]: " response
response=${response,,}
[[ ! "$response" =~ ^(yes|y)$ ]] && return 1
return 0
[[ "$response" =~ ^(yes|y)$ ]]
}
is_root() {
user=$(whoami)
[[ $user != "root" ]] && echo "Script must be run with sudo rights!" && exit 1
[[ $user != "root" ]] && echo "Script must be run with sudo" && exit 1
}