![]() temp.ps1 Remove-Item temp.ps1Ģ- When I run a ps1 file with an LF line ending, can it call another ps1 file with mixed CRLF line endings? # Execute a script with mixed newline formats. PS> "one`ntwo`r`nthree" > temp.txt (Get-Content temp.txt).Count Remove-Item temp.txt The following examples demonstrate this - they work the same on all supported platforms ( "`n" creates a LF-only newline, "`r`n" a CRLF newline): # Read a file with mixed newline formats. While not documented as such, PowerShell has always worked this way, and, given its commitment to backward compatibility, this won't change (which in this case is definitely a blessing, given that PowerShell (Core) is now cross-platform and must be able to handle files with LF-only newlines on Unix-like platforms). Yes - both PowerShell editions - the legacy, ships-with-Windows, Windows-only Windows PowerShell edition (whose latest and final version is v5.1), as well as the cross-platform, install-on-demand, PowerShell (Core) edition (v6+) - treat CRLF and LF newlines interchangeably - both with respect to reading source code and reading files - even if the two newline formats are mixed in a single file. ![]() The conceptual about_Special_Characters help topic discusses `r (CR) and `n (LF) separately, but not explicitly in terms of their potential function as newline characters / sequences (line breaks the topic uses the term "new line" to refer to a LF character, specifically).I am looking for documentation that explains the PowerShell core requirement for LF vs CRLF line ending in Linux environments.Īs of this writing, there appears to be no such documentation: ![]() Let me complement it by answering your questions one by one: ![]() Stackprotector's community wiki answer, inspired by a link provided by Ben Voigt, provides the gist of an answer to your questions. ![]()
0 Comments
Leave a Reply. |