diff mbox series

main: Print just the command basename

Message ID 20180524062023.9968-1-mikey@neuling.org
State Accepted
Headers show
Series main: Print just the command basename | expand

Commit Message

Michael Neuling May 24, 2018, 6:20 a.m. UTC
Instead of outputting:
  Usage: /root/mikey/pdbg/.libs/pdbg
output
  Usage: pdbg

Signed-off-by: Michael Neuling <mikey@neuling.org>
---
 src/main.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/src/main.c b/src/main.c
index 20f5319b65..950b1358e5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -295,7 +295,7 @@  static bool parse_options(int argc, char *argv[])
 	} while (c != EOF && !opt_error);
 
 	if (opt_error)
-		print_usage(argv[0]);
+		print_usage(basename(argv[0]));
 
 	return opt_error;
 }
@@ -613,7 +613,7 @@  int main(int argc, char *argv[])
 	}
 
 	if (optind >= argc) {
-		print_usage(argv[0]);
+		print_usage(basename(argv[0]));
 		return 1;
 	}
 
@@ -640,13 +640,14 @@  int main(int argc, char *argv[])
 	}
 
 	PR_ERROR("Unsupported command: %s\n", argv[optind]);
-	print_usage(argv[0]);
+	print_usage(basename(argv[0]));
 	return 1;
 
 found_action:
 	if (rc <= 0) {
                 printf("No valid targets found or specified. Try adding -p/-c/-t options to specify a target.\n");
-                printf("Alternatively run %s -a probe to get a list of all valid targets\n", argv[0]);
+                printf("Alternatively run '%s -a probe' to get a list of all valid targets\n",
+		       basename(argv[0]));
 		rc = 1;
 	} else
 		rc = 0;