PowerShell 管道会自动加换行符

字符编码

数据经过管道 | 这么一传,就多了 \r\n 字符(在 Windows,平台相关)

PowerShell
$ (Write-Output "").Length
0
 
$ Write-Output "" | hexyl.exe --border none
 00000000  0d 0a
 
$ @"
> uname
> uname
> "@ | wsl
Linux
-bash: 行 2: $'uname\r': 未找到命令

好在只是出现在 PowerShell 中,我可以用 Announcing Built-in Core Utilities for Windows | Task TaskFile 绕过这个限制。