diff options
author | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2018-03-25 01:59:38 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2018-03-25 01:59:38 +0100 |
commit | b9d829bc9abe0f5ce0234475505b33fe5b942cb4 (patch) | |
tree | 62254553207ba3af0e11e5a4bc3b19407cc4cf2a /servicecmd/disable.c | |
parent | f97add9041c7cf330d2743b1dca9267676bdaa72 (diff) |
Cleanup command error handling in "service"
- Add helper for checking number of arguments
- Add helper for printing "please read help" message
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'servicecmd/disable.c')
-rw-r--r-- | servicecmd/disable.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/servicecmd/disable.c b/servicecmd/disable.c index 1901381..8a6f9f3 100644 --- a/servicecmd/disable.c +++ b/servicecmd/disable.c @@ -31,18 +31,15 @@ static int cmd_disable(int argc, char **argv) char *linkname, *ptr; struct stat sb; - if (argc < 2 || argc > 3) { - fputs("Wrong number of arguments for `disable'.\n" - "Try `service help disable' for more information.\n", - stderr); + if (check_arguments(argv[0], argc, 2, 3)) return EXIT_FAILURE; - } for (ptr = argv[1]; isalnum(*ptr) || *ptr == '_'; ++ptr) ; if (*ptr != '\0') { fprintf(stderr, "Invalid service name '%s'\n", argv[1]); + tell_read_help(argv[0]); return EXIT_FAILURE; } |