-
Notifications
You must be signed in to change notification settings - Fork 0
/
fat_letters
executable file
·225 lines (217 loc) · 7.14 KB
/
fat_letters
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/usr/bin/env bash
#!/bin/bash
#
# @author Zeus Intuivo <[email protected]>
#
#
COLORED="";
TEST="";
YELLOW_OVER_DARKBLUE="\\033[38;5;220m\\033[48;5;20m"
RESET="\\033[0m"
function bigger_letter() {
local ONE
while read -r ONE ; do
{
# NOT Colored
if [ -z "$COLORED" ] ; then # is empty
{
#| sed 's/o\|p\|\.\|_/o/g' \
if [[ "$TEST" == 'YES' ]] ; then
{
echo """$ONE""" | sed 's/o/ /g'
echo """$ONE""" | sed 's/o/ /g'
}
else
{
echo """$ONE""" | sed 's/#/##/g' | sed 's/o\|p\|\.\|_/oo/g' | sed 's/o/ /g'
echo """$ONE""" | sed 's/#/##/g' | sed 's/o\|p\|\.\|_/oo/g' | sed 's/o/ /g'
}
fi
}
else
{
echo -e "$YELLOW_OVER_DARKBLUE""""$ONE""""$RESET" | sed 's/o/ /g'
echo -e "$YELLOW_OVER_DARKBLUE""""$ONE""""$RESET" | sed 's/o/ /g'
}
fi
}
done <<< """$(figlet -f banner $1 \
| sed 's/ /o/g' \
| sed 's/#oooo#oo/##____##_.pppp/g' \
| sed 's/ooooo#oo/______##_.pppp/g' \
| sed 's/o#####oo/_#######_.pppp/g' \
| sed 's/#ooooo#o/##_____##.pppp/g' \
| sed 's/oooooo#o/_______##.pppp/g' \
| sed 's/o#####oo/_#######_.pppp/g' \
| sed 's/#ooooooo/###______.pppp/g' \
| sed 's/#######o/#########.pppp/g' \
| sed 's/oo###ooo/__#####__.pppp/g' \
| sed 's/o#ooo#oo/_##___##_.pppp/g' \
| sed 's/#ooooo#o/##_____##.pppp/g' \
| sed 's/o###o#o/_####_##.pppp/g' \
| sed 's/#oo#o#o/##__#_##.pppp/g' \
| sed 's/#o##o#o/##_##_##.pppp/g' \
| sed 's/##oo##o/###__###.pppp/g' \
| sed 's/#oooooo/###_____.pppp/g' \
| sed 's/ooooo#o/_____###.pppp/g' \
| sed 's/#####oo/#######_.pppp/g' \
| sed 's/#oooo#o/##____##.pppp/g' \
| sed 's/o#oo#oo/_##__##_.pppp/g' \
| sed 's/oo##ooo/__####__.pppp/g' \
| sed 's/o####oo/_######_.pppp/g' \
| sed 's/######o/########.pppp/g' \
| sed 's/#oo###o/##__####.pppp/g' \
| sed 's/o#ooooo/_###____.pppp/g' \
| sed 's/oo#oooo/__###___.pppp/g' \
| sed 's/ooo#ooo/___###__.pppp/g' \
| sed 's/oooo#oo/____###_.pppp/g' \
| sed 's/#ooo#oo/##___##_.pppp/g' \
| sed 's/####ooo/######__.pppp/g' \
| sed 's/##ooo#o/###___##.pppp/g' \
| sed 's/#o#oo#o/##_#__##.pppp/g' \
| sed 's/#ooo##o/##___###.pppp/g' \
| sed 's/#####o/#######.pppp/g' \
| sed 's/#ooo#o/##___##.pppp/g' \
| sed 's/o#o#oo/_##_##_.pppp/g' \
| sed 's/oo#ooo/__###__.pppp/g' \
| sed 's/o##ooo/_####__.pppp/g' \
| sed 's/#o#ooo/##_##__.pppp/g' \
| sed 's/o#oo/_###_.pppp/g' \
| sed 's/###o/#####.pppp/g' \
| sed 's/#o/###.pppp/g' \
| sed 's/\.pppp#o/_pppp##.pppp/g' \
)"""
} # end bigger_letter
#| sed 's/o##o/_####_.pppp/g' \
function bigger_letters_breaker() {
local params="${*}"
local tring_length="${#params}" # bash get string length
local res=""
# debug echo "params: $params"
# debug echo "tring_length: $tring_length"
# BASH Loops with numbers REF: https://www.cyberciti.biz/faq/unix-for-loop-1-to-10/
# Tested using bash version 4.1.5
local -i counter=0
local letter bletter
while [[ $counter -lt $tring_length ]] ; do
{
# your-unix-command-here
# Access String like array REF: https://stackoverflow.com/questions/7578930/bash-split-string-into-character-array
# debug echo "counter: $counter"
# debug echo "letter: $letter"
# debug echo "res: $res"
letter=${params:$counter:1}
if [ -z "${res}" ] ; then # is_empty
{
res=$(bigger_letter "$letter")
}
else
{
bletter=$(bigger_letter "$letter")
res=$(paste -d ' ' <(echo "$res") <(echo "$bletter"))
}
fi
counter=$((counter+1))
}
done
echo "${res}"
} # end bigger_letters_breaker
function trim_start_space() {
sed -e 's/^[[:space:]]*//' | sed 's/^\ //g' | sed 's/^\t//g'
}
function trim_end_space() {
sed -e 's/[[:space:]]*$//' | sed 's/\ $//g' | sed 's/\t$//g'
}
function trim() {
trim_start_space | trim_end_space
}
function last_five() {
sed 's/^.*\(.\{5\}\)$/\1/'
}
function test_bigger_letters() {
local params=":$#-+1234567890qwertzuiopasdfghjklyxcvbnm"
local -i tring_length="${#params}" # bash get string length
TEST="YES";
local res=""
# debug echo "params: $params"
# debug echo "tring_length: $tring_length"
# BASH Loops with numbers REF: https://www.cyberciti.biz/faq/unix-for-loop-1-to-10/
# Tested using bash version 4.1.5
local -i counter=0
local letter bletter
local -i largest ONE_LINE
local -i long
local cletter ONE_SEE_LINE
local -i error_length=0
while [[ $counter -lt $tring_length ]] ; do
{
# your-unix-command-here
# Access String like array REF: https://stackoverflow.com/questions/7578930/bash-split-string-into-character-array
# debug echo "counter: $counter"
# debug echo "letter: $letter"
# debug echo "res: $res"
letter=${params:$counter:1}
bletter=$(bigger_letters_breaker "$letter" )
# test that the result looks squared
largest=0
long=0
error_length=0
while read -r ONE_LINE; do
{
[[ -n "${ONE_LINE}" ]] && continue # skip empty
long="${#ONE_LINE}" # bash get string length
[ $long -eq $largest ] && continue
error_length=$((error_length+1))
largest=$long
}
done <<< "${bletter}"
# test that the ends all combined end in ".pppp"
#res=$(echo "$bletter" | trim | last_five | sort | uniq | tail -1)
res=$(echo "$bletter" | trim | last_five | sort | uniq | sed '/\.pppp/d' )
if [[ "${res}" == "" ]] && [ $error_length -lt 4 ] ; then
{
echo "($letter):passed: "
}
else
{
COLORED="YES";
bletter=$(bigger_letters_breaker "$letter" )
COLORED="";
echo "failed test for letter ($letter): res ($res) length errs ($error_length) "
cletter=$(figlet -f banner "$letter")
# echo -e "$YELLOW_OVER_DARKBLUE$ONE_SEE_LINE$RESET" | sed 's/ /o/g'
# echo "${cletter}" | sed 's/ /_/g'
OLD_IFS=IFS
IFS=''
for ONE_SEE_LINE in ${cletter}; do
#while read -r ONE_SEE_LINE; do
{
[[ -n "${ONE_SEE_LINE}" ]] && continue
# echo -e "$YELLOW_OVER_DARKBLUE$ONE_SEE_LINE$RESET" | sed 's/ /_/g'
# echo "${cletter}" | sed 's/ /_/g'
echo "${cletter// /_}"
}
done
# done <<< "${cletter}"
IFS=$OLD_IFS
echo "$bletter"
}
fi
counter=$((counter+1))
}
done
TEST="NO";
} # end test_bigger_letters
COLORED="";
# debug COLORED="YES"; bigger_letters_breaker q
# debug
if [[ -n "${1:-}" ]] && [[ "${1:-}" == "--test" ]] ; then
{
shift 1
test_bigger_letters "${*:-}"
}
else
{
bigger_letters_breaker "${*}"
}
fi