Make user functions more robust
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user