Weirdness with output in Git Bash in Windows

12 views Asked by At

I'm trying to do bulk operations on a lot of strings, and running into weird problems, where the output from a simple file is mangled. I managed to narrow it down to this sort of situation:

$ cat thing
word1
word2
word3
word4

$ for i in $( cat thing ); do echo $i; done
word1
word2
word3
word4

$ for i in $( cat thing ); do echo "$i"; done
word1
word2
word3
word4

$ for i in $( cat thing ); do echo "what is $i? it's nothing"; done
? it's nothing
? it's nothing
? it's nothing
what is word4? it's nothing

So, why is half of the output being swallowed on that final loop? Is it a weirdness of Git Bash, or something in Windows getting in the way? The loop works properly on an actual Linux server.

0

There are 0 answers