Skip to content

Commit a719903

Browse files
committed
Fix bitcoin-cli exit status code
1 parent 34b9ea7 commit a719903

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/bitcoin-cli.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "util.h"
77
#include "init.h"
88
#include "rpcclient.h"
9+
#include "rpcprotocol.h"
910
#include "ui_interface.h" /* for _(...) */
1011
#include "chainparams.h"
1112

@@ -55,23 +56,25 @@ int main(int argc, char* argv[])
5556
try
5657
{
5758
if(!AppInitRPC(argc, argv))
58-
return 1;
59+
return abs(RPC_MISC_ERROR);
5960
}
6061
catch (std::exception& e) {
6162
PrintExceptionContinue(&e, "AppInitRPC()");
63+
return abs(RPC_MISC_ERROR);
6264
} catch (...) {
6365
PrintExceptionContinue(NULL, "AppInitRPC()");
66+
return abs(RPC_MISC_ERROR);
6467
}
6568

69+
int ret = abs(RPC_MISC_ERROR);
6670
try
6771
{
68-
if(!CommandLineRPC(argc, argv))
69-
return 1;
72+
ret = CommandLineRPC(argc, argv);
7073
}
7174
catch (std::exception& e) {
7275
PrintExceptionContinue(&e, "CommandLineRPC()");
7376
} catch (...) {
7477
PrintExceptionContinue(NULL, "CommandLineRPC()");
7578
}
76-
return 0;
79+
return ret;
7780
}

src/rpcclient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ int CommandLineRPC(int argc, char *argv[])
233233
}
234234
catch (std::exception& e) {
235235
strPrint = string("error: ") + e.what();
236-
nRet = 87;
236+
nRet = abs(RPC_MISC_ERROR);
237237
}
238238
catch (...) {
239239
PrintException(NULL, "CommandLineRPC()");

0 commit comments

Comments
 (0)