summaryrefslogtreecommitdiff
path: root/hexdraw.sh
blob: 78a6e74b59789fbd2e8d2620933ebf1db081b5da (plain)
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
#!/bin/sh
# Script to mimic the encoding half of Roman Czyborra's hexdraw
# script using only tr and sed. Should be 100% portable in both
# the POSIX sense and the legacy Unix sense.

tr '[\n ]' '[ \n]' \
| sed -e 's/	\([^ ]*\) /\1/g' \
| tr '[\n ]' '[ \n]' \
| sed -e '/^:/!b x
s/:/:@/
: r
s/@----/0@/
t r
s/@---#/1@/
t r
s/@--#-/2@/
t r
s/@--##/3@/
t r
s/@-#--/4@/
t r
s/@-#-#/5@/
t r
s/@-##-/6@/
t r
s/@-###/7@/
t r
s/@#---/8@/
t r
s/@#--#/9@/
t r
s/@#-#-/A@/
t r
s/@#-##/B@/
t r
s/@##--/C@/
t r
s/@##-#/D@/
t r
s/@###-/E@/
t r
s/@####/F@/
t r
s/@//
: x'