Skip to content

Commit

Permalink
cleaning _gsh_save so that it works correctly when explicitly called
Browse files Browse the repository at this point in the history
  • Loading branch information
phyver committed May 9, 2024
1 parent 1829cb3 commit 9d02cb0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion lib/gsh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ Do you still want to quit? [y/n]") "
__gsh_clean "$MISSION_NB"
[ "$GSH_MODE" != "DEBUG" ] && ! [ -d "$GSH_ROOT/.git" ] && gsh unprotect
[ -e "$GSH_ROOT/.save" ] && __save
# remove the ".save" file to make sure we don't always save from now on!
# remove the ".save" file to make sure we don't automatically save if call
# start.sh directly from the directory
rm -f "$GSH_ROOT/.save"

## NOTE: without that, calling exit in zsh doesn't work if there are running
Expand Down
18 changes: 9 additions & 9 deletions scripts/_gsh_save
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ then
exit 2
fi

case "$(cd "$(dirname "$SAVEFILE")"; pwd -P)" in
"$GSH_ROOT"*)
echo "Error: the savefile cannot be inside GameShell directory structure." >&2
exit 4
;;
esac
# case "$(cd "$(dirname "$SAVEFILE")"; pwd -P)" in
# "$GSH_ROOT"*)
# echo "Error: the savefile cannot be inside GameShell directory structure." >&2
# exit 4
# ;;
# esac


if ! [ -r "$GSH_ROOT" ]
Expand All @@ -41,14 +41,14 @@ fi
GSH_LAST_CHECKED_MISSION=$(_gsh_plm)
sed-i "s/^GSH_LAST_CHECKED_MISSION=.*/GSH_LAST_CHECKED_MISSION=$GSH_LAST_CHECKED_MISSION/" "$GSH_ROOT/lib/header.sh"

tar -zcf "$GSH_ROOT.tgz" -C "$GSH_EXEC_DIR" "$(basename "$GSH_ROOT")"
tar --exclude="$SAVEFILE.tgz" -zcf "$SAVEFILE.tgz" -C "$(dirname "$GSH_ROOT")" "$(basename "$GSH_ROOT")"
ARCHIVE_OK=$?

cat "$GSH_ROOT/lib/header.sh" "$GSH_ROOT.tgz" > "$SAVEFILE"
cat "$GSH_ROOT/lib/header.sh" "$SAVEFILE.tgz" > "$SAVEFILE"
SAVE_OK=$?
chmod +x "$SAVEFILE"

rm -f "$GSH_ROOT.tgz"
rm --system -f "$SAVEFILE.tgz"

if [ "$ARCHIVE_OK" -ne 0 ] || [ "$SAVE_OK" -ne 0 ]
then
Expand Down

0 comments on commit 9d02cb0

Please sign in to comment.