Skip to content

Commit db18129

Browse files
Florent Bouchez Tichadouarthur tartempion
authored andcommitted
accepts "cd ~" for mission 3
and move back to cellar on init
1 parent 343e383 commit db18129

10 files changed

Lines changed: 141 additions & 37 deletions

File tree

missions/basic/03_cd_HOME_throne/check.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,29 @@ _mission_check() {
66
goal=$(readlink-f "$(eval_gettext "\$GSH_HOME/Castle/Main_building/Throne_room")")
77
current=$(readlink-f "$PWD")
88

9+
10+
# Verify the current location
11+
if [ "$goal" != "$current" ]; then
12+
echo "$(gettext "You are not in the throne room.")"
13+
return 1
14+
fi
15+
16+
917
ppc=$(. fc-lnr.sh | grep -v '^[[:blank:]]*gsh' | sed -n '2p;3q')
1018

11-
# FIXME: also accept other commands to go back to the starting point?
12-
# FIXME: add an error message
13-
[ "$goal" = "$current" ] && [ "$ppc" = "cd" ]
19+
if echo "$ppc" | grep -q "^[[:blank:]]*\(cd\|cd[[:blank:]][[:blank:]]*\~\)[[:blank:]]*$"; then
20+
# Accepts only "cd" and "cd ~"
21+
return 0
22+
fi
23+
24+
# "cd ../../../../" and variants are not valid.
25+
if echo "$ppc" | grep -q "^[[:blank:]]*cd[[:blank:]][[:blank:]]*\.\..*$"; then
26+
echo "$(gettext "The previous to last command is too complex.")"
27+
else
28+
echo "$(gettext "The previous to last command must take you to the starting point.")"
29+
fi
30+
31+
return 1
1432
}
1533

1634
_mission_check

missions/basic/03_cd_HOME_throne/goal/en.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Useful commands
1717
===============
1818

1919
cd
20-
Move back to the starting location.
20+
Move back to GameShell's starting location.
2121

2222
cd LOCATION1/LOCATION2/LOCATION3
2323
Make several moves in one command.

missions/basic/03_cd_HOME_throne/goal/fr.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Commandes utiles
1919
================
2020

2121
cd
22-
Revient au lieu initial.
22+
Revient au lieu de départ de GameShell.
2323

2424
cd LIEU1/LIEU2/LIEU3
2525
Fait plusieurs déplacements avec une commande.

missions/basic/03_cd_HOME_throne/i18n/en.po

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# AUTOMATICALLY GENERATED -- DO NOT EDIT
22
msgid ""
3-
msgstr "Content-Type: text/plain; charset=UTF-8\n"
3+
msgstr "Content-Type: text/plain; charset=ASCII\n"
44
"Content-Transfer-Encoding: 8bit\n"
55

66
#, sh-format
77
msgid "$GSH_HOME/Castle/Main_building/Throne_room"
88
msgstr "$GSH_HOME/Castle/Main_building/Throne_room"
99

10+
msgid "$GSH_HOME/Castle/Cellar"
11+
msgstr "$GSH_HOME/Castle/Cellar"
12+
1013
# path for the text file containing the goal
1114
msgid "$MISSION_DIR/goal/en.txt"
1215
msgstr "$MISSION_DIR/goal/en.txt"
@@ -18,3 +21,16 @@ msgstr "$MISSION_DIR/skip/en.txt"
1821
# path for the text file containing the treasure message
1922
msgid "$MISSION_DIR/treasure-msg/en.txt"
2023
msgstr "$MISSION_DIR/treasure-msg/en.txt"
24+
25+
msgid "The previous to last command is too complex."
26+
msgstr "The previous to last command is too complex."
27+
28+
msgid "The previous to last command must take you to the starting point."
29+
msgstr "The previous to last command must take you to the starting point."
30+
31+
msgid "You are not in the throne room."
32+
msgstr "You are not in the throne room."
33+
34+
#, sh-format
35+
msgid "You have been teleported to"
36+
msgstr "You have been teleported to"

missions/basic/03_cd_HOME_throne/i18n/fr.po

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ msgstr "Content-Type: text/plain; charset=UTF-8\n"
66
msgid "$GSH_HOME/Castle/Main_building/Throne_room"
77
msgstr "$GSH_HOME/Chateau/Batiment_principal/Salle_du_trone"
88

9+
msgid "$GSH_HOME/Castle/Cellar"
10+
msgstr "$GSH_HOME/Chateau/Cave"
11+
912
# path for the text file containing the goal
1013
msgid "$MISSION_DIR/goal/en.txt"
1114
msgstr "$MISSION_DIR/goal/fr.txt"
@@ -17,3 +20,16 @@ msgstr "$MISSION_DIR/skip/fr.txt"
1720
# path for the text file containing the treasure message
1821
msgid "$MISSION_DIR/treasure-msg/en.txt"
1922
msgstr "$MISSION_DIR/treasure-msg/fr.txt"
23+
24+
msgid "The previous to last command is too complex."
25+
msgstr "L'avant-dernière commande est trop complexe."
26+
27+
msgid "The previous to last command must take you to the starting point."
28+
msgstr "L'avant-dernière commande doit vous ramener au point de départ."
29+
30+
msgid "You are not in the throne room."
31+
msgstr "Vous n'êtes pas dans la salle du trône."
32+
33+
#, sh-format
34+
msgid "You have been teleported to"
35+
msgstr "Vous avez été téléporté à"
Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,45 @@
11
# mte90 <mte90net@gmail.com>, 2022.
2-
msgid ""
3-
msgstr ""
4-
"Project-Id-Version: \n"
5-
"POT-Creation-Date: \n"
6-
"PO-Revision-Date: 2022-07-11 14:15+0200\n"
7-
"Last-Translator: mte90 <mte90net@gmail.com>\n"
8-
"Language-Team: Italian <kde-i18n-it@kde.org>\n"
9-
"Language: it\n"
10-
"MIME-Version: 1.0\n"
11-
"Content-Type: text/plain; charset=UTF-8\n"
12-
"Content-Transfer-Encoding: 8bit\n"
13-
"X-Generator: Lokalize 22.04.1\n"
14-
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
2+
msgid ""
3+
msgstr "Project-Id-Version: \n"
4+
"POT-Creation-Date: \n"
5+
"PO-Revision-Date: 2022-07-11 14:15+0200\n"
6+
"Last-Translator: mte90 <mte90net@gmail.com>\n"
7+
"Language-Team: Italian <kde-i18n-it@kde.org>\n"
8+
"Language: it\n"
9+
"MIME-Version: 1.0\n"
10+
"Content-Type: text/plain; charset=UTF-8\n"
11+
"Content-Transfer-Encoding: 8bit\n"
12+
"X-Generator: Lokalize 22.04.1\n"
13+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
1514

1615
#, sh-format
17-
msgid "$GSH_HOME/Castle/Main_building/Throne_room"
18-
msgstr "$GSH_HOME/Castello/Palazzo_principale/Sala_del_trono"
16+
msgid "$GSH_HOME/Castle/Main_building/Throne_room"
17+
msgstr "$GSH_HOME/Castello/Palazzo_principale/Sala_del_trono"
18+
19+
msgid "$GSH_HOME/Castle/Cellar"
20+
msgstr "$GSH_HOME/Castello/Cantina"
1921

2022
# path for the text file containing the goal
21-
msgid "$MISSION_DIR/goal/en.txt"
22-
msgstr "$MISSION_DIR/goal/it.txt"
23+
msgid "$MISSION_DIR/goal/en.txt"
24+
msgstr "$MISSION_DIR/goal/it.txt"
2325

2426
# path for the text file containing the skip message
25-
msgid "$MISSION_DIR/skip/en.txt"
26-
msgstr "$MISSION_DIR/skip/it.txt"
27+
msgid "$MISSION_DIR/skip/en.txt"
28+
msgstr "$MISSION_DIR/skip/it.txt"
2729

2830
# path for the text file containing the treasure message
29-
msgid "$MISSION_DIR/treasure-msg/en.txt"
30-
msgstr "$MISSION_DIR/treasure-msg/it.txt"
31+
msgid "$MISSION_DIR/treasure-msg/en.txt"
32+
msgstr "$MISSION_DIR/treasure-msg/it.txt"
33+
34+
msgid "The previous to last command is too complex."
35+
msgstr ""
36+
37+
msgid "The previous to last command must take you to the starting point."
38+
msgstr ""
39+
40+
msgid "You are not in the throne room."
41+
msgstr ""
42+
43+
#, sh-format
44+
msgid "You have been teleported to"
45+
msgstr ""

missions/basic/03_cd_HOME_throne/i18n/template.pot

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ msgstr "Content-Type: text/plain; charset=UTF-8\n"
66
msgid "$GSH_HOME/Castle/Main_building/Throne_room"
77
msgstr ""
88

9+
msgid "$GSH_HOME/Castle/Cellar"
10+
msgstr ""
11+
912
# path for the text file containing the goal
1013
msgid "$MISSION_DIR/goal/en.txt"
1114
msgstr ""
@@ -17,3 +20,16 @@ msgstr ""
1720
# path for the text file containing the treasure message
1821
msgid "$MISSION_DIR/treasure-msg/en.txt"
1922
msgstr ""
23+
24+
msgid "The previous to last command is too complex."
25+
msgstr ""
26+
27+
msgid "The previous to last command must take you to the starting point."
28+
msgstr ""
29+
30+
msgid "You are not in the throne room."
31+
msgstr ""
32+
33+
#, sh-format
34+
msgid "You have been teleported to"
35+
msgstr ""
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env sh
2+
3+
current=$(pwd -P)
4+
expected=$(cd "$(eval_gettext '$GSH_HOME/Castle/Cellar')"; pwd -P)
5+
6+
if [ "$current" != "$expected" ]
7+
then
8+
cd "$expected"
9+
expected=${expected#$GSH_ROOT}
10+
expected=${expected#/}
11+
echo "$(eval_gettext "You have been teleported to") .../$expected"
12+
fi
13+
14+
unset current expected
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/usr/bin/env sh
22

3+
mkdir -p "$(eval_gettext '$GSH_HOME/Castle/Cellar')"
34
mkdir -p "$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room')"

missions/basic/03_cd_HOME_throne/test.sh

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,35 @@ add_cmd dummy1
77
add_cmd dummy2
88
add_cmd dummy3
99

10-
cd
11-
add_cmd gsh check
12-
gsh assert check false
13-
10+
# OK
11+
cd "$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room')"
1412
add_cmd cd
1513
add_cmd cd "$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room')"
16-
cd
1714
add_cmd gsh check
18-
gsh assert check false
15+
gsh assert check true
1916

17+
# OK
18+
cd "$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room')"
19+
add_cmd cd \~
2020
add_cmd cd "$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room')"
21-
add_cmd cd ../../../
21+
add_cmd gsh check
22+
gsh assert check true
23+
24+
# not OK, using cd ../.. shouldn't work
25+
cd "$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room')"
26+
add_cmd cd ../..
2227
add_cmd cd "$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room')"
23-
cd
2428
add_cmd gsh check
2529
gsh assert check false
2630

27-
cd "$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room')"
31+
# commands OK, but not in appropriate directory
32+
cd
2833
add_cmd cd
2934
add_cmd cd "$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room')"
3035
add_cmd gsh check
31-
gsh assert check true
36+
gsh assert check false
3237

38+
# OK, with several gsh commands in between actual commands
3339
cd "$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room')"
3440
add_cmd cd
3541
add_cmd gsh goal
@@ -38,6 +44,7 @@ add_cmd gsh goal
3844
add_cmd gsh check
3945
gsh assert check true
4046

47+
# OK, with aliases for gsh commands
4148
alias gc="gsh check"
4249
cd "$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room')"
4350
add_cmd cd
@@ -46,6 +53,7 @@ add_cmd gc
4653
gsh assert check true
4754
unalias gc
4855

56+
# OK, with nested aliases for gsh commands
4957
alias check="gsh check"
5058
alias gc=check
5159
cd "$(eval_gettext '$GSH_HOME/Castle/Main_building/Throne_room')"

0 commit comments

Comments
 (0)