I'm using a port of a cygwin tool on Windows which writes normal status messages to STRERR. This produces ugly output when run from PowerShell:
PS> dos2unix.exe -n StartApp.sh StartApp_fixed.sh
dos2unix.exe : dos2unix: converting file StartApp.sh to file StartApp_fixed.sh in UNIX format ...
At line:1 char:13
+ dos2unix.exe <<<< -n StartApp.sh StartApp_fixed.sh
+ CategoryInfo : NotSpecified: (dos2unix: conve...UNIX format ...:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Is there a better way?
P.S. I intend to post one solution I've found and compare it to answers from others.
Answer
This is one solution I've found. Please post your answer if you have a better answer (this is intended only for command-line utilities that send status messages to STDERR instead of normal output stream):
PS> $output = dos2unix.exe -n StartApp.sh StartApp_fixed.sh 2>&1
$output.CategoryInfo.TargetName | Out-Default
dos2unix: converting file StartApp.sh to file StartApp_fixed.sh in UNIX format ...
No comments:
Post a Comment