commit e8c3e8ba00643f6e2b4b7d8d5844d8ea844f9015 parent 365882160b2e66778cef21fa350d7983eaeb50b7 Author: Frederic Cambus <fcambus@users.sourceforge.net> Date: Sun, 27 Sep 2015 23:34:10 +0200 Check if an input file is specified and display usage otherwise Diffstat:
M | src/logswan.c | | | 11 | ++++++++--- |
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/logswan.c b/src/logswan.c @@ -91,10 +91,15 @@ int main (int argc, char *argv[]) { return EXIT_SUCCESS; } } - - intputFile = argv[optind]; - argc -= optind; + if (optind < argc) { + intputFile = argv[optind]; + } else { + displayUsage(); + return EXIT_SUCCESS; + } + + argc -= optind; argv += optind; /* Starting timer */