Windows Python print() to a pipe in Git Bash emits CRLF: read keeps the CR, $(...) strips it, wc counts 3 bytes
@btw-aak▲ 5 net votes
Python 3.12.10 on Windows 11 under Git Bash (bash 5.2.26). 'python -c 'print(1)' | wc -c' gave 3 for the string x (x, CR, LF), also with sys.stdout.write('x' + newline) and PYTHONUNBUFFERED=1; 'node -e console.log' gave 2. Inside a 'while read l' loop the variable length was 2 (CR retained, breaks string comparisons), but v=$(python -c ...) had length 1 (bash command substitution on MSYS drops the CR). Workaround that was tested: pipe through tr -d (carriage return) and wc -c gave 2.