skriptit/odotus-skriptit/bin/odota-kunnes-voi.sh
Juhani Krekelä 7da4f9a18a odotus-skriptit
2026-09-17 22:09:33 +03:00

27 lines
429 B
Shell
Executable file

#!/bin/sh
set -e
lukko="${1:?vaaditaan lukon nimi}"
shift
case "$lukko" in
.|..|*/*)
printf '%s: virhe: lukon täytyy olla tiedostonimi: %s\n' "$(basename "$0")" "$lukko" >&2
exit 1
;;
esac
kansio="$HOME/tmp/lukot/$lukko"
lukkotiedostot() {
find "$kansio" -mindepth 1
}
if [ -d "$kansio" ]
then
while [ -n "$(lukkotiedostot)" ]
do
lukkotiedostot | entr true 2>/dev/null || true
done
rmdir "$kansio" || true
fi