Skip to content

Commit ff4cfbd

Browse files
committed
refactor: add escape variable - tcsh will have different char escaping
1 parent 14bb337 commit ff4cfbd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

β€Žgenerator.shβ€Ž

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ for shell in sh bash fish ksh zsh; do
3838
fn='function '
3939
dot='.'
4040
echo='echo -e'
41+
escape='\\'
4142
if='if '
4243
then='; then '
4344
else='; else '
@@ -53,6 +54,7 @@ for shell in sh bash fish ksh zsh; do
5354
fn='function '
5455
dot=
5556
echo='echo -e'
57+
escape='\\'
5658
if='if '
5759
then='; then '
5860
else='; else '
@@ -68,6 +70,7 @@ for shell in sh bash fish ksh zsh; do
6870
fn='function '
6971
dot='.'
7072
echo='echo -e'
73+
escape='\\'
7174
if='if '
7275
then='; '
7376
else='; else; '
@@ -84,6 +87,7 @@ end'
8487
dot=
8588
# shellcheck disable=SC2016
8689
echo='$ECHO'
90+
escape='\\'
8791
if='if '
8892
then='; then '
8993
else='; else '
@@ -178,7 +182,7 @@ SH_ECHO
178182
echo ""
179183
printf "%s%s" "${echoFunction}" "${brackets}"
180184
# write the code down
181-
echo "${startSym}${echo}"' "\\033['"${finalStyleCode}${code}${colorCode}m${para}"'\\033[m"'"${endSym}"
185+
echo "${startSym}${echo} "'"'"${escape}033[${finalStyleCode}${code}${colorCode}m${para}${escape}033[m"'"'"${endSym}"
182186
} >> "${tempDist}"
183187
fi
184188
done
@@ -207,7 +211,7 @@ LOLCAT
207211
# echo.Reset to remove color code on output
208212
fnName="${fn}echo${dot}Reset${brackets}"
209213
cat << RESET >> "${tempDist}"
210-
${fnName}${startSym}echo "${para}" | tr -d '[:cntrl:]' | sed -E "s/\\\\[((;)?[0-9]{1,3}){0,3}m//g" | xargs${endSym}
214+
${fnName}${startSym}echo "${para}" | tr -d '[:cntrl:]' | sed -E "s/${escape//\//\/\/}[((;)?[0-9]{1,3}){0,3}m//g" | xargs${endSym}
211215
RESET
212216
mv -f "${tempDist}" "${newDist}"
213217
} &

0 commit comments

Comments
Β (0)