feat(utils.sh): 添加密码输入功能
This commit is contained in:
parent
50c81fcaa3
commit
7fc4c53d78
21
utils.sh
21
utils.sh
@ -56,7 +56,7 @@ confirm_action() {
|
||||
}
|
||||
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1;
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
pkg_install() {
|
||||
@ -69,6 +69,25 @@ pkg_install() {
|
||||
fi
|
||||
}
|
||||
|
||||
read_password() {
|
||||
echo -n "Password: "
|
||||
password=""
|
||||
while IFS= read -r -s -n1 char; do
|
||||
if [[ $char == $'\0' ]]; then
|
||||
break
|
||||
elif [[ $char == $'\177' ]]; then
|
||||
if [ -n "$password" ]; then
|
||||
password=${password%?}
|
||||
echo -ne "\b \b"
|
||||
fi
|
||||
else
|
||||
password+="$char"
|
||||
echo -n "*"
|
||||
fi
|
||||
done
|
||||
echo
|
||||
}
|
||||
|
||||
# ============================================================
|
||||
|
||||
check_internet_access
|
||||
|
||||
Loading…
Reference in New Issue
Block a user