kadwanev / retry

The command line retry tool
254 stars 28 forks source link

Default writes to stderr #5

Closed joscha closed 8 years ago

joscha commented 8 years ago

retry writes all messages to stderr by default. Shouldn't only be the actual failure (e.g. retries exhausted) and the failed command output be written to stderr? The rest could technically just go towards stdout, that would make it easier to pick out the actual failure in a CI result. I'd be happy to provide an according PR.

kadwanev commented 8 years ago

My thinking is that each failure of the retry command is a failure that deserves messaging to stderr and would allow anything parsing the result to identify the output from the last run rather than every attempt.

I've thought about things like this a little bit but don't have enough of a use case to justify it. Do you have something you're trying to accomplish that would benefit from the change? Could you describe it?

joscha commented 8 years ago

I completely agree with the above, however the first attempt, should it be successful, should not be written to stderr, but stdout in my eyes. But I guess that would require buffering the output, which is not a sane thing to do without knowing how much there is. The reason I opened this was, because I used it in a CI setting and could see the first attempt in stderr. Will close this.

kadwanev commented 8 years ago

If the first attempt is successful, retry doesn't write anything. All output comes from the process, be it stdout or stderr. Check this out:

$ retry -e ruby -e 'STDERR.puts "howdy"' > /dev/null
howdy
$
$ retry -e ruby -e 'STDOUT.puts "howdy"' > /dev/null
$
$ retry -e ruby -e 'STDERR.puts "howdy"; exit 2' > /dev/null
howdy
Before retry #1: sleeping 0.3 seconds
howdy
Before retry #2: sleeping 0.6 seconds
howdy
Before retry #3: sleeping 1.2 seconds
...
$ retry -e ruby -e 'STDOUT.puts "howdy"; exit 2' > /dev/null
Before retry #1: sleeping 0.3 seconds
Before retry #2: sleeping 0.6 seconds
Before retry #3: sleeping 1.2 seconds
Before retry #4: sleeping 2.4 seconds
...
kadwanev commented 8 years ago

Also, I do see a case where you'd want to retry something that needed stdin piped input. I figure having a buffer size parameter can work and it would obviously fail if stdin didn't fit in the buffer. Issue #3 if you want to give it a shot. :)