-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbing_dict.sh
29 lines (25 loc) · 875 Bytes
/
bing_dict.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
DICT=
DIR=$(cd "$(dirname "$BASH_SOURCE[0]]")" && pwd)
function setup_dict() {
if [[ -n "${DICT}" ]]; then
echo "Setting up dictionary file copied from: ${DICT}"
elif [[ -f "/usr/dict/words" ]]; then
DICT="/usr/dict/words"
echo "Setting up dictionary file copied from UNIX built-in dictionary"
elif [[ -f "/usr/share/dict/words" ]]; then
DICT="/usr/share/dict/words"
echo "Setting up dictionary file copied from UNIX built-in dictionary"
elif [[ -d "/usr/share/dict" ]] && [[ $(ls "/usr/share/dict" | wc -l) -ne "0" ]]; then
DICT="/usr/share/dict/"
DICT="$DICT$(ls "${DICT}" | head -n 1)"
echo "Setting up dictionary file copied from: ${DICT}"
else
echo "Please input path to dictionary file in the script's DICT variable"
exit 1
fi
cp "${DICT}" "${DIR}/words"
}
if [[ ! -f "${DIR}/words" ]]; then
setup_dict
fi