【发布时间】:2018-03-14 22:26:54
【问题描述】:
考虑以下 PowerShell 代码:
@"
"@.GetEnumerator() | %{[int]$_}
在我的电脑上输出
13
10
它们分别是用于回车和换行的 ASCII 控制字符的十进制表示。
The same code executed on AppVeyor outputs just a single number:
10
换句话说,PowerShell 在此处字符串中使用的字符之间似乎存在差异。我预计来源是[System.Environment]::newline 但the same environment AppVeyor environment that output the single character in the here string, output
13
10
为[System.Environment]::newline。 [System.Environment]::newline 似乎不是此处字符串中换行符的来源。
【问题讨论】:
-
它只占用了字符串中的任何内容。
"@`"`n`n`n`"@.GetEnumerator() | %{[int]`$_}" | sc Test1.ps1; "@`"`n`r`n`n`"@.GetEnumerator() | %{[int]`$_}" | sc Test2.ps1; .\Test1.ps1 <#10#>; .\Test2.ps1 <#13, 10#> -
谢谢@PetSerAl。默认情况下,它看起来像 "AppVeyor is checking out files with LF (\n) endings on Windows"。
标签: powershell newline appveyor herestring