Commit af44f4b2a56ea3b8f57fb117d4768a57e000ac24

Authored by Horst Kronstorfer
Committed by Wolfgang Denk
1 parent 67c2cb1e69

Print program basename instead of whole path in usage()

Signed-off-by: Horst Kronstorfer <hkronsto@frequentis.com>

Showing 1 changed file with 9 additions and 3 deletions Side-by-side Diff

... ... @@ -25,6 +25,9 @@
25 25 * MA 02111-1307 USA
26 26 */
27 27  
  28 +/* We want the GNU version of basename() */
  29 +#define _GNU_SOURCE
  30 +
28 31 #include <errno.h>
29 32 #include <fcntl.h>
30 33 #include <stdio.h>
31 34  
... ... @@ -79,7 +82,10 @@
79 82 struct stat txt_file_stat;
80 83  
81 84 int fp, ep;
  85 + const char *prg;
82 86  
  87 + prg = basename(argv[0]);
  88 +
83 89 /* Parse the cmdline */
84 90 while ((option = getopt(argc, argv, "s:o:rbp:h")) != -1) {
85 91 switch (option) {
86 92  
... ... @@ -104,11 +110,11 @@
104 110 padbyte = strtol(optarg, NULL, 0);
105 111 break;
106 112 case 'h':
107   - usage(argv[0]);
  113 + usage(prg);
108 114 return EXIT_SUCCESS;
109 115 default:
110 116 fprintf(stderr, "Wrong option -%c\n", option);
111   - usage(argv[0]);
  117 + usage(prg);
112 118 return EXIT_FAILURE;
113 119 }
114 120 }
... ... @@ -118,7 +124,7 @@
118 124 fprintf(stderr,
119 125 "Please specify the size of the envrionnment "
120 126 "partition.\n");
121   - usage(argv[0]);
  127 + usage(prg);
122 128 return EXIT_FAILURE;
123 129 }
124 130