Skip to content

Commit

Permalink
cleaning temporary files in missions
Browse files Browse the repository at this point in the history
a couple of missions didn't clean after themselves
  • Loading branch information
phyver committed May 8, 2024
1 parent 6e8b4ed commit 6b2d814
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 23 deletions.
6 changes: 4 additions & 2 deletions missions/intermediate/04_bg_xeyes/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ _mission_check() {
then
echo "$(gettext "There is no 'xeyes' process running.")"
ps -e | awk '/xeyes/ {print $1}' | xargs kill -9 2> /dev/null
false
rm -f "$tmp_file"
return 1
else
true
rm -f "$tmp_file"
return 0
fi
}

Expand Down
2 changes: 2 additions & 0 deletions missions/processes/00_shared/init.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env sh

trap 'rm -f "$GSH_TMP/test-proc-name"' EXIT

# use a subshell, that should guarantee that no message is displayed when the
# test-proc-name process is killed.
_mission_init() (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env sh

rm -f "$GSH_TMP/secret_key"
rm -f "$GSH_TMP/secret_key" "$GSH_TMP/merlin"
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,30 @@ _mission_init() (
if [ -n "$CC" ]
then

(
# in debug mode, don't hide messages
if [ "$GSH_MODE" != DEBUG ] || [ -z "$GSH_VERBOSE_DEBUG" ]
then
exec 1>/dev/null
exec 2>/dev/null
fi
if ! [ -x "$GSH_TMP/merlin" ]
then
(
# in debug mode, don't hide messages
if [ "$GSH_MODE" != DEBUG ] || [ -z "$GSH_VERBOSE_DEBUG" ]
then
exec 1>/dev/null
exec 2>/dev/null
fi

# under BSD, libintl is installed in /usr/local and we need to pass
# "-lintl" to the compiler, so we have to try several things!
{
echo "GSH: compiling merlin.c, first try" >&2
echo $CC "$MISSION_DIR/merlin.c" -o "$GSH_TMP/merlin"
$CC "$MISSION_DIR/merlin.c" -o "$GSH_TMP/merlin"
} ||
{
echo "GSH: compiling merlin.c, second try"
echo $CC -I/usr/local/include/ -L/usr/local/lib "$MISSION_DIR/merlin.c" -lintl -o "$GSH_TMP/merlin"
$CC -I/usr/local/include/ -L/usr/local/lib "$MISSION_DIR/merlin.c" -lintl -o "$GSH_TMP/merlin"
}
) || { echo "compilation failed" >&2; return 1; }
# under BSD, libintl is installed in /usr/local and we need to pass
# "-lintl" to the compiler, so we have to try several things!
{
echo "GSH: compiling merlin.c, first try" >&2
echo $CC "$MISSION_DIR/merlin.c" -o "$GSH_TMP/merlin"
$CC "$MISSION_DIR/merlin.c" -o "$GSH_TMP/merlin"
} ||
{
echo "GSH: compiling merlin.c, second try"
echo $CC -I/usr/local/include/ -L/usr/local/lib "$MISSION_DIR/merlin.c" -lintl -o "$GSH_TMP/merlin"
$CC -I/usr/local/include/ -L/usr/local/lib "$MISSION_DIR/merlin.c" -lintl -o "$GSH_TMP/merlin"
}
) || { echo "compilation failed" >&2; return 1; }
fi
copy_bin "$GSH_TMP/merlin" "$(eval_gettext '$GSH_HOME/Castle/Observatory')/merlin"
else
copy_bin "$MISSION_DIR"/merlin.sh "$(eval_gettext '$GSH_HOME/Castle/Observatory')/merlin"
Expand Down

0 comments on commit 6b2d814

Please sign in to comment.