From 42ab0172abc4363af13737e9ec4ec818c3f91fb8 Mon Sep 17 00:00:00 2001 From: Antonio Ognio Date: Fri, 19 Mar 2010 04:19:42 -0500 Subject: [PATCH] Solving issue #191 on Google Code: -v and --version should print the version of Redis --- redis.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/redis.c b/redis.c index 7c0a86956..ce4c50b69 100644 --- a/redis.c +++ b/redis.c @@ -1102,6 +1102,8 @@ static dictType keylistDictType = { dictListDestructor /* val destructor */ }; +static void version(); + /* ========================= Random utility functions ======================= */ /* Redis generally does not try to recover from out of memory conditions @@ -9122,11 +9124,19 @@ static void daemonize(void) { } } +static void version() { + printf("Redis server version %s\n", REDIS_VERSION); + exit(0); +} + int main(int argc, char **argv) { time_t start; initServerConfig(); if (argc == 2) { + if ((strcmp(argv[1], "-v") == 0) || (strcmp(argv[1], "--version") == 0)) { + version(); + } resetServerSaveParams(); loadServerConfig(argv[1]); } else if (argc > 2) {