Skip to content

Commit

Permalink
fix: do not report errors for configuration file errors. (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexStocks authored Jan 13, 2025
2 parents 75b6d76 + 19af026 commit 81bef3a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/kiwi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,19 @@ bool KiwiDB::ParseArgs(int argc, char* argv[]) {
{"slaveof", required_argument, 0, 's'}, {"redis-compatible-mode", no_argument, 0, 'c'},
};
// kiwi [/path/to/kiwi.conf] [options]
if (options_.GetConfigName().empty() && argc > 1 && ::access(argv[1], R_OK) == 0) {
options_.SetConfigName(argv[1]);
argc = argc - 1;
argv = argv + 1;
if (argv == nullptr) {
return false;
}
if (options_.GetConfigName().empty() && argc > 1 && argv[1] != nullptr) {
struct stat st {};
if (stat(argv[1], &st) == 0 && S_ISREG(st.st_mode) && ::access(argv[1], R_OK) == 0) {
options_.SetConfigName(argv[1]);
argc = argc - 1;
argv = argv + 1;
} else {
std::cerr << "Configuration file [" << argv[1] << "]: " << strerror(errno) << "\n";
return false;
}
}
while (1) {
int this_option_optind = optind ? optind : 1;
Expand Down

0 comments on commit 81bef3a

Please sign in to comment.