Permalink
Browse files

Error out if the command line option for a config file fails.

If you are going to specify a config file, it better be there.

Thanks to gregor herrmann for the idea for this.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information...
gregkh committed Apr 23, 2013
1 parent 0828aeb commit 23b14831fc3d62617d93990dd9789de520b10eff
Showing with 7 additions and 0 deletions.
  1. +7 −0 bti.c
View
7 bti.c
@@ -1254,6 +1254,7 @@ int main(int argc, char *argv[], char *envp[])
{ "retweet", 1, NULL, 'w' },
{ }
};
+ struct stat s;
struct session *session;
pid_t child;
char *tweet;
@@ -1411,6 +1412,12 @@ int main(int argc, char *argv[], char *envp[])
free(session->configfile);
session->configfile = strdup(optarg);
dbg("configfile = %s\n", session->configfile);
+ if (stat(session->configfile, &s) == -1) {
+ fprintf(stderr,
+ "Config file '%s' is not found.\n",
+ session->configfile);
+ goto exit;
+ }
/*
* read the config file now. Yes, this could override

0 comments on commit 23b1483

Please sign in to comment.