Skip to content

Commit f06705e

Browse files
Improve coding style of loop statements
Ref: https://google.github.io/styleguide/shell.xml?showone=Loops#Loops
1 parent 0103b94 commit f06705e

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

β€Žgenerator.sh

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ fi
2929

3030
echo.BoldGreen "ColorEcho generator start!"
3131

32-
for shell in sh bash fish ksh zsh
33-
do
32+
for shell in sh bash fish ksh zsh; do
3433
{
3534
echo.BoldYellow "Generating ColorEcho for ${shell} shell ..."
3635
#shell specify configs and tricks
@@ -95,27 +94,23 @@ else
9594
fi
9695
SH_ECHO
9796
fi
98-
awk '{print $1}' "${table}" | while IFS= read -r color
99-
do
97+
awk '{print $1}' "${table}" | while IFS= read -r color; do
10098
#light or not
101-
for light in "" "Light"
102-
do
99+
for light in "" "Light"; do
103100
if [ "${light}" = "" ]; then
104101
code=3
105102
else
106103
code=9
107104
fi
108105
#bold or not
109-
for bold in "" "Bold"
110-
do
106+
for bold in "" "Bold"; do
111107
if [ "${bold}" = "" ]; then
112108
bCode=
113109
else
114110
bCode='1;'
115111
fi
116112
#underline or not
117-
for underLine in "" "UL"
118-
do
113+
for underLine in "" "UL"; do
119114
{
120115
echo ""
121116
echo "${fn}echo${dot}${light}${bold}${underLine}${color}${brackets}"

β€Žtest-scripts/bash

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ dir="$(cd "$(dirname "$0")" && pwd)"
55
script="${dir}/../dist/ColorEcho.bash"
66
. "${script}"
77

8-
awk '/^function +echo/ {print $2}' "${script}" | while IFS= read -r x
9-
do
8+
awk '/^function +echo/ {print $2}' "${script}" | while IFS= read -r x; do
109
${x} "${x}"
1110
done

β€Žtest-scripts/sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ dir="$(cd "$(dirname "$_")" && pwd)"
55
script="${dir}/../dist/ColorEcho.sh"
66
. "${script}"
77

8-
grep -E "echo[a-zA-Z]+()" "${script}" | sed 's/()//g' | while IFS= read -r x
9-
do
8+
grep -E "echo[a-zA-Z]+()" "${script}" | sed 's/()//g' | while IFS= read -r x; do
109
${x} "${x}"
1110
done

0 commit comments

Comments
Β (0)