Improved jargroup_list loop code to better handle spaces.

This commit is contained in:
Marcus Whybrow 2012-06-12 02:14:15 +01:00
parent a4fb3800e8
commit 17221b3aa4

View File

@ -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