From 02c6775472590d58a6019fea5f6fb3c98d14be86 Mon Sep 17 00:00:00 2001 From: Jerry Lee Date: Sat, 16 Mar 2024 13:13:18 +0800 Subject: [PATCH] refactor(`find-in-jars`): add `IFS=` for `read`, more robust file paths may contain leading spaces --- bin/find-in-jars | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/find-in-jars b/bin/find-in-jars index fd00d3fd..eda51301 100755 --- a/bin/find-in-jars +++ b/bin/find-in-jars @@ -378,7 +378,7 @@ __outputResultOfJarFile() { # Prevent grep from exiting in case of no match # https://unix.stackexchange.com/questions/330660 grep "${grep_opt_args[@]}" || true - } | while read -r file; do + } | while IFS= read -r file; do clearResponsiveMessage if [ -t 1 ]; then printf "$JAR_COLOR%s$SEP_COLOR%s$COLOR_RESET%s\n" "$jar_file" "$separator" "$file" @@ -394,7 +394,7 @@ findInJarFiles() { local counter=1 total_jar_count jar_file read -r total_jar_count - while read -r jar_file; do + while IFS= read -r jar_file; do printResponsiveMessage "finding in jar($((counter++))/$total_jar_count): $jar_file" listZipEntries "$jar_file" | __outputResultOfJarFile "$jar_file" done