Skip to content

Commit be7a7ed

Browse files
committed
bug when copying the shell files for missions 29 and 30
when no compiler is found, the shell file were copied with a shebang of "#!/usr/bin/env bash", so that their names wasn't used by ps. (Instead, the processes appeared with a name of "bash")
1 parent bad0ecf commit be7a7ed

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

missions/processes/00_shared/init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ _mission_init() (
1818
"$GSH_TMP/test-proc-name" &
1919
PID=$!
2020
name=$(my_ps $PID | grep $PID | grep -v sh | grep "test-proc-name")
21-
# kill -9 $PID
21+
kill -9 $PID
2222
if [ -z "$name" ]
2323
then
2424
echo "$(eval_gettext "Process names should be equal to the corresponding filename for mission \$MISSION_NAME.")" >&2

missions/processes/01_ps_kill/init.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ _install_script() (
4646
fi
4747
mission_source "$MISSION_DIR/deps.sh" || return 1
4848

49-
cp "$MISSION_DIR/spell.sh" "$GSH_TMP/$(gettext "spell")"
50-
chmod 755 "$GSH_TMP/$(gettext "spell")"
49+
# make sure the shebang for the spell.sh script is a real path to sh
50+
# otherwise, ps will not use the filename as the process name...
51+
sh=$(command -v sh)
52+
echo "#! $sh" > "$GSH_TMP/$(gettext "spell")"
53+
cat "$MISSION_DIR/spell.sh" >> "$GSH_TMP/$(gettext "spell")"
54+
chmod +x "$GSH_TMP/$(gettext "spell")"
5155
)
5256

5357
if _compile || _install_script

missions/processes/02_ps_kill_signal/init.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env sh
22

33
_compile() (
4-
54
if command -v gcc >/dev/null
65
then
76
CC=gcc
@@ -59,9 +58,13 @@ _install_script() (
5958
return 1
6059
fi
6160
mission_source "$MISSION_DIR/deps.sh" || return 1
62-
cp "$MISSION_DIR/spell.sh" "$GSH_TMP/$(gettext "spell")"
63-
chmod 755 "$GSH_TMP/$(gettext "spell")"
64-
61+
#
62+
# make sure the shebang for the spell.sh script is a real path to sh
63+
# otherwise, ps will not use the filename as the process name...
64+
sh=$(command -v sh)
65+
echo "#! $sh" > "$GSH_TMP/$(gettext "spell")"
66+
cat "$MISSION_DIR/spell.sh" >> "$GSH_TMP/$(gettext "spell")"
67+
chmod +x "$GSH_TMP/$(gettext "spell")"
6568
)
6669

6770
if _compile || _install_script

missions/processes/03_pstree_kill/init.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env sh
22

33
_compile() (
4-
54
if ! command -v pstree >/dev/null
65
then
76
echo "$(eval_gettext "The command 'pstree' is required for mission \$MISSION_NAME.
@@ -81,21 +80,21 @@ _install_script() (
8180

8281
echo "#! $sh" > "$GSH_TMP/$(gettext "nice_fairy")"
8382
cat "$MISSION_DIR/nice_fairy.sh" >> "$GSH_TMP/$(gettext "nice_fairy")"
84-
chmod 755 "$GSH_TMP/$(gettext "nice_fairy")"
83+
chmod +x "$GSH_TMP/$(gettext "nice_fairy")"
8584

8685
mkdir -p "$GSH_TMP/fairy/"
8786
echo "#! $sh" > "$GSH_TMP/fairy/$(gettext "spell")"
8887
cat "$MISSION_DIR/fairy/spell.sh" >> "$GSH_TMP/fairy/$(gettext "spell")"
89-
chmod 755 "$GSH_TMP/fairy/$(gettext "spell")"
88+
chmod +x "$GSH_TMP/fairy/$(gettext "spell")"
9089

9190
echo "#! $sh" > "$GSH_TMP/$(gettext "mischievous_imp")"
9291
cat "$MISSION_DIR/mischievous_imp.sh" >> "$GSH_TMP/$(gettext "mischievous_imp")"
93-
chmod 755 "$GSH_TMP/$(gettext "mischievous_imp")"
92+
chmod +x "$GSH_TMP/$(gettext "mischievous_imp")"
9493

9594
mkdir -p "$GSH_TMP/imp/"
9695
echo "#! $sh" > "$GSH_TMP/imp/$(gettext "spell")"
9796
cat "$MISSION_DIR/imp/spell.sh" >> "$GSH_TMP/imp/$(gettext "spell")"
98-
chmod 755 "$GSH_TMP/imp/$(gettext "spell")"
97+
chmod +x "$GSH_TMP/imp/$(gettext "spell")"
9998
)
10099

101100

0 commit comments

Comments
 (0)