I came across some strange behavior when resolving a package, and redirecting the output into a file.
So for instance, if I resolve a package like so:
$ swift package resolve > resolve.log
I would expect that all the output from this command would end up in the file resolve.log, and I would not see any output in the terminal. However this is not actually what happens. Instead, almost all the output goes to resolve.log, except for one line:
$ swift package resolve > resolve.log
Completed resolution in 4.95s
Out of curiosity, I searched the package manager repo to see if I could find where this was output from, and with a cursory review I wasn't able to find a string similar to this output from anywhere.
So where is this string coming from, and how is it making it to my stdout instead of the redirected destination?
And, it's really a function of the shell. The ">" in the command line invocation is actually a directive to the shell to re-direct stdout. The swift compiler itself is not doing anything other than writing to stdout and stderr.
Yeah I am aware of the function of the redirect operator. My confusion/ignorance was only that I didn't expect such a message to be writing to stderr, so it seemed like the compiler was somehow "overriding" the redirect, which is why I was asking about the behavior of the compiler/package manager since it seemed to be doing the impossible.
It does seem odd to me that this message is directed to a different place than the others. Everything else printed by that command is intended for humans too.
Out of curiosity, I searched the package manager repo to see if I could find where this was output from, and with a cursory review I wasn't able to find a string similar to this output from anywhere.