#!/usr/bin/env bash trap 'echo ""; kill -- -$$' INT # shellcheck source=../lib/load-configuration . "${0%/*}/../lib/load-configuration" runtail() { # tail will quit with follow=name when the file is deleted # thus no manual cleanup is needed tail --follow=name "$1" -n +1 2>/dev/null & } # Check if we're already building something, and if so, tail it before we wait for new files CURRENTLOG=$(printf '%s\n' "$work_dir/"tmp.build-packages.*/*.build-log | sort | tail -n 1) if [[ -f $CURRENTLOG ]]; then runtail "$CURRENTLOG" fi inotifywait -P -r -m "$work_dir" -e create --include '(\.build-log$)|(tmp\.build-packages\.[a-zA-Z0-9]+$)' --format '%w%f' -q | while read -r FILE; do if [[ -z $FILE || -d $FILE ]]; then continue fi runtail "$FILE" done