What method should I use to write error messages to ‘stderr’ using ‘printf’ in a bash script?

First, yes, 1>&2 is the right thing to do. Second, the reason your 1>&2 2>errors.txt example doesn’t work is because of the details of exactly what redirection does. 1>&2 means “make filehandle 1 point to wherever filehandle 2 does currently” — i.e. stuff that would have been written to stdout now goes to stderr. 2>errors.txt …

Read more

UTF-8 output from PowerShell

Not an expert on encoding, but after reading these… http://blogs.msdn.com/b/powershell/archive/2006/12/11/outputencoding-to-the-rescue.aspx http://technet.microsoft.com/en-us/library/hh847796.aspx http://www.johndcook.com/blog/2008/08/25/powershell-output-redirection-unicode-or-ascii/ … it seems fairly clear that the $OutputEncoding variable only affects data piped to native applications. If sending to a file from withing PowerShell, the encoding can be controlled by the -encoding parameter on the out-file cmdlet e.g. write-output “hello” | out-file “enctest.txt” …

Read more