如何在Windows 7中让GNU并行运行git bash? [英] How do I get GNU parallel to work on git bash in Windows 7?
问题描述
通过遵循 answer ,我能够在git-bash中全局安装GNU Parallel.
I was able to install GNU Parallel globally in git-bash by following this answer.
但是,在运行 parallel-tutorial ,
parallel -k echo ::: A B C > abc-file
我不断收到此错误
sh: -c: option requires an argument
sh: -c: option requires an argument
sh: -c: option requires an argument
.
.
.
我在做什么错了?
推荐答案
因此,根本原因是,如果命令行太长,CygWin(与GNU/Linux相反)不尊重STDERR的重定向.
So the root cause is that CygWin (contrary to GNU/Linux) does not respect redirection of STDERR if the command line is too long.
GNU Parallel通过二进制搜索长度来找出最长的命令行.这在CygWin上实在是太慢了,因为派生12 MB的命令行非常慢(并且12 MB似乎是我的CygWin版本的限制).
GNU Parallel figures out how long the longest possible command line is by doing a binary search for the length. This is awfully slow on CygWin because forking a 12 MB command line is horribly slow (and 12 MB seems to be the limit in my version of CygWin).
幸运的是,它只需要做一次.此后,GNU Parallel将行长度缓存在~/.parallel/tmp/HOSTNAME/linelen
中,这就是删除~/.parallel/tmp
时遇到此问题的原因.
Luckily it only has do be done once. After this GNU Parallel caches the line length in ~/.parallel/tmp/HOSTNAME/linelen
, and this is the reason why you experience the problem when ~/.parallel/tmp
is removed.
这也是使用其他版本似乎可行的原因:您只完成了一次运行,因此就缓存了长度.做到这一点的不是版本更改.
This is also the reason why it seemed that using a different version worked: You simply had a single run that finished, and thus cached the length. It was not the change of version that did this.
直到我设法让CygWin忽略sh: -c: option requires an argument
,您所需要做的就是忽略它并耐心等待.我可能还应该发出一个小警告,以使CygWin用户知道他们必须在第一时间耐心等待.
Until I manage to get CygWin to ignore the sh: -c: option requires an argument
all you need to do is to ignore it and be patient. I should probably also put in a small warning, to let CygWin users know that they have to be patient the first time.
运行:
parallel echo ::: 1
它将吐出sh: -c: option requires an argument
大约25次,但这很好.大约需要30秒才能完成.
It will spit out the sh: -c: option requires an argument
around 25 times, but that is fine. It will take around 30 seconds to complete.
此后,一切都应该很快,并且您应该不会看到错误.
After this everything should be fast(er) and you should not see the error.
它应该在GIT的最新版本中得到修复: https://savannah.gnu .org/git/?group = parallel
It should be fixed in the newest version in GIT: https://savannah.gnu.org/git/?group=parallel
这篇关于如何在Windows 7中让GNU并行运行git bash?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!