scrut(1): return program_name ternary to former position
This commit is contained in:
parent
338a3e7155
commit
44d461fb16
@ -39,16 +39,15 @@ usage(char *argv0) {
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char sel[(sizeof opts) / (sizeof *opts)];
|
||||
program_name = (argv[0] == NULL ? program_name : argv[0]);
|
||||
|
||||
if (argc < 2) { return usage(program_name); }
|
||||
if (argc < 2) { return usage(argv[0] == NULL ? program_name : argv[0]); }
|
||||
|
||||
{ /* option parsing */
|
||||
char *p;
|
||||
|
||||
memset(sel, '\0', sizeof sel);
|
||||
for (int c; (c = getopt(argc, argv, opts)) != -1;) {
|
||||
if ((p = strchr(opts, c)) == NULL) { return usage(program_name); }
|
||||
if ((p = strchr(opts, c)) == NULL) { return usage(argv[0]); }
|
||||
else { sel[p - opts] = c; }
|
||||
}
|
||||
|
||||
@ -62,7 +61,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
if (optind == argc) { return usage(program_name); }
|
||||
if (optind == argc) { return usage(argv[0]); }
|
||||
|
||||
for (argv += optind ; *argv != NULL; ++argv) {
|
||||
struct stat buf;
|
||||
|
Loading…
Reference in New Issue
Block a user