diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-03-27 16:05:11 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-03-27 16:05:11 +0200 |
commit | b224acf16c442784aa03c916afdb091e330c3c02 (patch) | |
tree | 66dc1b0b0ba1af54ccb90ef0a66436392076a891 | |
parent | 446f7a2761b3f15e52f396ec337799d788efac97 (diff) |
fix word filter, update man page and add install script
-rw-r--r-- | os1eindopdracht/makefile | 14 | ||||
-rwxr-xr-x | os1eindopdracht/uhm | 2 | ||||
-rw-r--r-- | os1eindopdracht/uhm.1 | 16 |
3 files changed, 25 insertions, 7 deletions
diff --git a/os1eindopdracht/makefile b/os1eindopdracht/makefile new file mode 100644 index 0000000..49a11ec --- /dev/null +++ b/os1eindopdracht/makefile @@ -0,0 +1,14 @@ +.PHONY: install uninstall + +PREFIX = /usr/local +MANPREFIX = $(PREFIX)/share/man + +install: + mkdir -p $(PREFIX)/bin + cp -f ./uhm ./uhm.awk $(PREFIX)/bin + cp -f ./uhm.1 $(MANPREFIX)/man1/uhm.1 + chmod 755 $(PREFIX)/bin/uhm $(PREFIX)/bin/uhm.awk + +uninstall: + rm -f $(PREFIX)/bin/uhm $(PREFIX)/bin/uhm.awk + rm -f $(MANPREFIX)/man1/uhm.1 diff --git a/os1eindopdracht/uhm b/os1eindopdracht/uhm index 5d13a13..fbf2305 100755 --- a/os1eindopdracht/uhm +++ b/os1eindopdracht/uhm @@ -34,7 +34,7 @@ if [ -z "$WORD" ]; then [ ! "`wc -l "$DICT" | cut -d' ' -f1`" -gt "0" ] && echo "dictionary file is empty!" && exit 1 # filter words containing apostrophe or space, or words longer than 12 characters - WORD="`sed -e "/' /d" -e '/.\{13\}/d' "$DICT" | sort -R | head -n1`" + WORD="`sed -e "/[' ]/d" -e '/.\{13\}/d' "$DICT" | sort -R | head -n1`" # check if word is empty [ -z "$WORD" ] && echo "no usable words found in dictionary" && exit 1 fi diff --git a/os1eindopdracht/uhm.1 b/os1eindopdracht/uhm.1 index ab15eff..ae67b76 100644 --- a/os1eindopdracht/uhm.1 +++ b/os1eindopdracht/uhm.1 @@ -9,22 +9,26 @@ Play a game of hangman, optionally using a custom dictionary or custom word. The terminal screen will always get cleared before playing. The player can input a single letter per turn. The player's turn is indicated -by a caret '> ' prompt. When the word contains the input letter, the player +by a caret `> ' prompt. When the word contains the input letter, the player keeps the same amount of turns. When the word does not contain the input letter, the player loses a turn. The game exits once all turns are depleted, or the player has guessed the word. .SH OPTIONS .TP \fB-h\fP -show help +Show help .TP \fB-w \fIword\fP -set custom word to \fIword\fP +Set custom word to \fIword\fP .TP \fB-d \fIfile\fP -load random word from dictionary \fIfile\fP. Any words containing spaces, -apostrophes, or words longer than 12 characters will get filtered. \fIfile\fP -must be a regular file. +Load random word from dictionary \fIfile\fP. + +\fIfile\fP must be a regular file containing a single word on each line. The +default dictionary used is /usr/share/dict/words. + +Any words containing spaces, apostrophes, or words longer than 12 characters +will get filtered. .SH AUTHOR Written by Loek Le Blansch. .SH COPYRIGHT |