如何fswatch运行调用静态参数的程序? [英] How to run fswatch to call a program with static arguments?

查看:243
本文介绍了如何fswatch运行调用静态参数的程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用fswatch v0.0.2像这样(在这种情况下当一个文件改变运行Django的测试套装)

I used to use fswatch v0.0.2 like so (in this instance to run django test suit when a file changed)

$> fswatch。 蟒蛇manage.py测试

这工作得很好。

我要排除一些人导致测试运行超过每一次保存更多的文件(文本卓异被保存.tmp文件,我怀疑pyc文件也导致此)

I wanted to exclude some files that were causing the test to run more than once per save (Sublime text was saving a .tmp file, and I suspect .pyc files were also causing this)

所以我升级fswatch启用-e模式。

So I upgraded fswatch to enable the -e mode.

不过fs​​watch的方式发生了变化,这是造成我的麻烦 - 它现在接受管的说法,像这样:

However the way fswatch has changed which is causing me troubles - it now accepts a pipe argument like so:

$> fswatch。 | xargs的-n1程序

我无法弄清楚如何参数传递给程序在这里。例如这不起作用:

I can't figure out how to pass in arguments to the program here. e.g. this does not work:

$> fswatch。 | xargs的-n1蟒蛇manage.py测试

也没有这样的:

$> fswatch。 | xargs的-n1蟒蛇manage.py测试

我怎么能做到这一点没有在bash脚本封装了我的命令?

how can I do this without packaging up my command in a bash script?

推荐答案

fswatch 文档(无论是的 Texinfo手册的,或维基,或< A HREF =htt​​ps://github.com/emcrisostomo/fswatch> README )有这方面的例子是如何做的:

fswatch documentation (either the Texinfo manual, or the wiki, or README) have examples of how this is done:

$ fswatch [opts] -0 path ... | xargs -0 -n1 -I{} your full command goes here

陷阱:


  • -0 :用它来制作用换行确认路径间preTED正确

  • -o :用它来有 fswatch 泡沫中的所有事件集合到一个单一在该组仅打印的记录的数量。

  • -I {} :指定一个占位符,你错过了的xargs 间preting正确的伎俩在这些情况下,您的命令参数,你的的不希望记录(在这种情况下,因为 -o 使用,记录数在设置)传递到所执行的命令。

  • -0: use it to make sure paths with newlines are interpreted correctly.
  • -o: use it to have fswatch "bubble" all the events in the set into a single one printing only the number of records in the set.
  • -I{}: specifying a placeholder is the trick you missed for xargs interpreting correctly your command arguments in those cases where you do not want the record (in this case, since -o was used, the number of records in the set) to be passed down to the command being executed.

这篇关于如何fswatch运行调用静态参数的程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆