From fa9d8ed8009438f91e46b6a2aa3c925c3608c513 Mon Sep 17 00:00:00 2001 From: "git@daemon.de" Date: Tue, 28 Jan 2014 13:33:38 +0100 Subject: [PATCH] don't print the whole usage if called wrongly, just tell about it. --- src/pcp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pcp.c b/src/pcp.c index ae5638f..f280a7f 100644 --- a/src/pcp.c +++ b/src/pcp.c @@ -23,13 +23,15 @@ #include "pcp.h" #include "defines.h" -void usage() { +void usage(int error) { fprintf(stderr, PCP_HELP_INTRO); - fprintf(stderr, PCP_HELP); + if(error == 0) + fprintf(stderr, PCP_HELP); version(); exit(EXIT_FAILURE); } + void version() { fprintf(stderr, "pcp version %d.%d.%d, use --help to learn how to use.\n", PCP_VERSION_MAJOR, PCP_VERSION_MINOR, PCP_VERSION_PATCH); @@ -224,9 +226,9 @@ int main (int argc, char **argv) { case 'v': version(); case 'h': - usage(); + usage(0); default: - usage(); + usage(1); } }