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:
parent
fc4688cc6f
commit
986bbd5a3c
1 changed files with 6 additions and 1 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue