release: install.sh accepts any y/n answer, and a non-terminal install builds the engine models

ask() takes the default on Enter or EOF, ignores whitespace, accepts any answer starting with y or n and
re-asks otherwise. Without a terminal (or with --yes) DO_ENGINE defaults to building the models.

RELEASE_NOTES.md: the install.sh engine setup, [Engine] Enabled = auto, and the FSR Ray Regeneration backend
that this build does not carry.
This commit is contained in:
woutermans committed 2026-10-14 20:50:35 +02:00
1 parent 747ac8538d
commit d9e4627e60
2 files changed
+11 -4

No files matched your search

+7 -4
View File
@@ -52,15 +52,17 @@ CACHE="${D4R_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/d4r}"
# Questions only on a terminal; otherwise (or with --yes) every default applies.
interactive() { (( YES == 0 )) && [[ -t 0 && -t 1 ]]; }
ask() { # ask "QUESTION" DEFAULT(y|n): 0 for yes
ask() { # ask "QUESTION" DEFAULT(y|n): 0 for yes. Enter takes the default; any answer starting with y or n counts.
local answer
if ! interactive; then [[ $2 == y ]]; return; fi
while true; do
read -r -p "$1 [$([[ $2 == y ]] && echo Y/n || echo y/N)] " answer || answer=''
read -r -p "$1 [$([[ $2 == y ]] && echo Y/n || echo y/N)] " answer || { echo; answer=''; }
answer="${answer//[[:space:]]/}"
case "${answer,,}" in
'') [[ $2 == y ]]; return ;;
y|yes) return 0 ;;
n|no) return 1 ;;
y*) return 0 ;;
n*) return 1 ;;
*) echo ' Please answer y or n (or press Enter for the default).' ;;
esac
done
}
@@ -182,6 +184,7 @@ if (( REBUILD == 0 )) && [[ "$DO_ENGINE" != 0 && -f "$STAMP" && "$(cat "$STAMP")
echo 'The engine models in this folder are up to date.'
done_msg; exit 0
fi
if [[ "$DO_ENGINE" == ask ]] && ! interactive; then DO_ENGINE=1; fi
if [[ "$DO_ENGINE" == ask ]]; then
echo
echo "Set up d4r's own DLSS engine (recommended)?"