From 17221b3aa4a3d39e3cb5a2aa4bba0e5252072cd1 Mon Sep 17 00:00:00 2001 From: Marcus Whybrow Date: Tue, 12 Jun 2012 02:14:15 +0100 Subject: [PATCH] Improved jargroup_list loop code to better handle spaces. --- init/msm | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/init/msm b/init/msm index 6b9becc..87188c0 100755 --- a/init/msm +++ b/init/msm @@ -520,14 +520,19 @@ server_set_active() { # Lists the jar files grouped by jar groups. jargroup_list() { - for group in $(ls -1 "$JAR_STORAGE_PATH"); do - echo "${group}:" - for jar in $(ls -1r "$JAR_STORAGE_PATH/$group"); do - if [[ "$jar" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}- ]]; then - echo " $jar" + local jargroup_name + local jar_name + + while IFS= read -r -d $'\0' jargroup_path; do + jargroup_name="$(basename "${jargroup_path}")" + echo "$jargroup_name" + while IFS= read -r -d $'\0' jar_path; do + jar_name="$(basename "${jar_path}")" + if [[ "$jar_name" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}- ]]; then + echo " $jar_name" fi - done - done + done < <(find "${JAR_STORAGE_PATH}/${jargroup_name}" -mindepth 1 -maxdepth 1 -type f -print0) + done < <(find "${JAR_STORAGE_PATH}" -mindepth 1 -maxdepth 1 -type d -print0) } # Creates a new jargroup