glob.c 426 B

123456789101112131415161718192021222324
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <glob.h>
  5. int main(int argc, char **argv) {
  6. int i;
  7. glob_t g;
  8. argc--;
  9. argv++;
  10. g.gl_offs = 0;
  11. for (i = 0; i < argc; i++) {
  12. glob(argv[i], GLOB_DOOFFS | (i ? GLOB_APPEND : 0) | (strchr(argv[i], '*') ? 0 : GLOB_NOCHECK), NULL, &g);
  13. }
  14. execvp(g.gl_pathv[0], g.gl_pathv);
  15. fprintf(stderr, "Error: could not execute %s\n", g.gl_pathv[0]);
  16. return 1;
  17. }