if [ -d "$dir/.index" -a \! -f "$meta" ] && LOCK "$meta"; then
touch "$meta" # preliminary touch to prevent concurrent generators
find "$dir" -type f -mindepth 1 -maxdepth 1 \
- | grep -E "$file_pattern" \
+ | grep -aE "$file_pattern" \
- | while v="$(line)"; do
+ | while read -r v; do
meta_line "$v"
done >"$meta"
elif [ -d "$dir/.index" -a "$dir" -nt "$meta" ] && LOCK "$meta"; then
touch "$meta"
find "$dir" -type f -mindepth 1 -maxdepth 1 \
- | grep -E "$file_pattern" \
+ | grep -aE "$file_pattern" \
- | while v="$(line)"; do
+ | while read -r v; do
if [ "$v" -nt "$meta" ]; then
grep -qF " $(meta_name "$v")" "$meta" \
|| meta_line "$v"