<p>The <code>grep</code> binary shipped with Git for Windows is from MSYS2 and hence it requires the MSYS2 libraries:</p>

<div class="highlight highlight-source-shell"><pre>$ ls -lh /c/tmp/git-grep/
total 4.9M
-rwxr-xr-x 1 enrico None 210K Mar 11  2016 grep.exe
-rwxr-xr-x 1 enrico None 3.3M Sep  9 09:38 msys-2.0.dll
-rwxr-xr-x 1 enrico None 108K Apr  1  2016 msys-gcc_s-1.dll
-rwxr-xr-x 1 enrico None 912K Nov  4  2014 msys-iconv-2.dll
-rwxr-xr-x 1 enrico None  44K Mar  2  2016 msys-intl-8.dll
-rwxr-xr-x 1 enrico None 282K Jan 20  2016 msys-pcre-1.dll</pre></div>

<p>These are the required libraries for grep.exe and as you can see, it would require about 5 MB more space. Compared to the overall size of the Windows binaries and their dependencies, this is not that much. I'm not yet completely sure why the MSYS2 grep works that differently, maybe because it uses the MSYS2 path manipulation magic behind the scenes.</p>

<p>I tried to self-compile grep using the patch which is used by MSYS2 (<a href="https://github.com/Alexpux/MSYS2-packages/blob/master/grep/grep-2.23-msys2.patch">https://github.com/Alexpux/MSYS2-packages/blob/master/grep/grep-2.23-msys2.patch</a>) which "only" modifies the build environment but the resulting binary has the recursion problem again.<br>
So I assume there is something in the MSYS2 libraries which changes the behaviour of handling paths and their encodings.</p>

<p>After all the troubles we had with <code>grep</code> on Windows so far, I'm actually tempted to bundle the MSYS2 binary along with the necessary libraries. At least this would safe us from the ugly patching in <a href="https://github.com/geany/geany/pull/1237" class="issue-link js-issue-link" data-url="https://github.com/geany/geany/issues/1237" data-id="177679109" data-error-text="Failed to load issue title" data-permission-text="Issue title is private">#1237</a>.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/issues/1260#issuecomment-254053387">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJ6BEebJXE68818tY0VvATwEVn5ldks5q0kICgaJpZM4KRshZ">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJ0S1zxI5KzrvTj4igLGUD1b2WX2hks5q0kICgaJpZM4KRshZ.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/geany/geany/issues/1260#issuecomment-254053387"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany","title":"geany/geany","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany"}},"updates":{"snippets":[{"icon":"PERSON","message":"@eht16 in #1260: The `grep` binary shipped with Git for Windows is from MSYS2 and hence it requires the MSYS2 libraries:\r\n```sh\r\n$ ls -lh /c/tmp/git-grep/\r\ntotal 4.9M\r\n-rwxr-xr-x 1 enrico None 210K Mar 11  2016 grep.exe\r\n-rwxr-xr-x 1 enrico None 3.3M Sep  9 09:38 msys-2.0.dll\r\n-rwxr-xr-x 1 enrico None 108K Apr  1  2016 msys-gcc_s-1.dll\r\n-rwxr-xr-x 1 enrico None 912K Nov  4  2014 msys-iconv-2.dll\r\n-rwxr-xr-x 1 enrico None  44K Mar  2  2016 msys-intl-8.dll\r\n-rwxr-xr-x 1 enrico None 282K Jan 20  2016 msys-pcre-1.dll\r\n```\r\nThese are the required libraries for grep.exe and as you can see, it would require about 5 MB more space. Compared to the overall size of the Windows binaries and their dependencies, this is not that much. I'm not yet completely sure why the MSYS2 grep works that differently, maybe because it uses the MSYS2 path manipulation magic behind the scenes.\r\n\r\nI tried to self-compile grep using the patch which is used by MSYS2 (https://github.com/Alexpux/MSYS2-packages/blob/master/grep/grep-2.23-msys2.patch) which \"only\" modifies the build environment but the resulting binary has the recursion problem again.\r\nSo I assume there is something in the MSYS2 libraries which changes the behaviour of handling paths and their encodings.\r\n\r\nAfter all the troubles we had with `grep` on Windows so far, I'm actually tempted to bundle the MSYS2 binary along with the necessary libraries. At least this would safe us from the ugly patching in #1237."}],"action":{"name":"View Issue","url":"https://github.com/geany/geany/issues/1260#issuecomment-254053387"}}}</script>