Skip to content

Commit 9306f69

Browse files
committed
refactor: shellcheck feedback
* Changed variable assignment to avoid unnecessary exports. * Simplified the process of generating JSON entries for `shortnamearray.json`. * Enhanced readability and maintainability of `generate-docker-compose.sh` and `generate-dockerfiles.sh`.
1 parent 71853f2 commit 9306f69

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

generate-docker-compose.sh

100755100644
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@ curl -O "https://raw.githubusercontent.com/GameServerManagers/LinuxGSM/master/lg
55
echo -n "{" >"shortnamearray.json"
66
echo -n "\"include\":[" >>"shortnamearray.json"
77

8-
while read line; do
9-
export shortname=$(echo "$line" | awk -F, '{ print $1 }')
10-
export servername=$(echo "$line" | awk -F, '{ print $2 }')
11-
export gamename=$(echo "$line" | awk -F, '{ print $3 }')
12-
export distro=$(echo "$line" | awk -F, '{ print $4 }')
8+
while read -r line; do
9+
shortname=$(echo "$line" | awk -F, '{ print $1 }')
10+
export shortname
11+
servername=$(echo "$line" | awk -F, '{ print $2 }')
12+
export servername
13+
gamename=$(echo "$line" | awk -F, '{ print $3 }')
14+
export gamename
15+
distro=$(echo "$line" | awk -F, '{ print $4 }')
16+
export distro
1317
touch "docker-compose/docker-compose-${shortname}.yml"
1418
echo "Generating docker-compose-${shortname}.yml (${gamename})"
1519
jinjanate docker-compose.yml.j2 >"docker-compose/docker-compose-${shortname}.yml"
16-
echo -n "{" >>"shortnamearray.json"
17-
echo -n "\"shortname\":" >>"shortnamearray.json"
18-
echo -n "\"${shortname}\"" >>"shortnamearray.json"
19-
echo -n "}," >>"shortnamearray.json"
20+
{ printf '{"shortname":"%s"},' "$shortname"; } >>"shortnamearray.json"
2021
done < <(tail -n +1 serverlist.csv)
2122
sed -i '$ s/.$//' "shortnamearray.json"
2223
echo -n "]" >>"shortnamearray.json"

generate-dockerfiles.sh

100755100644
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@ echo -n "{" >"shortnamearray.json"
66
echo -n "\"include\":[" >>"shortnamearray.json"
77

88
while read line; do
9-
export shortname=$(echo "$line" | awk -F, '{ print $1 }')
10-
export servername=$(echo "$line" | awk -F, '{ print $2 }')
11-
export gamename=$(echo "$line" | awk -F, '{ print $3 }')
12-
export distro=$(echo "$line" | awk -F, '{ print $4 }')
9+
shortname=$(echo "$line" | awk -F, '{ print $1 }')
10+
export shortname
11+
servername=$(echo "$line" | awk -F, '{ print $2 }')
12+
export servername
13+
gamename=$(echo "$line" | awk -F, '{ print $3 }')
14+
export gamename
15+
distro=$(echo "$line" | awk -F, '{ print $4 }')
16+
export distro
1317
touch "dockerfiles/Dockerfile.${shortname}"
1418
echo "Generating Dockerfile.${shortname} (${gamename})"
1519
jinjanate Dockerfile.j2 >"dockerfiles/Dockerfile.${shortname}"
16-
echo -n "{" >>"shortnamearray.json"
17-
echo -n "\"shortname\":" >>"shortnamearray.json"
18-
echo -n "\"${shortname}\"" >>"shortnamearray.json"
19-
echo -n "}," >>"shortnamearray.json"
20+
{ printf '{"shortname":"%s"},' "$shortname"; } >>"shortnamearray.json"
2021
done < <(tail -n +2 serverlist.csv)
2122
sed -i '$ s/.$//' "shortnamearray.json"
2223
echo -n "]" >>"shortnamearray.json"

0 commit comments

Comments
 (0)