2017-10-03 15 views
3

는 다음 PowerShell에서 코드를 생각해 보자.

The same code executed on AppVeyor outputs just a single number

:

10 

즉은, PowerShell을 시스템에서 여기 문자열에 사용하는 문자 사이에 변화가있을 것으로 보인다. 나는 소스가 [System.Environment]::newline에 대한 [System.Environment]::newline하지만 the same environment AppVeyor environment that output the single character in the here string, output

13 
10 

을 것으로 예상. [System.Environment]::newline은 여기 문자열에서 개행 문자의 소스가 아닌 것 같습니다.

+0

. GetEnumerator() | % {[int]'$ _} "|"{@} " sc Test1.ps1; "@" "'''''n'n'"@. GetEnumerator() | % {[int]'$ _} "| sc Test2.ps1; . \ Test1.ps1 <#10#>; . \ Test2.ps1 <#13, 10#>'' – PetSerAl

+0

감사합니다. @PetSerAl. [ "AppVeyor가 Windows에서 LF (\ n) 결말을 가진 파일을 체크 아웃하고 있습니다]"(http://help.appveyor.com/discussions/problems/1119-allow-changing-git-autocrlf-setting) 기본적으로 . – alx9r

답변

1

PowerShell 스크립트는 기본적으로 문자열입니다. 그리고 줄 분리에 이미 "`n" 또는 "`r`n"을 사용해야합니다. 따라서 PowerShell 문자열 리터럴이 여러 줄을 넘는 경우 PowerShell 파서는 문자열 리터럴 값의 일부로이 문자열 리터럴 내부에서 사용 된 줄 구분 기호를 유지합니다.

예를이를 위해 :

"'a`nb`r`nc'.GetEnumerator() | %{[int]`$_}" | Set-Content .\Test.ps1 
.\Test.ps1 

인쇄됩니다 : 그것은 단지 당신의 문자열에 어떤했다

97 
10 
98 
13 
10 
99