1

我有这个代码:

# Generate bash script
$bashScript = "#!/bin/bash`n";
$bashScript += [string]::Join("`n", $cmds)

[System.IO.File]::WriteAllLines($location.ToString() + ".\build.sh", $bashScript);

问题是我总是CRLF在文件末尾得到字符!

#!/bin/bash [LF]
tsc ... [LF]
java ... [LF]
java ... [CR][LF]

除了最后更换,我能做些什么CRLF吗?

4

1 回答 1

4

我不会说 Powershell,但在我看来,你已经告诉它写一个大行 ( $bash_script),最后有一个换行符 (CRLF)。WriteAllText改为打电话。确保文件末尾有一个 LF。

$bashScript = "#!/bin/bash`n" + [string]::Join("`n", $cmds) + "`n"
[System.IO.File]::WriteAllText($location.ToString() + ".\build.sh", $bashScript);
于 2012-10-30T09:53:16.043 回答