Add prompt to global functions
This commit is contained in:
10
functions
10
functions
@@ -5,16 +5,16 @@
|
|||||||
# Don't run this script directly
|
# Don't run this script directly
|
||||||
[[ "${BASH_SOURCE[0]}" == "${0}" ]] && exit 0
|
[[ "${BASH_SOURCE[0]}" == "${0}" ]] && exit 0
|
||||||
|
|
||||||
|
prompt() { read -pr "Enter $1: " "$1"; }
|
||||||
|
|
||||||
ask_ok() {
|
askOk() {
|
||||||
|
declare response
|
||||||
|
(( YES_SWITCH )) && return 0
|
||||||
read -r -p "$* [y/N]: " response
|
read -r -p "$* [y/N]: " response
|
||||||
response=${response,,}
|
[[ ${response,,} =~ ^(yes|y)$ ]]
|
||||||
[[ "$response" =~ ^(yes|y)$ ]]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
is_root() {
|
is_root() {
|
||||||
user=$(whoami)
|
user=$(whoami)
|
||||||
[[ $user != "root" ]] && echo "Script must be run with sudo" && exit 1
|
[[ $user != "root" ]] && echo "Script must be run with sudo" && exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user