Open segevfiner opened 6 years ago
The "\r\n" is from the searched file that has CRLF line endings. The matched line is just printed directly to the screen including the "\r\n". I think this is wrong even on Unix platforms when you are writing to a tty... Although you are a lot less likely to encounter CRLF there.
One way would be to avoid printing "\r\n", converting that to "\n" on output. It is also possible on Windows to disable "\r\n" using _setmode
, but I'm not sure whether that's a good idea. We will get files with NL line endings like that, and I'm not sure if the Windows console requires "\r\n" or can handle just "\n".
P.S. The following always adds -O2 if there is no "-O" flag, that's kinda surprising for those expecting standard autoconf behavior. The comment should probably say that you need to add "-O0" to disable optimizations for debugging.
Hi, Try using this build of ag for Windows, which does not have this problem: https://github.com/JFLarvoire/the_silver_searcher/releases Jean-François
I have loved 'ag' on linux & mac. When I tried to start using it in a Windows dev environment I am building up... I want to install Ag with chocolatey.
Unfortunately, the version installed by Chocolatey is still showing the same output problem today in April of 2021.
C:\Users\username>ag --version
ag version 2.1.0
Features:
+jit +lzma +zlib
C:\Users\username>which ag
C:\ProgramData\chocolatey\bin\ag.exe
C:\Users\username>
I have not setup a WIndows dev box in a long while, and I was excited to learn that all my favorite dev tools are available in Chcolatey :D
However, the "current" Chocolatey delivered 'Ag' has got this problem and it is killing my VIM user experience on Windows because I use 'Ag' as my search tool within Vim.
In my case, Vim is not completely choking on the extra '0d' characters, instead.. the 'quickfix' window is loaded with results that have the '^M' character at the end of each line -- this is damaging the ability to parse line/column numbers out of the output for jumping around.
Hi Jason,
The ag version in Chocolatey is just the Linux version recompiled for Windows, and it does not behave well in Windows. (To say the least.) I recommend that you install my build of ag optimized for Windows using the Microsoft winget package manager:
1) If you don't already have it, get the latest winget from https://github.com/microsoft/winget-cli/releases
2) Run winget install "The Silver Searcher"
Jean-François
I'm using this build ag-2018-08-08_2.2.0-2-gbd82cd3-x64.zip.
This is probably due to using
\r\n
for a line ending. Windows translates\n
to\r\n
on output to stdio in text mode. Just use\n
when using stdio on Windows. (Powershell also translates the lone\r
to\r\n
so there you get doubled newlines).