Skip to content

Commit

Permalink
prevent infinite loop when all the missions are cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
phyver committed Jun 22, 2021
1 parent df6c7dd commit 4efc44b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions lib/gsh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,22 @@ __gsh_start() {

if [ "$exit_status" -ne 0 ]
then
# the GSH_CANCELLED variable keeps track of consecutive cancelled missions
# to prevent looping if all the missions are cancelled.
# It is unset on the first non-cancelled mission.
if echo "$GSH_CANCELLED" | grep -Eq ":$MISSION_NB(:|$)"
then
echo "$(gettext "Error: no mission was found!
Aborting.")" >&2
exit 1
fi
color_echo yellow "$(eval_gettext "Error: mission \$MISSION_NB is cancelled because some dependencies are not met.")" >&2
GSH_CANCELLED=$GSH_CANCELLED:$MISSION_NB
__log_action "$MISSION_NB" "CANCEL_DEP_PB"
__gsh_start "$((MISSION_NB + 1))"
return
fi
unset GSH_CANCELLED

if ! . mainshell.sh
then
Expand Down
4 changes: 2 additions & 2 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Do you want to remove it and start a new game? [y/N]') "
# hide cursor and disable echoing of keystrokes
tput civis 2>/dev/null
stty -echo 2>/dev/null
trap "tput cnorm 2>/dev/null; stty echo 2>/dev/null; echo" INT TERM
trap "tput cnorm 2>/dev/null; stty echo 2>/dev/null; echo" INT TERM EXIT


# remove all the game data
Expand Down Expand Up @@ -380,7 +380,7 @@ Do you want to remove it and start a new game? [y/N]') "
if [ "$MISSION_NB" -eq 1 ]
then
echo "$(gettext "Error: no mission was found!
Aborting.")"
Aborting.")" >&2
exit 1
fi
if [ "$GSH_MODE" = "DEBUG" ]
Expand Down

0 comments on commit 4efc44b

Please sign in to comment.