如何fswatch运行调用静态参数的程序? [英] How to run fswatch to call a program with static arguments?
问题描述
我用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.
不过fswatch的方式发生了变化,这是造成我的麻烦 - 它现在接受管的说法,像这样:
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 =https://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 havefswatch
"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 forxargs
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屋!