-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--replace not working correctly with carriage returns on Windows #1500
Comments
I have a Windows machine; I'll try to find time this weekend to reproduce this. At the moment I'm at a Darwin machine, which behaves the way you've shown for Linux. |
It looks like
|
Yep,
And, indeed, if the space before the
|
How delightful. Thanks for tracking that down! |
Originally reported by @sergeevabc. Namely, the third command below produces unexpected output:
Using
xxd
confirms the extra space:I have not been able to reproduce this on Linux, even after inserting carriage returns. Below is copied from my comment in #416:
OK, so I'm assuming that
echo
on Windows probably emits a\r\n
as a new line, so let's try that:It's quite likely here that
(.*)
is matching the\r
so the replacement actually winds up beingArrowsmith\r 1931
. We can confirm this by looking at the hex output:You can see the
0d
in there, which corresponds to\r
. The strange output is actually what one expects:Because
\r
will move the cursor position back to the beginning of the line. Subsequent printing then overwrites characters that were already printed. e.g.,Adding the
--crlf
flag seemingly gets this right:Confirming with
xxd
that there is a single space:Notice that there is only one
0x20
byte there. So I can't reproduce your issue, at least on Linux, and in theory, the above should be equivalent to what you're doing.The text was updated successfully, but these errors were encountered: