logo

utils-std

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

basename.sh (1314B)


  1. #!/bin/sh
  2. # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. # SPDX-License-Identifier: MPL-2.0
  4. target="$(dirname "$0")/../cmd/basename"
  5. plans=9
  6. . "$(dirname "$0")/tap.sh"
  7. t 'no args' '' '.
  8. '
  9. t '/usr/bin' '/usr/bin' 'bin
  10. '
  11. t '/usr//bin' '/usr//bin' 'bin
  12. '
  13. t '-- /usr//bin' '-- /usr//bin' 'bin
  14. '
  15. t 'suffix' '/usr//bin-test -test' 'bin
  16. '
  17. t dash '-' '-
  18. '
  19. t double-dash '--' '.
  20. '
  21. t_args opt_a 'str1
  22. str2
  23. ' -a any/str1 any/str2
  24. t_args opt_s 'stdio
  25. unistd
  26. ' -s .h include/stdio.h include/unistd.h
  27. #atf_test_case usage
  28. #usage_body() {
  29. # atf_check -s exit:1 -e "inline:usage: basename string [suffix]\n" ../cmd/basename 1 2 3
  30. #}
  31. #atf_test_case devfull
  32. #devfull_body() {
  33. # has_glibc && atf_skip "glibc ignoring write errors for puts()"
  34. # [ "$(uname -s)" = "NetBSD" ] && atf_skip "NetBSD ignoring write errors for puts()"
  35. # [ "$(uname -s)" = "FreeBSD" ] && atf_skip "FreeBSD ignoring write errors for puts()"
  36. #
  37. # atf_check -s exit:1 -e 'inline:basename: puts: No space left on device\n' sh -c '../cmd/basename >/dev/full'
  38. # atf_check -s exit:1 -e 'inline:basename: puts: No space left on device\n' sh -c '../cmd/basename "/usr/bin" >/dev/full'
  39. # atf_check -s exit:1 -e 'inline:basename: puts: No space left on device\n' sh -c '../cmd/basename "/usr//bin-test" "-test" >/dev/full'
  40. #}