scrut(1): return program_name ternary to former position

This commit is contained in:
Emma Tebibyte 2024-07-28 18:33:49 -06:00
parent 338a3e7155
commit 44d461fb16
Signed by: emma
GPG Key ID: 06FA419A1698C270

View File

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