Fix bitcoin-cli exit status code#3736
Conversation
There was a problem hiding this comment.
Maybe we should also return 1 in the case of an exception (so don't default ret to 0)
There was a problem hiding this comment.
Yes, I was also thinking about that, but I was not sure.
So I will update the pull then.
|
update:
|
|
ACK on code changes (didn't test yet) |
ACK |
|
Nothing new in this pull, but I wonder why this returns 87. IMO it should simply be 1 (=-RPC_MISC_ERROR): https://github.com/bitcoin/bitcoin/blob/master/src/rpcclient.cpp#L236 |
|
cozz: Can you refactor the 1 and 0 into RET_SUCCESS and RET_FAIL variables? |
|
RET_SUCCESS / RET_FAIL is not any POSIX or C standard is it? We're also not using them in any other place at the moment. If you want to use constants, using abs(constant_from_RPCErrorCode) from src/rpcprotocol.h would make more sense as that's where the error code that are returned by CommandLineRPC (and thus by the -cli now) come from. |
|
update:
We might break a script by changing this error code, but should be very unlikely. |
|
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/875acdf78693332a1500557ee728a4341dbe2d4c for binaries and test log. |
There was a problem hiding this comment.
Execution will never get here. PrintException does a re-throw unlike PrintExceptionContinue. I'd never code it that way and would put the throw in the catch() statement itself for clarity, but this is part of our legacy.
There was a problem hiding this comment.
I see. Removing this then.
|
ACK on the abs(RPC_MISC_ERROR) change. |
a719903 Fix bitcoin-cli exit status code (Cozz Lovan)
bitcoin-cli returns 1 on success and 0 on error. By convention it should be the other way round.
It is not possible to distinguish between different error codes, all errors return 0.
But for an AppInitRPC error, we would return 1...