summaryrefslogtreecommitdiff
path: root/os1eindopdracht/uhm.awk
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-03-27 15:42:52 +0200
committerlonkaars <loek@pipeframe.xyz>2023-03-27 15:42:52 +0200
commit446f7a2761b3f15e52f396ec337799d788efac97 (patch)
tree5ac72ae3a92470eb6b2f875506438385d3f7be4c /os1eindopdracht/uhm.awk
parent1ea23e3b923ea89b97a51edc75e1a8d13264e758 (diff)
add manpage and check requirements
Diffstat (limited to 'os1eindopdracht/uhm.awk')
-rwxr-xr-xos1eindopdracht/uhm.awk22
1 files changed, 9 insertions, 13 deletions
diff --git a/os1eindopdracht/uhm.awk b/os1eindopdracht/uhm.awk
index c34333f..c57f7c5 100755
--- a/os1eindopdracht/uhm.awk
+++ b/os1eindopdracht/uhm.awk
@@ -1,7 +1,5 @@
#!/bin/awk -f
-function prompt() {
- printf "> "
-}
+function prompt() { printf "> " }
BEGIN {
word=word
@@ -11,15 +9,6 @@ BEGIN {
prompt()
}
-function header() {
- printf "\n\n\n"
- hidden_word = word
- # replace all characters not in set `guessed_letters` with "_"
- gsub("[^'"guessed_letters"]", "_", hidden_word)
- print "current word: " hidden_word
- print "you have " guesses " guess" (guesses == 1 ? "" : "es") " left"
-}
-
function guess(a) {
if (index(guessed_letters, a) != 0) {
print "already guessed " a "!"
@@ -41,7 +30,14 @@ function guess(a) {
exit 0
}
- header()
+ # print header
+ printf "\n\n\n"
+ hidden_word = word
+ # replace all characters not in set `guessed_letters` with "_"
+ gsub("[^'"guessed_letters"]", "_", hidden_word)
+ print "current word: " hidden_word
+ print "guessed letters: " guessed_letters
+ print "you have " guesses " guess" (guesses == 1 ? "" : "es") " left"
}
{