setup.sh: fix read for piped mode — detect non-interactive and skip prompt

This commit is contained in:
Ada
2026-04-06 10:25:16 -04:00
parent fd16032a91
commit 02e2c2687d

View File

@@ -34,6 +34,12 @@ if ! command -v curl &> /dev/null; then
exit 1 exit 1
fi fi
# Detect interactive vs piped mode
INTERACTIVE=true
if [ ! -t 0 ]; then
INTERACTIVE=false
fi
# Check for Docker # Check for Docker
DOCKER_INSTALLED=false DOCKER_INSTALLED=false
if command -v docker &> /dev/null; then if command -v docker &> /dev/null; then
@@ -68,13 +74,19 @@ echo "Data: SQLite database is stored in a Docker named volume."
echo " Use 'docker compose down -v' to DELETE the database." echo " Use 'docker compose down -v' to DELETE the database."
echo "" echo ""
# Confirm # Confirm (skip in non-interactive/piped mode)
echo -n "Continue? [Y/n]: " if [ "$INTERACTIVE" = "true" ]; then
read -r CONFIRM echo -n "Continue? [Y/n]: "
CONFIRM=${CONFIRM:-Y} read -r CONFIRM
if [ "$CONFIRM" != "Y" ] && [ "$CONFIRM" != "y" ]; then CONFIRM=${CONFIRM:-Y}
if [ "$CONFIRM" != "Y" ] && [ "$CONFIRM" != "y" ]; then
echo "Aborted." echo "Aborted."
exit 0 exit 0
fi
else
echo "(Running in non-interactive mode — proceeding automatically)"
echo "To interactively confirm, run: curl -sL ... | bash"
echo ""
fi fi
echo "" echo ""