Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

waffles: rewrite main file finding loop and print loop

  • Loading branch information...
commit 7598cbaa2f8832a483facb3aa9c6ef212a6a756c 1 parent 4b7126f
@falconindy authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 waffles
View
12 waffles
@@ -1,6 +1,11 @@
#!/bin/bash
-IFS=$'\n' read -r -d $'\0' -a waffles < <(find /mnt/Gluttony/waffles -type f -links 1 \( -iname \*.flac -o -iname \*.mp3 \) -exec dirname {} \; | uniq)
+WAFFLE_DIR="/mnt/Gluttony/waffles"
+
+declare -a waffles
+while read -d $'\0' waffle; do
+ waffles+=("$waffle")
+done < <(find "$WAFFLE_DIR" -links 1 -iregex '.*\.\(flac\|mp3\)' -printf '%h\0' | uniq -z)
if [[ -n $1 ]]; then
items=("${waffles[@]:$1:${2:-1}}")
@@ -8,6 +13,5 @@ else
items=("${waffles[@]}")
fi
-for item in "${items[@]}"; do
- echo $item
-done
+(( ${#items[@]} )) && printf "%q\n" "${items[@]}"
+
Please sign in to comment.
Something went wrong with that request. Please try again.