Using zsh, I was trying to break the while loop after file move event, but break happens only after the second one. This only occurs when I try to execute script
#!/bin/zsh
while read changed; do
echo $changed
if [ $changed = MOVE_SELF ]; then
echo "File was moved."
break
fi
done < <(inotifywait -m -e move_self --format "%e" $1)
echo "HI THERE"
in zsh. However, if I try the same code with #!/bin/bash it works as expected (loop breaks after the first event).
Behavior in zsh and bash is different. One of the possible solutions is to use
&for command in process substitution. Diff:Looks like zsh is blocking waits for process substitution to execute again. Output of
zsh -xafter first execution ofinotitywaitwithout&: