-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
runes
executable file
Β·59 lines (54 loc) Β· 1.13 KB
/
runes
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env sh
# Set up the actual work of translation
translate()
{
echo "$1" | tr '[:upper:]' '[:lower:]' |
sed 's/th/α¦/g;
s/ng/α/g;
s/[kc]/α²/g;
s/[vw]/αΉ/g;
s/[jy]/α/g;
s/a/α¨/g;
s/b/α/g;
s/d/α/g;
s/e/α/g;
s/f/α /g;
s/g/α·/g;
s/h/α»/g;
s/i/α/g;
s/l/α/g;
s/m/α/g;
s/n/αΎ/g;
s/o/α/g;
s/p/α/g;
s/r/α±/g;
s/s/α/g;
s/t/α/g;
s/u/α’/g;
s/z/α/g'
}
# If first argument is a file then translate and output
# the entire files contents
if [ -f "$1" ]; then
while read -r line
do
translate "$line"
done < "$1"
exit 0
fi
# If input is standard input like echo "text" it translates
if [ -n "$1" ]; then
for word in "$@"
do
translate "$word" | tr "\n" " "
done
echo && exit 0
fi
# Interactive mode to read line after line of user
# supplied standard input, or will allow piping strings in
# or cat a whole file and pipe that in.
while read -r line
do
translate "$line"
done < '/dev/stdin'
exit 0