diff mbox

[ndctl] ndctl: Bail out with unkown command in case of an unknown command

Message ID 1457970816-5625-1-git-send-email-jthumshirn@suse.de (mailing list archive)
State Accepted
Commit bcf2a0617bed
Headers show

Commit Message

Johannes Thumshirn March 14, 2016, 3:53 p.m. UTC
handle_internal_command() only returns to main if it doesn't find the
specified command and does not set an errno.

When running an unknown command you get the following error message:
$ ./ndctl asd
Failed to run command 'asd': Success

Instead of a more appropriate:
$ ./ndctl asd
Unknown command: 'asd'

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 ndctl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Dan Williams March 14, 2016, 3:56 p.m. UTC | #1
On Mon, Mar 14, 2016 at 8:53 AM, Johannes Thumshirn <jthumshirn@suse.de> wrote:
> handle_internal_command() only returns to main if it doesn't find the
> specified command and does not set an errno.
>
> When running an unknown command you get the following error message:
> $ ./ndctl asd
> Failed to run command 'asd': Success
>
> Instead of a more appropriate:
> $ ./ndctl asd
> Unknown command: 'asd'
>
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
>  ndctl.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/ndctl.c b/ndctl.c
> index ded1588..18b5dc6 100644
> --- a/ndctl.c
> +++ b/ndctl.c
> @@ -159,8 +159,7 @@ int main(int argc, const char **argv)
>                 goto out;
>         }
>         handle_internal_command(argc, argv);
> -       fprintf(stderr, "Failed to run command '%s': %s\n",
> -               argv[0], strerror(errno));
> +       fprintf(stderr, "Unknown command: '%s'\n", argv[0]);
>  out:
>         return 1;

Looks good to me, applied.
diff mbox

Patch

diff --git a/ndctl.c b/ndctl.c
index ded1588..18b5dc6 100644
--- a/ndctl.c
+++ b/ndctl.c
@@ -159,8 +159,7 @@  int main(int argc, const char **argv)
 		goto out;
 	}
 	handle_internal_command(argc, argv);
-	fprintf(stderr, "Failed to run command '%s': %s\n",
-		argv[0], strerror(errno));
+	fprintf(stderr, "Unknown command: '%s'\n", argv[0]);
 out:
 	return 1;
 }