int b_basename(int argc, register char** argv, Shbltin_t* context) { char* string; char* suffix = 0; int all = 0; cmdinit(argc, argv, context, ERROR_CATALOG, 0); for (;;) { switch (optget(argv, usage)) { case 'a': all = 1; continue; case 's': all = 1; suffix = opt_info.arg; continue; case ':': error(2, "%s", opt_info.arg); break; case '?': error(ERROR_usage(2), "%s", opt_info.arg); break; } break; } argv += opt_info.index; argc -= opt_info.index; if (error_info.errors || argc < 1 || !all && argc > 2) error(ERROR_usage(2), "%s", optusage(NiL)); if (!all) namebase(sfstdout, argv[0], argv[1]); else while (string = *argv++) namebase(sfstdout, string, suffix); return 0; }
int b_basename(int argc,register char *argv[], void* context) { register int n; cmdinit(argc, argv, context, ERROR_CATALOG, 0); while (n = optget(argv, usage)) switch (n) { case ':': error(2, "%s", opt_info.arg); break; case '?': error(ERROR_usage(2), "%s", opt_info.arg); break; } argv += opt_info.index; argc -= opt_info.index; if(error_info.errors || argc < 1 || argc > 2) error(ERROR_usage(2), "%s", optusage(NiL)); namebase(sfstdout,argv[0],argv[1]); return(0); }