且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Bash脚本-fswatch触发bash函数

更新时间:2023-12-05 20:01:34

BUT然后它在循环中运行....,我也遇到了这个问题,因为在您的之后./automater.sh 执行,目录中有一些新文件更改,您可以使用exclude选项忽略这些文件,在我的情况下,例如:

BUT then it runs in a loop...., I also hit this, because after your ./automater.sh execution, there are some new file changes in your directory, you can use exclude option to ignore these files, in my case like:

fswatch -l 5 -o -e.*" -i"\\.py $".|阅读时\做 \单元测试||真的完毕

  • -l,每5秒钟检查一次文件更改
  • -o,将所有更改批处理为一个数字
  • -e,排除文件,.*"表示首先排除所有文件
  • -i,包含文件,"\.py $"表示包含所有.py文件
  • ||正确,当您在shell脚本中使用时,似乎需要使您的命令返回true,我使用此技巧来仅第一次正确地解决 问题
  • -l, check file changes every 5 seconds
  • -o, to batch all changes to one number
  • -e, exclude file, ".*" means exclude all files firstly
  • -i, include file, "\.py$" means include all .py files
  • || true, seems need to make your command return true when your use in shell script, I use this trick to solve only first time correctly issue

还可以运行 fswatch.src 和您在单独的终端窗口中的运行"命令,以查找新更改.

Also you can run fswatch . src and your 'run' command in separate terminal window to find what are the newly changes are.