mirror of https://mirror.osredm.com/root/redis.git
Use exit code 1 on error in redis-cli (#10468)
On error, redis-cli was returning `REDIS_ERR` on some cases by mistake. `REDIS_ERR` is `-1` which becomes `255` as exit code. This commit changes it and returns `1` on errors to be consistent.
This commit is contained in:
parent
6075f50663
commit
7da1cc3e90
|
@ -2758,7 +2758,7 @@ static int noninteractive(int argc, char **argv) {
|
||||||
|
|
||||||
retval = issueCommand(argc, sds_args);
|
retval = issueCommand(argc, sds_args);
|
||||||
sdsfreesplitres(sds_args, argc);
|
sdsfreesplitres(sds_args, argc);
|
||||||
return retval;
|
return retval == REDIS_OK ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
|
@ -2845,7 +2845,7 @@ static int evalMode(int argc, char **argv) {
|
||||||
break; /* Return to the caller. */
|
break; /* Return to the caller. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retval;
|
return retval == REDIS_OK ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
|
@ -9064,11 +9064,7 @@ int main(int argc, char **argv) {
|
||||||
if (cliConnect(0) != REDIS_OK) exit(1);
|
if (cliConnect(0) != REDIS_OK) exit(1);
|
||||||
return evalMode(argc,argv);
|
return evalMode(argc,argv);
|
||||||
} else {
|
} else {
|
||||||
int connected = (cliConnect(CC_QUIET) == REDIS_OK);
|
cliConnect(CC_QUIET);
|
||||||
/* Try to serve command even we are not connected. e.g. help command */
|
return noninteractive(argc,argv);
|
||||||
int retval = noninteractive(argc,argv);
|
|
||||||
/* If failed to connect, exit with "1" for backward compatibility */
|
|
||||||
if (retval != REDIS_OK && !connected) exit(1);
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue