5 Commits
Author SHA1 Message Date
DragonSlayer_14andClaude Sonnet 5 950eb5d361 Refactor: Verschachtelung im Ollama-Speicherort-Dialog reduziert
Der whiptail-Zweig verschachtelte vier Ebenen tief und verteilte drei
identische chosen="$default_path"-Zuweisungen über if/else-Paare, um
eine einzige lineare Entscheidung abzubilden. Die Ja/Nein-Abfrage und
der Eingabedialog folgen jetzt beide dem Guard-Clause-Muster
(if [[ -z "$chosen" ]]; then ... fi), das bereits für den CLI-Fallback
weiter unten in derselben Funktion verwendet wird.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WMUd2fGsPCtTCVQkSS5TA
2026-09-06 21:33:48 +02:00
DragonSlayer_14andClaude Sonnet 5 9278241dd0 Refactor: Ja/Nein-Abfrage in gemeinsame Hilfsfunktion ausgelagert
prompt_target_user und prompt_ollama_models_path implementierten die
gleiche CLI-Ja/Nein-Abfrage (read + Trim + Regex-Prüfung) unabhängig
voneinander. Beide Kopien waren bereits leicht auseinandergelaufen
(unterschiedliches Fallback-Zeichen, unterschiedliche Regex-
Reihenfolge). confirm_yes_no() bündelt die Logik an einer Stelle.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WMUd2fGsPCtTCVQkSS5TA
2026-09-06 21:32:42 +02:00
DragonSlayer_14andClaude Sonnet 5 1fa3770e6e Fix: ESC im Ollama-Speicherort-Dialog fällt auf Standardpfad zurück
whiptail liefert bei ESC den Exit-Code 255, der bisher wie ein
explizites "Nein" (Exit-Code 1) behandelt und in den Eingabedialog für
einen eigenen Pfad geleitet wurde. Das widersprach dem direkt
folgenden Eingabedialog, in dem ESC/Abbruch stattdessen den
Standardpfad übernimmt. ESC verhält sich jetzt in beiden Dialogen
gleich.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WMUd2fGsPCtTCVQkSS5TA
2026-09-06 21:31:53 +02:00
DragonSlayer_14andClaude Sonnet 5 775b03e9de Fix: Trimmen der Ja/Nein-Antwort per xargs durch sed ersetzt
xargs interpretiert Anführungszeichen/Backslashes in der Eingabe und
schlägt bei ungültiger Eingabe mit leerer Ausgabe fehl. Das ließ eine
eigentlich verneinende Antwort fälschlich als "Ja" (Standardpfad)
durchgehen. sed wird bereits an allen anderen Trim-Stellen in dieser
Funktion verwendet und kennt dieses Fehlverhalten nicht.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WMUd2fGsPCtTCVQkSS5TA
2026-09-06 21:31:38 +02:00
DragonSlayer_14andClaude Sonnet 5 d9ec12dba3 Feat: Bestätigungsabfrage vor Ollama-Speicherort-Dialog hinzufügen
prompt_ollama_models_path() fragt jetzt zuerst per Ja/Nein, ob der
konfigurierte Standard-Speicherort (OLLAMA_MODELS_DEFAULT) verwendet werden
soll - analog zum bestehenden Muster in tui_prompt_target_user(). Nur bei
"Eigenen Pfad angeben" erscheint der Eingabedialog, vorbelegt mit genau
diesem Standardpfad. Gilt für whiptail-TUI und den CLI-Fallback gleichermaßen.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WMUd2fGsPCtTCVQkSS5TA
2026-09-06 21:15:29 +02:00
+42 -11
View File
@@ -135,6 +135,23 @@ run_whiptail() {
fi
}
# Ask a yes/no question on the CLI. Returns 0 for yes, 1 for no.
# On read failure (e.g. closed stdin), falls back to default_answer.
# Usage: confirm_yes_no "<prompt>" "<y|n default answer>" "$tty_in" "$tty_out"
confirm_yes_no() {
local prompt="$1"
local default_answer="$2"
local tty_in="$3"
local tty_out="$4"
local answer=""
read -r -p "$prompt" answer < "$tty_in" > "$tty_out" 2>&1 || answer="$default_answer"
answer="$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' <<< "$answer")"
if [[ -z "$answer" ]]; then
answer="$default_answer"
fi
[[ "$answer" =~ ^[YyJj] ]]
}
# Determine and prompt for the non-root target user
prompt_target_user() {
if [[ -n "${TARGET_USER:-}" ]]; then
@@ -173,9 +190,7 @@ prompt_target_user() {
if [[ -n "$candidate" && "$candidate" != "root" ]]; then
printf "\n%bTarget User Detection:%b\n" "${CLR_CYAN}" "${CLR_RESET}" > "$tty_out"
printf "Detected target user: %b%s%b\n" "${CLR_BOLD}" "$candidate" "${CLR_RESET}" > "$tty_out"
local answer=""
read -r -p "Use target user '$candidate'? [Y/n]: " answer < "$tty_in" > "$tty_out" 2>&1 || answer="y"
if [[ -z "$answer" || "$answer" =~ ^[YyJj] ]]; then
if confirm_yes_no "Use target user '$candidate'? [Y/n]: " "y" "$tty_in" "$tty_out"; then
chosen="$candidate"
fi
fi
@@ -255,29 +270,44 @@ prompt_ollama_models_path() {
tty_out="/dev/stderr"
fi
# If whiptail is available and running on an active terminal, use whiptail dialog
# If whiptail is available and running on an active terminal, first ask
# whether the configured default path should be used, and only show
# the free-text path dialog (pre-filled with that default) if not.
if command_exists whiptail && has_tty; then
local yesno_status=0
run_whiptail --title "Ollama KI-Modelle Speicherort" \
--yes-button "Standard verwenden" --no-button "Eigenen Pfad angeben" \
--yesno "Standard-Speicherort für Ollama-Modelle:\n\n$default_path\n\nMöchtest du diesen Speicherort verwenden?" \
12 70 || yesno_status=$?
if [[ "$yesno_status" -eq 0 || "$yesno_status" -eq 255 ]]; then
# Yes, or ESC/Cancel (255) - use the configured default,
# consistent with the inputbox fallback below where an
# empty or cancelled dialog also keeps the default instead
# of asking again.
chosen="$default_path"
fi
if [[ -z "$chosen" ]]; then
local tui_tmp
tui_tmp="$(mktemp)"
if run_whiptail --output-fd 3 --title "Ollama KI-Modelle Speicherort" \
--inputbox "Bitte gib den Speicherort für die Ollama KI-Modelle an:" \
10 70 "$default_path" \
3> "$tui_tmp"; then
local tui_input
tui_input="$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' < "$tui_tmp")"
if [[ -n "$tui_input" ]]; then
chosen="$tui_input"
else
chosen="$default_path"
fi
chosen="$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' < "$tui_tmp")"
fi
rm -f "$tui_tmp"
[[ -z "$chosen" ]] && chosen="$default_path"
fi
fi
# CLI fallback if whiptail was not used or failed
if [[ -z "$chosen" ]]; then
printf "\n%bOllama KI-Modelle Speicherort:%b\n" "${CLR_CYAN}" "${CLR_RESET}" > "$tty_out"
printf "Standard-Pfad: %b%s%b\n" "${CLR_BOLD}" "$default_path" "${CLR_RESET}" > "$tty_out"
if confirm_yes_no "Standard-Speicherort verwenden? [J/n]: " "j" "$tty_in" "$tty_out"; then
chosen="$default_path"
else
local input_path=""
read -r -p "Speicherort für Ollama-Modelle eingeben [$default_path]: " input_path < "$tty_in" > "$tty_out" 2>&1 || true
input_path="$(echo "$input_path" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
@@ -287,6 +317,7 @@ prompt_ollama_models_path() {
chosen="$default_path"
fi
fi
fi
else
chosen="$default_path"
fi