Skip to content

Commit ff7c935

Browse files
zdykstraahesford
andcommitted
zfsbootmenu-core.sh: fix instant timed prompts
bin/zfsbootmenu cheats and passes a timeout of 0 seconds, which is an instant timeout / success. Protect that value and restrict infinite timeouts to negative numbers entirely. Co-authored-by: Zach Dykstra <[email protected]> Co-authored-by: Andrew J. Hesford <[email protected]>
1 parent c3a2808 commit ff7c935

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

zfsbootmenu/bin/zfsbootmenu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ unset src sources
2828
mkdir -p "${BASE:=/zfsbootmenu}"
2929

3030
while [ ! -e "${BASE}/initialized" ]; do
31-
if ! timed_prompt -d 0 \
31+
if ! timed_prompt -d -1 \
3232
-m "$( colorize red "ZFSBootMenu must be initialized to continue" )" \
3333
-r "initialize" \
3434
-e "abort "; then

zfsbootmenu/lib/zfsbootmenu-core.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@ has_resume_device() {
12631263
}
12641264

12651265
# getopts arguments:
1266-
# -d prompt countdown/delay; non-positive values will wait forever
1266+
# -d prompt countdown/delay; negative values will wait forever
12671267
# -p prompt with countdown timer (use %0.Xd as a placeholder for time)
12681268
# -m+ message to be printed above the prompt, usable multiple times
12691269
# -r message to be prefixed with [RETURN] (accept)
@@ -1281,9 +1281,11 @@ timed_prompt() {
12811281
delay="${OPTARG:-0}"
12821282
if [ "${delay}" -gt 0 ] >/dev/null 2>&1; then
12831283
:
1284-
elif [ "${delay}" -le 0 ] >/dev/null 2>&1; then
1284+
elif [ "${delay}" -lt 0 ] >/dev/null 2>&1; then
12851285
delay="30"
12861286
infinite="yes"
1287+
elif [ "${delay}" -eq 0 ] >/dev/null 2>&1; then
1288+
return 0
12871289
else
12881290
zdebug "delay argument for timed_prompt is not numeric"
12891291
return 0

0 commit comments

Comments
 (0)