update hy2.sh

This commit is contained in:
2026-03-19 16:06:36 +08:00
parent 7cd9d5c415
commit 7786a3e8ac

20
hy2.sh
View File

@@ -32,26 +32,12 @@ prompt_nonempty() {
local prompt="$1"
local value=""
while true; do
read -r -p "$prompt" value
read -r -p "$prompt" value < /dev/tty
if [[ -n "${value// }" ]]; then
printf '%s' "$value"
return 0
fi
yellow "输入不能为空,请重新输入。"
done
}
prompt_secret_nonempty() {
local prompt="$1"
local value=""
while true; do
read -r -s -p "$prompt" value
echo
if [[ -n "${value// }" ]]; then
printf '%s' "$value"
return 0
fi
yellow "输入不能为空,请重新输入。"
yellow "输入不能为空,请重新输入。" >&2
done
}
@@ -505,7 +491,7 @@ main() {
subdomain="${subdomain:-$default_subdomain}"
subdomain="$(printf '%s' "$subdomain" | tr 'A-Z' 'a-z' | tr -cd 'a-z0-9-')"
CF_API_TOKEN="$(prompt_secret_nonempty '请输入 Cloudflare API Token: ')"
CF_API_TOKEN="$(prompt_nonempty '请输入 Cloudflare API Token: ')"
export CF_API_TOKEN
password="$(generate_password)"