summaryrefslogtreecommitdiff
path: root/os1eindopdracht/uhm
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
parent1ea23e3b923ea89b97a51edc75e1a8d13264e758 (diff)
add manpage and check requirements
Diffstat (limited to 'os1eindopdracht/uhm')
-rwxr-xr-xos1eindopdracht/uhm8
1 files changed, 5 insertions, 3 deletions
diff --git a/os1eindopdracht/uhm b/os1eindopdracht/uhm
index 324a863..5d13a13 100755
--- a/os1eindopdracht/uhm
+++ b/os1eindopdracht/uhm
@@ -1,4 +1,4 @@
-#!/bin/dash
+#!/bin/sh
WORD=""
DICT="/usr/share/dict/words"
ARGC=0
@@ -28,11 +28,13 @@ done
if [ -z "$WORD" ]; then
# check if dictionary file exists
[ ! -e "$DICT" ] && echo "dictionary file doesn't exist!" && exit 1
+ # check if dictionary file is a regular file (not directory, block device, etc.)
+ [ ! -f "$DICT" ] && echo "dictionary file isn't a regular file!" && exit 1
# check if dictionary file contains at least one line
[ ! "`wc -l "$DICT" | cut -d' ' -f1`" -gt "0" ] && echo "dictionary file is empty!" && exit 1
- # filter words containing apostrophe or words longer than 12 characters
- WORD="`sed -e "/'/d" -e '/.\{13\}/d' "$DICT" | sort -R | head -n1`"
+ # filter words containing apostrophe or space, or words longer than 12 characters
+ 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