Fix set -e bug causing silent exit after valid input
- Replace all `[[ condition ]] && die` with `if/fi` — the && pattern exits silently when the condition is false under set -e - Removed -e from set flags (kept -uo pipefail), all error paths are now explicit - Declare `input` as local in ask/ask_yn/ask_choice to prevent leakage - Use `read -r input || true` to handle EOF safely - Fix ask_choice arithmetic to avoid (()) triggering exit on false Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
452a603cdf
commit
431e5493fc
3 changed files with 24 additions and 22 deletions
|
|
@ -41,7 +41,7 @@ ensure_git() {
|
|||
fi
|
||||
warn "git not found."
|
||||
ask_yn _install "Install git now?" "y"
|
||||
[[ "$_install" != "y" ]] && die "git is required."
|
||||
if [[ "$_install" != "y" ]]; then die "git is required."; fi
|
||||
install_pkg git
|
||||
command -v git &>/dev/null || die "git installation failed."
|
||||
success "git installed: $(git --version)"
|
||||
|
|
@ -69,7 +69,8 @@ ensure_container_runtime() {
|
|||
"podman (recommended)" \
|
||||
"docker"
|
||||
|
||||
case "$_runtime" in
|
||||
local runtime_choice="$_runtime"
|
||||
case "$runtime_choice" in
|
||||
podman*)
|
||||
_install_podman
|
||||
CONTAINER_CMD="podman"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue