Skip to content

Commit

Permalink
cleaning some temporary files in gameshell
Browse files Browse the repository at this point in the history
I'm not sure why, but even after this commit, while running in debug
mode, some temporary environment files (the "env_before" and "env_after"
files) still do not get deleted.
  • Loading branch information
phyver committed May 8, 2024
1 parent 3284a0a commit 6e8b4ed
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/bin_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ test_mktemp() (
if ! tmp=$(mktemp 2>/dev/null)
then
echo "Error: command 'mktemp' not working." >&2
rm -f "$tmp"
return 1
fi
if [ -z "$tmp" ]
then
echo "Error: command 'mktemp' returned the empty string." >&2
rm -f "$tmp"
return 1
fi
rm -f "$tmp"
Expand Down
4 changes: 3 additions & 1 deletion lib/gsh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,14 @@ __gsh_start() {
then
echo "$(gettext "Error: no mission was found!
Aborting.")" >&2
rm -f "$env_before" "$env_after"
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))"
rm -f "$env_before" "$env_after"
return
fi
unset GSH_CANCELLED
Expand All @@ -281,10 +283,10 @@ Aborting.")" >&2
Run the command
\$ gsh reset
to make sure the mission is initialized properly.")" >&2
rm -f "$env_before" "$env_after"
fi
fi
fi
rm -f "$env_before" "$env_after"

__log_action "$MISSION_NB" "START"

Expand Down
2 changes: 1 addition & 1 deletion lib/gshrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if [ -s "$tempfile" ]
then
export PAGER=more
fi
rm -f "$mktemp"
rm -f "$tempfile"

# try to prevent using sudo and similar
su() {
Expand Down

0 comments on commit 6e8b4ed

Please sign in to comment.