Skip to content

Commit 5e8c5fc

Browse files
committed
scripts: template_setup_posix: Add interactive mode user input check
This commit updates the POSIX setup script to validate the user inputs in the interactive mode. Signed-off-by: Stephanos Ioannidis <[email protected]>
1 parent be5df7f commit 5e8c5fc

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

scripts/template_setup_posix

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@ popd()
1414
command popd "$@" > /dev/null
1515
}
1616

17+
ask_yn()
18+
{
19+
local reply
20+
21+
while true; do
22+
read -n 1 -r -p "$1 [y/n]? " reply && echo
23+
24+
case "${reply}" in
25+
Y | y) return 0 ;;
26+
N | n) return 1 ;;
27+
*) echo "Invalid choice '${reply}'" ;;
28+
esac
29+
done
30+
}
31+
1732
# Display script usage
1833
usage()
1934
{
@@ -35,11 +50,8 @@ user_prompt()
3550
echo "distribution bundle archive."
3651
echo
3752

38-
read -n 1 -r -p "Register Zephyr SDK CMake package [y/n]? " yn && echo
39-
[ "${yn}" = "y" ] && do_cmake_pkg="y"
40-
41-
read -n 1 -r -p "Install host tools [y/n]? " yn && echo
42-
[ "${yn}" = "y" ] && do_hosttools="y"
53+
ask_yn "Register Zephyr SDK CMake package" && do_cmake_pkg="y"
54+
ask_yn "Install host tools" && do_hosttools="y"
4355

4456
echo
4557
}

0 commit comments

Comments
 (0)