Skip to content

Commit

Permalink
refactor(find-in-jars): add IFS= for read, more robust 💪
Browse files Browse the repository at this point in the history
file paths may contain leading spaces
  • Loading branch information
oldratlee committed Mar 21, 2024
1 parent 0b4180c commit 0ca9fed
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bin/find-in-jars
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit 0ca9fed

Please sign in to comment.