【发布时间】:2022-12-01 15:38:24
【问题描述】:
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).
【问题讨论】:
-
I'd suggest tagging this only zsh and not bash; the bash behavior is well-understood, so you need only zsh experts looking at this question, not bash experts.
-
@rowboat, Thank you.
<(... &)works fine. Would you mind writing an answer? I need-m, example above is simplified. -
请问为什么进程替换有两个
<标志,即done < <(inotify ...)?我本以为只有一个。 -
@user1934428,看看这个:stackoverflow.com/a/28927847/15036204