Skip to content

Commit 3f985ff

Browse files
committed
refactor: use printf directly instead of string concatenation
Replace string concatenation with direct printf calls for building the profiles list message. This is more maintainable and consistent with other printf statements in the script. Benefits: - Avoids error-prone string building with ANSI escape sequences - More consistent with the rest of the script - Cleaner and easier to maintain - No temporary variables needed Addresses Copilot AI code review suggestion.
1 parent 2cf48cd commit 3f985ff

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

dockerfiles/codespacesURL.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,6 @@ fi
2525
# Define an array of available tutorial profiles
2626
targets=("maven" "node" "python" "multi" "cpp" "dotnet" "golang" "android" "default" "wizard")
2727

28-
# Initialize message string
29-
message="📚 Available tutorial profiles: "
30-
31-
# Build the profiles list message
32-
for target in "${targets[@]}"; do
33-
message+="\033[36m${target}\033[0m, "
34-
done
35-
36-
# Remove the trailing comma and space
37-
message=${message%??}
38-
3928
# Display information to user
4029
printf "\n"
4130
printf "🚀 Jenkins Quickstart Tutorials Setup\n"
@@ -44,8 +33,19 @@ printf "\n"
4433
printf "Once you run \033[42;30mdocker compose --profile <profile-name> up\033[0m,\n"
4534
printf "Jenkins will be accessible at: \033[36m%s\033[0m\n" "${service_url}"
4635
printf "\n"
47-
printf "%b\n" "${message}"
48-
printf "\n"
36+
37+
# Display available profiles with color formatting
38+
printf "📚 Available tutorial profiles: "
39+
first=true
40+
for target in "${targets[@]}"; do
41+
if [ "${first}" = true ]; then
42+
printf "\033[36m%s\033[0m" "${target}"
43+
first=false
44+
else
45+
printf ", \033[36m%s\033[0m" "${target}"
46+
fi
47+
done
48+
printf "\n\n"
4949
printf "Quick start commands:\n"
5050
for target in "${targets[@]}"; do
5151
printf " • \033[42;30mdocker compose --profile %s up -d\033[0m - Start %s tutorial\n" "${target}" "${target}"

0 commit comments

Comments
 (0)