Skip to content

Commit ea9d10c

Browse files
committed
refactor: refactor startSym/endSym to enable one-line declarations
1 parent d6fd8a0 commit ea9d10c

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

β€Žgenerator.shβ€Ž

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,42 +38,50 @@ for shell in sh bash fish ksh zsh; do
3838
fn='function '
3939
dot='.'
4040
echo='echo -e'
41-
startSym=' {'
42-
endSym='}'
4341
endIf='fi'
4442
brackets='()'
4543
para='*'
44+
startSym=' {
45+
'
46+
endSym='
47+
}'
4648
;;
4749
"ksh")
4850
fn='function '
4951
dot=
5052
echo='echo -e'
51-
startSym=' {'
52-
endSym='}'
5353
endIf='fi'
5454
brackets=
5555
para='*'
56+
startSym=' {
57+
'
58+
endSym='
59+
}'
5660
;;
5761
"fish")
5862
fn='function '
5963
dot='.'
6064
echo='echo -e'
61-
startSym=
62-
endSym='end'
6365
endIf='end'
6466
brackets=
6567
para='argv'
68+
startSym='
69+
'
70+
endSym='
71+
end'
6672
;;
6773
"sh")
6874
fn=
6975
dot=
7076
# shellcheck disable=SC2016
7177
echo='$ECHO'
72-
startSym=' {'
73-
endSym='}'
7478
endIf='fi'
7579
brackets='()'
7680
para='*'
81+
startSym=' {
82+
'
83+
endSym='
84+
}'
7785
;;
7886
esac
7987

@@ -158,9 +166,7 @@ SH_ECHO
158166
echo ""
159167
printf "%s%s" "${echoFunction}" "${brackets}"
160168
# write the code down
161-
echo "${startSym}"
162-
echo " ${echo}"' "\\033['"${finalStyleCode}${code}""$(grep "${color}" "${table}" | awk '{print $2}')"'m$'"${para}"'\\033[m"'
163-
echo "${endSym}"
169+
echo "${startSym}${echo}"' "\\033['"${finalStyleCode}${code}""$(grep "${color}" "${table}" | awk '{print $2}')"'m$'"${para}"'\\033[m"'"${endSym}"
164170
} >> "${tempDist}"
165171
fi
166172
done
@@ -183,21 +189,17 @@ SH_ECHO
183189
esac
184190

185191
cat << LOLCAT >> "${tempDist}"
186-
${fnName}${startSym}
187-
${ifCond}
192+
${fnName}${startSym}${ifCond}
188193
echo "\$${para}" | lolcat
189194
else
190195
echo "\$${para}"
191-
${endIf}
192-
${endSym}
196+
${endIf}${endSym}
193197
LOLCAT
194198

195199
# echo.Reset to remove color code on output
196200
fnName="${fn}echo${dot}Reset${brackets}"
197201
cat << RESET >> "${tempDist}"
198-
${fnName}${startSym}
199-
echo "\$${para}" | tr -d '[:cntrl:]' | sed -E "s/\\\\[((;)?[0-9]{1,3}){0,3}m//g" | xargs
200-
${endSym}
202+
${fnName}${startSym}echo "\$${para}" | tr -d '[:cntrl:]' | sed -E "s/\\\\[((;)?[0-9]{1,3}){0,3}m//g" | xargs${endSym}
201203
RESET
202204
mv -f "${tempDist}" "${newDist}"
203205
} &

0 commit comments

Comments
Β (0)