fix: gen_secret SIGPIPE crash with set -o pipefail

tr/head pipe causes SIGPIPE exit 141, killing script silently.
Wrap with set +o pipefail guard.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vadym Samoilenko 2026-02-23 13:46:01 +00:00
parent fc4688cc6f
commit 986bbd5a3c

View file

@ -34,8 +34,13 @@ header(){ echo -e "\n${BOLD}${CYAN}═══════════════
# ─── Helpers ──────────────────────────────────────────────────────────────────
gen_secret() {
# Generate a random string of given length (default 64)
# set +o pipefail to prevent SIGPIPE from tr being treated as an error
local len="${1:-64}"
LC_ALL=C tr -dc 'A-Za-z0-9!@#%^&*()-_=+' </dev/urandom | head -c "$len"
local result
set +o pipefail
result=$(LC_ALL=C tr -dc 'A-Za-z0-9@#%^_=+' </dev/urandom | head -c "$len")
set -o pipefail
printf '%s' "$result"
}
prompt_with_default() {