logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/

dirname.c (524B)


  1. // utils-std: Collection of commonly available Unix tools
  2. // SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. // SPDX-License-Identifier: 0BSD
  4. #include <libgen.h> // dirname()
  5. #include <stdio.h> // puts()
  6. #include <string.h> // strcmp()
  7. int
  8. main(int argc, char *argv[])
  9. {
  10. if(argc != 2)
  11. {
  12. if((argc == 3) && (strcmp(argv[1], "--") == 0))
  13. {
  14. argv++;
  15. argc--;
  16. }
  17. else
  18. {
  19. fputs("usage: dirname string\n", stderr);
  20. return 1;
  21. }
  22. }
  23. puts(dirname(argv[1]));
  24. return 0;
  25. }