non-interactive --yes: ask() assumes prompt default (no read); timezone defaults UTC; --username implies force-create; create-user name defaults to mk under --yes

This commit is contained in:
mk committed 2026-07-28 05:21:23 +03:00
1 parent 34137d185e
commit 8930e7aa76
3 files changed
+99 -4

No files matched your search

+6
View File
@@ -2,9 +2,15 @@
# prompt.sh — plain y/N prompts.
# ask "prompt?" [default y|n] -> sets REPLY
# Under ${ALL:-0} (the --yes flag) assume the stated default without
# reading stdin, so a fully non-interactive run never blocks on a read.
ask() {
local p="$1" d="${2:-y}" hint
if [[ "$d" == "y" ]]; then hint="[Y/n]"; else hint="[y/N]"; fi
if (( ${ALL:-0} )); then
REPLY="$d"
return
fi
read -rp "$p $hint " REPLY
[[ -z "$REPLY" ]] && REPLY="$d"
}