我正在尝试运行以下功能
foo () {
sleep 1
echo "outside inotify"
(inotifywait . -e create |
while read path action file; do
echo "test"
sleep 1
done)
echo "end"
}
直到 inotifywait 它运行正常;我懂了:
>> foo
outside inotify
Setting up watches.
Watches established.
但是,一旦我创建了一个文件,我就会得到
>>> fooo
outside inotify
Setting up watches.
Watches established.
test
foo:6: command not found: sleep
end
知道为什么吗?另外,我是否需要在 inotifywait 周围生成子进程()?有什么好处?
谢谢你。
编辑 我意识到我在 zsh 上运行