Skip to content

Commit 2611f36

Browse files
committed
zfsbootmenu: clean up main loop
Rather than relying on a call to draw_be to determine if the bootenvs file is empty, the main loop should use the return code of populate_be_list to determine if any boot environments were found. The sanity checks in draw_be are still present.
1 parent 0f87c5f commit 2611f36

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

zfsbootmenu/bin/zfsbootmenu

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,19 @@ while true; do
8282
if [ "${BE_SELECTED}" -eq 0 ]; then
8383
# Populate the BE list, load any keys as necessary
8484
# If no BEs were found, remove the empty environment file
85-
populate_be_list "${BASE}/bootenvs" || rm -f "${BASE}/bootenvs"
85+
if ! populate_be_list "${BASE}/bootenvs" ; then
86+
rm -f "${BASE}/bootenvs"
8687

87-
bootenv="$( draw_be "${BASE}/bootenvs" )"
88-
ret=$?
89-
90-
if [ "${ret}" -eq 130 ]; then
91-
# No BEs were found, so print a warning and drop to the emergency shell
9288
timed_prompt -d 10 \
9389
-m "$( colorize red "No boot environments with kernels found" )" \
9490
-m "$( colorize red "Dropping to an emergency shell to allow recovery attempts" )"
9591
tput clear
9692
tput cnorm
9793
exit 1
98-
elif [ "${ret}" -ne 0 ]; then
99-
# Esc was pressed
100-
continue
10194
fi
10295

103-
# A selection was made, so split "key,selected_be" pair
96+
bootenv="$( draw_be "${BASE}/bootenvs" )" || continue
97+
10498
# shellcheck disable=SC2162
10599
IFS=, read key selected_be <<<"${bootenv}"
106100
zdebug "selected key: ${key}"

0 commit comments

Comments
 (0)