I am trying to capture the output of running an external command as a string, but the result returned by Powershell is always an array of strings. It is my understanding that Powershell splits the output on newlines (Windows or Unix line endings) and stores the result in an array, but I would like these newlines to be preserved since this is for an svn pre-commit hook script to detect if a committed file has mixed line endings.
$output = svnlook cat -t $transId -r $repos $filename
At this point line endings have been stripped, and $output
is an array of strings, one per line of output.
Redirecting to a file does not seem to work since this normalizes the line endings. How do you tell Powershell to not split a command's output?
Thanks!
Pipe the command output into the Out-String
cmdlet:
$output = svnlook cat -t $transId -r $repos $filename | Out-String
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With