Skip to content

Commit

Permalink
deploy.sh: only proceed with prompt if y/N
Browse files Browse the repository at this point in the history
and not if any other character is used (like ENTER or other)
  • Loading branch information
mraveux authored and sisou committed Dec 11, 2024
1 parent e83420f commit fa4080a
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,19 @@ confirm_prompt() {
return 0
fi

echo -e "${YELLOW}${prompt_message}${NC}"
read -n 1 -r
echo # Move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo -e "${RED}Operation cancelled.${NC}"
exit 1
fi
while true; do
echo -e "${YELLOW}${prompt_message}${NC}"
read -n 1 -r
echo # Move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
return 0
elif [[ $REPLY =~ ^[Nn]$ ]]; then
echo -e "${RED}Operation cancelled.${NC}"
exit 1
fi
# If neither Y/y nor N/n was pressed, continue the loop
echo -e "${YELLOW}Please answer 'y' or 'n'${NC}"
done
}

# Function to handle SSH deployment
Expand Down

0 comments on commit fa4080a

Please sign in to comment.