[Pdbg] [PATCH] main: Print just the command basename

Michael Neuling mikey at neuling.org
Thu May 24 16:20:23 AEST 2018


Instead of outputting:
  Usage: /root/mikey/pdbg/.libs/pdbg
output
  Usage: pdbg

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

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;
-- 
2.17.0



More information about the Pdbg mailing list