mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 06:51:16 +08:00
fix(installer): make prompt_yes_no bash 3.2 compatible
The helper used ${var,,} (bash 4+ lowercase parameter expansion) and
[[ =~ ]], which fail on macOS default /bin/bash (3.2.57) with:
bash: ${default,,}: bad substitution
With 'set -e' at the top of the script, that aborts the whole
installer for macOS users who don't have a newer bash on PATH.
Replace the lowercase expansions with POSIX-style case patterns
(`[yY]|[yY][eE][sS]|...`) that behave identically and parse cleanly
on bash 3.2. Verified with a 15-case behavior test on both bash 3.2
and bash 5.2 — all pass.
This commit is contained in:
@@ -128,8 +128,9 @@ prompt_yes_no() {
|
||||
local prompt_suffix
|
||||
local answer=""
|
||||
|
||||
case "${default,,}" in
|
||||
y|yes|true|1) prompt_suffix="[Y/n]" ;;
|
||||
# Use case patterns (not ${var,,}) so this works on bash 3.2 (macOS /bin/bash).
|
||||
case "$default" in
|
||||
[yY]|[yY][eE][sS]|[tT][rR][uU][eE]|1) prompt_suffix="[Y/n]" ;;
|
||||
*) prompt_suffix="[y/N]" ;;
|
||||
esac
|
||||
|
||||
@@ -144,16 +145,18 @@ prompt_yes_no() {
|
||||
|
||||
answer="${answer#"${answer%%[![:space:]]*}"}"
|
||||
answer="${answer%"${answer##*[![:space:]]}"}"
|
||||
answer="${answer,,}"
|
||||
|
||||
if [ -z "$answer" ]; then
|
||||
case "${default,,}" in
|
||||
y|yes|true|1) return 0 ;;
|
||||
case "$default" in
|
||||
[yY]|[yY][eE][sS]|[tT][rR][uU][eE]|1) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
[[ "$answer" =~ ^y(es)?$ ]]
|
||||
case "$answer" in
|
||||
[yY]|[yY][eE][sS]) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
is_termux() {
|
||||
|
||||
Reference in New Issue
Block a user