Streaming "get" prints logging info to STDOUT instead of STDERR
In version >1.6, when you using the streaming get functionality (s3cmd get s3://BUCKETNAME -), there is some logging information that is printed to STDOUT instead of STDERR that prevents me from piping the data to other tools (for example, piping json data to jq).
$ s3cmd get s3://rishi-test-s3cmd/test.txt - 2> /dev/null
download: 's3://rishi-test-s3cmd/test.txt' -> '-' [1 of 1]
download: 's3://rishi-test-s3cmd/test.txt' -> '-' [1 of 1]
Hello, World
My name is Rishi
30 of 30 100% in 0s 165.59 B/s done
Can this be altered so that logging info is printed to STDERR?
I looked at this a bit last night. First, replacing stdout with a new file descriptor to /dev/null, when --quiet is sent, is the wrong thing to do. This is addressed in new branch bug/stdout for consideration: https://github.com/s3tools/s3cmd/tree/bug/stdout
Now when using get --quiet, all output() messages are not emitted. There is still one progress message getting printed which I haven't figured out why.
We've got a couple choices:
- Omit printing these status messages to stdout when destination for a file is stdout (effectively what --progress/no-progress does)
- Print these status messages to stderr instead
With the above branch, and --quiet --no-progress, I get the desired result - no progress message is printed, and the stdout contains the file just downloaded. I'd prefer for that last status message, with 'done' on the end, to automatically not be printed, just like the other status messages aren't printed. Need to see why that's happening...
Fixed by #1315.