From 82bd7043acc0fff56d74d14e58eeff596b859d78 Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Tue, 13 Aug 2024 19:25:43 +0200 Subject: [PATCH 01/30] 2 directory names / script names differed only in case which is a problem on case insensitive filesystems... --- i18n/en.po | 4 ++-- i18n/fr.po | 4 ++-- .../en.txt | 0 .../fr.txt | 0 .../it.txt | 0 i18n/it.po | 4 ++-- i18n/template.pot | 2 +- lib/gsh.sh | 19 +++++++++++++++++++ scripts/_gsh_HELP | 6 ------ scripts/_gsh_help | 6 ------ 10 files changed, 26 insertions(+), 19 deletions(-) rename i18n/{gameshell-HELP => gameshell-full-help}/en.txt (100%) rename i18n/{gameshell-HELP => gameshell-full-help}/fr.txt (100%) rename i18n/{gameshell-HELP => gameshell-full-help}/it.txt (100%) delete mode 100755 scripts/_gsh_HELP delete mode 100755 scripts/_gsh_help diff --git a/i18n/en.po b/i18n/en.po index 32486a1b..5a673fcb 100644 --- a/i18n/en.po +++ b/i18n/en.po @@ -1,7 +1,7 @@ # AUTOMATICALLY GENERATED -- DO NOT EDIT #, sh-format -msgid "$GSH_ROOT/i18n/gameshell-HELP/en.txt" -msgstr "$GSH_ROOT/i18n/gameshell-HELP/en.txt" +msgid "$GSH_ROOT/i18n/gameshell-full-help/en.txt" +msgstr "$GSH_ROOT/i18n/gameshell-full-help/en.txt" #, sh-format msgid "$GSH_ROOT/i18n/gameshell-help/en.txt" diff --git a/i18n/fr.po b/i18n/fr.po index 9242ac71..1f36739c 100644 --- a/i18n/fr.po +++ b/i18n/fr.po @@ -4,8 +4,8 @@ msgstr "Content-Type: text/plain; charset=UTF-8\n" "Plural-Forms: nplurals=2; plural=n>1;\n" #, sh-format -msgid "$GSH_ROOT/i18n/gameshell-HELP/en.txt" -msgstr "$GSH_ROOT/i18n/gameshell-HELP/fr.txt" +msgid "$GSH_ROOT/i18n/gameshell-full-help/en.txt" +msgstr "$GSH_ROOT/i18n/gameshell-full-help/fr.txt" #, sh-format msgid "$GSH_ROOT/i18n/gameshell-help/en.txt" diff --git a/i18n/gameshell-HELP/en.txt b/i18n/gameshell-full-help/en.txt similarity index 100% rename from i18n/gameshell-HELP/en.txt rename to i18n/gameshell-full-help/en.txt diff --git a/i18n/gameshell-HELP/fr.txt b/i18n/gameshell-full-help/fr.txt similarity index 100% rename from i18n/gameshell-HELP/fr.txt rename to i18n/gameshell-full-help/fr.txt diff --git a/i18n/gameshell-HELP/it.txt b/i18n/gameshell-full-help/it.txt similarity index 100% rename from i18n/gameshell-HELP/it.txt rename to i18n/gameshell-full-help/it.txt diff --git a/i18n/it.po b/i18n/it.po index 548a4ae5..aed99ffd 100644 --- a/i18n/it.po +++ b/i18n/it.po @@ -14,8 +14,8 @@ msgstr "Project-Id-Version: \n" "X-Generator: Lokalize 22.04.1\n" #, sh-format -msgid "$GSH_ROOT/i18n/gameshell-HELP/en.txt" -msgstr "$GSH_ROOT/i18n/gameshell-HELP/it.txt" +msgid "$GSH_ROOT/i18n/gameshell-full-help/en.txt" +msgstr "$GSH_ROOT/i18n/gameshell-full-help/it.txt" #, sh-format msgid "$GSH_ROOT/i18n/gameshell-help/en.txt" diff --git a/i18n/template.pot b/i18n/template.pot index dd66df7b..0c0c03fc 100644 --- a/i18n/template.pot +++ b/i18n/template.pot @@ -1,5 +1,5 @@ #, sh-format -msgid "$GSH_ROOT/i18n/gameshell-HELP/en.txt" +msgid "$GSH_ROOT/i18n/gameshell-full-help/en.txt" msgstr "" #, sh-format diff --git a/lib/gsh.sh b/lib/gsh.sh index edc52a4e..69bd86fb 100644 --- a/lib/gsh.sh +++ b/lib/gsh.sh @@ -639,6 +639,17 @@ _gsh_test() { } +### +# don't put the next 2 functions in $GSH_ROOT/scripts/_gsh_help / _gsh_HELP +# because it doesn't work on case insensitive filesystems +_gsh_help() { + parchment "$(eval_gettext '$GSH_ROOT/i18n/gameshell-help/en.txt')" Parchment2 | pager +} + +_gsh_HELP() { + parchment "$(eval_gettext '$GSH_ROOT/i18n/gameshell-full-help/en.txt')" Parchment2 | pager +} + gsh() { local _TEXTDOMAIN=$TEXTDOMAIN export TEXTDOMAIN="gsh" @@ -708,6 +719,14 @@ gsh() { __gsh_start "$@" ;; + "help") + _gsh_help + ;; + + "HELP") + _gsh_HELP + ;; + *) if command -v "_gsh_$cmd" >/dev/null then diff --git a/scripts/_gsh_HELP b/scripts/_gsh_HELP deleted file mode 100755 index 638672b5..00000000 --- a/scripts/_gsh_HELP +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env sh - -. gsh_gettext.sh - -parchment "$(eval_gettext '$GSH_ROOT/i18n/gameshell-HELP/en.txt')" Parchment2 | pager - diff --git a/scripts/_gsh_help b/scripts/_gsh_help deleted file mode 100755 index d2ec695a..00000000 --- a/scripts/_gsh_help +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env sh - -. gsh_gettext.sh - -parchment "$(eval_gettext '$GSH_ROOT/i18n/gameshell-help/en.txt')" Parchment2 | pager - From 7b2fa74b29870cff8534734b458a03e4d4d03542 Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Tue, 27 Aug 2024 16:20:09 +0200 Subject: [PATCH 02/30] the cal command is now in package "ncal" (Debian / Ubuntu) --- Dockerfile | 2 +- README-fr.md | 2 +- README-it.md | 2 +- README.md | 2 +- doc/deps.md | 4 ++-- missions/misc/01_cal_nostradamus/i18n/en.po | 4 ++-- missions/misc/01_cal_nostradamus/i18n/fr.po | 4 ++-- missions/misc/01_cal_nostradamus/i18n/it.po | 4 ++-- missions/misc/01_cal_nostradamus/i18n/template.pot | 2 +- missions/misc/01_cal_nostradamus/init.sh | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2f6e1d7c..e5d575f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ RUN apt install --no-install-recommends --assume-yes \ procps \ nano \ tree \ - bsdmainutils \ + ncal \ x11-apps RUN apt clean RUN rm -rf /var/lib/apt/lists/* diff --git a/README-fr.md b/README-fr.md index 4a298348..daee626d 100644 --- a/README-fr.md +++ b/README-fr.md @@ -35,7 +35,7 @@ missions ont des dépendances additionnelles : elles seront annulées si leurs dépendances ne sont pas satisfaites. Sur Debian ou Ubuntu, lancez la commande suivante pour installer toutes les dépendances pour le jeu et les missions. ```sh -$ sudo apt install gettext-base man-db psmisc nano tree bsdmainutils x11-apps +$ sudo apt install gettext-base man-db psmisc nano tree ncal x11-apps ``` Consultez le [manuel utilisateur](doc/user_manual.md) (en anglais) pour voir comment installer les dépendances sur d'autres systèmes (macOS, BSD, ...). diff --git a/README-it.md b/README-it.md index 892d0544..2a714102 100644 --- a/README-it.md +++ b/README-it.md @@ -21,7 +21,7 @@ Come cominciare GameShell dovrebbe funzionare in qualunque sistema Linux standard, e anche su macOS e BSD (ma abbiamo eseguito pochi test su questi). Su Debian e Ubuntu, le uniche dipendenze (oltre `bash`) sono i pacchetti `gettext-base` e `awk`(questo di solito presente di default). Alcune missioni hanno dipendenze addizionali: queste missioni verranno saltate se le dipendenze non sono state risolte. Su Debian o Ubuntu, esegui i comandi seguenti per installare tutte le dipendenze del gioco e delle missioni. ```sh -$ sudo apt install gettext man-db procps psmisc nano tree bsdmainutils x11-apps wget +$ sudo apt install gettext man-db procps psmisc nano tree ncal x11-apps wget ``` Controlla il [manuale utente](doc/user_manual.md) per vedere come installare le dipendenze su altri sistemi (macOS, BSD, ...). diff --git a/README.md b/README.md index ae2504dc..1fd3988a 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ dependencies: these missions will be skipped if the dependencies are not met. On Debian or Ubuntu, run the following command to install all game and mission dependencies. ```sh -$ sudo apt install gettext man-db procps psmisc nano tree bsdmainutils x11-apps wget +$ sudo apt install gettext man-db procps psmisc nano tree ncal x11-apps wget ``` Check the [user manual](doc/user_manual.md) to see how to install the game dependencies on other systems (macOS, BSD, ...). diff --git a/doc/deps.md b/doc/deps.md index f0be0dd3..8a40de1b 100644 --- a/doc/deps.md +++ b/doc/deps.md @@ -20,14 +20,14 @@ the following - `pstree` (`psmisc` package in Debian/Ubuntu) - `nano` (`nano` package in Debian/Ubuntu) - `tree` (`tree` package in Debian/Ubuntu) - - `cal` (`bsdmainutils` package in Debian/Ubuntu) + - `cal` (`ncal` package in Debian/Ubuntu) - `xeyes` (`x11-apps` package in Debian/Ubuntu) On a Debian / Ubuntu system, the following ensures you have everything you need to run GameShell without problems. ```sh -$ sudo apt install gettext-base man-db procps psmisc nano tree bsdmainutils x11-apps +$ sudo apt install gettext-base man-db procps psmisc nano tree ncal x11-apps ``` diff --git a/missions/misc/01_cal_nostradamus/i18n/en.po b/missions/misc/01_cal_nostradamus/i18n/en.po index 3181ecf1..75c2bf91 100644 --- a/missions/misc/01_cal_nostradamus/i18n/en.po +++ b/missions/misc/01_cal_nostradamus/i18n/en.po @@ -24,9 +24,9 @@ msgstr "That's not even a valid answer!" #, sh-format msgid "The command 'cal' is required for mission $MISSION_NAME.\n" - "(Debian / Ubuntu: install package 'bsdmainutils')" + "(Debian / Ubuntu: install package 'ncal')" msgstr "The command 'cal' is required for mission $MISSION_NAME.\n" - "(Debian / Ubuntu: install package 'bsdmainutils')" + "(Debian / Ubuntu: install package 'ncal')" #, sh-format msgid "What was the day of the week for the $MM-$DD-$YYYY?" diff --git a/missions/misc/01_cal_nostradamus/i18n/fr.po b/missions/misc/01_cal_nostradamus/i18n/fr.po index 136baf49..780f0f2e 100644 --- a/missions/misc/01_cal_nostradamus/i18n/fr.po +++ b/missions/misc/01_cal_nostradamus/i18n/fr.po @@ -23,9 +23,9 @@ msgstr "Ce n'est même pas une réponse valide !" #, sh-format msgid "The command 'cal' is required for mission $MISSION_NAME.\n" - "(Debian / Ubuntu: install package 'bsdmainutils')" + "(Debian / Ubuntu: install package 'ncal')" msgstr "La commande 'cal' est nécessaire pour la mission $MISSION_NAME.\n" - "(Debian / Ubuntu : installez le paquet 'bsdmainutils')" + "(Debian / Ubuntu : installez le paquet 'ncal')" #, sh-format msgid "What was the day of the week for the $MM-$DD-$YYYY?" diff --git a/missions/misc/01_cal_nostradamus/i18n/it.po b/missions/misc/01_cal_nostradamus/i18n/it.po index 0c6255df..ffb6e162 100644 --- a/missions/misc/01_cal_nostradamus/i18n/it.po +++ b/missions/misc/01_cal_nostradamus/i18n/it.po @@ -35,10 +35,10 @@ msgstr "Non é una risposta valida!" #, sh-format msgid "" "The command 'cal' is required for mission $MISSION_NAME.\n" -"(Debian / Ubuntu: install package 'bsdmainutils')" +"(Debian / Ubuntu: install package 'ncal')" msgstr "" "Il comando 'cal' é richiesto per la missione $MISSION_NAME.\n " -"(Debian / Ubuntu: installa il pacchetto 'bsdmainutils')" +"(Debian / Ubuntu: installa il pacchetto 'ncal')" #, sh-format msgid "What was the day of the week for the $MM-$DD-$YYYY?" diff --git a/missions/misc/01_cal_nostradamus/i18n/template.pot b/missions/misc/01_cal_nostradamus/i18n/template.pot index f164cbad..f13067b9 100644 --- a/missions/misc/01_cal_nostradamus/i18n/template.pot +++ b/missions/misc/01_cal_nostradamus/i18n/template.pot @@ -23,7 +23,7 @@ msgstr "" #, sh-format msgid "The command 'cal' is required for mission $MISSION_NAME.\n" - "(Debian / Ubuntu: install package 'bsdmainutils')" + "(Debian / Ubuntu: install package 'ncal')" msgstr "" #, sh-format diff --git a/missions/misc/01_cal_nostradamus/init.sh b/missions/misc/01_cal_nostradamus/init.sh index 7eaf1cd8..30bb43e3 100644 --- a/missions/misc/01_cal_nostradamus/init.sh +++ b/missions/misc/01_cal_nostradamus/init.sh @@ -3,7 +3,7 @@ _mission_init() ( if ! command -v cal >/dev/null; then echo "$(eval_gettext "The command 'cal' is required for mission \$MISSION_NAME. -(Debian / Ubuntu: install package 'bsdmainutils')")" >&2 +(Debian / Ubuntu: install package 'ncal')")" >&2 return 1 fi # keep the date between 1902 and 2038 to avoid problems with 32bits systems From 4fe0d55f63f53561f1da19749ffd78c9d42009ee Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Tue, 7 May 2024 21:46:25 +0200 Subject: [PATCH 03/30] first version of a "control-C" mission --- missions/index.txt | 1 + missions/intermediate/05_control-C/Makefile | 41 +++++++++ .../05_control-C/ascii-art/explosion.txt | 13 +++ .../05_control-C/ascii-art/fireworks.txt | 11 +++ missions/intermediate/05_control-C/auto.sh | 24 ++++++ .../intermediate/05_control-C/charmiglio.sh | 85 +++++++++++++++++++ missions/intermediate/05_control-C/check.sh | 24 ++++++ missions/intermediate/05_control-C/clean.sh | 3 + missions/intermediate/05_control-C/goal.sh | 5 ++ .../intermediate/05_control-C/goal/en.txt | 26 ++++++ .../intermediate/05_control-C/goal/fr.txt | 27 ++++++ missions/intermediate/05_control-C/i18n/en.po | 38 +++++++++ .../05_control-C/i18n/template.pot | 36 ++++++++ missions/intermediate/05_control-C/init.sh | 10 +++ missions/intermediate/05_control-C/test.sh | 34 ++++++++ missions/intermediate/index.txt | 1 + 16 files changed, 379 insertions(+) create mode 100644 missions/intermediate/05_control-C/Makefile create mode 100644 missions/intermediate/05_control-C/ascii-art/explosion.txt create mode 100644 missions/intermediate/05_control-C/ascii-art/fireworks.txt create mode 100644 missions/intermediate/05_control-C/auto.sh create mode 100644 missions/intermediate/05_control-C/charmiglio.sh create mode 100644 missions/intermediate/05_control-C/check.sh create mode 100644 missions/intermediate/05_control-C/clean.sh create mode 100644 missions/intermediate/05_control-C/goal.sh create mode 100644 missions/intermediate/05_control-C/goal/en.txt create mode 100644 missions/intermediate/05_control-C/goal/fr.txt create mode 100644 missions/intermediate/05_control-C/i18n/en.po create mode 100644 missions/intermediate/05_control-C/i18n/template.pot create mode 100644 missions/intermediate/05_control-C/init.sh create mode 100644 missions/intermediate/05_control-C/test.sh diff --git a/missions/index.txt b/missions/index.txt index c9305d44..bf8394f5 100644 --- a/missions/index.txt +++ b/missions/index.txt @@ -5,6 +5,7 @@ misc/02_nano_journal intermediate/02_alias_journal intermediate/03_tab_spider_lair intermediate/04_bg_xeyes +intermediate/05_control-C !finding_files_maze/00_shared finding_files_maze/01_ls_cd finding_files_maze/02_tree diff --git a/missions/intermediate/05_control-C/Makefile b/missions/intermediate/05_control-C/Makefile new file mode 100644 index 00000000..bd85007b --- /dev/null +++ b/missions/intermediate/05_control-C/Makefile @@ -0,0 +1,41 @@ +SH_FILES=$(wildcard *.sh) +EXCEPTIONS= +OTHER_FILES= + +LANGUAGES=$(wildcard i18n/*.po) +LANGUAGES:=$(filter-out i18n/en.po, $(LANGUAGES)) +SH_FILES:=$(filter-out $(EXCEPTIONS), $(SH_FILES)) +SORT=--sort-output +OPTIONS=--indent --no-wrap --no-location + +all: i18n/en.po $(LANGUAGES) + +add-locations: SORT=--add-location --sort-by-file +add-locations: all + +i18n/en.po: i18n/template.pot FORCE + @echo "msgen $@" + @msgen $(OPTIONS) $(SORT) i18n/template.pot --output=$@ + @echo "# AUTOMATICALLY GENERATED -- DO NOT EDIT" | cat - $@ > $@~ + @mv $@~ $@ + +$(LANGUAGES):%.po: i18n/template.pot FORCE + @echo "msgmerge $@" + @msgmerge --update $(OPTIONS) $(SORT) $@ i18n/template.pot + +i18n/template.pot: $(SH_FILES) $(OTHER_FILES) FORCE + @mkdir -p i18n/ + @echo "generating i18n/template.pot" + @xgettext --from-code=UTF-8 --omit-header $(OPTIONS) $(SORT) --join-existing --output i18n/template.pot $(SH_FILES) $(OTHER_FILES) + @echo "done" + +new: i18n/template.pot + @read -p "language code: " lang; \ + [ -e "./i18n/$$lang.po" ] && echo "file i18n/$$lang.po already exists" && exit; \ + echo "file i18n/$$lang.po created"; \ + msgcat $(OPTIONS) --output i18n/$$lang.po i18n/template.pot + +clean: + rm -f i18n/*~ + +.PHONY: all clean new FORCE diff --git a/missions/intermediate/05_control-C/ascii-art/explosion.txt b/missions/intermediate/05_control-C/ascii-art/explosion.txt new file mode 100644 index 00000000..99832ccc --- /dev/null +++ b/missions/intermediate/05_control-C/ascii-art/explosion.txt @@ -0,0 +1,13 @@ + + _.-^^---....,,-- + _-- --_ + < >) + | | + \._ _./ + ```--. . , ; .--''' + | | | + .-=|| | |=-. + `-=#$%&%$#=-' + | ; :| + _____.,-#%&$@%#&#~,._____ + diff --git a/missions/intermediate/05_control-C/ascii-art/fireworks.txt b/missions/intermediate/05_control-C/ascii-art/fireworks.txt new file mode 100644 index 00000000..1fd24bce --- /dev/null +++ b/missions/intermediate/05_control-C/ascii-art/fireworks.txt @@ -0,0 +1,11 @@ + + .''. + .''. . *''* :_\/_: . + :_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'. + .''.: /\ : ./)\ ':'* /\ * : '..'. -=:o:=- + :_\/_:'.:::. ' *''* * '.\'/.' _\(/_'.':'.' + : /\ : ::::: *_\/_* -= o =- /)\ ' * + '..' ':::' * /\ * .'/.\'. ' + * *..* : + * + * diff --git a/missions/intermediate/05_control-C/auto.sh b/missions/intermediate/05_control-C/auto.sh new file mode 100644 index 00000000..4dc721f7 --- /dev/null +++ b/missions/intermediate/05_control-C/auto.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env sh + +set -m + +for _ in $(seq 6) +do + eval "$(gettext charmiglio)" 2>/dev/null & + PID=$! + sleep 3 + kill -s INT "-$PID" 2> /dev/null + + case "$(cat "$GSH_TMP/control-C")" in + *[!0-9]*) + break + ;; + *) + : + ;; + esac +done + +gsh check < "$GSH_TMP/control-C" + + diff --git a/missions/intermediate/05_control-C/charmiglio.sh b/missions/intermediate/05_control-C/charmiglio.sh new file mode 100644 index 00000000..0529e267 --- /dev/null +++ b/missions/intermediate/05_control-C/charmiglio.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env sh + +. gsh_gettext.sh + +control_c_start() { + [ -f "$GSH_TMP/control-C" ] || exit 255 + n=$(cat "$GSH_TMP/control-C") + case "$n" in + "" | *[!0-9]* ) + echo + echo + echo "$(eval_gettext 'Found it! The special incantion is $n')" + ;; + *) + echo + echo + echo "$(gettext "Don't interrupt me when I'm in a trance!!!")" + ;; + esac + exit 1 +} + +control_c_end() { + [ -f "$GSH_TMP/control-C" ] || exit 255 + n=$(cat "$GSH_TMP/control-C") + case "$n" in + "" | *[!0-9]* ) + echo + echo + echo "$(eval_gettext 'Found it! The special incantion is $n')" + ;; + *) + echo "$((n-1))" > "$GSH_TMP/control-C" + echo + echo + echo "$(gettext "Sorry, I fell asleep... Let's try again.")" + ;; + esac + exit 1 +} + +mumble() { + seconds=$1 + now=$(date +%s) + + while [ "$(($(date +%s) - now))" -le "$seconds" ] + do + printf "$(gettext "Merlin mumbles ")" >&2 + random_string "$((8 + $(RANDOM)%42))" | tr "A-Z" " " >&2 + sleep 0.1 + done +} + +check() { + [ -f "$GSH_TMP/control-C" ] || exit 255 + n=$(cat "$GSH_TMP/control-C") + case "$n" in + "" | *[!0-9]* ) + # we already know the solution + echo + echo "$(eval_gettext 'Found it! The special incantation is $n')" + exit 0 + ;; + *) + if [ "$n" -le 0 ] + then + # if we've finished, print the solution and save it + n=$(random_string 5) + echo "$n" > "$GSH_TMP/control-C" + echo + echo "$(eval_gettext 'Found it! The special incantation is $n')" + exit 0 + fi + esac +} + +trap 'control_c_start' INT +mumble 2 # mumble for 2 second +check +trap 'control_c_end' INT +mumble 120 # mumble for 2 minutes +echo +echo "$(gettext "Sorry, I fell asleep... Let's try again.")" + +echo "$(gettext "NOTE: you need to interrupt Merlin before he wakes up.")" diff --git a/missions/intermediate/05_control-C/check.sh b/missions/intermediate/05_control-C/check.sh new file mode 100644 index 00000000..f70584c0 --- /dev/null +++ b/missions/intermediate/05_control-C/check.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env sh + +_mission_check() { + r=$(cat "$GSH_TMP/control-C") + printf "%s " "$(gettext "What's the fireworks incantation?")" + read -r n + + case "$r" in + "" | *[!0-9]*) + if [ "$n" = "$r" ] + then + cat "$MISSION_DIR/ascii-art/fireworks.txt" + return 0 + else + cat "$MISSION_DIR/ascii-art/explosion.txt" + return 1 + fi + ;; + *) + cat "$MISSION_DIR/ascii-art/explosion.txt" + return 1 + esac +} +_mission_check diff --git a/missions/intermediate/05_control-C/clean.sh b/missions/intermediate/05_control-C/clean.sh new file mode 100644 index 00000000..f230756a --- /dev/null +++ b/missions/intermediate/05_control-C/clean.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +rm -f "$GSH_TMP/control-C" diff --git a/missions/intermediate/05_control-C/goal.sh b/missions/intermediate/05_control-C/goal.sh new file mode 100644 index 00000000..96b1d958 --- /dev/null +++ b/missions/intermediate/05_control-C/goal.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +command="$(gettext 'charmiglio')" +sed "s/\\\$command/$command/g" "$(eval_gettext '$MISSION_DIR/goal/en.txt')" +unset command diff --git a/missions/intermediate/05_control-C/goal/en.txt b/missions/intermediate/05_control-C/goal/en.txt new file mode 100644 index 00000000..b834af72 --- /dev/null +++ b/missions/intermediate/05_control-C/goal/en.txt @@ -0,0 +1,26 @@ +Mission goal +============ + +The wizard Merlin appears next to you and asks for your help. +You need to whisper the magic word + $ $command +to put him into a trance so that he can remember a special +incantation for creating fireworks. + +The only problem is that after a couple of seconds in a trance, +Merlin falls asleep! You thus need to interrupt him whenever +that's the case, so that he can try again. + + +NOTE: it will probably take several tries before Merlin +actually remembers the incantation + + +Useful commands +=============== + +$command + this (non standard) command puts Merlin into a trance + +Control-c (also written ^c) + pressing Control and c at the same times interrupts the current command diff --git a/missions/intermediate/05_control-C/goal/fr.txt b/missions/intermediate/05_control-C/goal/fr.txt new file mode 100644 index 00000000..cc52acfa --- /dev/null +++ b/missions/intermediate/05_control-C/goal/fr.txt @@ -0,0 +1,27 @@ +Objectif +========= + +Le sorcier Merlin apparait à vos cotés et vous demande de +l'aide. Vous devez murmurer le mot magique + $ $command +pour le mettre dans une transe qui devrait lui permettre de +se souvenir d'une incantation spéciale pour créer des feux +d'artifice. + +Le seul problème est qu'après quelques secondes en trance, +Merlin s'endort ! Vous devez donc l'interrompre dans ce cas +pour qu'il puisse ré-essayer. + + +NOTE: il faudra probablement plusieurs essais pour que +Merlin retrouve son incantation. + + +Commandes utiles +================ + +$command + cette commande (non standard) met Merlin dans une transe + +Contrôle-c (aussi noté ^c) + appuyer sur les touches Contrôle et c en même temps interrompt la commande en cours diff --git a/missions/intermediate/05_control-C/i18n/en.po b/missions/intermediate/05_control-C/i18n/en.po new file mode 100644 index 00000000..a964d708 --- /dev/null +++ b/missions/intermediate/05_control-C/i18n/en.po @@ -0,0 +1,38 @@ +# AUTOMATICALLY GENERATED -- DO NOT EDIT +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +#, sh-format +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/en.txt" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "$MISSION_DIR/skip/en.txt" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "$MISSION_DIR/treasure-msg/en.txt" + +#, sh-format +msgid "FOUND: $n" +msgstr "FOUND: $n" + +msgid "Let me think a little more!!!" +msgstr "Let me think a little more!!!" + +msgid "What's the magic word?" +msgstr "What's the magic word?" + +msgid "You need to interrupt Merlin before he falls asleep.\n" + "Refer to the goal for details." +msgstr "You need to interrupt Merlin before he falls asleep.\n" + "Refer to the goal for details." + +msgid "You're right, that's not working" +msgstr "You're right, that's not working" + +msgid "charmiglio" +msgstr "charmiglio" diff --git a/missions/intermediate/05_control-C/i18n/template.pot b/missions/intermediate/05_control-C/i18n/template.pot new file mode 100644 index 00000000..9d8c81d8 --- /dev/null +++ b/missions/intermediate/05_control-C/i18n/template.pot @@ -0,0 +1,36 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +#, sh-format +msgid "$MISSION_DIR/goal/en.txt" +msgstr "" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" + +#, sh-format +msgid "FOUND: $n" +msgstr "" + +msgid "Let me think a little more!!!" +msgstr "" + +msgid "What's the magic word?" +msgstr "" + +msgid "You need to interrupt Merlin before he falls asleep.\n" + "Refer to the goal for details." +msgstr "" + +msgid "You're right, that's not working" +msgstr "" + +msgid "charmiglio" +msgstr "" diff --git a/missions/intermediate/05_control-C/init.sh b/missions/intermediate/05_control-C/init.sh new file mode 100644 index 00000000..5ac2aadf --- /dev/null +++ b/missions/intermediate/05_control-C/init.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +_mission_init() { + # nb of tries to make + echo $((3 + $(RANDOM) % 3)) > "$GSH_TMP/control-C" + + cp "$MISSION_DIR/charmiglio.sh" "$GSH_BIN/$(gettext charmiglio)" + chmod +x "$GSH_BIN/$(gettext charmiglio)" +} +_mission_init diff --git a/missions/intermediate/05_control-C/test.sh b/missions/intermediate/05_control-C/test.sh new file mode 100644 index 00000000..f47c342e --- /dev/null +++ b/missions/intermediate/05_control-C/test.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env sh + +set -m + +do_test() { + nb=$1 + delay=$2 + + for _ in $(seq "$nb") + do + eval "$(gettext charmiglio)" 2>/dev/null & + PID=$! + sleep "$delay" + kill -s INT "-$PID" 2> /dev/null + + case "$(cat "$GSH_TMP/control-C")" in + *[!0-9]*) + break + ;; + *) + : + ;; + esac + done +} + +do_test 10 0.3 +gsh assert check false < "$GSH_TMP/control-C" + +do_test 3 3 +gsh assert check false < "$GSH_TMP/control-C" + +do_test 6 3 +gsh assert check true < "$GSH_TMP/control-C" diff --git a/missions/intermediate/index.txt b/missions/intermediate/index.txt index 0ffc136d..9bca21db 100644 --- a/missions/intermediate/index.txt +++ b/missions/intermediate/index.txt @@ -2,3 +2,4 @@ 02_alias_journal 03_tab_spider_lair 04_bg_xeyes +05_control-C From 36f74ca5d0f2e86bed334eeea6956256b33f9330 Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Wed, 8 May 2024 02:35:29 +0200 Subject: [PATCH 04/30] minor work on control-C mission --- .../intermediate/05_control-C/goal/en.txt | 6 +++-- .../intermediate/05_control-C/goal/fr.txt | 4 +++- missions/intermediate/05_control-C/i18n/en.po | 23 +++++++++++++++++++ .../05_control-C/i18n/template.pot | 23 +++++++++++++++++++ 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/missions/intermediate/05_control-C/goal/en.txt b/missions/intermediate/05_control-C/goal/en.txt index b834af72..506b3073 100644 --- a/missions/intermediate/05_control-C/goal/en.txt +++ b/missions/intermediate/05_control-C/goal/en.txt @@ -20,7 +20,9 @@ Useful commands =============== $command - this (non standard) command puts Merlin into a trance + this (non standard) command puts Merlin into a trance Control-c (also written ^c) - pressing Control and c at the same times interrupts the current command + pressing Control and c at the same times interrupts the current command + by sending the INT ("INTerrupt") signal to the process + diff --git a/missions/intermediate/05_control-C/goal/fr.txt b/missions/intermediate/05_control-C/goal/fr.txt index cc52acfa..25c2369a 100644 --- a/missions/intermediate/05_control-C/goal/fr.txt +++ b/missions/intermediate/05_control-C/goal/fr.txt @@ -24,4 +24,6 @@ $command cette commande (non standard) met Merlin dans une transe Contrôle-c (aussi noté ^c) - appuyer sur les touches Contrôle et c en même temps interrompt la commande en cours + appuyer sur les touches Contrôle et c en même temps interrompt + la commande en cours en envoyant le signal INT ("INTerrupt") au + processus diff --git a/missions/intermediate/05_control-C/i18n/en.po b/missions/intermediate/05_control-C/i18n/en.po index a964d708..6a29a5a5 100644 --- a/missions/intermediate/05_control-C/i18n/en.po +++ b/missions/intermediate/05_control-C/i18n/en.po @@ -16,13 +16,36 @@ msgstr "$MISSION_DIR/skip/en.txt" msgid "$MISSION_DIR/treasure-msg/en.txt" msgstr "$MISSION_DIR/treasure-msg/en.txt" +msgid "Don't interrupt me when I'm in a trance!!!" +msgstr "Don't interrupt me when I'm in a trance!!!" + #, sh-format msgid "FOUND: $n" msgstr "FOUND: $n" +#, sh-format +msgid "Found it! The special incantation is $n" +msgstr "Found it! The special incantation is $n" + +#, sh-format +msgid "Found it! The special incantion is $n" +msgstr "Found it! The special incantion is $n" + msgid "Let me think a little more!!!" msgstr "Let me think a little more!!!" +msgid "Merlin mumbles " +msgstr "Merlin mumbles " + +msgid "NOTE: you need to interrupt Merlin before he wakes up." +msgstr "NOTE: you need to interrupt Merlin before he wakes up." + +msgid "Sorry, I fell asleep... Let's try again." +msgstr "Sorry, I fell asleep... Let's try again." + +msgid "What's the fireworks incantation?" +msgstr "What's the fireworks incantation?" + msgid "What's the magic word?" msgstr "What's the magic word?" diff --git a/missions/intermediate/05_control-C/i18n/template.pot b/missions/intermediate/05_control-C/i18n/template.pot index 9d8c81d8..cb150a01 100644 --- a/missions/intermediate/05_control-C/i18n/template.pot +++ b/missions/intermediate/05_control-C/i18n/template.pot @@ -15,13 +15,36 @@ msgstr "" msgid "$MISSION_DIR/treasure-msg/en.txt" msgstr "" +msgid "Don't interrupt me when I'm in a trance!!!" +msgstr "" + #, sh-format msgid "FOUND: $n" msgstr "" +#, sh-format +msgid "Found it! The special incantation is $n" +msgstr "" + +#, sh-format +msgid "Found it! The special incantion is $n" +msgstr "" + msgid "Let me think a little more!!!" msgstr "" +msgid "Merlin mumbles " +msgstr "" + +msgid "NOTE: you need to interrupt Merlin before he wakes up." +msgstr "" + +msgid "Sorry, I fell asleep... Let's try again." +msgstr "" + +msgid "What's the fireworks incantation?" +msgstr "" + msgid "What's the magic word?" msgstr "" From d3009359a3f938c17640edeb2e90622426c8fe6d Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Wed, 8 May 2024 11:35:58 +0200 Subject: [PATCH 05/30] add '.' characters when Merlin is falling asleep --- .../intermediate/05_control-C/charmiglio.sh | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/missions/intermediate/05_control-C/charmiglio.sh b/missions/intermediate/05_control-C/charmiglio.sh index 0529e267..72353183 100644 --- a/missions/intermediate/05_control-C/charmiglio.sh +++ b/missions/intermediate/05_control-C/charmiglio.sh @@ -40,13 +40,24 @@ control_c_end() { } mumble() { - seconds=$1 - now=$(date +%s) + seconds=$1 # how long to mumble randomly (real time will be between $seconds and $seconds+1 + sleep=$2 # should '.' characters appears as times passes - while [ "$(($(date +%s) - now))" -le "$seconds" ] + now=$(date +%s) + d=0 + while [ "$d" -le "$seconds" ] do + d=$(($(date +%s) - now)) printf "$(gettext "Merlin mumbles ")" >&2 - random_string "$((8 + $(RANDOM)%42))" | tr "A-Z" " " >&2 + if [ "$sleep" ] + then + # generate a string of length 26 containing more and more '.' characters + i=$((d*2)) + alpha=$(echo "xnyjqmiwkgbplvadrhfuotcsez.........................." | awk "{print substr(\$0, $i<27?$i:27, 26)}" ) + else + alpha="a-z" + fi + random_string "$((8 + $(RANDOM)%42))" | tr "a-zA-Z" "$alpha " >&2 sleep 0.1 done } @@ -78,7 +89,7 @@ trap 'control_c_start' INT mumble 2 # mumble for 2 second check trap 'control_c_end' INT -mumble 120 # mumble for 2 minutes +mumble 120 sleep # mumble for 2 minutes, falling to sleep echo echo "$(gettext "Sorry, I fell asleep... Let's try again.")" From 7785859ae9597f10fef505d1d5e9f68da3cdb271 Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Wed, 8 May 2024 15:02:59 +0200 Subject: [PATCH 06/30] French translations for control-C --- .../intermediate/05_control-C/charmiglio.sh | 8 ++-- .../intermediate/05_control-C/goal/fr.txt | 2 +- missions/intermediate/05_control-C/i18n/en.po | 22 ---------- missions/intermediate/05_control-C/i18n/fr.po | 42 +++++++++++++++++++ missions/intermediate/05_control-C/i18n/it.po | 38 +++++++++++++++++ .../05_control-C/i18n/template.pot | 21 ---------- missions/intermediate/05_control-C/init.sh | 3 +- 7 files changed, 86 insertions(+), 50 deletions(-) mode change 100644 => 100755 missions/intermediate/05_control-C/charmiglio.sh create mode 100644 missions/intermediate/05_control-C/i18n/fr.po create mode 100644 missions/intermediate/05_control-C/i18n/it.po diff --git a/missions/intermediate/05_control-C/charmiglio.sh b/missions/intermediate/05_control-C/charmiglio.sh old mode 100644 new mode 100755 index 72353183..c1583a16 --- a/missions/intermediate/05_control-C/charmiglio.sh +++ b/missions/intermediate/05_control-C/charmiglio.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/bin/sh . gsh_gettext.sh @@ -9,7 +9,7 @@ control_c_start() { "" | *[!0-9]* ) echo echo - echo "$(eval_gettext 'Found it! The special incantion is $n')" + echo "$(eval_gettext 'Found it! The special incantation is $n')" ;; *) echo @@ -27,7 +27,7 @@ control_c_end() { "" | *[!0-9]* ) echo echo - echo "$(eval_gettext 'Found it! The special incantion is $n')" + echo "$(eval_gettext 'Found it! The special incantation is $n')" ;; *) echo "$((n-1))" > "$GSH_TMP/control-C" @@ -47,7 +47,7 @@ mumble() { d=0 while [ "$d" -le "$seconds" ] do - d=$(($(date +%s) - now)) + d=$(($(date +%s) - now + 1)) printf "$(gettext "Merlin mumbles ")" >&2 if [ "$sleep" ] then diff --git a/missions/intermediate/05_control-C/goal/fr.txt b/missions/intermediate/05_control-C/goal/fr.txt index 25c2369a..18b6e95a 100644 --- a/missions/intermediate/05_control-C/goal/fr.txt +++ b/missions/intermediate/05_control-C/goal/fr.txt @@ -8,7 +8,7 @@ pour le mettre dans une transe qui devrait lui permettre de se souvenir d'une incantation spéciale pour créer des feux d'artifice. -Le seul problème est qu'après quelques secondes en trance, +Le seul problème est qu'après quelques secondes en transe, Merlin s'endort ! Vous devez donc l'interrompre dans ce cas pour qu'il puisse ré-essayer. diff --git a/missions/intermediate/05_control-C/i18n/en.po b/missions/intermediate/05_control-C/i18n/en.po index 6a29a5a5..f0ed9f4d 100644 --- a/missions/intermediate/05_control-C/i18n/en.po +++ b/missions/intermediate/05_control-C/i18n/en.po @@ -19,21 +19,10 @@ msgstr "$MISSION_DIR/treasure-msg/en.txt" msgid "Don't interrupt me when I'm in a trance!!!" msgstr "Don't interrupt me when I'm in a trance!!!" -#, sh-format -msgid "FOUND: $n" -msgstr "FOUND: $n" - #, sh-format msgid "Found it! The special incantation is $n" msgstr "Found it! The special incantation is $n" -#, sh-format -msgid "Found it! The special incantion is $n" -msgstr "Found it! The special incantion is $n" - -msgid "Let me think a little more!!!" -msgstr "Let me think a little more!!!" - msgid "Merlin mumbles " msgstr "Merlin mumbles " @@ -46,16 +35,5 @@ msgstr "Sorry, I fell asleep... Let's try again." msgid "What's the fireworks incantation?" msgstr "What's the fireworks incantation?" -msgid "What's the magic word?" -msgstr "What's the magic word?" - -msgid "You need to interrupt Merlin before he falls asleep.\n" - "Refer to the goal for details." -msgstr "You need to interrupt Merlin before he falls asleep.\n" - "Refer to the goal for details." - -msgid "You're right, that's not working" -msgstr "You're right, that's not working" - msgid "charmiglio" msgstr "charmiglio" diff --git a/missions/intermediate/05_control-C/i18n/fr.po b/missions/intermediate/05_control-C/i18n/fr.po new file mode 100644 index 00000000..1101d704 --- /dev/null +++ b/missions/intermediate/05_control-C/i18n/fr.po @@ -0,0 +1,42 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +#, sh-format +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/fr.txt" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" + +msgid "Don't interrupt me when I'm in a trance!!!" +msgstr "Ne m'interromps pas pendant ma transe !!!" + +#, sh-format +msgid "Found it! The special incantation is $n" +msgstr "Trouvé ! L'incantation spéciale est $n" + +msgid "Merlin mumbles " +msgstr "Merlin marmonne " + +msgid "NOTE: you need to interrupt Merlin before he wakes up." +msgstr "NOTE : vous devez interrompre Merlin avant son réveil." + +msgid "Sorry, I fell asleep... Let's try again." +msgstr "Désolé, je m'étais endormi... Essayons encore." + +msgid "What's the fireworks incantation?" +msgstr "Quelle est l'incantation pour les feux d'artifice ?" + +msgid "charmiglio" +msgstr "charmiglio" + +#, fuzzy, sh-format +#~ msgid "Found it! The special incantion is $n" +#~ msgstr "Trouvé ! L'incantation spéciale est $n" diff --git a/missions/intermediate/05_control-C/i18n/it.po b/missions/intermediate/05_control-C/i18n/it.po new file mode 100644 index 00000000..3f142971 --- /dev/null +++ b/missions/intermediate/05_control-C/i18n/it.po @@ -0,0 +1,38 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +#, sh-format +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/it.txt" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" + +msgid "Don't interrupt me when I'm in a trance!!!" +msgstr "" + +#, sh-format +msgid "Found it! The special incantation is $n" +msgstr "" + +msgid "Merlin mumbles " +msgstr "" + +msgid "NOTE: you need to interrupt Merlin before he wakes up." +msgstr "" + +msgid "Sorry, I fell asleep... Let's try again." +msgstr "" + +msgid "What's the fireworks incantation?" +msgstr "" + +msgid "charmiglio" +msgstr "" diff --git a/missions/intermediate/05_control-C/i18n/template.pot b/missions/intermediate/05_control-C/i18n/template.pot index cb150a01..9d60e3bd 100644 --- a/missions/intermediate/05_control-C/i18n/template.pot +++ b/missions/intermediate/05_control-C/i18n/template.pot @@ -18,21 +18,10 @@ msgstr "" msgid "Don't interrupt me when I'm in a trance!!!" msgstr "" -#, sh-format -msgid "FOUND: $n" -msgstr "" - #, sh-format msgid "Found it! The special incantation is $n" msgstr "" -#, sh-format -msgid "Found it! The special incantion is $n" -msgstr "" - -msgid "Let me think a little more!!!" -msgstr "" - msgid "Merlin mumbles " msgstr "" @@ -45,15 +34,5 @@ msgstr "" msgid "What's the fireworks incantation?" msgstr "" -msgid "What's the magic word?" -msgstr "" - -msgid "You need to interrupt Merlin before he falls asleep.\n" - "Refer to the goal for details." -msgstr "" - -msgid "You're right, that's not working" -msgstr "" - msgid "charmiglio" msgstr "" diff --git a/missions/intermediate/05_control-C/init.sh b/missions/intermediate/05_control-C/init.sh index 5ac2aadf..ea16e3e9 100644 --- a/missions/intermediate/05_control-C/init.sh +++ b/missions/intermediate/05_control-C/init.sh @@ -4,7 +4,6 @@ _mission_init() { # nb of tries to make echo $((3 + $(RANDOM) % 3)) > "$GSH_TMP/control-C" - cp "$MISSION_DIR/charmiglio.sh" "$GSH_BIN/$(gettext charmiglio)" - chmod +x "$GSH_BIN/$(gettext charmiglio)" + copy_bin "$MISSION_DIR/charmiglio.sh" "$GSH_BIN/$(gettext charmiglio)" } _mission_init From e0ff64cd640f23e6e3a36231625e3ff038a8ae38 Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Thu, 9 May 2024 21:48:27 +0200 Subject: [PATCH 07/30] better control-c mission --- missions/index.txt | 3 +- .../{05_control-C => 05_background}/Makefile | 0 .../intermediate/05_background/ascii-art/f1 | 3 + .../intermediate/05_background/ascii-art/f2 | 4 + .../intermediate/05_background/ascii-art/f3 | 4 + .../intermediate/05_background/ascii-art/f4 | 5 + .../intermediate/05_background/ascii-art/f5 | 5 + .../intermediate/05_background/ascii-art/f6 | 4 + missions/intermediate/05_background/auto.sh | 5 + .../intermediate/05_background/charmiglio.sh | 24 ++++ missions/intermediate/05_background/check.sh | 37 ++++++ .../{05_control-C => 05_background}/goal.sh | 0 .../intermediate/05_background/goal/en.txt | 28 ++++ .../intermediate/05_background/goal/fr.txt | 29 ++++ .../i18n/en.po | 25 ++-- .../intermediate/05_background/i18n/fr.po | 33 +++++ .../i18n/it.po | 30 ++--- .../i18n/template.pot | 17 +-- .../{05_control-C => 05_background}/init.sh | 3 - missions/intermediate/05_background/test.sh | 17 +++ missions/intermediate/05_control-C/auto.sh | 24 ---- .../intermediate/05_control-C/charmiglio.sh | 96 -------------- missions/intermediate/05_control-C/clean.sh | 3 - .../intermediate/05_control-C/goal/en.txt | 28 ---- .../intermediate/05_control-C/goal/fr.txt | 29 ---- missions/intermediate/05_control-C/i18n/fr.po | 42 ------ .../intermediate/06_control-C/Charmiglio.sh | 125 ++++++++++++++++++ missions/intermediate/06_control-C/Makefile | 41 ++++++ .../ascii-art/explosion.txt | 0 .../ascii-art/fireworks.txt | 0 missions/intermediate/06_control-C/auto.sh | 24 ++++ .../{05_control-C => 06_control-C}/check.sh | 10 +- missions/intermediate/06_control-C/clean.sh | 3 + missions/intermediate/06_control-C/goal.sh | 5 + .../intermediate/06_control-C/goal/en.txt | 36 +++++ .../intermediate/06_control-C/goal/fr.txt | 36 +++++ missions/intermediate/06_control-C/i18n/en.po | 49 +++++++ missions/intermediate/06_control-C/i18n/fr.po | 48 +++++++ missions/intermediate/06_control-C/i18n/it.po | 49 +++++++ .../06_control-C/i18n/template.pot | 47 +++++++ missions/intermediate/06_control-C/init.sh | 10 ++ .../{05_control-C => 06_control-C}/test.sh | 8 +- missions/intermediate/index.txt | 3 +- 43 files changed, 713 insertions(+), 279 deletions(-) rename missions/intermediate/{05_control-C => 05_background}/Makefile (100%) create mode 100644 missions/intermediate/05_background/ascii-art/f1 create mode 100644 missions/intermediate/05_background/ascii-art/f2 create mode 100644 missions/intermediate/05_background/ascii-art/f3 create mode 100644 missions/intermediate/05_background/ascii-art/f4 create mode 100644 missions/intermediate/05_background/ascii-art/f5 create mode 100644 missions/intermediate/05_background/ascii-art/f6 create mode 100644 missions/intermediate/05_background/auto.sh create mode 100755 missions/intermediate/05_background/charmiglio.sh create mode 100644 missions/intermediate/05_background/check.sh rename missions/intermediate/{05_control-C => 05_background}/goal.sh (100%) create mode 100644 missions/intermediate/05_background/goal/en.txt create mode 100644 missions/intermediate/05_background/goal/fr.txt rename missions/intermediate/{05_control-C => 05_background}/i18n/en.po (51%) create mode 100644 missions/intermediate/05_background/i18n/fr.po rename missions/intermediate/{05_control-C => 05_background}/i18n/it.po (50%) rename missions/intermediate/{05_control-C => 05_background}/i18n/template.pot (62%) rename missions/intermediate/{05_control-C => 05_background}/init.sh (61%) create mode 100644 missions/intermediate/05_background/test.sh delete mode 100644 missions/intermediate/05_control-C/auto.sh delete mode 100755 missions/intermediate/05_control-C/charmiglio.sh delete mode 100644 missions/intermediate/05_control-C/clean.sh delete mode 100644 missions/intermediate/05_control-C/goal/en.txt delete mode 100644 missions/intermediate/05_control-C/goal/fr.txt delete mode 100644 missions/intermediate/05_control-C/i18n/fr.po create mode 100755 missions/intermediate/06_control-C/Charmiglio.sh create mode 100644 missions/intermediate/06_control-C/Makefile rename missions/intermediate/{05_control-C => 06_control-C}/ascii-art/explosion.txt (100%) rename missions/intermediate/{05_control-C => 06_control-C}/ascii-art/fireworks.txt (100%) create mode 100644 missions/intermediate/06_control-C/auto.sh rename missions/intermediate/{05_control-C => 06_control-C}/check.sh (50%) create mode 100644 missions/intermediate/06_control-C/clean.sh create mode 100644 missions/intermediate/06_control-C/goal.sh create mode 100644 missions/intermediate/06_control-C/goal/en.txt create mode 100644 missions/intermediate/06_control-C/goal/fr.txt create mode 100644 missions/intermediate/06_control-C/i18n/en.po create mode 100644 missions/intermediate/06_control-C/i18n/fr.po create mode 100644 missions/intermediate/06_control-C/i18n/it.po create mode 100644 missions/intermediate/06_control-C/i18n/template.pot create mode 100644 missions/intermediate/06_control-C/init.sh rename missions/intermediate/{05_control-C => 06_control-C}/test.sh (74%) diff --git a/missions/index.txt b/missions/index.txt index bf8394f5..01cddc07 100644 --- a/missions/index.txt +++ b/missions/index.txt @@ -5,7 +5,8 @@ misc/02_nano_journal intermediate/02_alias_journal intermediate/03_tab_spider_lair intermediate/04_bg_xeyes -intermediate/05_control-C +intermediate/05_background +intermediate/06_control-C !finding_files_maze/00_shared finding_files_maze/01_ls_cd finding_files_maze/02_tree diff --git a/missions/intermediate/05_control-C/Makefile b/missions/intermediate/05_background/Makefile similarity index 100% rename from missions/intermediate/05_control-C/Makefile rename to missions/intermediate/05_background/Makefile diff --git a/missions/intermediate/05_background/ascii-art/f1 b/missions/intermediate/05_background/ascii-art/f1 new file mode 100644 index 00000000..4b3118b4 --- /dev/null +++ b/missions/intermediate/05_background/ascii-art/f1 @@ -0,0 +1,3 @@ + .:::. + ::::: + ':::' diff --git a/missions/intermediate/05_background/ascii-art/f2 b/missions/intermediate/05_background/ascii-art/f2 new file mode 100644 index 00000000..40ea2799 --- /dev/null +++ b/missions/intermediate/05_background/ascii-art/f2 @@ -0,0 +1,4 @@ + . + _\(/_ + ./)\ + ' diff --git a/missions/intermediate/05_background/ascii-art/f3 b/missions/intermediate/05_background/ascii-art/f3 new file mode 100644 index 00000000..784393d0 --- /dev/null +++ b/missions/intermediate/05_background/ascii-art/f3 @@ -0,0 +1,4 @@ + *''* + *_\/_* + * /\ * + *..* diff --git a/missions/intermediate/05_background/ascii-art/f4 b/missions/intermediate/05_background/ascii-art/f4 new file mode 100644 index 00000000..ded7a9c4 --- /dev/null +++ b/missions/intermediate/05_background/ascii-art/f4 @@ -0,0 +1,5 @@ + : +'.\'/.' +-= o =- +.'/.\'. + : diff --git a/missions/intermediate/05_background/ascii-art/f5 b/missions/intermediate/05_background/ascii-art/f5 new file mode 100644 index 00000000..c6731730 --- /dev/null +++ b/missions/intermediate/05_background/ascii-art/f5 @@ -0,0 +1,5 @@ + . +.'.:.'. +-=:o:=- +'.':'.' + ' diff --git a/missions/intermediate/05_background/ascii-art/f6 b/missions/intermediate/05_background/ascii-art/f6 new file mode 100644 index 00000000..b3e976ec --- /dev/null +++ b/missions/intermediate/05_background/ascii-art/f6 @@ -0,0 +1,4 @@ + .''. + :_\/_: + : /\ : + '..' diff --git a/missions/intermediate/05_background/auto.sh b/missions/intermediate/05_background/auto.sh new file mode 100644 index 00000000..f9bb5b0c --- /dev/null +++ b/missions/intermediate/05_background/auto.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +set -m + +charmiglio & charmiglio & charmiglio & gsh check diff --git a/missions/intermediate/05_background/charmiglio.sh b/missions/intermediate/05_background/charmiglio.sh new file mode 100755 index 00000000..a11a8b1a --- /dev/null +++ b/missions/intermediate/05_background/charmiglio.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +. gsh_gettext.sh + +command=$(gettext "charmiglio") + + +file="$MISSION_DIR/ascii-art/f$((1 + $(RANDOM)%6))" +indent=$(echo " " | head -c "$((4 * ($(RANDOM)%8)))") + +rm -f "$GSH_TMP/charmiglio.pids" +for i in $(seq $((5 + $(RANDOM)%10))) +do + echo "$indent *" + sleep 0.1 +done + +awk -v indent="$indent" '{print indent, $0}' < "$file" + +echo $$ >> "$GSH_TMP/charmiglio.pids" + +sleep 1 + +exit 0 diff --git a/missions/intermediate/05_background/check.sh b/missions/intermediate/05_background/check.sh new file mode 100644 index 00000000..1784da88 --- /dev/null +++ b/missions/intermediate/05_background/check.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env sh + +command="$(gettext 'charmiglio')" + +PIDS=$GSH_TMP/charmiglio.pids + +_check() { + rm -f "$PIDS" + + echo "$(gettext "Let's have a look:")" + + sleep 2 + + if [ ! -f "$PIDS" ] + then + echo "$(gettext "Mmm... I didn't see anything.")" + return 1 + fi + + NB=$(cat "$PIDS" | wc -l) + cat $PIDS + echo "NB = '$NB'" + if [ "$NB" -ge 3 ] + then + echo "$(gettext "Great, that looked good!")" + return 0 + elif [ "$NB" -lt 3 ] + then + echo "$(eval_gettext "Mmm... I only saw \$NB fireworks. That's not enough.")" + return 1 + else + echo "you shouldn't see this!" + return 1 + fi +} + +_check diff --git a/missions/intermediate/05_control-C/goal.sh b/missions/intermediate/05_background/goal.sh similarity index 100% rename from missions/intermediate/05_control-C/goal.sh rename to missions/intermediate/05_background/goal.sh diff --git a/missions/intermediate/05_background/goal/en.txt b/missions/intermediate/05_background/goal/en.txt new file mode 100644 index 00000000..fc02db19 --- /dev/null +++ b/missions/intermediate/05_background/goal/en.txt @@ -0,0 +1,28 @@ +Mission goal +============ + +The king's pyrotechnician appears next to you. He asks you to fire **at least +3 of them** so he can see them from far away. + +A single firework can be created with the magical word + + $command + + +Useful commands +=============== + +$command + this (non standard) command creates a single small firework + +COMMAND & + run the given command, but don't wait until it is finished to return + The command will run in the "background". + +COMMAND1 ; COMMAND2 ; ... ; COMMANDn + run the given commands one after the other + Each command is run when the previous one is finished. + +COMMAND1 & COMMAND2 & ... & COMMANDn + run the given commands "in parallel" + All the commands are run in the "background", except the last one. diff --git a/missions/intermediate/05_background/goal/fr.txt b/missions/intermediate/05_background/goal/fr.txt new file mode 100644 index 00000000..7244ff09 --- /dev/null +++ b/missions/intermediate/05_background/goal/fr.txt @@ -0,0 +1,29 @@ +Objectif +========= + +L'artificier royal apparait à vos cotés. Il vous demande de tirer **au moins 3 +jeux d'artifices" pour qu'il puisse les voir de loin. + +Une fusée simple peut être lancée avec le mot magique + + $command + + +Commandes utiles +================ + +$command + cette commande (non standard) lance un feu d'artifice simple + +COMMANDE & + exécute la commande mais n'attend pas qu'elle soit terminée pour reprendre + l'exécution du shell + La commande s'exécute "en arrière plan". + +COMMAND1 ; COMMAND2 ; ... ; COMMANDn + exécute les commandes données, l'une après l'autre + Chaque commande est exécutée lorsque la précédente est terminée. + +COMMAND1 & COMMAND2 & ... & COMMANDn + exécute les commandes données, "en parallèle" + Toutes les commandes sont exécutées "en arrière plan", sauf la dernière. diff --git a/missions/intermediate/05_control-C/i18n/en.po b/missions/intermediate/05_background/i18n/en.po similarity index 51% rename from missions/intermediate/05_control-C/i18n/en.po rename to missions/intermediate/05_background/i18n/en.po index f0ed9f4d..e9081ea2 100644 --- a/missions/intermediate/05_control-C/i18n/en.po +++ b/missions/intermediate/05_background/i18n/en.po @@ -16,24 +16,19 @@ msgstr "$MISSION_DIR/skip/en.txt" msgid "$MISSION_DIR/treasure-msg/en.txt" msgstr "$MISSION_DIR/treasure-msg/en.txt" -msgid "Don't interrupt me when I'm in a trance!!!" -msgstr "Don't interrupt me when I'm in a trance!!!" +msgid "Great, that looked good!" +msgstr "Great, that looked good!" -#, sh-format -msgid "Found it! The special incantation is $n" -msgstr "Found it! The special incantation is $n" - -msgid "Merlin mumbles " -msgstr "Merlin mumbles " - -msgid "NOTE: you need to interrupt Merlin before he wakes up." -msgstr "NOTE: you need to interrupt Merlin before he wakes up." +msgid "Let's have a look:" +msgstr "Let's have a look:" -msgid "Sorry, I fell asleep... Let's try again." -msgstr "Sorry, I fell asleep... Let's try again." +#, sh-format +msgid "Mmm... I didn't see anything." +msgstr "Mmm... I didn't see anything." -msgid "What's the fireworks incantation?" -msgstr "What's the fireworks incantation?" +#, sh-format +msgid "Mmm... I only saw $NB fireworks. That's not enough." +msgstr "Mmm... I only saw $NB fireworks. That's not enough." msgid "charmiglio" msgstr "charmiglio" diff --git a/missions/intermediate/05_background/i18n/fr.po b/missions/intermediate/05_background/i18n/fr.po new file mode 100644 index 00000000..5347729e --- /dev/null +++ b/missions/intermediate/05_background/i18n/fr.po @@ -0,0 +1,33 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +#, sh-format +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/fr.txt" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "$MISSION_DIR/skip/fr.txt" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "$MISSION_DIR/treasure-msg/fr.txt" + +msgid "Great, that looked good!" +msgstr "Super, c'était très joli !" + +msgid "Let's have a look:" +msgstr "Regardons à quoi ça ressemble :" + +#, sh-format +msgid "Mmm... I didn't see anything." +msgstr "Mmm... Je n'ai rien vu." + +#, sh-format +msgid "Mmm... I only saw $NB fireworks. That's not enough." +msgstr "Mmm... Je n'ai vu que $NB feux d'artifices. Ce n'est pas assez." + +msgid "charmiglio" +msgstr "charmiglio" diff --git a/missions/intermediate/05_control-C/i18n/it.po b/missions/intermediate/05_background/i18n/it.po similarity index 50% rename from missions/intermediate/05_control-C/i18n/it.po rename to missions/intermediate/05_background/i18n/it.po index 3f142971..cfe0e351 100644 --- a/missions/intermediate/05_control-C/i18n/it.po +++ b/missions/intermediate/05_background/i18n/it.po @@ -1,3 +1,4 @@ +# AUTOMATICALLY GENERATED -- DO NOT EDIT msgid "" msgstr "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -5,7 +6,7 @@ msgstr "Content-Type: text/plain; charset=UTF-8\n" # path for the text file containing the goal #, sh-format msgid "$MISSION_DIR/goal/en.txt" -msgstr "$MISSION_DIR/goal/it.txt" +msgstr "$MISSION_DIR/goal/en.txt" # path for the text file containing the skip message msgid "$MISSION_DIR/skip/en.txt" @@ -15,24 +16,19 @@ msgstr "" msgid "$MISSION_DIR/treasure-msg/en.txt" msgstr "" -msgid "Don't interrupt me when I'm in a trance!!!" -msgstr "" - -#, sh-format -msgid "Found it! The special incantation is $n" -msgstr "" - -msgid "Merlin mumbles " -msgstr "" +msgid "Great, that looked good!" +msgstr "Great, that looked good!" -msgid "NOTE: you need to interrupt Merlin before he wakes up." -msgstr "" +msgid "Let's have a look:" +msgstr "Let's have a look:" -msgid "Sorry, I fell asleep... Let's try again." -msgstr "" +#, sh-format +msgid "Mmm... I didn't see anything." +msgstr "Mmm... I didn't see anything." -msgid "What's the fireworks incantation?" -msgstr "" +#, sh-format +msgid "Mmm... I only saw $NB fireworks. That's not enough." +msgstr "Mmm... I only saw $NB fireworks. That's not enough." msgid "charmiglio" -msgstr "" +msgstr "charmiglio" diff --git a/missions/intermediate/05_control-C/i18n/template.pot b/missions/intermediate/05_background/i18n/template.pot similarity index 62% rename from missions/intermediate/05_control-C/i18n/template.pot rename to missions/intermediate/05_background/i18n/template.pot index 9d60e3bd..b96ab195 100644 --- a/missions/intermediate/05_control-C/i18n/template.pot +++ b/missions/intermediate/05_background/i18n/template.pot @@ -15,23 +15,18 @@ msgstr "" msgid "$MISSION_DIR/treasure-msg/en.txt" msgstr "" -msgid "Don't interrupt me when I'm in a trance!!!" +msgid "Great, that looked good!" msgstr "" -#, sh-format -msgid "Found it! The special incantation is $n" -msgstr "" - -msgid "Merlin mumbles " +msgid "Let's have a look:" msgstr "" -msgid "NOTE: you need to interrupt Merlin before he wakes up." -msgstr "" - -msgid "Sorry, I fell asleep... Let's try again." +#, sh-format +msgid "Mmm... I didn't see anything." msgstr "" -msgid "What's the fireworks incantation?" +#, sh-format +msgid "Mmm... I only saw $NB fireworks. That's not enough." msgstr "" msgid "charmiglio" diff --git a/missions/intermediate/05_control-C/init.sh b/missions/intermediate/05_background/init.sh similarity index 61% rename from missions/intermediate/05_control-C/init.sh rename to missions/intermediate/05_background/init.sh index ea16e3e9..4e0fba64 100644 --- a/missions/intermediate/05_control-C/init.sh +++ b/missions/intermediate/05_background/init.sh @@ -1,9 +1,6 @@ #!/usr/bin/env sh _mission_init() { - # nb of tries to make - echo $((3 + $(RANDOM) % 3)) > "$GSH_TMP/control-C" - copy_bin "$MISSION_DIR/charmiglio.sh" "$GSH_BIN/$(gettext charmiglio)" } _mission_init diff --git a/missions/intermediate/05_background/test.sh b/missions/intermediate/05_background/test.sh new file mode 100644 index 00000000..52135504 --- /dev/null +++ b/missions/intermediate/05_background/test.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env sh + +set -m + +gsh assert check false +charmiglio & gsh assert check false +charmiglio & charmiglio & gsh assert check false +charmiglio & charmiglio & charmiglio & gsh assert check true +charmiglio & charmiglio & charmiglio & charmiglio & gsh assert check true + +charmiglio & charmiglio & charmiglio +gsh assert check false + +charmiglio; charmiglio; charmiglio; +gsh assert check false + + diff --git a/missions/intermediate/05_control-C/auto.sh b/missions/intermediate/05_control-C/auto.sh deleted file mode 100644 index 4dc721f7..00000000 --- a/missions/intermediate/05_control-C/auto.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env sh - -set -m - -for _ in $(seq 6) -do - eval "$(gettext charmiglio)" 2>/dev/null & - PID=$! - sleep 3 - kill -s INT "-$PID" 2> /dev/null - - case "$(cat "$GSH_TMP/control-C")" in - *[!0-9]*) - break - ;; - *) - : - ;; - esac -done - -gsh check < "$GSH_TMP/control-C" - - diff --git a/missions/intermediate/05_control-C/charmiglio.sh b/missions/intermediate/05_control-C/charmiglio.sh deleted file mode 100755 index c1583a16..00000000 --- a/missions/intermediate/05_control-C/charmiglio.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/sh - -. gsh_gettext.sh - -control_c_start() { - [ -f "$GSH_TMP/control-C" ] || exit 255 - n=$(cat "$GSH_TMP/control-C") - case "$n" in - "" | *[!0-9]* ) - echo - echo - echo "$(eval_gettext 'Found it! The special incantation is $n')" - ;; - *) - echo - echo - echo "$(gettext "Don't interrupt me when I'm in a trance!!!")" - ;; - esac - exit 1 -} - -control_c_end() { - [ -f "$GSH_TMP/control-C" ] || exit 255 - n=$(cat "$GSH_TMP/control-C") - case "$n" in - "" | *[!0-9]* ) - echo - echo - echo "$(eval_gettext 'Found it! The special incantation is $n')" - ;; - *) - echo "$((n-1))" > "$GSH_TMP/control-C" - echo - echo - echo "$(gettext "Sorry, I fell asleep... Let's try again.")" - ;; - esac - exit 1 -} - -mumble() { - seconds=$1 # how long to mumble randomly (real time will be between $seconds and $seconds+1 - sleep=$2 # should '.' characters appears as times passes - - now=$(date +%s) - d=0 - while [ "$d" -le "$seconds" ] - do - d=$(($(date +%s) - now + 1)) - printf "$(gettext "Merlin mumbles ")" >&2 - if [ "$sleep" ] - then - # generate a string of length 26 containing more and more '.' characters - i=$((d*2)) - alpha=$(echo "xnyjqmiwkgbplvadrhfuotcsez.........................." | awk "{print substr(\$0, $i<27?$i:27, 26)}" ) - else - alpha="a-z" - fi - random_string "$((8 + $(RANDOM)%42))" | tr "a-zA-Z" "$alpha " >&2 - sleep 0.1 - done -} - -check() { - [ -f "$GSH_TMP/control-C" ] || exit 255 - n=$(cat "$GSH_TMP/control-C") - case "$n" in - "" | *[!0-9]* ) - # we already know the solution - echo - echo "$(eval_gettext 'Found it! The special incantation is $n')" - exit 0 - ;; - *) - if [ "$n" -le 0 ] - then - # if we've finished, print the solution and save it - n=$(random_string 5) - echo "$n" > "$GSH_TMP/control-C" - echo - echo "$(eval_gettext 'Found it! The special incantation is $n')" - exit 0 - fi - esac -} - -trap 'control_c_start' INT -mumble 2 # mumble for 2 second -check -trap 'control_c_end' INT -mumble 120 sleep # mumble for 2 minutes, falling to sleep -echo -echo "$(gettext "Sorry, I fell asleep... Let's try again.")" - -echo "$(gettext "NOTE: you need to interrupt Merlin before he wakes up.")" diff --git a/missions/intermediate/05_control-C/clean.sh b/missions/intermediate/05_control-C/clean.sh deleted file mode 100644 index f230756a..00000000 --- a/missions/intermediate/05_control-C/clean.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env sh - -rm -f "$GSH_TMP/control-C" diff --git a/missions/intermediate/05_control-C/goal/en.txt b/missions/intermediate/05_control-C/goal/en.txt deleted file mode 100644 index 506b3073..00000000 --- a/missions/intermediate/05_control-C/goal/en.txt +++ /dev/null @@ -1,28 +0,0 @@ -Mission goal -============ - -The wizard Merlin appears next to you and asks for your help. -You need to whisper the magic word - $ $command -to put him into a trance so that he can remember a special -incantation for creating fireworks. - -The only problem is that after a couple of seconds in a trance, -Merlin falls asleep! You thus need to interrupt him whenever -that's the case, so that he can try again. - - -NOTE: it will probably take several tries before Merlin -actually remembers the incantation - - -Useful commands -=============== - -$command - this (non standard) command puts Merlin into a trance - -Control-c (also written ^c) - pressing Control and c at the same times interrupts the current command - by sending the INT ("INTerrupt") signal to the process - diff --git a/missions/intermediate/05_control-C/goal/fr.txt b/missions/intermediate/05_control-C/goal/fr.txt deleted file mode 100644 index 18b6e95a..00000000 --- a/missions/intermediate/05_control-C/goal/fr.txt +++ /dev/null @@ -1,29 +0,0 @@ -Objectif -========= - -Le sorcier Merlin apparait à vos cotés et vous demande de -l'aide. Vous devez murmurer le mot magique - $ $command -pour le mettre dans une transe qui devrait lui permettre de -se souvenir d'une incantation spéciale pour créer des feux -d'artifice. - -Le seul problème est qu'après quelques secondes en transe, -Merlin s'endort ! Vous devez donc l'interrompre dans ce cas -pour qu'il puisse ré-essayer. - - -NOTE: il faudra probablement plusieurs essais pour que -Merlin retrouve son incantation. - - -Commandes utiles -================ - -$command - cette commande (non standard) met Merlin dans une transe - -Contrôle-c (aussi noté ^c) - appuyer sur les touches Contrôle et c en même temps interrompt - la commande en cours en envoyant le signal INT ("INTerrupt") au - processus diff --git a/missions/intermediate/05_control-C/i18n/fr.po b/missions/intermediate/05_control-C/i18n/fr.po deleted file mode 100644 index 1101d704..00000000 --- a/missions/intermediate/05_control-C/i18n/fr.po +++ /dev/null @@ -1,42 +0,0 @@ -msgid "" -msgstr "Content-Type: text/plain; charset=UTF-8\n" - "Content-Transfer-Encoding: 8bit\n" - -# path for the text file containing the goal -#, sh-format -msgid "$MISSION_DIR/goal/en.txt" -msgstr "$MISSION_DIR/goal/fr.txt" - -# path for the text file containing the skip message -msgid "$MISSION_DIR/skip/en.txt" -msgstr "" - -# path for the text file containing the treasure message -msgid "$MISSION_DIR/treasure-msg/en.txt" -msgstr "" - -msgid "Don't interrupt me when I'm in a trance!!!" -msgstr "Ne m'interromps pas pendant ma transe !!!" - -#, sh-format -msgid "Found it! The special incantation is $n" -msgstr "Trouvé ! L'incantation spéciale est $n" - -msgid "Merlin mumbles " -msgstr "Merlin marmonne " - -msgid "NOTE: you need to interrupt Merlin before he wakes up." -msgstr "NOTE : vous devez interrompre Merlin avant son réveil." - -msgid "Sorry, I fell asleep... Let's try again." -msgstr "Désolé, je m'étais endormi... Essayons encore." - -msgid "What's the fireworks incantation?" -msgstr "Quelle est l'incantation pour les feux d'artifice ?" - -msgid "charmiglio" -msgstr "charmiglio" - -#, fuzzy, sh-format -#~ msgid "Found it! The special incantion is $n" -#~ msgstr "Trouvé ! L'incantation spéciale est $n" diff --git a/missions/intermediate/06_control-C/Charmiglio.sh b/missions/intermediate/06_control-C/Charmiglio.sh new file mode 100755 index 00000000..31edfa94 --- /dev/null +++ b/missions/intermediate/06_control-C/Charmiglio.sh @@ -0,0 +1,125 @@ +#!/bin/sh + +. gsh_gettext.sh + +CODE=$1 +STATE=init + +trap 'control_c' INT +control_c() { + if [ "$STATE" = "init" ] + then + echo + echo "$(eval_gettext 'Too soon! You must leave enough time for the magical reaction to start!')" + exit 1 + else + echo + cat "$MISSION_DIR/ascii-art/explosion.txt" + echo "$(gettext "That's not working, try a different combination...")" + fi + exit 1 +} + + +indent=8 +width=16 +magical_reaction() { + seconds=$1 # how long to magical_reaction randomly (real time will be between $seconds and $seconds+1 + dud=$2 # should more '.' characters appears as times passes + + now=$(date +%s) + delay=0 + while [ "$delay" -le "$seconds" ] + do + delay=$(($(date +%s) - now)) + # NOTE: if I put $(RANDOM) inside the $((...)), interrupting the process during + # the RANDOM execution returns an empty string, and the shell complains about + # invalid arithmetic expression + r=$(RANDOM) + indent=$((indent - 2 + r%5)) + [ "$indent" -lt 0 ] && indent=0 + r=$(RANDOM) + width=$((width - 2 + r%5)) + [ "$width" -lt 1 ] && width=1 + if [ "$dud" ] + then + i=$((delay/2 + 2)) + else + i=1 + fi + alpha=$(echo "#%*():_-............." | awk "{print substr(\$0, $i<10?$i:10, 10)}" ) + printf "%*s%s\n" "$indent" '' "$(random_string "$width" "$alpha")" >&2 + sleep 0.1 + done +} + +check() { + [ -f "$GSH_TMP/control-C" ] || exit 255 + n=$(cat "$GSH_TMP/control-C") + case "$n" in + "" | *[!0-9]* ) + if [ "$n" = "$CODE" ] + then + echo + echo "$(eval_gettext 'It works! The special incantation is $CODE')" + cat "$MISSION_DIR/ascii-art/fireworks.txt" + exit 0 + else + echo "$CODE" >> "$GSH_TMP/control-C.codes" + fi + ;; + *) + if [ "$n" -le 0 ] + then + # if we've finished, print the solution and save it + echo "$CODE" > "$GSH_TMP/control-C" + echo + echo "$(eval_gettext 'It works! The special incantation is $CODE')" + cat "$MISSION_DIR/ascii-art/fireworks.txt" + exit 0 + else + echo "$CODE" >> "$GSH_TMP/control-C.codes" + echo "$((n-1))" > "$GSH_TMP/control-C" + fi + esac + STATE="final" +} + +init() { + case "$CODE" in + "") + command=$(gettext "Charmiglio") + echo "$(eval_gettext 'usage: $command CCCC + where CCCC is a sequence of 4 ASCII letters (a-zA-Z)')" + exit 1 + ;; + + *[!a-zA-Z]*) + echo "$(gettext "The incantation can only use ASCII letters.")" + exit 1 + ;; + ????) + : # 4 letters, OK + ;; + *) + echo "$(gettext "The incantation requires exactly 4 letters.")" + exit 1 + ;; + esac + + if grep -qsx "$CODE" "$GSH_TMP/control-C.codes" + then + echo "already tried!" + exit 1 + fi +} + + +init +magical_reaction 2 # magical reaction for 2 second +check +magical_reaction 600 dud # dud for 10 minutes + +echo +echo "$(gettext "That's not working, try a different combination...")" +echo "$(gettext "NOTE: you should interrupt the magical reaction after a few seconds!")" diff --git a/missions/intermediate/06_control-C/Makefile b/missions/intermediate/06_control-C/Makefile new file mode 100644 index 00000000..bd85007b --- /dev/null +++ b/missions/intermediate/06_control-C/Makefile @@ -0,0 +1,41 @@ +SH_FILES=$(wildcard *.sh) +EXCEPTIONS= +OTHER_FILES= + +LANGUAGES=$(wildcard i18n/*.po) +LANGUAGES:=$(filter-out i18n/en.po, $(LANGUAGES)) +SH_FILES:=$(filter-out $(EXCEPTIONS), $(SH_FILES)) +SORT=--sort-output +OPTIONS=--indent --no-wrap --no-location + +all: i18n/en.po $(LANGUAGES) + +add-locations: SORT=--add-location --sort-by-file +add-locations: all + +i18n/en.po: i18n/template.pot FORCE + @echo "msgen $@" + @msgen $(OPTIONS) $(SORT) i18n/template.pot --output=$@ + @echo "# AUTOMATICALLY GENERATED -- DO NOT EDIT" | cat - $@ > $@~ + @mv $@~ $@ + +$(LANGUAGES):%.po: i18n/template.pot FORCE + @echo "msgmerge $@" + @msgmerge --update $(OPTIONS) $(SORT) $@ i18n/template.pot + +i18n/template.pot: $(SH_FILES) $(OTHER_FILES) FORCE + @mkdir -p i18n/ + @echo "generating i18n/template.pot" + @xgettext --from-code=UTF-8 --omit-header $(OPTIONS) $(SORT) --join-existing --output i18n/template.pot $(SH_FILES) $(OTHER_FILES) + @echo "done" + +new: i18n/template.pot + @read -p "language code: " lang; \ + [ -e "./i18n/$$lang.po" ] && echo "file i18n/$$lang.po already exists" && exit; \ + echo "file i18n/$$lang.po created"; \ + msgcat $(OPTIONS) --output i18n/$$lang.po i18n/template.pot + +clean: + rm -f i18n/*~ + +.PHONY: all clean new FORCE diff --git a/missions/intermediate/05_control-C/ascii-art/explosion.txt b/missions/intermediate/06_control-C/ascii-art/explosion.txt similarity index 100% rename from missions/intermediate/05_control-C/ascii-art/explosion.txt rename to missions/intermediate/06_control-C/ascii-art/explosion.txt diff --git a/missions/intermediate/05_control-C/ascii-art/fireworks.txt b/missions/intermediate/06_control-C/ascii-art/fireworks.txt similarity index 100% rename from missions/intermediate/05_control-C/ascii-art/fireworks.txt rename to missions/intermediate/06_control-C/ascii-art/fireworks.txt diff --git a/missions/intermediate/06_control-C/auto.sh b/missions/intermediate/06_control-C/auto.sh new file mode 100644 index 00000000..63e4eb2c --- /dev/null +++ b/missions/intermediate/06_control-C/auto.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env sh + +set -m + + for c in a b c d e f + do + eval "$(gettext Charmiglio)" "$c$c$c$c" 2>/dev/null & + PID=$! + sleep 4 + kill -s INT "-$PID" 2> /dev/null + + case "$(cat "$GSH_TMP/control-C")" in + *[!0-9]*) + break + ;; + *) + : + ;; + esac + done + +gsh check < "$GSH_TMP/control-C" + + diff --git a/missions/intermediate/05_control-C/check.sh b/missions/intermediate/06_control-C/check.sh similarity index 50% rename from missions/intermediate/05_control-C/check.sh rename to missions/intermediate/06_control-C/check.sh index f70584c0..4497b37f 100644 --- a/missions/intermediate/05_control-C/check.sh +++ b/missions/intermediate/06_control-C/check.sh @@ -2,22 +2,22 @@ _mission_check() { r=$(cat "$GSH_TMP/control-C") - printf "%s " "$(gettext "What's the fireworks incantation?")" + printf "%s " "$(gettext "What's a valid 4 letters sequence?")" read -r n case "$r" in - "" | *[!0-9]*) + *[!a-zA-Z]*) + return 1 + ;; + ????) if [ "$n" = "$r" ] then - cat "$MISSION_DIR/ascii-art/fireworks.txt" return 0 else - cat "$MISSION_DIR/ascii-art/explosion.txt" return 1 fi ;; *) - cat "$MISSION_DIR/ascii-art/explosion.txt" return 1 esac } diff --git a/missions/intermediate/06_control-C/clean.sh b/missions/intermediate/06_control-C/clean.sh new file mode 100644 index 00000000..01fe2e36 --- /dev/null +++ b/missions/intermediate/06_control-C/clean.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +rm -f "$GSH_TMP/control-C*" diff --git a/missions/intermediate/06_control-C/goal.sh b/missions/intermediate/06_control-C/goal.sh new file mode 100644 index 00000000..2edb9b32 --- /dev/null +++ b/missions/intermediate/06_control-C/goal.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +command="$(gettext 'Charmiglio')" +sed "s/\\\$command/$command/g" "$(eval_gettext '$MISSION_DIR/goal/en.txt')" +unset command diff --git a/missions/intermediate/06_control-C/goal/en.txt b/missions/intermediate/06_control-C/goal/en.txt new file mode 100644 index 00000000..0557f438 --- /dev/null +++ b/missions/intermediate/06_control-C/goal/en.txt @@ -0,0 +1,36 @@ +Mission goal +============ + +The king's pyrotechnician is trying to remember the magical incantation +for creating the grand finale for his fireworks. This incantation starts +with the work $command and must be followed by four random letters, as +in + + $ $command abcd +or + $ $command oops + +Help the pyrotechnician by finding 4 letters producing appropriate +fireworks. + + +NOTE: when the four letters are incorrect, the magical reaction +can take a very long time. You need to interrupt it! + +It will probably take several tries before finding a combination +of letters that works. + + +Useful commands +=============== + +$command CCCC + this (non standard) command creates some fireworks + - if the four letters are valid, the fireworks will start after a few + seconds + - if the four letters are not valid, the whole magical reaction will go + on for a long time + +Control-c (also written ^c) + pressing Control and c at the same times interrupts the current command + by sending the INT ("INTerrupt") signal to the process diff --git a/missions/intermediate/06_control-C/goal/fr.txt b/missions/intermediate/06_control-C/goal/fr.txt new file mode 100644 index 00000000..b9de6d5b --- /dev/null +++ b/missions/intermediate/06_control-C/goal/fr.txt @@ -0,0 +1,36 @@ +Objectif +========= + +L'artificier royal essaie de se souvenir de l'incantation magique qui génère +le bouquet final de son grand feu d'artifices. Cette incantation commence par +le mot $command et doit être suivie de quatre lettres aléatoires comme dans + + $ $command abcd +ou + $ $command oups + +Aidez l'artificier en trouvant quatres lettres qui produisent un feu +d'artifices approprié. + + +NOTE: lorsque les quatres lettres sont incorrectes, la réaction +magique peut prendre beaucoup de temps. Il faudra l'interrompre ! + +Il est probable que vous deviez faire plusieurs essais pour +trouver une suite de quatre lettres qui fonctionne. + + +Commandes utiles +================ + +$command CCCC + cette commande (non standard) génère un feu d'artifice + - si les quatre lettres sont valides, le feu d'artifice partira + au bout de quelques secondes + - si les quatres lettres ne sont pas valides, la réaction magique + continuera pendant longtemps + +Contrôle-c (aussi noté ^c) + appuyer sur les touches Contrôle et c en même temps interrompt + la commande en cours en envoyant le signal INT ("INTerrupt") au + processus diff --git a/missions/intermediate/06_control-C/i18n/en.po b/missions/intermediate/06_control-C/i18n/en.po new file mode 100644 index 00000000..a9a48bdc --- /dev/null +++ b/missions/intermediate/06_control-C/i18n/en.po @@ -0,0 +1,49 @@ +# AUTOMATICALLY GENERATED -- DO NOT EDIT +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +#, sh-format +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/en.txt" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "$MISSION_DIR/skip/en.txt" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "$MISSION_DIR/treasure-msg/en.txt" + +msgid "Charmiglio" +msgstr "Charmiglio" + +#, sh-format +msgid "It works! The special incantation is $CODE" +msgstr "It works! The special incantation is $CODE" + +msgid "NOTE: you should interrupt the magical reaction after a few seconds!" +msgstr "NOTE: you should interrupt the magical reaction after a few seconds!" + +msgid "That's not working, try a different combination..." +msgstr "That's not working, try a different combination..." + +msgid "The incantation can only use ASCII letters." +msgstr "The incantation can only use ASCII letters." + +msgid "The incantation requires exactly 4 letters." +msgstr "The incantation requires exactly 4 letters." + +#, sh-format +msgid "Too soon! You must leave enough time for the magical reaction to start!" +msgstr "Too soon! You must leave enough time for the magical reaction to start!" + +msgid "What's a valid 4 letters sequence?" +msgstr "What's a valid 4 letters sequence?" + +#, sh-format +msgid "usage: $command CCCC\n" + " where CCCC is a sequence of 4 ASCII letters (a-zA-Z)" +msgstr "usage: $command CCCC\n" + " where CCCC is a sequence of 4 ASCII letters (a-zA-Z)" diff --git a/missions/intermediate/06_control-C/i18n/fr.po b/missions/intermediate/06_control-C/i18n/fr.po new file mode 100644 index 00000000..48a249ed --- /dev/null +++ b/missions/intermediate/06_control-C/i18n/fr.po @@ -0,0 +1,48 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +#, sh-format +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/fr.txt" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" + +msgid "Charmiglio" +msgstr "Charmiglio" + +#, sh-format +msgid "It works! The special incantation is $CODE" +msgstr "Ça marche ! L'incantation spéciale est $CODE" + +msgid "NOTE: you should interrupt the magical reaction after a few seconds!" +msgstr "NOTE : vous devriez interrompre la réaction magique après quelques secondes !" + +msgid "That's not working, try a different combination..." +msgstr "Ça ne marche pas, essayez une autre combinaison..." + +msgid "The incantation can only use ASCII letters." +msgstr "L'incantation ne peut utiliser que des lettres ASCII." + +msgid "The incantation requires exactly 4 letters." +msgstr "L'incantation nécessite exactement 4 lettres." + +#, sh-format +msgid "Too soon! You must leave enough time for the magical reaction to start!" +msgstr "Trop tôt ! Vous devez laisser assez de temps pour que la réaction magique commence !" + +msgid "What's a valid 4 letters sequence?" +msgstr "Qu'est-ce qu'une combinaison valide ?" + +#, sh-format +msgid "usage: $command CCCC\n" + " where CCCC is a sequence of 4 ASCII letters (a-zA-Z)" +msgstr "utilisation : $command CCCC\n" + " où CCCC est une suite de 4 lettres ASCII (a-zA-Z)" diff --git a/missions/intermediate/06_control-C/i18n/it.po b/missions/intermediate/06_control-C/i18n/it.po new file mode 100644 index 00000000..693fda76 --- /dev/null +++ b/missions/intermediate/06_control-C/i18n/it.po @@ -0,0 +1,49 @@ +# AUTOMATICALLY GENERATED -- DO NOT EDIT +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +#, sh-format +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/en.txt" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" + +msgid "Charmiglio" +msgstr "Charmiglio" + +#, sh-format +msgid "It works! The special incantation is $CODE" +msgstr "It works! The special incantation is $CODE" + +msgid "NOTE: you should interrupt the magical reaction after a few seconds!" +msgstr "NOTE: you should interrupt the magical reaction after a few seconds!" + +msgid "That's not working, try a different combination..." +msgstr "That's not working, try a different combination..." + +msgid "The incantation can only use ASCII letters." +msgstr "The incantation can only use ASCII letters." + +msgid "The incantation requires exactly 4 letters." +msgstr "The incantation requires exactly 4 letters." + +#, sh-format +msgid "Too soon! You must leave enough time for the magical reaction to start!" +msgstr "Too soon! You must leave enough time for the magical reaction to start!" + +msgid "What's a valid 4 letters sequence?" +msgstr "What's a valid 4 letters sequence?" + +#, sh-format +msgid "usage: $command CCCC\n" + " where CCCC is a sequence of 4 ASCII letters (a-zA-Z)" +msgstr "usage: $command CCCC\n" + " where CCCC is a sequence of 4 ASCII letters (a-zA-Z)" diff --git a/missions/intermediate/06_control-C/i18n/template.pot b/missions/intermediate/06_control-C/i18n/template.pot new file mode 100644 index 00000000..416128ee --- /dev/null +++ b/missions/intermediate/06_control-C/i18n/template.pot @@ -0,0 +1,47 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + +# path for the text file containing the goal +#, sh-format +msgid "$MISSION_DIR/goal/en.txt" +msgstr "" + +# path for the text file containing the skip message +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" + +# path for the text file containing the treasure message +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" + +msgid "Charmiglio" +msgstr "" + +#, sh-format +msgid "It works! The special incantation is $CODE" +msgstr "" + +msgid "NOTE: you should interrupt the magical reaction after a few seconds!" +msgstr "" + +msgid "That's not working, try a different combination..." +msgstr "" + +msgid "The incantation can only use ASCII letters." +msgstr "" + +msgid "The incantation requires exactly 4 letters." +msgstr "" + +#, sh-format +msgid "Too soon! You must leave enough time for the magical reaction to start!" +msgstr "" + +msgid "What's a valid 4 letters sequence?" +msgstr "" + +#, sh-format +msgid "usage: $command CCCC\n" + " where CCCC is a sequence of 4 ASCII letters (a-zA-Z)" +msgstr "" diff --git a/missions/intermediate/06_control-C/init.sh b/missions/intermediate/06_control-C/init.sh new file mode 100644 index 00000000..d081f8dd --- /dev/null +++ b/missions/intermediate/06_control-C/init.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +_mission_init() { + # nb of tries to make + echo $((2 + $(RANDOM) % 3)) > "$GSH_TMP/control-C" + rm -f "$GSH_TMP/control-C.codes" + + copy_bin "$MISSION_DIR/Charmiglio.sh" "$GSH_BIN/$(gettext Charmiglio)" +} +_mission_init diff --git a/missions/intermediate/05_control-C/test.sh b/missions/intermediate/06_control-C/test.sh similarity index 74% rename from missions/intermediate/05_control-C/test.sh rename to missions/intermediate/06_control-C/test.sh index f47c342e..7f6d11c1 100644 --- a/missions/intermediate/05_control-C/test.sh +++ b/missions/intermediate/06_control-C/test.sh @@ -6,9 +6,9 @@ do_test() { nb=$1 delay=$2 - for _ in $(seq "$nb") + for c in $(echo "a b c d e f g h i j" | cut -d' ' -f1-$nb) do - eval "$(gettext charmiglio)" 2>/dev/null & + eval "$(gettext Charmiglio)" "$c$c$c$c" 2>/dev/null & PID=$! sleep "$delay" kill -s INT "-$PID" 2> /dev/null @@ -27,8 +27,8 @@ do_test() { do_test 10 0.3 gsh assert check false < "$GSH_TMP/control-C" -do_test 3 3 +do_test 2 4 gsh assert check false < "$GSH_TMP/control-C" -do_test 6 3 +do_test 6 4 gsh assert check true < "$GSH_TMP/control-C" diff --git a/missions/intermediate/index.txt b/missions/intermediate/index.txt index 9bca21db..4a518eb4 100644 --- a/missions/intermediate/index.txt +++ b/missions/intermediate/index.txt @@ -2,4 +2,5 @@ 02_alias_journal 03_tab_spider_lair 04_bg_xeyes -05_control-C +05_background +06_control-C From b4ab210c1530c861b501922557cd7136b599c9d4 Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Thu, 29 Aug 2024 14:05:48 +0200 Subject: [PATCH 08/30] feat(l1on): italian for 2 new missions --- .../intermediate/05_background/goal/it.txt | 28 ++++++++ .../intermediate/05_background/i18n/it.po | 48 ++++++++----- .../intermediate/06_control-C/goal/it.txt | 33 +++++++++ missions/intermediate/06_control-C/i18n/it.po | 71 +++++++++++-------- 4 files changed, 132 insertions(+), 48 deletions(-) create mode 100644 missions/intermediate/05_background/goal/it.txt create mode 100644 missions/intermediate/06_control-C/goal/it.txt diff --git a/missions/intermediate/05_background/goal/it.txt b/missions/intermediate/05_background/goal/it.txt new file mode 100644 index 00000000..876652f2 --- /dev/null +++ b/missions/intermediate/05_background/goal/it.txt @@ -0,0 +1,28 @@ +Obiettivi missione +============ + +IL pirotecnico del re appare vicino a te. Ti chiede se ne puoi accendere **almeno +3** così che possa vederli da lontano. + +Un singolo fuoco d'artificio può essere acceso con: + + $command + + +Comandi utili +=============== + +$command + questo commando (non standard) crea un piccolo fuoco d'artificio + +COMMAND & + esegue il comando, ma non aspetta finchè il comando ha finito per tornare al terminale + Il commando verrà eseguito in "background". + +COMMAND1 ; COMMAND2 ; ... ; COMMANDn + esegue i comandi uno dopo l'altro + Ogni comando è eseguito quando il precedente ha finito + +COMMAND1 & COMMAND2 & ... & COMMANDn + esegue i comandi "in parallelo" + Tutti i comandi sono eseguito in "background", eccetto l'ultimo. diff --git a/missions/intermediate/05_background/i18n/it.po b/missions/intermediate/05_background/i18n/it.po index cfe0e351..ecc03ae9 100644 --- a/missions/intermediate/05_background/i18n/it.po +++ b/missions/intermediate/05_background/i18n/it.po @@ -1,34 +1,44 @@ # AUTOMATICALLY GENERATED -- DO NOT EDIT -msgid "" -msgstr "Content-Type: text/plain; charset=UTF-8\n" - "Content-Transfer-Encoding: 8bit\n" +# mte90 , 2024. +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Last-Translator: mte90 \n" +"PO-Revision-Date: 2024-08-29 13:53+0200\n" +"Project-Id-Version: \n" +"Language-Team: Italian \n" +"Language: it_IT\n" +"MIME-Version: 1.0\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Lokalize 22.12.3\n" # path for the text file containing the goal #, sh-format -msgid "$MISSION_DIR/goal/en.txt" -msgstr "$MISSION_DIR/goal/en.txt" +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/it.txt" # path for the text file containing the skip message -msgid "$MISSION_DIR/skip/en.txt" -msgstr "" +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" # path for the text file containing the treasure message -msgid "$MISSION_DIR/treasure-msg/en.txt" -msgstr "" +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" -msgid "Great, that looked good!" -msgstr "Great, that looked good!" +msgid "Great, that looked good!" +msgstr "Ottimo, sembra tutto a posto!" -msgid "Let's have a look:" -msgstr "Let's have a look:" +msgid "Let's have a look:" +msgstr "Vediamo insieme:" #, sh-format -msgid "Mmm... I didn't see anything." -msgstr "Mmm... I didn't see anything." +msgid "Mmm... I didn't see anything." +msgstr "Mmm... non vedo niente." #, sh-format -msgid "Mmm... I only saw $NB fireworks. That's not enough." -msgstr "Mmm... I only saw $NB fireworks. That's not enough." +msgid "Mmm... I only saw $NB fireworks. That's not enough." +msgstr "Mmm... io vedo solo $NB fuochi d'artificio. Non sono sufficenti." -msgid "charmiglio" -msgstr "charmiglio" +msgid "charmiglio" +msgstr "charmiglio" diff --git a/missions/intermediate/06_control-C/goal/it.txt b/missions/intermediate/06_control-C/goal/it.txt new file mode 100644 index 00000000..05c45c18 --- /dev/null +++ b/missions/intermediate/06_control-C/goal/it.txt @@ -0,0 +1,33 @@ +Obiettivi missione +============ + +Il pirotecnico del re sta cercando di rcordarsi gli incantesimi magici +per creare il gran finale per il suo spettacolo. Questo incantesimo comincia +il lavoro $command e deve essere seguito da 4 lettere casuali come + + $ $command abcd +o + $ $command oops + +Aiuta il pirotecnico trovando 4 lettere per lanciare i fuochi giusti. + + +NOTA: quando le quattro lettere sono sbagliate, la reazione magica +può richiedere molto tempo. Devi interromperla! + +Sarà necessario provare diverse volte per trovare la combinazione giusta di +lettere che funziona. + + +Comandi utili +=============== + +$command CCCC + questo comando (non standard) create alcuni fuochi d'artificio + - se le quattro lettere sono valide, i fuochi cominceranno dopo pochi secondi + - se le quattro lettere non sono valide, la reazione magica richiederà molto + tempo per fallire + +Control-c (scritto anche come ^c) + premendo Control e c allo stesso tempo interrompe il comando attuale + inviando il segnale di INTerruzione al processo diff --git a/missions/intermediate/06_control-C/i18n/it.po b/missions/intermediate/06_control-C/i18n/it.po index 693fda76..897dd229 100644 --- a/missions/intermediate/06_control-C/i18n/it.po +++ b/missions/intermediate/06_control-C/i18n/it.po @@ -1,49 +1,62 @@ # AUTOMATICALLY GENERATED -- DO NOT EDIT -msgid "" -msgstr "Content-Type: text/plain; charset=UTF-8\n" - "Content-Transfer-Encoding: 8bit\n" +# mte90 , 2024. +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Last-Translator: mte90 \n" +"PO-Revision-Date: 2024-08-29 14:05+0200\n" +"Project-Id-Version: \n" +"Language-Team: Italian \n" +"Language: it_IT\n" +"MIME-Version: 1.0\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Lokalize 22.12.3\n" # path for the text file containing the goal #, sh-format -msgid "$MISSION_DIR/goal/en.txt" -msgstr "$MISSION_DIR/goal/en.txt" +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/it.txt" # path for the text file containing the skip message -msgid "$MISSION_DIR/skip/en.txt" -msgstr "" +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" # path for the text file containing the treasure message -msgid "$MISSION_DIR/treasure-msg/en.txt" -msgstr "" +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" -msgid "Charmiglio" -msgstr "Charmiglio" +msgid "Charmiglio" +msgstr "Charmiglio" #, sh-format -msgid "It works! The special incantation is $CODE" -msgstr "It works! The special incantation is $CODE" +msgid "It works! The special incantation is $CODE" +msgstr "Funziona! L'incantesimo speciale è $CODE" -msgid "NOTE: you should interrupt the magical reaction after a few seconds!" -msgstr "NOTE: you should interrupt the magical reaction after a few seconds!" +msgid "NOTE: you should interrupt the magical reaction after a few seconds!" +msgstr "NOTA: puoi interrompere la reazione magica dopo pochi secondi!" -msgid "That's not working, try a different combination..." -msgstr "That's not working, try a different combination..." +msgid "That's not working, try a different combination..." +msgstr "Non ha funzionato, prova una combinazione differente..." -msgid "The incantation can only use ASCII letters." -msgstr "The incantation can only use ASCII letters." +msgid "The incantation can only use ASCII letters." +msgstr "L'incantesimo può utilizzare solo caratteri ASCII." -msgid "The incantation requires exactly 4 letters." -msgstr "The incantation requires exactly 4 letters." +msgid "The incantation requires exactly 4 letters." +msgstr "L'incantesimo richiede esattamente 4 lettere." #, sh-format -msgid "Too soon! You must leave enough time for the magical reaction to start!" -msgstr "Too soon! You must leave enough time for the magical reaction to start!" +msgid "Too soon! You must leave enough time for the magical reaction to start!" +msgstr "" +"Troppo presto! Devi dare abbastanza tempo per l'avvio della reazione magica!" -msgid "What's a valid 4 letters sequence?" -msgstr "What's a valid 4 letters sequence?" +msgid "What's a valid 4 letters sequence?" +msgstr "Cosa è una sequenza valida di 4 lettere?" #, sh-format -msgid "usage: $command CCCC\n" - " where CCCC is a sequence of 4 ASCII letters (a-zA-Z)" -msgstr "usage: $command CCCC\n" - " where CCCC is a sequence of 4 ASCII letters (a-zA-Z)" +msgid "" +"usage: $command CCCC\n" +" where CCCC is a sequence of 4 ASCII letters (a-zA-Z)" +msgstr "" +"uso: $command CCCC\n" +" dove CCCC è una sequenza di 4 caratteri ASCII (a-zA-Z)" From ce693a8bcdbfe32d6c463fd79e8941fe6aefc03d Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Thu, 29 Aug 2024 14:06:55 +0200 Subject: [PATCH 09/30] feat(l1on): italian for 2 new missions --- missions/intermediate/05_background/goal/it.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/missions/intermediate/05_background/goal/it.txt b/missions/intermediate/05_background/goal/it.txt index 876652f2..9fc94fa4 100644 --- a/missions/intermediate/05_background/goal/it.txt +++ b/missions/intermediate/05_background/goal/it.txt @@ -17,7 +17,7 @@ $command COMMAND & esegue il comando, ma non aspetta finchè il comando ha finito per tornare al terminale - Il commando verrà eseguito in "background". + Il comando verrà eseguito in "background". COMMAND1 ; COMMAND2 ; ... ; COMMANDn esegue i comandi uno dopo l'altro @@ -25,4 +25,4 @@ COMMAND1 ; COMMAND2 ; ... ; COMMANDn COMMAND1 & COMMAND2 & ... & COMMANDn esegue i comandi "in parallelo" - Tutti i comandi sono eseguito in "background", eccetto l'ultimo. + Tutti i comandi sono eseguiti in "background", eccetto l'ultimo. From 9ab206dd32cc43506efccde201b2d014a5f197bf Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Thu, 29 Aug 2024 14:18:02 +0200 Subject: [PATCH 10/30] minor changes in a couple of goal files --- missions/intermediate/04_bg_xeyes/goal/en.txt | 6 +++--- missions/intermediate/04_bg_xeyes/goal/fr.txt | 7 ++++--- missions/intermediate/05_background/goal/en.txt | 8 ++++---- missions/intermediate/05_background/goal/fr.txt | 10 +++++----- missions/intermediate/06_control-C/goal/en.txt | 10 +++++----- missions/intermediate/06_control-C/goal/fr.txt | 10 +++++----- 6 files changed, 26 insertions(+), 25 deletions(-) diff --git a/missions/intermediate/04_bg_xeyes/goal/en.txt b/missions/intermediate/04_bg_xeyes/goal/en.txt index 9705bfe5..be10335a 100644 --- a/missions/intermediate/04_bg_xeyes/goal/en.txt +++ b/missions/intermediate/04_bg_xeyes/goal/en.txt @@ -18,6 +18,6 @@ xeyes COMMAND & Run the command in the background. -Control-c - This key binding usually interrupts the current command by sending - it the "INT" signal. +Control-c (also written ^c) + Pressing Control and c at the same times interrupts the current command + by sending the INT ("INTerrupt") signal to the process. diff --git a/missions/intermediate/04_bg_xeyes/goal/fr.txt b/missions/intermediate/04_bg_xeyes/goal/fr.txt index cc79deef..0e8540bc 100644 --- a/missions/intermediate/04_bg_xeyes/goal/fr.txt +++ b/missions/intermediate/04_bg_xeyes/goal/fr.txt @@ -19,6 +19,7 @@ xeyes COMMANDE & Lance la commande en tâche de fond. -Control-c - Cette combinaison de touche permet (en général) d'interrompre la - commande en cours d'exécution en lui envoyant le signal "INT". +Contrôle-c (aussi noté ^c) + Appuyer sur les touches Contrôle et c en même temps interrompt + la commande en cours en envoyant le signal INT ("INTerrupt") au + processus. diff --git a/missions/intermediate/05_background/goal/en.txt b/missions/intermediate/05_background/goal/en.txt index fc02db19..f6b7e959 100644 --- a/missions/intermediate/05_background/goal/en.txt +++ b/missions/intermediate/05_background/goal/en.txt @@ -13,16 +13,16 @@ Useful commands =============== $command - this (non standard) command creates a single small firework + This (non standard) command creates a single small firework. COMMAND & - run the given command, but don't wait until it is finished to return + Run the given command, but don't wait until it is finished to return. The command will run in the "background". COMMAND1 ; COMMAND2 ; ... ; COMMANDn - run the given commands one after the other + Run the given commands one after the other. Each command is run when the previous one is finished. COMMAND1 & COMMAND2 & ... & COMMANDn - run the given commands "in parallel" + Run the given commands "in parallel". All the commands are run in the "background", except the last one. diff --git a/missions/intermediate/05_background/goal/fr.txt b/missions/intermediate/05_background/goal/fr.txt index 7244ff09..96ef02cd 100644 --- a/missions/intermediate/05_background/goal/fr.txt +++ b/missions/intermediate/05_background/goal/fr.txt @@ -13,17 +13,17 @@ Commandes utiles ================ $command - cette commande (non standard) lance un feu d'artifice simple + Cette commande (non standard) lance un feu d'artifice simple. COMMANDE & - exécute la commande mais n'attend pas qu'elle soit terminée pour reprendre - l'exécution du shell + Exécute la commande mais n'attend pas qu'elle soit terminée pour reprendre + l'exécution du shell. La commande s'exécute "en arrière plan". COMMAND1 ; COMMAND2 ; ... ; COMMANDn - exécute les commandes données, l'une après l'autre + Exécute les commandes données, l'une après l'autre. Chaque commande est exécutée lorsque la précédente est terminée. COMMAND1 & COMMAND2 & ... & COMMANDn - exécute les commandes données, "en parallèle" + Exécute les commandes données, "en parallèle". Toutes les commandes sont exécutées "en arrière plan", sauf la dernière. diff --git a/missions/intermediate/06_control-C/goal/en.txt b/missions/intermediate/06_control-C/goal/en.txt index 0557f438..3b6edee2 100644 --- a/missions/intermediate/06_control-C/goal/en.txt +++ b/missions/intermediate/06_control-C/goal/en.txt @@ -25,12 +25,12 @@ Useful commands =============== $command CCCC - this (non standard) command creates some fireworks + This (non standard) command creates some fireworks: - if the four letters are valid, the fireworks will start after a few - seconds + seconds, - if the four letters are not valid, the whole magical reaction will go - on for a long time + on for a long time. Control-c (also written ^c) - pressing Control and c at the same times interrupts the current command - by sending the INT ("INTerrupt") signal to the process + Pressing Control and c at the same times interrupts the current command + by sending the INT ("INTerrupt") signal to the process. diff --git a/missions/intermediate/06_control-C/goal/fr.txt b/missions/intermediate/06_control-C/goal/fr.txt index b9de6d5b..0bc6e58f 100644 --- a/missions/intermediate/06_control-C/goal/fr.txt +++ b/missions/intermediate/06_control-C/goal/fr.txt @@ -24,13 +24,13 @@ Commandes utiles ================ $command CCCC - cette commande (non standard) génère un feu d'artifice + Cette commande (non standard) génère un feu d'artifice - si les quatre lettres sont valides, le feu d'artifice partira - au bout de quelques secondes + au bout de quelques secondes, - si les quatres lettres ne sont pas valides, la réaction magique - continuera pendant longtemps + continuera pendant longtemps. Contrôle-c (aussi noté ^c) - appuyer sur les touches Contrôle et c en même temps interrompt + Appuyer sur les touches Contrôle et c en même temps interrompt la commande en cours en envoyant le signal INT ("INTerrupt") au - processus + processus. From f3e5e7a907c1b491e9e6219560786d40fa151448 Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Thu, 29 Aug 2024 14:12:50 +0200 Subject: [PATCH 11/30] make the xeyes and cal missions skippable by default --- missions/index.txt | 46 ++++++++++--------- missions/intermediate/04_bg_xeyes/skip/en.txt | 4 ++ missions/intermediate/04_bg_xeyes/skip/fr.txt | 4 ++ missions/misc/01_cal_nostradamus/skip/en.txt | 4 ++ missions/misc/01_cal_nostradamus/skip/fr.txt | 4 ++ 5 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 missions/intermediate/04_bg_xeyes/skip/en.txt create mode 100644 missions/intermediate/04_bg_xeyes/skip/fr.txt create mode 100644 missions/misc/01_cal_nostradamus/skip/en.txt create mode 100644 missions/misc/01_cal_nostradamus/skip/fr.txt diff --git a/missions/index.txt b/missions/index.txt index 01cddc07..428ceb7f 100644 --- a/missions/index.txt +++ b/missions/index.txt @@ -1,22 +1,24 @@ -basic/index.txt -misc/01_cal_nostradamus -intermediate/01_alias_la -misc/02_nano_journal -intermediate/02_alias_journal -intermediate/03_tab_spider_lair -intermediate/04_bg_xeyes -intermediate/05_background -intermediate/06_control-C -!finding_files_maze/00_shared -finding_files_maze/01_ls_cd -finding_files_maze/02_tree -finding_files_maze/03_find_1 -pipe_intro_book_of_potions/index.txt -processes/index.txt -stdin_stdout_stderr/index.txt -permissions/index.txt -finding_files_maze/04_find_2 -finding_files_maze/05_find_xargs_grep -pipes_merchant_stall/index.txt -misc/03_tr_caesar_shift -FINAL_MISSION +# default Gameshell missions order + + basic/index.txt + misc/01_cal_nostradamus + intermediate/01_alias_la + misc/02_nano_journal + intermediate/02_alias_journal + intermediate/03_tab_spider_lair + intermediate/04_bg_xeyes + intermediate/05_background + intermediate/06_control-C + !finding_files_maze/00_shared + finding_files_maze/01_ls_cd + finding_files_maze/02_tree + finding_files_maze/03_find_1 + pipe_intro_book_of_potions/index.txt + processes/index.txt + stdin_stdout_stderr/index.txt + permissions/index.txt + finding_files_maze/04_find_2 + finding_files_maze/05_find_xargs_grep + pipes_merchant_stall/index.txt + misc/03_tr_caesar_shift + FINAL_MISSION diff --git a/missions/intermediate/04_bg_xeyes/skip/en.txt b/missions/intermediate/04_bg_xeyes/skip/en.txt new file mode 100644 index 00000000..8f8cf258 --- /dev/null +++ b/missions/intermediate/04_bg_xeyes/skip/en.txt @@ -0,0 +1,4 @@ +This mission is optionnal. You can skip it and go to the next one with the +command + + $ gsh skip diff --git a/missions/intermediate/04_bg_xeyes/skip/fr.txt b/missions/intermediate/04_bg_xeyes/skip/fr.txt new file mode 100644 index 00000000..a1ca28f6 --- /dev/null +++ b/missions/intermediate/04_bg_xeyes/skip/fr.txt @@ -0,0 +1,4 @@ +Cette mission est facultative. Vous pouvez l'ignorer et passer à la suivante +avec la commande + + $ gsh skip diff --git a/missions/misc/01_cal_nostradamus/skip/en.txt b/missions/misc/01_cal_nostradamus/skip/en.txt new file mode 100644 index 00000000..8f8cf258 --- /dev/null +++ b/missions/misc/01_cal_nostradamus/skip/en.txt @@ -0,0 +1,4 @@ +This mission is optionnal. You can skip it and go to the next one with the +command + + $ gsh skip diff --git a/missions/misc/01_cal_nostradamus/skip/fr.txt b/missions/misc/01_cal_nostradamus/skip/fr.txt new file mode 100644 index 00000000..a1ca28f6 --- /dev/null +++ b/missions/misc/01_cal_nostradamus/skip/fr.txt @@ -0,0 +1,4 @@ +Cette mission est facultative. Vous pouvez l'ignorer et passer à la suivante +avec la commande + + $ gsh skip From f55660e143eff26dfc44df1ff09d83cf960638b4 Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Thu, 29 Aug 2024 14:27:55 +0200 Subject: [PATCH 12/30] show skipable missions in gsh index --- i18n/en.po | 3 +++ i18n/fr.po | 3 +++ i18n/it.po | 3 +++ i18n/template.pot | 3 +++ scripts/_gsh_index | 16 +++++++++++----- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/i18n/en.po b/i18n/en.po index 5a673fcb..b5948f90 100644 --- a/i18n/en.po +++ b/i18n/en.po @@ -283,6 +283,9 @@ msgstr[1] "game time: %s in %d sessions" msgid "n" msgstr "n" +msgid "optional" +msgstr "optional" + msgid "password:" msgstr "password:" diff --git a/i18n/fr.po b/i18n/fr.po index 1f36739c..e4f357a9 100644 --- a/i18n/fr.po +++ b/i18n/fr.po @@ -290,6 +290,9 @@ msgstr[1] "temps de jeu : %s en %d sessions" msgid "n" msgstr "n" +msgid "optional" +msgstr "facultatif" + msgid "password:" msgstr "mot de passe :" diff --git a/i18n/it.po b/i18n/it.po index aed99ffd..908e78b9 100644 --- a/i18n/it.po +++ b/i18n/it.po @@ -298,6 +298,9 @@ msgstr[1] "tempo di gioco: %s in %d sessioni" msgid "n" msgstr "n" +msgid "optional" +msgstr "facoltativo" + msgid "password:" msgstr "password:" diff --git a/i18n/template.pot b/i18n/template.pot index 0c0c03fc..81f5f76a 100644 --- a/i18n/template.pot +++ b/i18n/template.pot @@ -266,6 +266,9 @@ msgstr[1] "" msgid "n" msgstr "" +msgid "optional" +msgstr "" + msgid "password:" msgstr "" diff --git a/scripts/_gsh_index b/scripts/_gsh_index index c20f0890..073de68d 100755 --- a/scripts/_gsh_index +++ b/scripts/_gsh_index @@ -11,22 +11,28 @@ do continue fi + SKIPABLE="" + if [ -f "$GSH_MISSIONS/$mission_dir/skip.txt" ] || [ -d "$GSH_MISSIONS/$mission_dir/skip" ] + then + SKIPABLE=" [$(gettext "optional")]" + fi + if grep -q "^$n CHECK_OK" "$GSH_CONFIG/missions.log" then COLOR="green" - STATUS=" ($(gettext "completed"))" + STATUS=" ($(gettext "completed"))" elif grep -q "^$n CHECK_OOPS" "$GSH_CONFIG/missions.log" then COLOR="red" - STATUS=" ($(gettext "failed"))" + STATUS=" ($(gettext "failed"))" elif grep -q "^$n SKIP" "$GSH_CONFIG/missions.log" then COLOR="yellow" - STATUS=" ($(gettext "skipped"))" + STATUS=" ($(gettext "skipped"))" elif grep -q "^$n CANCEL_DEP_PB" "$GSH_CONFIG/missions.log" then COLOR="magenta" - STATUS=" ($(gettext "cancelled"))" + STATUS=" ($(gettext "cancelled"))" else COLOR="white" STATUS="" @@ -39,7 +45,7 @@ do fi printf "%s%2d " "$LEAD" "$n" - color_echo "$COLOR" "$mission_dir$STATUS" + color_echo "$COLOR" "$mission_dir$SKIPABLE$STATUS" n="$((n + 1))" done < "$GSH_CONFIG/index.txt" | pager From c75c2e713726806c84a6497f5941c1bcf3f13870 Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Wed, 28 Aug 2024 14:49:18 +0200 Subject: [PATCH 13/30] reset to current mission when next mission isn't found --- lib/gsh.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/gsh.sh b/lib/gsh.sh index 69bd86fb..a884fda2 100644 --- a/lib/gsh.sh +++ b/lib/gsh.sh @@ -44,7 +44,7 @@ __log_action() { _gsh_reset() { - local MISSION_NB="$(_gsh_pcm)" + local MISSION_NB="${1:-$(_gsh_pcm)}" if [ -z "$MISSION_NB" ] then local fn_name="${FUNCNAME[0]}" @@ -226,11 +226,10 @@ __gsh_start() { color_echo red "$(eval_gettext "Error: mission \$MISSION_NB doesn't exist!")" >&2 echo __log_action "$MISSION_NB" "UNKNOWN_MISSION" - gsh reset + gsh reset $(($MISSION_NB-1)) # reset the previous (current) mission return 1 fi - # re-source static.sh, in case some important directory was removed by accident [ -f "$MISSION_DIR/static.sh" ] && mission_source "$MISSION_DIR/static.sh" @@ -671,8 +670,8 @@ gsh() { ;; "reset") export GSH_LAST_ACTION='reset' - __gsh_clean - _gsh_reset + __gsh_clean "$1" + _gsh_reset "$1" ;; "resetstatic") _gsh_resetstatic From 7a7a2ca308bf38065b639117ee35e9ac3cfda89e Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Wed, 28 Aug 2024 16:09:28 +0200 Subject: [PATCH 14/30] adding the possibility of having several index files in the same archive $./utils/archive.sh -I index-short.txt -I index-all.txt MISSIONS will generate a standalone archive with 3 index files (and all the necessary missions): - index.txt, containing all the MISSIONS given as arguments - index-short.txt, containing the missions from index-short.txt - index-all.txt, containing the missions from index-all.txt You can choose which index file to use when starting a Gameshell instance: $ ./gameshell.sh or equivalently $ ./gameshell.sh index.txt uses index.txt and $ ./gameshell.sh index-short.txt uses index-short.txt --- scripts/make_index | 13 ++++-- utils/archive.sh | 113 ++++++++++++++++++++++++++++----------------- 2 files changed, 80 insertions(+), 46 deletions(-) diff --git a/scripts/make_index b/scripts/make_index index 37cd4f89..ce8dbfe5 100755 --- a/scripts/make_index +++ b/scripts/make_index @@ -113,11 +113,18 @@ make_index() { # without argument, use the default index file parse_index "$GSH_MISSIONS/index.txt" || exit 1 return 0 - # when given a directory containing either a "bin" directory or a - # "static.sh" script, this is a dummy mission. Just print the path - # prefixed with a "!" fi + if [ "$#" -eq 1 ] && [ -f "$GSH_MISSIONS/$1" ] + then + # with a single file argument, we assume it is an index file + parse_index "$GSH_MISSIONS/$1" || exit 1 + return 0 + fi + + # otherwise, parse each mission / index file from the arguments + # (Note, it should not be used from a GameShell instance, but only directly + # from ``start.sh`` or from ``utils/archive.sh`` while [ "$#" -gt 0 ] do MISSION_DIR=$(readlink-f "$1") diff --git a/utils/archive.sh b/utils/archive.sh index 9781601f..8cf18e88 100755 --- a/utils/archive.sh +++ b/utils/archive.sh @@ -19,6 +19,8 @@ options: and not using gettext -N ... name of the archive / top directory (default: "gameshell") + -I FILE additional existing index file to include + (can be given several times) -S simple -S index @@ -60,9 +62,11 @@ GENERATE_MO=1 KEEP_PO=0 # this is set to 1 if we generate .mo files. Setting it to 1 here # (or before generating .mo files) will keep the .po files LANGUAGES="" -VERBOSE= +VERBOSE="" -while getopts "hp:N:atPzL:EvS:p:" opt +INDEX_FILES="" + +while getopts "hp:N:atPzL:EvS:p:I:" opt do case $opt in h) @@ -86,6 +90,14 @@ do ;; esac ;; + I) + if [ "$OPTARG" = "index.txt" ] + then + echo "Warning: ignoring additional index file with name 'index.txt'" + else + INDEX_FILES="INDEX_FILES:$OPTARG" + fi + ;; a) KEEP_AUTO=1 ;; @@ -146,15 +158,7 @@ mkdir "$TMP_DIR/$NAME" # use POSIX options to make sure it is portable cp -RPp "$GSH_ROOT/start.sh" "$GSH_ROOT/scripts" "$GSH_ROOT/utils" "$GSH_ROOT/lib" "$GSH_ROOT/i18n" "$TMP_DIR/$NAME" -# copy missions mkdir "$TMP_DIR/$NAME/missions" -if [ -z "$VERBOSE" ] -then - printf "copying missions: " -else - echo "copying missions" -fi - if ! make_index "$@" > "$TMP_DIR/$NAME/missions/index.txt" then echo "Error: archive.sh, couldn't make index.txt" @@ -164,44 +168,67 @@ then exit 1 fi -NB_MISSIONS=0 -NB_DUMMY=0 -cat "$TMP_DIR/$NAME/missions/index.txt" | while read MISSION_DIR +# copy missions +if [ -z "$VERBOSE" ] +then + printf "copying missions: " +else + echo "copying missions" +fi + +# NB_MISSIONS=0 +# NB_DUMMY=0 +ALL_INDEX_FILES="$TMP_DIR/$NAME/missions/index.txt" +IFS=: +for FILE in $INDEX_FILES do - DUMMY= - case $MISSION_DIR in - "" | "#"* ) - continue - ;; - "!"*) - MISSION_DIR=$(echo "$MISSION_DIR" | cut -c2-) - NB_DUMMY=$((NB_DUMMY + 1)) - DUMMY=1 - ;; - esac - NB_MISSIONS=$((NB_MISSIONS + 1)) - if [ -z "$VERBOSE" ] - then - if [ -z "$DUMMY" ] - then - printf "." - else - printf "!" - fi - else - if [ -z "$DUMMY" ] + cp "$FILE" "$TMP_DIR/$NAME/missions/$(basename "$FILE")" + ALL_INDEX_FILES="$ALL_INDEX_FILES:$TMP_DIR/$NAME/missions/$(basename "$FILE")" +done + +for FILE in $ALL_INDEX_FILES +do + cat "$FILE" | while read MISSION_DIR + do + DUMMY= + case $MISSION_DIR in + "" | "#"* ) + continue + ;; + "!"*) + MISSION_DIR=$(echo "$MISSION_DIR" | cut -c2-) + # NB_DUMMY=$((NB_DUMMY + 1)) + DUMMY=1 + ;; + esac + # NB_MISSIONS=$((NB_MISSIONS + 1)) + if [ -z "$VERBOSE" ] then - echo " - $MISSION_DIR" + if [ -z "$DUMMY" ] + then + printf "." + else + printf "!" + fi else - echo " ! $MISSION_DIR (dummy)" + if [ -z "$DUMMY" ] + then + echo " - $MISSION_DIR" + else + echo " ! $MISSION_DIR (dummy)" + fi fi - fi - mkdir -p "$TMP_DIR/$NAME/missions/$MISSION_DIR" - ARCHIVE_MISSION_DIR=$TMP_DIR/$NAME/missions/$MISSION_DIR - # NOTE: macOS' cp doesn't have '--archive', and '-a' is not POSIX. - # use POSIX options to make sure it is portable - cp -RPp "$GSH_MISSIONS/$MISSION_DIR"/* "$ARCHIVE_MISSION_DIR" + mkdir -p "$TMP_DIR/$NAME/missions/$MISSION_DIR" + ARCHIVE_MISSION_DIR=$TMP_DIR/$NAME/missions/$MISSION_DIR + # NOTE: macOS' cp doesn't have '--archive', and '-a' is not POSIX. + # use POSIX options to make sure it is portable + cp -RPp "$GSH_MISSIONS/$MISSION_DIR"/* "$ARCHIVE_MISSION_DIR" + done done + +# reset IFS +unset IFS + [ -n "$VERBOSE" ] || echo # define new GSH_ROOT From 50ddd2741afb99e2dfc1e4896c9cbb0a7cfb16da Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Mon, 18 Nov 2024 10:34:06 +0100 Subject: [PATCH 15/30] spelling --- scripts/_gsh_index | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/_gsh_index b/scripts/_gsh_index index 073de68d..4b3ba8e5 100755 --- a/scripts/_gsh_index +++ b/scripts/_gsh_index @@ -11,10 +11,10 @@ do continue fi - SKIPABLE="" + SKIPPABLE="" if [ -f "$GSH_MISSIONS/$mission_dir/skip.txt" ] || [ -d "$GSH_MISSIONS/$mission_dir/skip" ] then - SKIPABLE=" [$(gettext "optional")]" + SKIPPABLE=" [$(gettext "optional")]" fi if grep -q "^$n CHECK_OK" "$GSH_CONFIG/missions.log" @@ -45,7 +45,7 @@ do fi printf "%s%2d " "$LEAD" "$n" - color_echo "$COLOR" "$mission_dir$SKIPABLE$STATUS" + color_echo "$COLOR" "$mission_dir$SKIPPABLE$STATUS" n="$((n + 1))" done < "$GSH_CONFIG/index.txt" | pager From 856a3ad1a851ef1221ceeec332a062c335321ad1 Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Mon, 4 Nov 2024 16:28:32 +0100 Subject: [PATCH 16/30] updated gitignore file --- .gitignore | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 07cf065e..cf9eb3a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +Images/gsh-*-orig.gif tmp TODO .bin @@ -8,8 +9,6 @@ TODO World locale/ *~ -gameshell.sh -gameshell-save.sh -gameshell.tgz -boxes-data.awk +gameshell* game shell* +boxes-data.awk From aec2e809893db2677301e92db06e3d34420f363c Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Mon, 4 Nov 2024 16:44:27 +0100 Subject: [PATCH 17/30] automatic testing did not test the last missions! --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 7c4e3f49..2296c78a 100644 --- a/Makefile +++ b/Makefile @@ -37,22 +37,22 @@ new: i18n/template.pot ## check that the auto.sh scripts work as expected check: clean ./utils/archive.sh -at -N "game shell (1)" - ./"game shell (1).sh" -q -c 'gsh systemconfig; for _ in $$(seq 42); do gsh auto --abort < <(echo gsh); done; gsh stat' + ./"game shell (1).sh" -q -c 'gsh systemconfig; for _ in $$(seq 50); do gsh auto --abort < <(echo gsh); done; gsh stat' ## check that the auto.sh scripts work as expected, in verbose mode check-verbose: clean ./utils/archive.sh -at -N "game shell (1)" - ./"game shell (1).sh" -Dq -c 'gsh systemconfig; for _ in $$(seq 42); do gsh auto --abort; done; gsh stat' + ./"game shell (1).sh" -Dq -c 'gsh systemconfig; for _ in $$(seq 50); do gsh auto --abort; done; gsh stat' ## run all the test.sh and auto.sh scripts tests-bash: clean ./utils/archive.sh -at -N "game shell (1)" - ./"game shell (1).sh" -Bdq -c 'gsh systemconfig; for _ in $$(seq 42); do gsh goal|cat; gsh test --abort; gsh auto --abort; done; gsh stat' + ./"game shell (1).sh" -Bdq -c 'gsh systemconfig; for _ in $$(seq 50); do gsh goal|cat; gsh test --abort; gsh auto --abort; done; gsh stat' ## run all the test.sh and auto.sh scripts tests-zsh: clean ./utils/archive.sh -at -N "game shell (1)" - ./"game shell (1).sh" -Zdq -c 'gsh systemconfig; for _ in $$(seq 42); do gsh goal|cat; gsh test --abort; gsh auto --abort; done; gsh stat' + ./"game shell (1).sh" -Zdq -c 'gsh systemconfig; for _ in $$(seq 50); do gsh goal|cat; gsh test --abort; gsh auto --abort; done; gsh stat' clean: rm -rf i18n/*~ locale gameshell gameshell.tar gameshell.tgz gameshell.sh gameshell-save*.sh scripts/boxes-data.awk From 26e6ac8104ed1d22fe132cbe234ad2326a912ec2 Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Mon, 4 Nov 2024 16:21:10 +0100 Subject: [PATCH 18/30] additional messages for the pyrotechnician's missions --- missions/intermediate/05_background/check.sh | 6 +- .../intermediate/05_background/i18n/en.po | 3 + .../intermediate/05_background/i18n/fr.po | 3 + .../intermediate/05_background/i18n/it.po | 58 ++++++------- .../05_background/i18n/template.pot | 3 + .../intermediate/06_control-C/Charmiglio.sh | 12 ++- missions/intermediate/06_control-C/i18n/en.po | 3 + missions/intermediate/06_control-C/i18n/fr.po | 3 + missions/intermediate/06_control-C/i18n/it.po | 81 +++++++++---------- .../06_control-C/i18n/template.pot | 3 + 10 files changed, 103 insertions(+), 72 deletions(-) diff --git a/missions/intermediate/05_background/check.sh b/missions/intermediate/05_background/check.sh index 1784da88..c316c254 100644 --- a/missions/intermediate/05_background/check.sh +++ b/missions/intermediate/05_background/check.sh @@ -14,12 +14,12 @@ _check() { if [ ! -f "$PIDS" ] then echo "$(gettext "Mmm... I didn't see anything.")" + echo + echo "$(gettext "NOTE: you need to make sure the pyrotechnician sees all the fireworks while he is waiting.")" return 1 fi NB=$(cat "$PIDS" | wc -l) - cat $PIDS - echo "NB = '$NB'" if [ "$NB" -ge 3 ] then echo "$(gettext "Great, that looked good!")" @@ -27,6 +27,8 @@ _check() { elif [ "$NB" -lt 3 ] then echo "$(eval_gettext "Mmm... I only saw \$NB fireworks. That's not enough.")" + echo + echo "$(gettext "NOTE: you need to make sure the pyrotechnician sees all the fireworks while he is waiting.")" return 1 else echo "you shouldn't see this!" diff --git a/missions/intermediate/05_background/i18n/en.po b/missions/intermediate/05_background/i18n/en.po index e9081ea2..d02300ea 100644 --- a/missions/intermediate/05_background/i18n/en.po +++ b/missions/intermediate/05_background/i18n/en.po @@ -30,5 +30,8 @@ msgstr "Mmm... I didn't see anything." msgid "Mmm... I only saw $NB fireworks. That's not enough." msgstr "Mmm... I only saw $NB fireworks. That's not enough." +msgid "NOTE: you need to make sure the pyrotechnician sees all the fireworks while he is waiting." +msgstr "NOTE: you need to make sure the pyrotechnician sees all the fireworks while he is waiting." + msgid "charmiglio" msgstr "charmiglio" diff --git a/missions/intermediate/05_background/i18n/fr.po b/missions/intermediate/05_background/i18n/fr.po index 5347729e..ccbb8b13 100644 --- a/missions/intermediate/05_background/i18n/fr.po +++ b/missions/intermediate/05_background/i18n/fr.po @@ -29,5 +29,8 @@ msgstr "Mmm... Je n'ai rien vu." msgid "Mmm... I only saw $NB fireworks. That's not enough." msgstr "Mmm... Je n'ai vu que $NB feux d'artifices. Ce n'est pas assez." +msgid "NOTE: you need to make sure the pyrotechnician sees all the fireworks while he is waiting." +msgstr "NOTE : vous devez vous débrouiller pour que l'artificier voie tous les feux d'artifice pendant qu'il attend." + msgid "charmiglio" msgstr "charmiglio" diff --git a/missions/intermediate/05_background/i18n/it.po b/missions/intermediate/05_background/i18n/it.po index ecc03ae9..01d86cfb 100644 --- a/missions/intermediate/05_background/i18n/it.po +++ b/missions/intermediate/05_background/i18n/it.po @@ -1,44 +1,46 @@ # AUTOMATICALLY GENERATED -- DO NOT EDIT # mte90 , 2024. -msgid "" -msgstr "" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Last-Translator: mte90 \n" -"PO-Revision-Date: 2024-08-29 13:53+0200\n" -"Project-Id-Version: \n" -"Language-Team: Italian \n" -"Language: it_IT\n" -"MIME-Version: 1.0\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Lokalize 22.12.3\n" +msgid "" +msgstr "Project-Id-Version: \n" + "PO-Revision-Date: 2024-08-29 13:53+0200\n" + "Last-Translator: mte90 \n" + "Language-Team: Italian \n" + "Language: it_IT\n" + "MIME-Version: 1.0\n" + "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + "Plural-Forms: nplurals=2; plural=(n != 1);\n" + "X-Generator: Lokalize 22.12.3\n" # path for the text file containing the goal #, sh-format -msgid "$MISSION_DIR/goal/en.txt" -msgstr "$MISSION_DIR/goal/it.txt" +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/it.txt" # path for the text file containing the skip message -msgid "$MISSION_DIR/skip/en.txt" -msgstr "" +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" # path for the text file containing the treasure message -msgid "$MISSION_DIR/treasure-msg/en.txt" -msgstr "" +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" -msgid "Great, that looked good!" -msgstr "Ottimo, sembra tutto a posto!" +msgid "Great, that looked good!" +msgstr "Ottimo, sembra tutto a posto!" -msgid "Let's have a look:" -msgstr "Vediamo insieme:" +msgid "Let's have a look:" +msgstr "Vediamo insieme:" #, sh-format -msgid "Mmm... I didn't see anything." -msgstr "Mmm... non vedo niente." +msgid "Mmm... I didn't see anything." +msgstr "Mmm... non vedo niente." #, sh-format -msgid "Mmm... I only saw $NB fireworks. That's not enough." -msgstr "Mmm... io vedo solo $NB fuochi d'artificio. Non sono sufficenti." +msgid "Mmm... I only saw $NB fireworks. That's not enough." +msgstr "Mmm... io vedo solo $NB fuochi d'artificio. Non sono sufficenti." -msgid "charmiglio" -msgstr "charmiglio" +msgid "NOTE: you need to make sure the pyrotechnician sees all the fireworks while he is waiting." +msgstr "" + +msgid "charmiglio" +msgstr "charmiglio" diff --git a/missions/intermediate/05_background/i18n/template.pot b/missions/intermediate/05_background/i18n/template.pot index b96ab195..8f71731b 100644 --- a/missions/intermediate/05_background/i18n/template.pot +++ b/missions/intermediate/05_background/i18n/template.pot @@ -29,5 +29,8 @@ msgstr "" msgid "Mmm... I only saw $NB fireworks. That's not enough." msgstr "" +msgid "NOTE: you need to make sure the pyrotechnician sees all the fireworks while he is waiting." +msgstr "" + msgid "charmiglio" msgstr "" diff --git a/missions/intermediate/06_control-C/Charmiglio.sh b/missions/intermediate/06_control-C/Charmiglio.sh index 31edfa94..28755184 100755 --- a/missions/intermediate/06_control-C/Charmiglio.sh +++ b/missions/intermediate/06_control-C/Charmiglio.sh @@ -48,7 +48,17 @@ magical_reaction() { i=1 fi alpha=$(echo "#%*():_-............." | awk "{print substr(\$0, $i<10?$i:10, 10)}" ) - printf "%*s%s\n" "$indent" '' "$(random_string "$width" "$alpha")" >&2 + printf "%*s%s" "$indent" '' "$(random_string "$width" "$alpha")" >&2 + if [ "$delay" -gt 2 ] && [ "$((delay % 10))" -eq 0 ] && [ "$show_msg" != 0 ] + then + printf "\t\t$(gettext "You can stop the incantation with Control-c.")" + show_msg=0 + fi + if [ "$((delay % 10))" -eq 1 ] + then + show_msg=1 + fi + echo sleep 0.1 done } diff --git a/missions/intermediate/06_control-C/i18n/en.po b/missions/intermediate/06_control-C/i18n/en.po index a9a48bdc..b40f80ef 100644 --- a/missions/intermediate/06_control-C/i18n/en.po +++ b/missions/intermediate/06_control-C/i18n/en.po @@ -42,6 +42,9 @@ msgstr "Too soon! You must leave enough time for the magical reaction to start! msgid "What's a valid 4 letters sequence?" msgstr "What's a valid 4 letters sequence?" +msgid "You can stop the incantation with Control-c." +msgstr "You can stop the incantation with Control-c." + #, sh-format msgid "usage: $command CCCC\n" " where CCCC is a sequence of 4 ASCII letters (a-zA-Z)" diff --git a/missions/intermediate/06_control-C/i18n/fr.po b/missions/intermediate/06_control-C/i18n/fr.po index 48a249ed..d0346d7a 100644 --- a/missions/intermediate/06_control-C/i18n/fr.po +++ b/missions/intermediate/06_control-C/i18n/fr.po @@ -41,6 +41,9 @@ msgstr "Trop tôt ! Vous devez laisser assez de temps pour que la réaction mag msgid "What's a valid 4 letters sequence?" msgstr "Qu'est-ce qu'une combinaison valide ?" +msgid "You can stop the incantation with Control-c." +msgstr "Vous pouvez arêter l'incantation avec Contrôle-c" + #, sh-format msgid "usage: $command CCCC\n" " where CCCC is a sequence of 4 ASCII letters (a-zA-Z)" diff --git a/missions/intermediate/06_control-C/i18n/it.po b/missions/intermediate/06_control-C/i18n/it.po index 897dd229..c17f3e6d 100644 --- a/missions/intermediate/06_control-C/i18n/it.po +++ b/missions/intermediate/06_control-C/i18n/it.po @@ -1,62 +1,61 @@ # AUTOMATICALLY GENERATED -- DO NOT EDIT # mte90 , 2024. -msgid "" -msgstr "" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Last-Translator: mte90 \n" -"PO-Revision-Date: 2024-08-29 14:05+0200\n" -"Project-Id-Version: \n" -"Language-Team: Italian \n" -"Language: it_IT\n" -"MIME-Version: 1.0\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Lokalize 22.12.3\n" +msgid "" +msgstr "Project-Id-Version: \n" + "PO-Revision-Date: 2024-08-29 14:05+0200\n" + "Last-Translator: mte90 \n" + "Language-Team: Italian \n" + "Language: it_IT\n" + "MIME-Version: 1.0\n" + "Content-Type: text/plain; charset=UTF-8\n" + "Content-Transfer-Encoding: 8bit\n" + "Plural-Forms: nplurals=2; plural=(n != 1);\n" + "X-Generator: Lokalize 22.12.3\n" # path for the text file containing the goal #, sh-format -msgid "$MISSION_DIR/goal/en.txt" -msgstr "$MISSION_DIR/goal/it.txt" +msgid "$MISSION_DIR/goal/en.txt" +msgstr "$MISSION_DIR/goal/it.txt" # path for the text file containing the skip message -msgid "$MISSION_DIR/skip/en.txt" -msgstr "" +msgid "$MISSION_DIR/skip/en.txt" +msgstr "" # path for the text file containing the treasure message -msgid "$MISSION_DIR/treasure-msg/en.txt" -msgstr "" +msgid "$MISSION_DIR/treasure-msg/en.txt" +msgstr "" -msgid "Charmiglio" -msgstr "Charmiglio" +msgid "Charmiglio" +msgstr "Charmiglio" #, sh-format -msgid "It works! The special incantation is $CODE" -msgstr "Funziona! L'incantesimo speciale è $CODE" +msgid "It works! The special incantation is $CODE" +msgstr "Funziona! L'incantesimo speciale è $CODE" -msgid "NOTE: you should interrupt the magical reaction after a few seconds!" -msgstr "NOTA: puoi interrompere la reazione magica dopo pochi secondi!" +msgid "NOTE: you should interrupt the magical reaction after a few seconds!" +msgstr "NOTA: puoi interrompere la reazione magica dopo pochi secondi!" -msgid "That's not working, try a different combination..." -msgstr "Non ha funzionato, prova una combinazione differente..." +msgid "That's not working, try a different combination..." +msgstr "Non ha funzionato, prova una combinazione differente..." -msgid "The incantation can only use ASCII letters." -msgstr "L'incantesimo può utilizzare solo caratteri ASCII." +msgid "The incantation can only use ASCII letters." +msgstr "L'incantesimo può utilizzare solo caratteri ASCII." -msgid "The incantation requires exactly 4 letters." -msgstr "L'incantesimo richiede esattamente 4 lettere." +msgid "The incantation requires exactly 4 letters." +msgstr "L'incantesimo richiede esattamente 4 lettere." #, sh-format -msgid "Too soon! You must leave enough time for the magical reaction to start!" -msgstr "" -"Troppo presto! Devi dare abbastanza tempo per l'avvio della reazione magica!" +msgid "Too soon! You must leave enough time for the magical reaction to start!" +msgstr "Troppo presto! Devi dare abbastanza tempo per l'avvio della reazione magica!" -msgid "What's a valid 4 letters sequence?" -msgstr "Cosa è una sequenza valida di 4 lettere?" +msgid "What's a valid 4 letters sequence?" +msgstr "Cosa è una sequenza valida di 4 lettere?" + +msgid "You can stop the incantation with Control-c." +msgstr "" #, sh-format -msgid "" -"usage: $command CCCC\n" -" where CCCC is a sequence of 4 ASCII letters (a-zA-Z)" -msgstr "" -"uso: $command CCCC\n" -" dove CCCC è una sequenza di 4 caratteri ASCII (a-zA-Z)" +msgid "usage: $command CCCC\n" + " where CCCC is a sequence of 4 ASCII letters (a-zA-Z)" +msgstr "uso: $command CCCC\n" + " dove CCCC è una sequenza di 4 caratteri ASCII (a-zA-Z)" diff --git a/missions/intermediate/06_control-C/i18n/template.pot b/missions/intermediate/06_control-C/i18n/template.pot index 416128ee..883b8463 100644 --- a/missions/intermediate/06_control-C/i18n/template.pot +++ b/missions/intermediate/06_control-C/i18n/template.pot @@ -41,6 +41,9 @@ msgstr "" msgid "What's a valid 4 letters sequence?" msgstr "" +msgid "You can stop the incantation with Control-c." +msgstr "" + #, sh-format msgid "usage: $command CCCC\n" " where CCCC is a sequence of 4 ASCII letters (a-zA-Z)" From e21e5775d986732d6d8fcfeca4443bdec63b13cd Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Mon, 4 Nov 2024 11:23:56 +0100 Subject: [PATCH 19/30] removing empty directories and language text files in archive.sh also, wrong option for archive.sh documented in doc --- doc/gameshell.md | 13 ++++++------- utils/archive.sh | 30 ++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/doc/gameshell.md b/doc/gameshell.md index 5be9dfa8..4b107901 100644 --- a/doc/gameshell.md +++ b/doc/gameshell.md @@ -139,14 +139,13 @@ You can customize the archive with the following options GameShell will ask for the player's name and email. This is useful in the classroom as it makes it easier to link a game to the corresponding student. (The player can run the archive in anonymous mode with the `-A` option.) -* `--password PASSWORD`: you can choose the admin password for the archive. +* `-p PASSWORD`: you can choose the admin password for the archive. This is also useful in the classroom as we might not want the students to learn of this password. :) -* `-a`: keep the automatic scripts. Some missions come with a script that - automagically completes the missions. By default, those scripts are **not** - included in the archive. Use `-a` if you want to keep them. * `-N NAME`: if you want the archive and its directory to be called something other than "GameShell", you can set the name with this option. -* `-k`: keep the GameShell archive. The compressed `tar` archive is appended - to a shell script to create the executable archive. With this option, you - can keep the "standard" `tar` archive as well as the executable one. + +More options are available and listed in the output of +```sh +$ ./utils/archive.sh -h +``` diff --git a/utils/archive.sh b/utils/archive.sh index 8cf18e88..1b04206c 100755 --- a/utils/archive.sh +++ b/utils/archive.sh @@ -26,6 +26,7 @@ options: -S index -S overwrite choose default savefile mode + (check the output of 'gameshell.sh -h' for their description) -a keep 'auto.sh' scripts for missions that have one -t keep 'test.sh' scripts for missions that have one @@ -95,7 +96,7 @@ do then echo "Warning: ignoring additional index file with name 'index.txt'" else - INDEX_FILES="INDEX_FILES:$OPTARG" + INDEX_FILES="$INDEX_FILES:$OPTARG" fi ;; a) @@ -182,6 +183,7 @@ ALL_INDEX_FILES="$TMP_DIR/$NAME/missions/index.txt" IFS=: for FILE in $INDEX_FILES do + [ -z "$FILE" ] && continue # ignore initial empty file due to leading ':' cp "$FILE" "$TMP_DIR/$NAME/missions/$(basename "$FILE")" ALL_INDEX_FILES="$ALL_INDEX_FILES:$TMP_DIR/$NAME/missions/$(basename "$FILE")" done @@ -246,7 +248,8 @@ fi # remove unwanted languages if [ -n "$LANGUAGES" ] then - echo "removing unwanted languages" + printf "removing unwanted languages: " + # remove po files find "$GSH_ROOT" -path "*/i18n/*.po" | while read -r po_file do if ! keep_language "${po_file%.po}" "$LANGUAGES" @@ -256,6 +259,25 @@ then rm --system -f "$po_file" fi done + + # remove translation text files for GameShell and standard translation text + # files for individual missions + for dir in "$GSH_ROOT/i18n"/* goal skip treasure-msg + do + dir=$(basename "$dir") + find "$GSH_ROOT" -path "*/$dir/*.txt" | while read -r txt_file + do + [ "$(basename "$txt_file")" = "en.txt" ] && continue + if ! keep_language "${txt_file%.txt}" "$LANGUAGES" + then + # --system makes GameShell use the standard rm utility instead of the "safe" + # rm implemented in scripts/rm + printf "." + rm --system -f "$txt_file" + fi + done + done + echo fi # generate .mo files @@ -320,10 +342,10 @@ echo "removing unnecessary files" find . -name "Makefile" | xargs rm --system -f find . -name "template.pot" | xargs rm --system -f [ "$KEEP_PO" -eq 0 ] && find . -name "*.po" | xargs rm --system -f + find . -name "i18n" | xargs rmdir 2> /dev/null [ "$KEEP_TEST" -ne 1 ] && find ./missions -name "test.sh" | xargs rm --system -f [ "$KEEP_AUTO" -ne 1 ] && find ./missions -name auto.sh | xargs rm --system -f - - # rm --system -f "$GSH_ROOT/scripts/boxes-data.awk" "$GSH_ROOT/utils/archive.sh" + rm --system -rf "$GSH_ROOT/utils/" ) # change admin password From b244934f625d378f69b893e87438b68210fd7b47 Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Mon, 4 Nov 2024 15:51:08 +0100 Subject: [PATCH 20/30] trying to get multiple index files working --- i18n/start-help/en.txt | 14 ++++++++++++-- i18n/start-help/fr.txt | 13 +++++++++++++ lib/gsh.sh | 2 +- scripts/_gsh_env | 1 + scripts/_gsh_index | 2 +- scripts/missiondir | 2 +- start.sh | 13 +++++++++---- utils/archive.sh | 42 ++++++++++++++++++++++++++++-------------- 8 files changed, 66 insertions(+), 23 deletions(-) diff --git a/i18n/start-help/en.txt b/i18n/start-help/en.txt index 2e52391a..2635c752 100644 --- a/i18n/start-help/en.txt +++ b/i18n/start-help/en.txt @@ -1,3 +1,13 @@ +usage: + $GSH_EXEC_FILE [OPTIONS] [INDEX_FILE1 INDEX_FILE2 ...] + +Possible values for INDEX_FILE are: $GSH_INDEX_FILES. + +If no INDEX_FILE is given, defaults to index.txt. + +Index files are ignored when continuing from a save file. + + options: -h this message -V display version @@ -13,8 +23,8 @@ options: -G do not use gettext for translation (everything will be in English) -L ... set LANGUAGE variable (ex: -L fr:it:en) - On non GNU systems, set the variable LC_MESSAGES - to a valid locale. + On non GNU systems, set the variable LC_MESSAGES to a valid locale. + This flag is ignored when continuing from a save file. -S simple the savefile is obtained by adding a "-save" suffix, diff --git a/i18n/start-help/fr.txt b/i18n/start-help/fr.txt index e7ab178e..61d0971c 100644 --- a/i18n/start-help/fr.txt +++ b/i18n/start-help/fr.txt @@ -1,3 +1,14 @@ +utilisation : + $GSH_EXEC_FILE [OPTIONS] [INDEX_FILE1 INDEX_FILE2 ...] + +Les valeurs possibles pour INDEX_FILE sont : $GSH_INDEX_FILES. + +Si aucun INDEX_FILE n'est donné, utilise index.txt par défaut. + +Les fichier index sont ignorés lorsqu'on reprend une session à partir d'un +fichier de sauvegarde. + + options : -h ce message -V affiche la version @@ -16,6 +27,8 @@ options : -L initialise la variable LANGUAGE (ex : -L fr:it:en) Pour les systèmes non GNU, initialisez la variable LC_MESSAGES avec une locale valide. + Cette option est sans effet lorsqu'on reprend une session à partir + d'un fichier de sauvegarde. -S simple le fichier de sauvegarde est obtenu en ajoutant un suffix "-save", diff --git a/lib/gsh.sh b/lib/gsh.sh index a884fda2..e3b8f4ec 100644 --- a/lib/gsh.sh +++ b/lib/gsh.sh @@ -119,7 +119,7 @@ _gsh_resetstatic() { printf "." >&2 fi - done < "$GSH_CONFIG/index.txt" + done < "$GSH_CONFIG/current_index.txt" echo "" >&2 unset MISSION_DIR DOMAIN diff --git a/scripts/_gsh_env b/scripts/_gsh_env index 24edc035..be71fb81 100755 --- a/scripts/_gsh_env +++ b/scripts/_gsh_env @@ -5,6 +5,7 @@ echo "=========================" echo " GSH_EXEC_FILE=$GSH_EXEC_FILE" echo " GSH_EXEC_DIR=$GSH_EXEC_DIR" echo " GSH_WORKING_DIR=$GSH_WORKING_DIR" +echo " GSH_INDEX_FILES=$GSH_INDEX_FILES" echo "=========================" echo " GSH_AUTOSAVE=$GSH_AUTOSAVE" echo " GSH_SAVEFILE_MODE=$GSH_SAVEFILE_MODE" diff --git a/scripts/_gsh_index b/scripts/_gsh_index index 4b3ba8e5..cd578bc5 100755 --- a/scripts/_gsh_index +++ b/scripts/_gsh_index @@ -48,4 +48,4 @@ do color_echo "$COLOR" "$mission_dir$SKIPPABLE$STATUS" n="$((n + 1))" -done < "$GSH_CONFIG/index.txt" | pager +done < "$GSH_CONFIG/current_index.txt" | pager diff --git a/scripts/missiondir b/scripts/missiondir index f2a80117..8142f3aa 100755 --- a/scripts/missiondir +++ b/scripts/missiondir @@ -12,7 +12,7 @@ fi # get the mission directory n=$1 -dir=$(awk -v n="$n" -v DIR="$GSH_MISSIONS" '/^\s*[#!]/{next} /^$/{next} {N++} (N == n){print DIR "/" $0; exit}' "$GSH_CONFIG/index.txt") +dir=$(awk -v n="$n" -v DIR="$GSH_MISSIONS" '/^\s*[#!]/{next} /^$/{next} {N++} (N == n){print DIR "/" $0; exit}' "$GSH_CONFIG/current_index.txt") if [ -z "$dir" ] then echo "Error: missiondir, mission '$n' not found." >&2 diff --git a/start.sh b/start.sh index 7623831c..b753feb8 100755 --- a/start.sh +++ b/start.sh @@ -25,10 +25,15 @@ export GSH_ROOT="$(dirname "$0")" . "$GSH_ROOT/lib/mission_source.sh" display_help() { - cat "$(eval_gettext "\$GSH_ROOT/i18n/start-help/en.txt")" + sed -e "s/\$GSH_EXEC_FILE/$GSH_EXEC_FILE/" \ + -e "s/\$GSH_INDEX_FILES/$(echo "$GSH_INDEX_FILES" | sed "s/:/, /g")/" \ + "$(eval_gettext "\$GSH_ROOT/i18n/start-help/en.txt")" } +# list of index files (default: only index.txt) +export GSH_INDEX_FILES=index.txt + # possible values: index, simple (default), overwrite export GSH_SAVEFILE_MODE="simple" export GSH_AUTOSAVE=1 @@ -198,7 +203,7 @@ progress() { if [ -z "$progress_I" ] then progress_filename=$GSH_ROOT/lib/ascii-art/titlescreen - local N=$(wc -l "$GSH_CONFIG/index.txt" | awk '{print $1}') + local N=$(wc -l "$GSH_CONFIG/current_index.txt" | awk '{print $1}') local size=$(wc -c "$progress_filename" | awk '{print $1}') progress_delta=$((size/N + 1)) # head -c$((progress_delta - 1)) $progress_filename => not POSIX compliant @@ -339,7 +344,7 @@ Do you want to remove it and start a new game? [y/N]') " clear fi - make_index "$@" | sed -e "s;$GSH_MISSIONS;.;" > "$GSH_CONFIG/index.txt" + make_index "$@" | sed -e "s;$GSH_MISSIONS;.;" > "$GSH_CONFIG/current_index.txt" if [ "$GSH_MODE" != "DEBUG" ] then @@ -449,7 +454,7 @@ Do you want to remove it and start a new game? [y/N]') " [ -z "$MISSION_SUB_NB" ] && MISSION_NB=$((MISSION_NB+1)) - done < "$GSH_CONFIG/index.txt" + done < "$GSH_CONFIG/current_index.txt" if [ "$MISSION_NB" -eq 1 ] then echo "$(gettext "Error: no mission was found! diff --git a/utils/archive.sh b/utils/archive.sh index 1b04206c..a2272fa5 100755 --- a/utils/archive.sh +++ b/utils/archive.sh @@ -19,7 +19,7 @@ options: and not using gettext -N ... name of the archive / top directory (default: "gameshell") - -I FILE additional existing index file to include + -I FILE additional index file to include in the archive (can be given several times) -S simple @@ -92,9 +92,9 @@ do esac ;; I) - if [ "$OPTARG" = "index.txt" ] + if [ "$OPTARG" = "index.txt" ] || [ "$OPTARG" = "current_index.txt" ] then - echo "Warning: ignoring additional index file with name 'index.txt'" + echo "Warning: ignoring additional index file with name '$OPTARG'" else INDEX_FILES="$INDEX_FILES:$OPTARG" fi @@ -159,6 +159,9 @@ mkdir "$TMP_DIR/$NAME" # use POSIX options to make sure it is portable cp -RPp "$GSH_ROOT/start.sh" "$GSH_ROOT/scripts" "$GSH_ROOT/utils" "$GSH_ROOT/lib" "$GSH_ROOT/i18n" "$TMP_DIR/$NAME" + +# generate default index file +ALL_INDEX_FILES=index.txt mkdir "$TMP_DIR/$NAME/missions" if ! make_index "$@" > "$TMP_DIR/$NAME/missions/index.txt" then @@ -169,7 +172,25 @@ then exit 1 fi +# generate additional index files +IFS=: +for FILE in $INDEX_FILES +do + [ -z "$FILE" ] && continue # ignore initial empty file due to leading ':' + ALL_INDEX_FILES="$ALL_INDEX_FILES:$(basename "$FILE")" + if ! make_index "$FILE" > "$TMP_DIR/$NAME/missions/$(basename "$FILE")" + then + echo "Error: archive.sh, couldn't make $(basename "$FILE")" + # --system makes GameShell use the standard rm utility instead of the "safe" + # rm implemented in scripts/rm + rm --system -rf "$TMP_DIR" + exit 1 + fi +done + # copy missions +# NB_MISSIONS=0 +# NB_DUMMY=0 if [ -z "$VERBOSE" ] then printf "copying missions: " @@ -177,19 +198,9 @@ else echo "copying missions" fi -# NB_MISSIONS=0 -# NB_DUMMY=0 -ALL_INDEX_FILES="$TMP_DIR/$NAME/missions/index.txt" -IFS=: -for FILE in $INDEX_FILES -do - [ -z "$FILE" ] && continue # ignore initial empty file due to leading ':' - cp "$FILE" "$TMP_DIR/$NAME/missions/$(basename "$FILE")" - ALL_INDEX_FILES="$ALL_INDEX_FILES:$TMP_DIR/$NAME/missions/$(basename "$FILE")" -done - for FILE in $ALL_INDEX_FILES do + FILE="$TMP_DIR/$NAME/missions/$FILE" cat "$FILE" | while read MISSION_DIR do DUMMY= @@ -239,6 +250,9 @@ export GSH_ROOT="$TMP_DIR/$NAME" export GSH_MISSIONS="$GSH_ROOT/missions" +sed-i "s/^export GSH_INDEX_FILES=.*/export GSH_INDEX_FILES=$ALL_INDEX_FILES/" "$GSH_ROOT/start.sh" + + # default GSH_NO_GETTEXT to 1 if -E was used if [ -n "$GSH_NO_GETTEXT" ] then From dd2e286f70a98e888bd33ba22d231b6f62b9554c Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Mon, 4 Nov 2024 16:45:46 +0100 Subject: [PATCH 21/30] minor change to always generate a "latest" archive --- .github/workflows/latest_game_archive.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/latest_game_archive.yml b/.github/workflows/latest_game_archive.yml index fa5c7f81..3205b565 100644 --- a/.github/workflows/latest_game_archive.yml +++ b/.github/workflows/latest_game_archive.yml @@ -4,12 +4,12 @@ on: push: branches: - "master" - tags-ignore: - - "*" jobs: pre-release: + name: "latest release" runs-on: "ubuntu-latest" + steps: - name: "Checkout source code" uses: "actions/checkout@v4" From ed52aebb733368a44459ee1d36ee3e3951003d84 Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Mon, 18 Nov 2024 11:35:18 +0100 Subject: [PATCH 22/30] only display small help message with -h to get the full list of options, use -H instead --- i18n/en.po | 7 +++++ i18n/fr.po | 7 +++++ i18n/it.po | 7 +++++ i18n/start-full-help/en.txt | 50 ++++++++++++++++++++++++++++++++++++ i18n/start-full-help/fr.txt | 51 +++++++++++++++++++++++++++++++++++++ i18n/start-full-help/it.txt | 40 +++++++++++++++++++++++++++++ i18n/start-help/en.txt | 30 ++-------------------- i18n/start-help/fr.txt | 27 ++------------------ i18n/start-help/it.txt | 27 -------------------- i18n/template.pot | 7 +++++ lib/header.sh | 4 +-- start.sh | 19 ++++++++++++-- 12 files changed, 192 insertions(+), 84 deletions(-) create mode 100644 i18n/start-full-help/en.txt create mode 100644 i18n/start-full-help/fr.txt create mode 100644 i18n/start-full-help/it.txt diff --git a/i18n/en.po b/i18n/en.po index b5948f90..397549b7 100644 --- a/i18n/en.po +++ b/i18n/en.po @@ -19,6 +19,10 @@ msgstr "$GSH_ROOT/i18n/gameshell-init-msg/en.txt" msgid "$GSH_ROOT/i18n/gameshell-welcome/en.txt" msgstr "$GSH_ROOT/i18n/gameshell-welcome/en.txt" +#, sh-format +msgid "$GSH_ROOT/i18n/start-full-help/en.txt" +msgstr "$GSH_ROOT/i18n/start-full-help/en.txt" + #, sh-format msgid "$GSH_ROOT/i18n/start-help/en.txt" msgstr "$GSH_ROOT/i18n/start-help/en.txt" @@ -76,6 +80,9 @@ msgstr[1] "%d missions skipped:" msgid "AUTOMATICALLY GENERATED ON STARTUP -- DO NOT MODIFY" msgstr "AUTOMATICALLY GENERATED ON STARTUP -- DO NOT MODIFY" +msgid "Available index files: " +msgstr "Available index files: " + #, sh-format msgid "Congratulations, mission $MISSION_NB has been successfully completed!" msgstr "Congratulations, mission $MISSION_NB has been successfully completed!" diff --git a/i18n/fr.po b/i18n/fr.po index e4f357a9..3dc605b7 100644 --- a/i18n/fr.po +++ b/i18n/fr.po @@ -23,6 +23,10 @@ msgstr "$GSH_ROOT/i18n/gameshell-init-msg/fr.txt" msgid "$GSH_ROOT/i18n/gameshell-welcome/en.txt" msgstr "$GSH_ROOT/i18n/gameshell-welcome/fr.txt" +#, sh-format +msgid "$GSH_ROOT/i18n/start-full-help/en.txt" +msgstr "$GSH_ROOT/i18n/start-full-help/fr.txt" + #, sh-format msgid "$GSH_ROOT/i18n/start-help/en.txt" msgstr "$GSH_ROOT/i18n/start-help/fr.txt" @@ -80,6 +84,9 @@ msgstr[1] "%d missions sautées :" msgid "AUTOMATICALLY GENERATED ON STARTUP -- DO NOT MODIFY" msgstr "AUTOMATIQUEMENT GÉNÉRÉ AU DÉMARRAGE -- NE PAS MODIFIER" +msgid "Available index files: " +msgstr "Fichiers index disponibles: " + #, sh-format msgid "Congratulations, mission $MISSION_NB has been successfully completed!" msgstr "Bravo, vous avez réussi la mission $MISSION_NB !" diff --git a/i18n/it.po b/i18n/it.po index 908e78b9..4269b1b7 100644 --- a/i18n/it.po +++ b/i18n/it.po @@ -33,6 +33,10 @@ msgstr "$GSH_ROOT/i18n/gameshell-init-msg/it.txt" msgid "$GSH_ROOT/i18n/gameshell-welcome/en.txt" msgstr "$GSH_ROOT/i18n/gameshell-welcome/it.txt" +#, sh-format +msgid "$GSH_ROOT/i18n/start-full-help/en.txt" +msgstr "$GSH_ROOT/i18n/start-full-help/it.txt" + #, sh-format msgid "$GSH_ROOT/i18n/start-help/en.txt" msgstr "$GSH_ROOT/i18n/start-help/it.txt" @@ -90,6 +94,9 @@ msgstr[1] "%d missioni saltate:" msgid "AUTOMATICALLY GENERATED ON STARTUP -- DO NOT MODIFY" msgstr "GENERATO ALL'AVVIO AUTOMATICAMENTE -- NON MODIFICARE" +msgid "Available index files: " +msgstr "" + #, sh-format msgid "Congratulations, mission $MISSION_NB has been successfully completed!" msgstr "Congratulazioni, la missione $MISSION_NB é stata completata con successo!" diff --git a/i18n/start-full-help/en.txt b/i18n/start-full-help/en.txt new file mode 100644 index 00000000..82af3699 --- /dev/null +++ b/i18n/start-full-help/en.txt @@ -0,0 +1,50 @@ +usage: + $GSH_EXEC_FILE [OPTIONS] [INDEX_FILE1 INDEX_FILE2 ...] + +Possible values for INDEX_FILE are: $GSH_INDEX_FILES. + +If no INDEX_FILE is given, defaults to index.txt. + +Index files are ignored when continuing from a save file. + + +options: + -h simple help message + -H this message + -V display version + -I show list of available index files + + -P passport mode: ask for name / emails of player + -A anonymous mode + -d debug mode + -D verbose debug mode + + -C continue current game (if relevant) + -R reset game + -F do not check for more recent savefiles, force using the given archive + + -G do not use gettext for translation (everything will be in English) + -L ... set LANGUAGE variable (ex: -L fr:it:en) + On non GNU systems, set the variable LC_MESSAGES to a valid locale. + This flag is ignored when continuing from a save file. + + -S simple + the savefile is obtained by adding a "-save" suffix, + each savefile overwrites the previous one + -S index + savefiles are numbered so that all savefiles are kept + -S overwrite + the savefile overwrite the initial GameShell file + (you can use option -R to start a new game from the start) + + -B use bash + -Z use zsh + + -q quiet: don't show information messages + -n black and white: don't use ANSI escape codes for color + -c ... give that command to GameShell (for testing) + + -U download last version of GameShell (requires network access) + -X only extract tgz archive + -K do not remove GameShell temporary directory on exit + diff --git a/i18n/start-full-help/fr.txt b/i18n/start-full-help/fr.txt new file mode 100644 index 00000000..1c6b7bcf --- /dev/null +++ b/i18n/start-full-help/fr.txt @@ -0,0 +1,51 @@ +utilisation : + $GSH_EXEC_FILE [OPTIONS] [INDEX_FILE1 INDEX_FILE2 ...] + +Les valeurs possibles pour INDEX_FILE sont : $GSH_INDEX_FILES. + +Si aucun INDEX_FILE n'est donné, utilise index.txt par défaut. + +Les fichier index sont ignorés lorsqu'on reprend une session à partir d'un +fichier de sauvegarde. + + +options : + -h message d'aide simplifié + -H ce message + -V affiche la version + -I affiche la liste des fichier index disponibles + + -P mode passeport : demande le nom / email du joueur + -D mode debug + -v lecture "verbeuse" des scripts de mission (seulement en mode debug) + -A mode anonyme + + -C continue la partie en cours (si pertinent) + -R recommence une partie du début + -F ne vérifie pas l'existence de fichiers de sauvegarde plus récents, + force l'utilisation de l'archive donnée + + -G désactive gettext pour les traductions (tout sera en Anglais) + -L initialise la variable LANGUAGE (ex : -L fr:it:en) + Pour les systèmes non GNU, initialisez la variable LC_MESSAGES + avec une locale valide. + Cette option est sans effet lorsqu'on reprend une session à partir + d'un fichier de sauvegarde. + + -S simple + le fichier de sauvegarde est obtenu en ajoutant un suffix "-save", + chaque fichier de sauvegarde remplace le précédent + -S index + les fichiers de sauvegarde sont numérotés pour que toutes les + sauvegardes soient conservées + -S overwrite + le fichier de sauvegarde remplace l'instance initial de GameShell + (on peut utiliser l'option -R pour lancer une partie à partir du début) + + -q mode silencieux : n'affiche pas les messages d'information + -n mode noir et blanc : n'utilise pas les séquences ANSI + -c CMD donne cette commande à GameShell (pour faire des tests) + + -U télécharge la dernière version de GameShell (nécessite un accès réseau) + -X extrait juste l'archive tgz + -K ne supprime pas le répertoire temporaire de GameShell à la sortie diff --git a/i18n/start-full-help/it.txt b/i18n/start-full-help/it.txt new file mode 100644 index 00000000..aeab87a8 --- /dev/null +++ b/i18n/start-full-help/it.txt @@ -0,0 +1,40 @@ +options: + -h messaggio di aiuto breve + -H questo avviso + -V mostra versione + -I ... + + -P modalitá passaporto: chiede il nome/email del giocatore + -A modalitá anonima + -d modalitá debug + -D modalitá debug verbosa + + -C continua la partita corrente (se rilevante) + -R reimposta la partita + -F non cercare salvataggi recenti, utilizza forzatamente l'archivio definito + + -G non utilizzare gettext per le traduzioni (sarà tutto in Inglese) + -L ... imposta la variabile LANGUAGE (ex: -L fr:it:en) + Su sistemi non GNU, imposta la variabile LC_MESSAGES + per un "locale" valido. + + -S simple + il file di salvataggio è generato con un suffiso "-save", + ogni salvataggio sovrascrive il precedente + -S index + i salvataggi sono numerati così sono tutti conservati + -S overwrite + il salvataggio sovrascrive il file iniziale di GameShell + (puoi utilizzare l'opzione -R per avviare un nuovo gioco dall'inizio) + + -B usa bash + -Z usa zsh + + -q silenzioso: non mostra avvisi informativi + -n bianco e nero: non usa i codici di escape ANSI per i colori + -c ... dai quel comando a GameShell (in testing) + + -U scarica l'ultima versione di GameShell (richiede accesso alla rete) + -X estrai solo l'archivio tgz + -K non rimuovere la cartella temporanea di GameShell all'uscita + diff --git a/i18n/start-help/en.txt b/i18n/start-help/en.txt index 2635c752..b2151099 100644 --- a/i18n/start-help/en.txt +++ b/i18n/start-help/en.txt @@ -8,41 +8,15 @@ If no INDEX_FILE is given, defaults to index.txt. Index files are ignored when continuing from a save file. -options: +main options: -h this message + -H show all available options -V display version - -P passport mode: ask for name / emails of player - -A anonymous mode - -d debug mode - -D verbose debug mode - - -C continue current game (if relevant) -R reset game -F do not check for more recent savefiles, force using the given archive - -G do not use gettext for translation (everything will be in English) -L ... set LANGUAGE variable (ex: -L fr:it:en) On non GNU systems, set the variable LC_MESSAGES to a valid locale. This flag is ignored when continuing from a save file. - -S simple - the savefile is obtained by adding a "-save" suffix, - each savefile overwrites the previous one - -S index - savefiles are numbered so that all savefiles are kept - -S overwrite - the savefile overwrite the initial GameShell file - (you can use option -R to start a new game from the start) - - -B use bash - -Z use zsh - - -q quiet: don't show information messages - -n black and white: don't use ANSI escape codes for color - -c ... give that command to GameShell (for testing) - - -U download last version of GameShell (requires network access) - -X only extract tgz archive - -K do not remove GameShell temporary directory on exit - diff --git a/i18n/start-help/fr.txt b/i18n/start-help/fr.txt index 61d0971c..2daa28af 100644 --- a/i18n/start-help/fr.txt +++ b/i18n/start-help/fr.txt @@ -9,41 +9,18 @@ Les fichier index sont ignorés lorsqu'on reprend une session à partir d'un fichier de sauvegarde. -options : +options principales : -h ce message + -H affiche toutes les options -V affiche la version - -P mode passeport : demande le nom / email du joueur - -D mode debug - -v lecture "verbeuse" des scripts de mission (seulement en mode debug) - -A mode anonyme - - -C continue la partie en cours (si pertinent) -R recommence une partie du début -F ne vérifie pas l'existence de fichiers de sauvegarde plus récents, force l'utilisation de l'archive donnée - -G désactive gettext pour les traductions (tout sera en Anglais) -L initialise la variable LANGUAGE (ex : -L fr:it:en) Pour les systèmes non GNU, initialisez la variable LC_MESSAGES avec une locale valide. Cette option est sans effet lorsqu'on reprend une session à partir d'un fichier de sauvegarde. - -S simple - le fichier de sauvegarde est obtenu en ajoutant un suffix "-save", - chaque fichier de sauvegarde remplace le précédent - -S index - les fichiers de sauvegarde sont numérotés pour que toutes les - sauvegardes soient conservées - -S overwrite - le fichier de sauvegarde remplace l'instance initial de GameShell - (on peut utiliser l'option -R pour lancer une partie à partir du début) - - -q mode silencieux : n'affiche pas les messages d'information - -n mode noir et blanc : n'utilise pas les séquences ANSI - -c CMD donne cette commande à GameShell (pour faire des tests) - - -U télécharge la dernière version de GameShell (nécessite un accès réseau) - -X extrait juste l'archive tgz - -K ne supprime pas le répertoire temporaire de GameShell à la sortie diff --git a/i18n/start-help/it.txt b/i18n/start-help/it.txt index 000ea47e..bdbc9fa5 100644 --- a/i18n/start-help/it.txt +++ b/i18n/start-help/it.txt @@ -2,37 +2,10 @@ options: -h questo avviso -V mostra versione - -P modalitá passaporto: chiede il nome/email del giocatore - -A modalitá anonima - -d modalitá debug - -D modalitá debug verbosa - - -C continua la partita corrente (se rilevante) -R reimposta la partita -F non cercare salvataggi recenti, utilizza forzatamente l'archivio definito - -G non utilizzare gettext per le traduzioni (sarà tutto in Inglese) -L ... imposta la variabile LANGUAGE (ex: -L fr:it:en) Su sistemi non GNU, imposta la variabile LC_MESSAGES per un "locale" valido. - -S simple - il file di salvataggio è generato con un suffiso "-save", - ogni salvataggio sovrascrive il precedente - -S index - i salvataggi sono numerati così sono tutti conservati - -S overwrite - il salvataggio sovrascrive il file iniziale di GameShell - (puoi utilizzare l'opzione -R per avviare un nuovo gioco dall'inizio) - - -B usa bash - -Z usa zsh - - -q silenzioso: non mostra avvisi informativi - -n bianco e nero: non usa i codici di escape ANSI per i colori - -c ... dai quel comando a GameShell (in testing) - - -U scarica l'ultima versione di GameShell (richiede accesso alla rete) - -X estrai solo l'archivio tgz - -K non rimuovere la cartella temporanea di GameShell all'uscita - diff --git a/i18n/template.pot b/i18n/template.pot index 81f5f76a..6dcbeb19 100644 --- a/i18n/template.pot +++ b/i18n/template.pot @@ -18,6 +18,10 @@ msgstr "" msgid "$GSH_ROOT/i18n/gameshell-welcome/en.txt" msgstr "" +#, sh-format +msgid "$GSH_ROOT/i18n/start-full-help/en.txt" +msgstr "" + #, sh-format msgid "$GSH_ROOT/i18n/start-help/en.txt" msgstr "" @@ -75,6 +79,9 @@ msgstr[1] "" msgid "AUTOMATICALLY GENERATED ON STARTUP -- DO NOT MODIFY" msgstr "" +msgid "Available index files: " +msgstr "" + #, sh-format msgid "Congratulations, mission $MISSION_NB has been successfully completed!" msgstr "" diff --git a/lib/header.sh b/lib/header.sh index 18384155..4a1830b3 100644 --- a/lib/header.sh +++ b/lib/header.sh @@ -34,7 +34,7 @@ GSH_EXEC_DIR=$(cd "$GSH_EXEC_DIR"; pwd -P) # just in case GSH_EXEC_DIR=${GSH_EXEC_DIR:-.} -while getopts ":hnPdDACRXUVqGL:KBZc:FS:" opt +while getopts ":hHInPdDACRXUVqGL:KBZc:FS:" opt do case "$opt" in V) @@ -85,7 +85,7 @@ do F) GSH_FORCE="true" ;; - h) + h | H | I) # used to avoid checking for more recent files GSH_HELP="true" ;; diff --git a/start.sh b/start.sh index b753feb8..8ae49d2b 100755 --- a/start.sh +++ b/start.sh @@ -24,6 +24,12 @@ export GSH_ROOT="$(dirname "$0")" # shellcheck source=lib/mission_source.sh . "$GSH_ROOT/lib/mission_source.sh" +display_full_help() { + sed -e "s/\$GSH_EXEC_FILE/$GSH_EXEC_FILE/" \ + -e "s/\$GSH_INDEX_FILES/$(echo "$GSH_INDEX_FILES" | sed "s/:/, /g")/" \ + "$(eval_gettext "\$GSH_ROOT/i18n/start-full-help/en.txt")" +} + display_help() { sed -e "s/\$GSH_EXEC_FILE/$GSH_EXEC_FILE/" \ -e "s/\$GSH_INDEX_FILES/$(echo "$GSH_INDEX_FILES" | sed "s/:/, /g")/" \ @@ -32,7 +38,7 @@ display_help() { # list of index files (default: only index.txt) -export GSH_INDEX_FILES=index.txt +export GSH_INDEX_FILES=index.txt # DO NOT CHANGE OR REMOVE THIS LINE, it is used by utils/archive.sh # possible values: index, simple (default), overwrite export GSH_SAVEFILE_MODE="simple" @@ -42,7 +48,7 @@ GSH_MODE="ANONYMOUS" # if GSH_NO_GETTEXT is non-empty, gettext won't be used anywhere, the only language will thus be English # export GSH_NO_GETTEXT=1 # DO NOT CHANGE OR REMOVE THIS LINE, it is used by utils/archive.sh RESET="" -while getopts ":hnPdDACRXUVqGL:KBZc:FS:" opt +while getopts ":hHInPdDACRXUVqGL:KBZc:FS:" opt do case $opt in S) @@ -60,6 +66,15 @@ do display_help exit 0 ;; + H) + display_full_help + exit 0 + ;; + I) + gettext "Available index files: " >&2 + echo "$GSH_INDEX_FILES" | sed "s/:/, /g" >&2 + exit 0 + ;; n) GSH_COLOR="" ;; From 8b6b66aecf074bb1457671e5c1c0817ccf432158 Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Mon, 18 Nov 2024 15:06:25 +0100 Subject: [PATCH 23/30] missing redirection to stderr for some messages --- missions/intermediate/06_control-C/Charmiglio.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/missions/intermediate/06_control-C/Charmiglio.sh b/missions/intermediate/06_control-C/Charmiglio.sh index 28755184..81c2275c 100755 --- a/missions/intermediate/06_control-C/Charmiglio.sh +++ b/missions/intermediate/06_control-C/Charmiglio.sh @@ -51,14 +51,14 @@ magical_reaction() { printf "%*s%s" "$indent" '' "$(random_string "$width" "$alpha")" >&2 if [ "$delay" -gt 2 ] && [ "$((delay % 10))" -eq 0 ] && [ "$show_msg" != 0 ] then - printf "\t\t$(gettext "You can stop the incantation with Control-c.")" + printf "\t\t$(gettext "You can stop the incantation with Control-c.")" >&2 show_msg=0 fi if [ "$((delay % 10))" -eq 1 ] then show_msg=1 fi - echo + echo >&2 sleep 0.1 done } From 6a71b2b77ccc29432b82532acdc82b16a1bd5b14 Mon Sep 17 00:00:00 2001 From: Olivier Mattelaer Date: Mon, 18 Nov 2024 13:39:48 +0100 Subject: [PATCH 24/30] fix semaphore --- missions/processes/02_ps_kill_signal/clean.sh | 3 ++- missions/processes/02_ps_kill_signal/spell.c | 15 +++++++++++++-- missions/processes/03_pstree_kill/clean.sh | 1 + missions/processes/03_pstree_kill/spell.c | 9 ++++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/missions/processes/02_ps_kill_signal/clean.sh b/missions/processes/02_ps_kill_signal/clean.sh index f3b9d8bd..06a0265e 100644 --- a/missions/processes/02_ps_kill_signal/clean.sh +++ b/missions/processes/02_ps_kill_signal/clean.sh @@ -4,5 +4,6 @@ kill -9 $(cat "$GSH_TMP/spell-term.pids" 2>/dev/null) 2>/dev/null kill -9 $(cat "$GSH_TMP/spell.pids" 2>/dev/null) 2>/dev/null my_ps | awk '/sleep|tail/ {print $1}' | xargs kill -9 2>/dev/null rm -f "$GSH_TMP/spell-term.pids" "$GSH_TMP/spell.pids" "$GSH_TMP/$(gettext "spell")" - +rm --system -f /dev/shm/sem.writing_sem_${USER} +rm --system -f /dev/shm/sem.printing_sem_${USER} [ -n "$GSH_NON_INTERACTIVE" ] || set -o monitor # monitor background processes (default) diff --git a/missions/processes/02_ps_kill_signal/spell.c b/missions/processes/02_ps_kill_signal/spell.c index 61061655..9cdfe908 100644 --- a/missions/processes/02_ps_kill_signal/spell.c +++ b/missions/processes/02_ps_kill_signal/spell.c @@ -119,11 +119,22 @@ int main() } // Initialize semaphores. - printing_sem = sem_open("/printing_sem", O_CREAT, 0644, 1); + // + char login[20]; + getlogin_r(login, 20); + char sem_path[30]; + strcpy(sem_path, "/printing_sem_"); + strcat(sem_path,login); + + printing_sem = sem_open(sem_path, O_CREAT, 0644, 1); if (printing_sem == SEM_FAILED) return 1; - writing_sem = sem_open("/writing_sem", O_CREAT, 0644, 1); + + strcpy(sem_path, "/writing_sem_"); + strcat(sem_path,login); + + writing_sem = sem_open(sem_path, O_CREAT, 0644, 1); if (writing_sem == SEM_FAILED) return 1; diff --git a/missions/processes/03_pstree_kill/clean.sh b/missions/processes/03_pstree_kill/clean.sh index 3de250d4..6ec5e4df 100644 --- a/missions/processes/03_pstree_kill/clean.sh +++ b/missions/processes/03_pstree_kill/clean.sh @@ -15,6 +15,7 @@ rm -f "$GSH_TMP/fairy.pid" rm -f "$GSH_TMP/imp.pid" rm -f "$GSH_TMP/$(gettext "nice_fairy")" rm -f "$GSH_TMP/$(gettext "mischievous_imp")" +rm --system -f /dev/shm/sem.writing_sem_${USER} ( cd "$(eval_gettext '$GSH_HOME/Castle/Cellar')" # keep at most 10 snowflakes diff --git a/missions/processes/03_pstree_kill/spell.c b/missions/processes/03_pstree_kill/spell.c index 7f4f4274..13741096 100644 --- a/missions/processes/03_pstree_kill/spell.c +++ b/missions/processes/03_pstree_kill/spell.c @@ -124,7 +124,14 @@ int main() /* printf(">>> log_file = '%s'\n", log_file); */ wordfree(&result); - writing_sem = sem_open("/writing_sem", O_CREAT, 0644, 1); + char login[20]; + getlogin_r(login, 20); + char sem_path[30]; + strcpy(sem_path, "/writing_sem_"); + strcat(sem_path,login); + + + writing_sem = sem_open(sem_path, O_CREAT, 0644, 1); if (writing_sem == SEM_FAILED) return 1; From 08023626d05e014246771be796551ccea8a93183 Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Mon, 18 Nov 2024 16:12:28 +0100 Subject: [PATCH 25/30] small clean for semaphore PR --- missions/processes/02_ps_kill_signal/clean.sh | 4 ++-- missions/processes/02_ps_kill_signal/spell.c | 17 +++++++++-------- missions/processes/03_pstree_kill/clean.sh | 2 +- missions/processes/03_pstree_kill/spell.c | 11 ++++++----- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/missions/processes/02_ps_kill_signal/clean.sh b/missions/processes/02_ps_kill_signal/clean.sh index 06a0265e..d3f74cb5 100644 --- a/missions/processes/02_ps_kill_signal/clean.sh +++ b/missions/processes/02_ps_kill_signal/clean.sh @@ -4,6 +4,6 @@ kill -9 $(cat "$GSH_TMP/spell-term.pids" 2>/dev/null) 2>/dev/null kill -9 $(cat "$GSH_TMP/spell.pids" 2>/dev/null) 2>/dev/null my_ps | awk '/sleep|tail/ {print $1}' | xargs kill -9 2>/dev/null rm -f "$GSH_TMP/spell-term.pids" "$GSH_TMP/spell.pids" "$GSH_TMP/$(gettext "spell")" -rm --system -f /dev/shm/sem.writing_sem_${USER} -rm --system -f /dev/shm/sem.printing_sem_${USER} +rm --system -f /dev/shm/"sem.writing_sem_${USER}" +rm --system -f /dev/shm/"sem.printing_sem_${USER}" [ -n "$GSH_NON_INTERACTIVE" ] || set -o monitor # monitor background processes (default) diff --git a/missions/processes/02_ps_kill_signal/spell.c b/missions/processes/02_ps_kill_signal/spell.c index 9cdfe908..42f3334b 100644 --- a/missions/processes/02_ps_kill_signal/spell.c +++ b/missions/processes/02_ps_kill_signal/spell.c @@ -120,19 +120,20 @@ int main() // Initialize semaphores. // - char login[20]; - getlogin_r(login, 20); - char sem_path[30]; - strcpy(sem_path, "/printing_sem_"); - strcat(sem_path,login); + char login[128]; + getlogin_r(login, 128); + char sem_path[256]; + strncpy(sem_path, "/printing_sem_", 128); + strncat(sem_path, login, 128); + sem_path[255] = '\0'; printing_sem = sem_open(sem_path, O_CREAT, 0644, 1); if (printing_sem == SEM_FAILED) return 1; - - strcpy(sem_path, "/writing_sem_"); - strcat(sem_path,login); + strncpy(sem_path, "/writing_sem_", 128); + strncat(sem_path, login, 128); + sem_path[255] = '\0'; writing_sem = sem_open(sem_path, O_CREAT, 0644, 1); if (writing_sem == SEM_FAILED) diff --git a/missions/processes/03_pstree_kill/clean.sh b/missions/processes/03_pstree_kill/clean.sh index 6ec5e4df..449c23b9 100644 --- a/missions/processes/03_pstree_kill/clean.sh +++ b/missions/processes/03_pstree_kill/clean.sh @@ -15,7 +15,7 @@ rm -f "$GSH_TMP/fairy.pid" rm -f "$GSH_TMP/imp.pid" rm -f "$GSH_TMP/$(gettext "nice_fairy")" rm -f "$GSH_TMP/$(gettext "mischievous_imp")" -rm --system -f /dev/shm/sem.writing_sem_${USER} +rm --system -f /dev/shm/"sem.writing_sem_${USER}" ( cd "$(eval_gettext '$GSH_HOME/Castle/Cellar')" # keep at most 10 snowflakes diff --git a/missions/processes/03_pstree_kill/spell.c b/missions/processes/03_pstree_kill/spell.c index 13741096..184a58d0 100644 --- a/missions/processes/03_pstree_kill/spell.c +++ b/missions/processes/03_pstree_kill/spell.c @@ -124,11 +124,12 @@ int main() /* printf(">>> log_file = '%s'\n", log_file); */ wordfree(&result); - char login[20]; - getlogin_r(login, 20); - char sem_path[30]; - strcpy(sem_path, "/writing_sem_"); - strcat(sem_path,login); + char login[128]; + getlogin_r(login, 128); + char sem_path[256]; + strncpy(sem_path, "/writing_sem_", 128); + strncat(sem_path, login, 128); + sem_path[255] = '\0'; writing_sem = sem_open(sem_path, O_CREAT, 0644, 1); From 111cf1a4d70d49f15c9f0ed4d7990f22ea28b37f Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Mon, 18 Nov 2024 17:39:45 +0100 Subject: [PATCH 26/30] make it possible to choose several index files I also change the way make_index works: - if used from a self extracting archive, prefix all arguments with $GSH_MISSIONS/ - otherwise, use the actual files given from the command line I also print a warning when giving index files in "continue" mode, as those are not used. --- i18n/en.po | 8 ++++++++ i18n/fr.po | 8 ++++++++ i18n/it.po | 8 ++++++++ i18n/template.pot | 8 ++++++++ scripts/make_index | 12 +++++------- start.sh | 41 +++++++++++++++++++++++++++++++++++------ 6 files changed, 72 insertions(+), 13 deletions(-) diff --git a/i18n/en.po b/i18n/en.po index 397549b7..52783e49 100644 --- a/i18n/en.po +++ b/i18n/en.po @@ -207,6 +207,14 @@ msgstr "There are stopped jobs in your session.\n" " $ jobs\n" "Do you still want to quit? [y/n]" +#, sh-format +msgid "Warning: command line arguments are ignored when continuing a game ($args)" +msgstr "Warning: command line arguments are ignored when continuing a game ($args)" + +#, sh-format +msgid "Warning: language is ignored when continuing a game ($args)" +msgstr "Warning: language is ignored when continuing a game ($args)" + msgid "Warning: the file 'treasure.sh' was sourced from a subshell.\n" "You should use the command\n" " $ gsh reset" diff --git a/i18n/fr.po b/i18n/fr.po index 3dc605b7..b9c1c9c5 100644 --- a/i18n/fr.po +++ b/i18n/fr.po @@ -212,6 +212,14 @@ msgstr "Il y a des processus stoppés dans votre session.\n" " $ jobs\n" "Êtes vous sûr de vouloir quitter ? [o/N]" +#, sh-format +msgid "Warning: command line arguments are ignored when continuing a game ($args)" +msgstr "Warning: les arguments sur la ligne de commande sont ignorés lorsqu'on reprend une partie ($args)" + +#, sh-format +msgid "Warning: language is ignored when continuing a game ($args)" +msgstr "Warning: la langue est ignorée lorsqu'on reprend une partie ($args)" + msgid "Warning: the file 'treasure.sh' was sourced from a subshell.\n" "You should use the command\n" " $ gsh reset" diff --git a/i18n/it.po b/i18n/it.po index 4269b1b7..75cfa594 100644 --- a/i18n/it.po +++ b/i18n/it.po @@ -222,6 +222,14 @@ msgstr "Ci sono dei processi fermati nella tua sessione.\n" "Vuoi uscire lo stesso? [s/n\n" "]" +#, sh-format +msgid "Warning: command line arguments are ignored when continuing a game ($args)" +msgstr "" + +#, sh-format +msgid "Warning: language is ignored when continuing a game ($args)" +msgstr "" + msgid "Warning: the file 'treasure.sh' was sourced from a subshell.\n" "You should use the command\n" " $ gsh reset" diff --git a/i18n/template.pot b/i18n/template.pot index 6dcbeb19..3f11566e 100644 --- a/i18n/template.pot +++ b/i18n/template.pot @@ -197,6 +197,14 @@ msgid "There are stopped jobs in your session.\n" "Do you still want to quit? [y/n]" msgstr "" +#, sh-format +msgid "Warning: command line arguments are ignored when continuing a game ($args)" +msgstr "" + +#, sh-format +msgid "Warning: language is ignored when continuing a game ($args)" +msgstr "" + msgid "Warning: the file 'treasure.sh' was sourced from a subshell.\n" "You should use the command\n" " $ gsh reset" diff --git a/scripts/make_index b/scripts/make_index index ce8dbfe5..6f3ab7bd 100755 --- a/scripts/make_index +++ b/scripts/make_index @@ -115,19 +115,17 @@ make_index() { return 0 fi - if [ "$#" -eq 1 ] && [ -f "$GSH_MISSIONS/$1" ] + # when used from a self extracting archive, all path are prefixed with the + # mission directory + if [ -n "$GSH_EXEC_FILE" ] then - # with a single file argument, we assume it is an index file - parse_index "$GSH_MISSIONS/$1" || exit 1 - return 0 + PREFIX="$GSH_MISSIONS/" fi # otherwise, parse each mission / index file from the arguments - # (Note, it should not be used from a GameShell instance, but only directly - # from ``start.sh`` or from ``utils/archive.sh`` while [ "$#" -gt 0 ] do - MISSION_DIR=$(readlink-f "$1") + MISSION_DIR=$(readlink-f "$PREFIX$1") if [ -e "$MISSION_DIR" ] then parse_mission "$MISSION_DIR" || exit 1 diff --git a/start.sh b/start.sh index 8ae49d2b..a8d577d5 100755 --- a/start.sh +++ b/start.sh @@ -38,7 +38,7 @@ display_help() { # list of index files (default: only index.txt) -export GSH_INDEX_FILES=index.txt # DO NOT CHANGE OR REMOVE THIS LINE, it is used by utils/archive.sh +export GSH_INDEX_FILES=index.txt # possible values: index, simple (default), overwrite export GSH_SAVEFILE_MODE="simple" @@ -102,6 +102,13 @@ do ;; L) export LANGUAGE="$OPTARG" # only works on GNU systems + if [ "$RESET" = FALSE ] + then + args="-L $OPTARG" + echo "$(eval_gettext 'Warning: language is ignored when continuing a game ($args)')" >&2 + echo "$(gettext 'Press Enter to continue.')" >&2 + read -r _ + fi ;; G) export GSH_NO_GETTEXT=1 @@ -249,18 +256,40 @@ init_gsh() { # - continue the previous game if [ -e "$GSH_CONFIG" ] then - if [ -z "$RESET" ] - then + + while [ -z "$RESET" ] + do local r printf "$(eval_gettext 'The directory $GSH_CONFIG contains meta-data from a previous game. Do you want to remove it and start a new game? [y/N]') " read -r r - [ "$r" = "$(gettext "y")" ] || [ "$r" = "$(gettext "Y")" ] || return 1 + if [ "$r" = "$(gettext "y")" ] || [ "$r" = "$(gettext "Y")" ] + then + RESET=TRUE + echo + fi + if [ -z "$r" ] || [ "$r" = "$(gettext "n")" ] || [ "$r" = "$(gettext "N")" ] + then + RESET=FALSE + echo + fi + done - elif [ "$RESET" = "FALSE" ] + else + # if no data is found, we need to initialize a new game + RESET=TRUE + fi + + if [ "$RESET" = FALSE ] + then + if [ "$#" -gt 0 ] then - return 1 + args=$* + echo "$(eval_gettext 'Warning: command line arguments are ignored when continuing a game ($args)')" >&2 + echo "$(gettext 'Press Enter to continue.')" >&2 + read -r _ fi + return 1 fi ### if we're here, we need to reset a new game From c86687141a84d3bd230e333130b7d82e15aa96f6 Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Mon, 18 Nov 2024 17:55:15 +0100 Subject: [PATCH 27/30] unnecessary 'set -m' in test / auto files I also had to fix some bugs so the test / auto files worked with non-interactive shells. --- missions/intermediate/05_background/auto.sh | 2 +- missions/intermediate/05_background/charmiglio.sh | 4 ++-- missions/intermediate/05_background/test.sh | 4 ++-- missions/intermediate/06_control-C/auto.sh | 7 ++++--- missions/intermediate/06_control-C/test.sh | 7 ++++--- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/missions/intermediate/05_background/auto.sh b/missions/intermediate/05_background/auto.sh index f9bb5b0c..f6a5358a 100644 --- a/missions/intermediate/05_background/auto.sh +++ b/missions/intermediate/05_background/auto.sh @@ -1,5 +1,5 @@ #!/usr/bin/env sh -set -m +# set -m charmiglio & charmiglio & charmiglio & gsh check diff --git a/missions/intermediate/05_background/charmiglio.sh b/missions/intermediate/05_background/charmiglio.sh index a11a8b1a..e7b34bac 100755 --- a/missions/intermediate/05_background/charmiglio.sh +++ b/missions/intermediate/05_background/charmiglio.sh @@ -6,10 +6,10 @@ command=$(gettext "charmiglio") file="$MISSION_DIR/ascii-art/f$((1 + $(RANDOM)%6))" -indent=$(echo " " | head -c "$((4 * ($(RANDOM)%8)))") +indent=$(echo " " | head -c "$((2 + 4 * ($(RANDOM)%8)))") rm -f "$GSH_TMP/charmiglio.pids" -for i in $(seq $((5 + $(RANDOM)%10))) +for i in $(seq $((5 + $(RANDOM)%5))) do echo "$indent *" sleep 0.1 diff --git a/missions/intermediate/05_background/test.sh b/missions/intermediate/05_background/test.sh index 52135504..3c8de836 100644 --- a/missions/intermediate/05_background/test.sh +++ b/missions/intermediate/05_background/test.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -set -m +# set -m gsh assert check false charmiglio & gsh assert check false @@ -11,7 +11,7 @@ charmiglio & charmiglio & charmiglio & charmiglio & gsh assert check true charmiglio & charmiglio & charmiglio gsh assert check false -charmiglio; charmiglio; charmiglio; +charmiglio; charmiglio; charmiglio gsh assert check false diff --git a/missions/intermediate/06_control-C/auto.sh b/missions/intermediate/06_control-C/auto.sh index 63e4eb2c..6293bb96 100644 --- a/missions/intermediate/06_control-C/auto.sh +++ b/missions/intermediate/06_control-C/auto.sh @@ -1,13 +1,14 @@ #!/usr/bin/env sh -set -m +# set -m for c in a b c d e f do - eval "$(gettext Charmiglio)" "$c$c$c$c" 2>/dev/null & + eval "$(gettext Charmiglio) $c$c$c$c &" 2>/dev/null PID=$! sleep 4 - kill -s INT "-$PID" 2> /dev/null + # NOTE: SIGINT signal doesn't work on non-interactive systems + kill "$PID" 2> /dev/null case "$(cat "$GSH_TMP/control-C")" in *[!0-9]*) diff --git a/missions/intermediate/06_control-C/test.sh b/missions/intermediate/06_control-C/test.sh index 7f6d11c1..c4d566a2 100644 --- a/missions/intermediate/06_control-C/test.sh +++ b/missions/intermediate/06_control-C/test.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -set -m +# set -m do_test() { nb=$1 @@ -8,10 +8,11 @@ do_test() { for c in $(echo "a b c d e f g h i j" | cut -d' ' -f1-$nb) do - eval "$(gettext Charmiglio)" "$c$c$c$c" 2>/dev/null & + eval "$(gettext Charmiglio) $c$c$c$c &" 2>/dev/null PID=$! sleep "$delay" - kill -s INT "-$PID" 2> /dev/null + # NOTE: SIGINT signal doesn't work on non-interactive systems + kill "$PID" 2> /dev/null case "$(cat "$GSH_TMP/control-C")" in *[!0-9]*) From c9e4881f69bd01f51ff97149576013dbd19ef15b Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Mon, 18 Nov 2024 20:25:50 +0100 Subject: [PATCH 28/30] renamed index.txt files to default.idx it is probably clearer that the default index file is called "default.idx" instead of index.txt --- doc/mission.md | 12 ++++++------ i18n/start-full-help/en.txt | 2 +- i18n/start-full-help/fr.txt | 2 +- i18n/start-help/en.txt | 2 +- i18n/start-help/fr.txt | 2 +- lib/gsh.sh | 2 +- missions/basic/{index.txt => default.idx} | 0 missions/{index.txt => default.idx} | 12 ++++++------ .../finding_files_maze/{index.txt => default.idx} | 0 missions/intermediate/{index.txt => default.idx} | 0 missions/misc/{index.txt => default.idx} | 0 missions/permissions/{index.txt => default.idx} | 0 .../{index.txt => default.idx} | 0 .../pipes_merchant_stall/{index.txt => default.idx} | 0 missions/processes/{index.txt => default.idx} | 0 .../stdin_stdout_stderr/{index.txt => default.idx} | 0 scripts/_gsh_index | 2 +- scripts/make_index | 8 ++++---- scripts/missiondir | 2 +- start.sh | 10 +++++----- utils/archive.sh | 10 +++++----- 21 files changed, 33 insertions(+), 33 deletions(-) rename missions/basic/{index.txt => default.idx} (100%) rename missions/{index.txt => default.idx} (73%) rename missions/finding_files_maze/{index.txt => default.idx} (100%) rename missions/intermediate/{index.txt => default.idx} (100%) rename missions/misc/{index.txt => default.idx} (100%) rename missions/permissions/{index.txt => default.idx} (100%) rename missions/pipe_intro_book_of_potions/{index.txt => default.idx} (100%) rename missions/pipes_merchant_stall/{index.txt => default.idx} (100%) rename missions/processes/{index.txt => default.idx} (100%) rename missions/stdin_stdout_stderr/{index.txt => default.idx} (100%) diff --git a/doc/mission.md b/doc/mission.md index 00aaefd2..9f6ec8ab 100644 --- a/doc/mission.md +++ b/doc/mission.md @@ -442,13 +442,13 @@ which make testing easier. Those files are not included in GameShell archives. -Adding the mission to the `index.txt` file ----------------------------------------- +Adding the mission to the `default.idx` file +------------------------------------------ When run without arguments GameShell will get the list of mission from the -file `$GSH_ROOT/missions/index.txt`. +file `$GSH_ROOT/missions/default.idx`. -You can give a list of `index.txt` files and mission directories as arguments +You can give a list of `default.idx` files and mission directories as arguments of GameShell if you want to customize the list / order of missions. This is particularly useful when testing a new mission: ```sh @@ -464,7 +464,7 @@ Dummy missions "Dummy" missions are used to share data between missions. A mission is "dummy" * either when it doesn't contain a `check.sh` script, -* or it is listed with a "`!`" in front of its name in the `index.txt` file. +* or it is listed with a "`!`" in front of its name in the `default.idx` file. A dummy mission is used during the initialisation phase, so that it can contain a `static.sh` file. It can for example be used to share executable @@ -483,7 +483,7 @@ cp "$MISSION_DIR/../00_shared/ascii-art/elephant.txt" "$GSH_HOME/Jungle/" ``` _Note:_ don't forget to include dummy missions in the corresponding -`index.txt` file, or it won't be included in GameShell executable archives by +`default.idx` file, or it won't be included in GameShell executable archives by default. diff --git a/i18n/start-full-help/en.txt b/i18n/start-full-help/en.txt index 82af3699..5f5a63ed 100644 --- a/i18n/start-full-help/en.txt +++ b/i18n/start-full-help/en.txt @@ -3,7 +3,7 @@ usage: Possible values for INDEX_FILE are: $GSH_INDEX_FILES. -If no INDEX_FILE is given, defaults to index.txt. +If no INDEX_FILE is given, defaults to default.idx. Index files are ignored when continuing from a save file. diff --git a/i18n/start-full-help/fr.txt b/i18n/start-full-help/fr.txt index 1c6b7bcf..d48a5730 100644 --- a/i18n/start-full-help/fr.txt +++ b/i18n/start-full-help/fr.txt @@ -3,7 +3,7 @@ utilisation : Les valeurs possibles pour INDEX_FILE sont : $GSH_INDEX_FILES. -Si aucun INDEX_FILE n'est donné, utilise index.txt par défaut. +Si aucun INDEX_FILE n'est donné, utilise default.idx par défaut. Les fichier index sont ignorés lorsqu'on reprend une session à partir d'un fichier de sauvegarde. diff --git a/i18n/start-help/en.txt b/i18n/start-help/en.txt index b2151099..7d57373a 100644 --- a/i18n/start-help/en.txt +++ b/i18n/start-help/en.txt @@ -3,7 +3,7 @@ usage: Possible values for INDEX_FILE are: $GSH_INDEX_FILES. -If no INDEX_FILE is given, defaults to index.txt. +If no INDEX_FILE is given, defaults to default.idx. Index files are ignored when continuing from a save file. diff --git a/i18n/start-help/fr.txt b/i18n/start-help/fr.txt index 2daa28af..d8706717 100644 --- a/i18n/start-help/fr.txt +++ b/i18n/start-help/fr.txt @@ -3,7 +3,7 @@ utilisation : Les valeurs possibles pour INDEX_FILE sont : $GSH_INDEX_FILES. -Si aucun INDEX_FILE n'est donné, utilise index.txt par défaut. +Si aucun INDEX_FILE n'est donné, utilise default.idx par défaut. Les fichier index sont ignorés lorsqu'on reprend une session à partir d'un fichier de sauvegarde. diff --git a/lib/gsh.sh b/lib/gsh.sh index e3b8f4ec..26e803c7 100644 --- a/lib/gsh.sh +++ b/lib/gsh.sh @@ -119,7 +119,7 @@ _gsh_resetstatic() { printf "." >&2 fi - done < "$GSH_CONFIG/current_index.txt" + done < "$GSH_CONFIG/index.idx" echo "" >&2 unset MISSION_DIR DOMAIN diff --git a/missions/basic/index.txt b/missions/basic/default.idx similarity index 100% rename from missions/basic/index.txt rename to missions/basic/default.idx diff --git a/missions/index.txt b/missions/default.idx similarity index 73% rename from missions/index.txt rename to missions/default.idx index 428ceb7f..5fe59aff 100644 --- a/missions/index.txt +++ b/missions/default.idx @@ -1,6 +1,6 @@ # default Gameshell missions order - basic/index.txt + basic/default.idx misc/01_cal_nostradamus intermediate/01_alias_la misc/02_nano_journal @@ -13,12 +13,12 @@ finding_files_maze/01_ls_cd finding_files_maze/02_tree finding_files_maze/03_find_1 - pipe_intro_book_of_potions/index.txt - processes/index.txt - stdin_stdout_stderr/index.txt - permissions/index.txt + pipe_intro_book_of_potions/default.idx + processes/default.idx + stdin_stdout_stderr/default.idx + permissions/default.idx finding_files_maze/04_find_2 finding_files_maze/05_find_xargs_grep - pipes_merchant_stall/index.txt + pipes_merchant_stall/default.idx misc/03_tr_caesar_shift FINAL_MISSION diff --git a/missions/finding_files_maze/index.txt b/missions/finding_files_maze/default.idx similarity index 100% rename from missions/finding_files_maze/index.txt rename to missions/finding_files_maze/default.idx diff --git a/missions/intermediate/index.txt b/missions/intermediate/default.idx similarity index 100% rename from missions/intermediate/index.txt rename to missions/intermediate/default.idx diff --git a/missions/misc/index.txt b/missions/misc/default.idx similarity index 100% rename from missions/misc/index.txt rename to missions/misc/default.idx diff --git a/missions/permissions/index.txt b/missions/permissions/default.idx similarity index 100% rename from missions/permissions/index.txt rename to missions/permissions/default.idx diff --git a/missions/pipe_intro_book_of_potions/index.txt b/missions/pipe_intro_book_of_potions/default.idx similarity index 100% rename from missions/pipe_intro_book_of_potions/index.txt rename to missions/pipe_intro_book_of_potions/default.idx diff --git a/missions/pipes_merchant_stall/index.txt b/missions/pipes_merchant_stall/default.idx similarity index 100% rename from missions/pipes_merchant_stall/index.txt rename to missions/pipes_merchant_stall/default.idx diff --git a/missions/processes/index.txt b/missions/processes/default.idx similarity index 100% rename from missions/processes/index.txt rename to missions/processes/default.idx diff --git a/missions/stdin_stdout_stderr/index.txt b/missions/stdin_stdout_stderr/default.idx similarity index 100% rename from missions/stdin_stdout_stderr/index.txt rename to missions/stdin_stdout_stderr/default.idx diff --git a/scripts/_gsh_index b/scripts/_gsh_index index cd578bc5..b014c315 100755 --- a/scripts/_gsh_index +++ b/scripts/_gsh_index @@ -48,4 +48,4 @@ do color_echo "$COLOR" "$mission_dir$SKIPPABLE$STATUS" n="$((n + 1))" -done < "$GSH_CONFIG/current_index.txt" | pager +done < "$GSH_CONFIG/index.idx" | pager diff --git a/scripts/make_index b/scripts/make_index index 6f3ab7bd..29fe963c 100755 --- a/scripts/make_index +++ b/scripts/make_index @@ -28,10 +28,10 @@ parse_mission() ( parse_index "$MISSION_DIR" || exit 1 elif [ -d "$MISSION_DIR" ] then - # if a directory contains index.txt, call parse_index recursively - if [ -f "$MISSION_DIR/index.txt" ] + # if a directory contains default.idx, call parse_index recursively + if [ -f "$MISSION_DIR/default.idx" ] then - parse_index "$MISSION_DIR/index.txt" || exit 1 + parse_index "$MISSION_DIR/default.idx" || exit 1 # if a directory contains a check.sh script, it is a standard mission elif [ -f "$MISSION_DIR/check.sh" ] || [ -n "$DUMMY" ] @@ -111,7 +111,7 @@ make_index() { if [ "$#" -eq 0 ] then # without argument, use the default index file - parse_index "$GSH_MISSIONS/index.txt" || exit 1 + parse_index "$GSH_MISSIONS/default.idx" || exit 1 return 0 fi diff --git a/scripts/missiondir b/scripts/missiondir index 8142f3aa..fed5ef18 100755 --- a/scripts/missiondir +++ b/scripts/missiondir @@ -12,7 +12,7 @@ fi # get the mission directory n=$1 -dir=$(awk -v n="$n" -v DIR="$GSH_MISSIONS" '/^\s*[#!]/{next} /^$/{next} {N++} (N == n){print DIR "/" $0; exit}' "$GSH_CONFIG/current_index.txt") +dir=$(awk -v n="$n" -v DIR="$GSH_MISSIONS" '/^\s*[#!]/{next} /^$/{next} {N++} (N == n){print DIR "/" $0; exit}' "$GSH_CONFIG/index.idx") if [ -z "$dir" ] then echo "Error: missiondir, mission '$n' not found." >&2 diff --git a/start.sh b/start.sh index a8d577d5..60694e42 100755 --- a/start.sh +++ b/start.sh @@ -37,8 +37,8 @@ display_help() { } -# list of index files (default: only index.txt) -export GSH_INDEX_FILES=index.txt +# list of index files (default: only default.idx) +export GSH_INDEX_FILES=default.idx # possible values: index, simple (default), overwrite export GSH_SAVEFILE_MODE="simple" @@ -225,7 +225,7 @@ progress() { if [ -z "$progress_I" ] then progress_filename=$GSH_ROOT/lib/ascii-art/titlescreen - local N=$(wc -l "$GSH_CONFIG/current_index.txt" | awk '{print $1}') + local N=$(wc -l "$GSH_CONFIG/index.idx" | awk '{print $1}') local size=$(wc -c "$progress_filename" | awk '{print $1}') progress_delta=$((size/N + 1)) # head -c$((progress_delta - 1)) $progress_filename => not POSIX compliant @@ -388,7 +388,7 @@ Do you want to remove it and start a new game? [y/N]') " clear fi - make_index "$@" | sed -e "s;$GSH_MISSIONS;.;" > "$GSH_CONFIG/current_index.txt" + make_index "$@" | sed -e "s;$GSH_MISSIONS;.;" > "$GSH_CONFIG/index.idx" if [ "$GSH_MODE" != "DEBUG" ] then @@ -498,7 +498,7 @@ Do you want to remove it and start a new game? [y/N]') " [ -z "$MISSION_SUB_NB" ] && MISSION_NB=$((MISSION_NB+1)) - done < "$GSH_CONFIG/current_index.txt" + done < "$GSH_CONFIG/index.idx" if [ "$MISSION_NB" -eq 1 ] then echo "$(gettext "Error: no mission was found! diff --git a/utils/archive.sh b/utils/archive.sh index a2272fa5..885865f0 100755 --- a/utils/archive.sh +++ b/utils/archive.sh @@ -92,7 +92,7 @@ do esac ;; I) - if [ "$OPTARG" = "index.txt" ] || [ "$OPTARG" = "current_index.txt" ] + if [ "$OPTARG" = "default.idx" ] then echo "Warning: ignoring additional index file with name '$OPTARG'" else @@ -161,11 +161,11 @@ cp -RPp "$GSH_ROOT/start.sh" "$GSH_ROOT/scripts" "$GSH_ROOT/utils" "$GSH_ROOT/li # generate default index file -ALL_INDEX_FILES=index.txt +ALL_INDEX_FILES=default.idx mkdir "$TMP_DIR/$NAME/missions" -if ! make_index "$@" > "$TMP_DIR/$NAME/missions/index.txt" +if ! make_index "$@" > "$TMP_DIR/$NAME/missions/default.idx" then - echo "Error: archive.sh, couldn't make index.txt" + echo "Error: archive.sh, couldn't make default.idx" # --system makes GameShell use the standard rm utility instead of the "safe" # rm implemented in scripts/rm rm --system -rf "$TMP_DIR" @@ -338,7 +338,7 @@ then printf "." fi fi - done < "$GSH_ROOT/missions/index.txt" + done < "$GSH_ROOT/missions/default.idx" echo } fi From 285d8b1a9d5078ef1da4ebf7e509b4db668479cd Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Mon, 18 Nov 2024 20:30:04 +0100 Subject: [PATCH 29/30] added -I option to short help message --- i18n/start-help/en.txt | 1 + i18n/start-help/fr.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/i18n/start-help/en.txt b/i18n/start-help/en.txt index 7d57373a..0c2d46ae 100644 --- a/i18n/start-help/en.txt +++ b/i18n/start-help/en.txt @@ -12,6 +12,7 @@ main options: -h this message -H show all available options -V display version + -I show list of available index files -R reset game -F do not check for more recent savefiles, force using the given archive diff --git a/i18n/start-help/fr.txt b/i18n/start-help/fr.txt index d8706717..39650c7e 100644 --- a/i18n/start-help/fr.txt +++ b/i18n/start-help/fr.txt @@ -13,6 +13,7 @@ options principales : -h ce message -H affiche toutes les options -V affiche la version + -I affiche la liste des fichier index disponibles -R recommence une partie du début -F ne vérifie pas l'existence de fichiers de sauvegarde plus récents, From d345dbe04a27ce3f9f0339e26034920a04bc9ced Mon Sep 17 00:00:00 2001 From: Pierre Hyvernat Date: Wed, 20 Nov 2024 12:21:22 +0100 Subject: [PATCH 30/30] remove warning in case language is changed because it doesn't work --- start.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/start.sh b/start.sh index 60694e42..880e882e 100755 --- a/start.sh +++ b/start.sh @@ -102,13 +102,6 @@ do ;; L) export LANGUAGE="$OPTARG" # only works on GNU systems - if [ "$RESET" = FALSE ] - then - args="-L $OPTARG" - echo "$(eval_gettext 'Warning: language is ignored when continuing a game ($args)')" >&2 - echo "$(gettext 'Press Enter to continue.')" >&2 - read -r _ - fi ;; G) export GSH_NO_GETTEXT=1